Zamień moduł kamery OpenCV na natywny moduł kamery Android, dodaj funkcjonalność robienia i zapisywania zdjęć

This commit is contained in:
Kacper Dudzic 2019-12-19 23:15:02 +01:00
parent 6353bd691b
commit ee078c75d5
67 changed files with 177 additions and 659 deletions

View File

@ -1 +1 @@
Lookify_robocze Lookifyv2

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -4,7 +4,7 @@ android {
compileSdkVersion 29 compileSdkVersion 29
buildToolsVersion "29.0.2" buildToolsVersion "29.0.2"
defaultConfig { defaultConfig {
applicationId "com.example.lookify_robocze" applicationId "com.example.lookifyv2"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 29 targetSdkVersion 29
versionCode 1 versionCode 1
@ -21,11 +21,10 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation project(path: ':openCVLibrary348') implementation project(path: ':openCVLibrary348')
} }

View File

@ -1,27 +0,0 @@
package com.example.lookify_robocze;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.lookify_robocze", appContext.getPackageName());
}
}

View File

@ -1,4 +1,4 @@
package com.example.test; package com.example.lookifyv2;
import android.content.Context; import android.content.Context;
@ -22,6 +22,6 @@ public class ExampleInstrumentedTest {
// Context of the app under test. // Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.test", appContext.getPackageName()); assertEquals("com.example.lookifyv2", appContext.getPackageName());
} }
} }

View File

@ -1,28 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lookify_robocze"> package="com.example.lookifyv2">
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission-sdk-23 android:name="android.permission.CAMERA" />
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.front"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.front.autofocus"
android:required="false" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -31,9 +12,9 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".About"></activity> <activity android:name=".Scan"></activity>
<activity android:name=".Help" /> <activity android:name=".Help" />
<activity android:name=".OpenCVCamera" /> <activity android:name=".About" />
<activity android:name=".MainActivity"> <activity android:name=".MainActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

View File

@ -1,92 +0,0 @@
package com.example.lookify_robocze;
import android.os.Bundle;
import android.util.Log;
import android.view.SurfaceView;
import android.view.WindowManager;
import androidx.appcompat.app.AppCompatActivity;
import org.opencv.android.OpenCVLoader;
import org.opencv.android.JavaCameraView;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.BaseLoaderCallback;
// Napisane z pomocą artykułu spod adresu https://blog.codeonion.com/2016/04/09/show-camera-on-android-app-using-opencv-for-android/
public class OpenCVCamera extends AppCompatActivity {
// Do logowania komunikatów typu success/failure
private static final String TAG = "OCVSample::Activity";
// Laduje kamere OpenCV
private CameraBridgeViewBase mOpenCvCameraView;
// Menadżer OpenCV do komunikacji aplikacji z telefonem
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
mOpenCvCameraView.enableView();
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
// Inicjalizacja narzędzia do przeglądania logów
public OpenCVCamera() {
Log.i(TAG, "Instantiated new " + this.getClass());
}
// Wyświatlanie kamery przy powstaniu activity
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_open_cvcamera);
mOpenCvCameraView = (JavaCameraView) findViewById(R.id.show_camera_activity_java_surface_view);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
}
// Działanie przy pauzie
@Override
public void onPause()
{
super.onPause();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
// Działanie po wznowieniu
@Override
public void onResume()
{
super.onResume();
if (!OpenCVLoader.initDebug()) {
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
} else {
Log.d(TAG, "OpenCV library found inside package. Using it!");
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
}
// Działanie przy "zamknięciu"
public void onDestroy() {
super.onDestroy();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
}

View File

@ -1,4 +1,4 @@
package com.example.lookify_robocze; package com.example.lookifyv2;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;

View File

@ -1,4 +1,4 @@
package com.example.lookify_robocze; package com.example.lookifyv2;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;

View File

@ -1,11 +1,13 @@
package com.example.lookify_robocze; package com.example.lookifyv2;
import android.Manifest;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
@ -13,41 +15,50 @@ public class MainActivity extends AppCompatActivity {
private Button button_help; private Button button_help;
private Button button_about; private Button button_about;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
button_scan = findViewById(R.id.camera_start_button); button_scan = findViewById(R.id.scan_start_button);
button_help = findViewById(R.id.help_start_button); button_help = findViewById(R.id.help_start_button);
button_about = findViewById(R.id.about_start_button); button_about = findViewById(R.id.about_start_button);
button_scan.setOnClickListener(new View.OnClickListener() { button_scan.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
openOpenCVCamera(); openScan();
} }
}); });
button_help.setOnClickListener(new View.OnClickListener() { button_help.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
openHelp(); openHelp();
} }
}); });
button_about.setOnClickListener(new View.OnClickListener() { button_about.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
openAbout(); openAbout();
} }
}); });
//Dezaktywacja przycisku skanowania, jeśli nie ma dostępu do kamery; żądanie dostępu do kamery i zapisu
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
button_scan.setEnabled(false);
ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
}
} }
public void openOpenCVCamera(){ //Aktywacja przycisku skanowania, jeśli uprawnienia zostały przyznane
Intent intent_OpenCVCamera = new Intent(this, OpenCVCamera.class); @Override
startActivity(intent_OpenCVCamera); public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == 0) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED
&& grantResults[1] == PackageManager.PERMISSION_GRANTED) {
button_scan.setEnabled(true);
}
}
} }
public void openHelp(){ public void openHelp(){
@ -59,5 +70,9 @@ public class MainActivity extends AppCompatActivity {
Intent intent_About = new Intent(this, About.class); Intent intent_About = new Intent(this, About.class);
startActivity(intent_About); startActivity(intent_About);
} }
}
public void openScan(){
Intent intent_Scan = new Intent(this, Scan.class);
startActivity(intent_Scan);
}
}

View File

@ -0,0 +1,58 @@
package com.example.lookifyv2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
//klasa napisana z pomocą tutorialu dostępnego na https://androidkennel.org/android-camera-access-tutorial/
public class Scan extends AppCompatActivity {
private Uri file;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scan);
openCamera();
}
//Uruchomienie androidowego modułu kamery
public void openCamera(){
Intent intent_Camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
file = Uri.fromFile(getOutputMediaFile());
intent_Camera.putExtra(MediaStore.EXTRA_OUTPUT, file);
startActivityForResult(intent_Camera, 100);
}
//Jeśli moduł kamery zostanie zamknięty zanim zrobione zostanie zdjęcie to activity skanowania się kończy
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 100) {
if (resultCode == RESULT_CANCELED) {
finish();
}
}
}
//Tworzenie katalogu dla danych aplikacji jesli nie istnieje; umieszczanie w nim tymczasowego pliku zdjecia w formacie .jpg
private static File getOutputMediaFile(){
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), "Lookify");
if (!mediaStorageDir.exists()){
if (!mediaStorageDir.mkdirs()){
return null;
}
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
return new File(mediaStorageDir.getPath() + File.separator +
"TEMP_"+ timeStamp + ".jpg"); //DO EDYCJI
}
}

View File

@ -1,108 +0,0 @@
package com.example.test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc;
public class ColorBlobDetector {
// Lower and Upper bounds for range checking in HSV color space
private Scalar mLowerBound = new Scalar(0);
private Scalar mUpperBound = new Scalar(0);
// Minimum contour area in percent for contours filtering
private static double mMinContourArea = 0.1;
// Color radius for range checking in HSV color space
private Scalar mColorRadius = new Scalar(25,50,50,0);
private Mat mSpectrum = new Mat();
private List<MatOfPoint> mContours = new ArrayList<MatOfPoint>();
// Cache
Mat mPyrDownMat = new Mat();
Mat mHsvMat = new Mat();
Mat mMask = new Mat();
Mat mDilatedMask = new Mat();
Mat mHierarchy = new Mat();
public void setColorRadius(Scalar radius) {
mColorRadius = radius;
}
public void setHsvColor(Scalar hsvColor) {
double minH = (hsvColor.val[0] >= mColorRadius.val[0]) ? hsvColor.val[0]-mColorRadius.val[0] : 0;
double maxH = (hsvColor.val[0]+mColorRadius.val[0] <= 255) ? hsvColor.val[0]+mColorRadius.val[0] : 255;
mLowerBound.val[0] = minH;
mUpperBound.val[0] = maxH;
mLowerBound.val[1] = hsvColor.val[1] - mColorRadius.val[1];
mUpperBound.val[1] = hsvColor.val[1] + mColorRadius.val[1];
mLowerBound.val[2] = hsvColor.val[2] - mColorRadius.val[2];
mUpperBound.val[2] = hsvColor.val[2] + mColorRadius.val[2];
mLowerBound.val[3] = 0;
mUpperBound.val[3] = 255;
Mat spectrumHsv = new Mat(1, (int)(maxH-minH), CvType.CV_8UC3);
for (int j = 0; j < maxH-minH; j++) {
byte[] tmp = {(byte)(minH+j), (byte)255, (byte)255};
spectrumHsv.put(0, j, tmp);
}
Imgproc.cvtColor(spectrumHsv, mSpectrum, Imgproc.COLOR_HSV2RGB_FULL, 4);
}
public Mat getSpectrum() {
return mSpectrum;
}
public void setMinContourArea(double area) {
mMinContourArea = area;
}
public void process(Mat rgbaImage) {
Imgproc.pyrDown(rgbaImage, mPyrDownMat);
Imgproc.pyrDown(mPyrDownMat, mPyrDownMat);
Imgproc.cvtColor(mPyrDownMat, mHsvMat, Imgproc.COLOR_RGB2HSV_FULL);
Core.inRange(mHsvMat, mLowerBound, mUpperBound, mMask);
Imgproc.dilate(mMask, mDilatedMask, new Mat());
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Imgproc.findContours(mDilatedMask, contours, mHierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
// Find max contour area
double maxArea = 0;
Iterator<MatOfPoint> each = contours.iterator();
while (each.hasNext()) {
MatOfPoint wrapper = each.next();
double area = Imgproc.contourArea(wrapper);
if (area > maxArea)
maxArea = area;
}
// Filter contours by area and resize to fit the original image size
mContours.clear();
each = contours.iterator();
while (each.hasNext()) {
MatOfPoint contour = each.next();
if (Imgproc.contourArea(contour) > mMinContourArea*maxArea) {
Core.multiply(contour, new Scalar(4,4), contour);
mContours.add(contour);
}
}
}
public List<MatOfPoint> getContours() {
return mContours;
}
}

View File

@ -1,200 +0,0 @@
package com.example.test;
import java.util.List;
import org.opencv.android.BaseLoaderCallback;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
import org.opencv.android.LoaderCallbackInterface;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.core.Size;
import org.opencv.android.CameraBridgeViewBase;
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
import org.opencv.imgproc.Imgproc;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnTouchListener;
import android.view.SurfaceView;
import com.example.test.R;
public class MainActivity extends Activity implements OnTouchListener, CvCameraViewListener2 {
private static final String TAG = "MainActivity";
private boolean mIsColorSelected = false;
private Mat mRgba;
private Scalar mBlobColorRgba;
private Scalar mBlobColorHsv;
private com.example.test.ColorBlobDetector mDetector;
private Mat mSpectrum;
private Size SPECTRUM_SIZE;
private Scalar CONTOUR_COLOR;
private CameraBridgeViewBase mOpenCvCameraView;
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
@Override
public void onManagerConnected(int status) {
switch (status) {
case LoaderCallbackInterface.SUCCESS:
{
Log.i(TAG, "OpenCV loaded successfully");
mOpenCvCameraView.enableView();
mOpenCvCameraView.setOnTouchListener(MainActivity.this);
} break;
default:
{
super.onManagerConnected(status);
} break;
}
}
};
public MainActivity() {
Log.i(TAG, "Instantiated new " + this.getClass());
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "called onCreate");
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.color_blob_detection_surface_view);
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.color_blob_detection_activity_surface_view);
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
mOpenCvCameraView.setCvCameraViewListener(this);
}
@Override
public void onPause()
{
super.onPause();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
@Override
public void onResume()
{
super.onResume();
if (!OpenCVLoader.initDebug()) {
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
} else {
Log.d(TAG, "OpenCV library found inside package. Using it!");
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
}
}
public void onDestroy() {
super.onDestroy();
if (mOpenCvCameraView != null)
mOpenCvCameraView.disableView();
}
public void onCameraViewStarted(int width, int height) {
mRgba = new Mat(height, width, CvType.CV_8UC4);
mDetector = new com.example.test.ColorBlobDetector();
mSpectrum = new Mat();
mBlobColorRgba = new Scalar(255);
mBlobColorHsv = new Scalar(255);
SPECTRUM_SIZE = new Size(200, 64);
CONTOUR_COLOR = new Scalar(255,0,0,255);
}
public void onCameraViewStopped() {
mRgba.release();
}
public boolean onTouch(View v, MotionEvent event) {
int cols = mRgba.cols();
int rows = mRgba.rows();
int xOffset = (mOpenCvCameraView.getWidth() - cols) / 2;
int yOffset = (mOpenCvCameraView.getHeight() - rows) / 2;
int x = (int)event.getX() - xOffset;
int y = (int)event.getY() - yOffset;
Log.i(TAG, "Touch image coordinates: (" + x + ", " + y + ")");
if ((x < 0) || (y < 0) || (x > cols) || (y > rows)) return false;
Rect touchedRect = new Rect();
touchedRect.x = (x>4) ? x-4 : 0;
touchedRect.y = (y>4) ? y-4 : 0;
touchedRect.width = (x+4 < cols) ? x + 4 - touchedRect.x : cols - touchedRect.x;
touchedRect.height = (y+4 < rows) ? y + 4 - touchedRect.y : rows - touchedRect.y;
Mat touchedRegionRgba = mRgba.submat(touchedRect);
Mat touchedRegionHsv = new Mat();
Imgproc.cvtColor(touchedRegionRgba, touchedRegionHsv, Imgproc.COLOR_RGB2HSV_FULL);
// Calculate average color of touched region
mBlobColorHsv = Core.sumElems(touchedRegionHsv);
int pointCount = touchedRect.width*touchedRect.height;
for (int i = 0; i < mBlobColorHsv.val.length; i++)
mBlobColorHsv.val[i] /= pointCount;
mBlobColorRgba = converScalarHsv2Rgba(mBlobColorHsv);
Log.i(TAG, "Touched rgba color: (" + mBlobColorRgba.val[0] + ", " + mBlobColorRgba.val[1] +
", " + mBlobColorRgba.val[2] + ", " + mBlobColorRgba.val[3] + ")");
mDetector.setHsvColor(mBlobColorHsv);
Imgproc.resize(mDetector.getSpectrum(), mSpectrum, SPECTRUM_SIZE, 0, 0, Imgproc.INTER_LINEAR_EXACT);
mIsColorSelected = true;
touchedRegionRgba.release();
touchedRegionHsv.release();
return false; // don't need subsequent touch events
}
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
if (mIsColorSelected) {
mDetector.process(mRgba);
List<MatOfPoint> contours = mDetector.getContours();
Log.e(TAG, "Contours count: " + contours.size());
Imgproc.drawContours(mRgba, contours, -1, CONTOUR_COLOR);
Mat colorLabel = mRgba.submat(4, 68, 4, 68);
colorLabel.setTo(mBlobColorRgba);
Mat spectrumLabel = mRgba.submat(4, 4 + mSpectrum.rows(), 70, 70 + mSpectrum.cols());
mSpectrum.copyTo(spectrumLabel);
}
return mRgba;
}
private Scalar converScalarHsv2Rgba(Scalar hsvColor) {
Mat pointMatRgba = new Mat();
Mat pointMatHsv = new Mat(1, 1, CvType.CV_8UC3, hsvColor);
Imgproc.cvtColor(pointMatHsv, pointMatRgba, Imgproc.COLOR_HSV2RGB_FULL, 4);
return new Scalar(pointMatRgba.get(0, 0));
}
}

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--Wzór ikony zaczerpnięty z httpswww.pinpng.compictureTbixRT_png-file-svg-mobile-camera-icon-png-transparent-->
<item
android:state_pressed="true"
android:drawable="@drawable/ikona_aparat_szkarlatna"/>
<item
android:state_enabled="false"
android:drawable="@drawable/ikona_aparat_szara"/>
<item
android:drawable="@drawable/ikona_aparat_czerwona"/>
</selector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@ -16,4 +16,5 @@
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -16,4 +16,5 @@
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -6,9 +6,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity"> tools:context=".MainActivity">
<Button <Button
android:id="@+id/camera_start_button" android:id="@+id/scan_start_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Scan" android:text="Scan"
@ -28,7 +27,7 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/camera_start_button" app:layout_constraintTop_toBottomOf="@+id/scan_start_button"
app:layout_constraintVertical_bias="0.0" /> app:layout_constraintVertical_bias="0.0" />
<Button <Button

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:opencv="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.opencv.android.JavaCameraView
android:id="@+id/show_camera_activity_java_surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"
opencv:camera_id="any"
opencv:layout_constraintBottom_toTopOf="parent"
opencv:layout_constraintEnd_toStartOf="parent"
opencv:layout_constraintStart_toStartOf="parent"
opencv:layout_constraintTop_toTopOf="parent"
opencv:show_fps="false" />
<Button
android:id="@+id/button"
android:layout_width="75dp"
android:layout_height="75dp"
android:background="@drawable/camera_icon"
opencv:layout_constraintBottom_toBottomOf="parent"
opencv:layout_constraintEnd_toEndOf="parent"
opencv:layout_constraintHorizontal_bias="0.5"
opencv:layout_constraintStart_toStartOf="parent"
opencv:layout_constraintTop_toTopOf="parent"
opencv:layout_constraintVertical_bias="0.975" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Scan">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dalej"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.opencv.android.JavaCameraView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/color_blob_detection_activity_surface_view" />
</FrameLayout>

View File

@ -1,3 +1,3 @@
<resources> <resources>
<string name="app_name">Lookify_robocze</string> <string name="app_name">Lookifyv2</string>
</resources> </resources>

View File

@ -1,17 +0,0 @@
package com.example.lookify_robocze;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@ -1,4 +1,4 @@
package com.example.test; package com.example.lookifyv2;
import org.junit.Test; import org.junit.Test;

View File

@ -1,4 +1,4 @@
#Tue Dec 03 21:31:50 CET 2019 #Wed Dec 18 17:40:14 CET 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\debug\jniLibs"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\jniLibs"/></dataSet></merger>

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\debug\shaders"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\shaders"/></dataSet></merger>

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\assets"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\build\intermediates\shader_assets\debug\compileDebugShaders\out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\debug\assets"/></dataSet></merger> <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\assets"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\build\intermediates\shader_assets\debug\compileDebugShaders\out"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\assets"/></dataSet></merger>

View File

@ -1 +1 @@
#Fri Dec 06 00:03:49 CET 2019 #Wed Dec 18 23:21:27 CET 2019

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\res"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\build\generated\res\rs\debug"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\res"><file path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\res\values\attrs.xml" qualifiers=""><declare-styleable name="CameraBridgeViewBase"> <merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\res"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\build\generated\res\rs\debug"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\res"><file path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\res\values\attrs.xml" qualifiers=""><declare-styleable name="CameraBridgeViewBase">
<attr format="boolean" name="show_fps"/> <attr format="boolean" name="show_fps"/>
<attr format="integer" name="camera_id"> <attr format="integer" name="camera_id">
<enum name="any" value="-1"/> <enum name="any" value="-1"/>
<enum name="back" value="99"/> <enum name="back" value="99"/>
<enum name="front" value="98"/> <enum name="front" value="98"/>
</attr> </attr>
</declare-styleable></file></source><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\build\generated\res\rs\debug"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\debug\res"/></dataSet><mergedItems><configuration qualifiers=""><declare-styleable name="CameraBridgeViewBase"> </declare-styleable></file></source><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\build\generated\res\rs\debug"/><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\build\generated\res\resValues\debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\res"/></dataSet><mergedItems><configuration qualifiers=""><declare-styleable name="CameraBridgeViewBase">
<attr format="boolean" name="show_fps"/> <attr format="boolean" name="show_fps"/>
<attr format="integer" name="camera_id"> <attr format="integer" name="camera_id">
<enum name="any" value="-1"/> <enum name="any" value="-1"/>

View File

@ -5,10 +5,9 @@
5 android:versionName="3.4.8" > 5 android:versionName="3.4.8" >
6 6
7 <uses-sdk 7 <uses-sdk
7-->C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47
8 android:minSdkVersion="14" 8 android:minSdkVersion="14"
8-->C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47 8-->C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
9 android:targetSdkVersion="29" /> 9 android:targetSdkVersion="29" />
9-->C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:15-44 9-->C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
10 10
11</manifest> 11</manifest>

View File

@ -1,37 +1,37 @@
-- Merging decision tree log --- -- Merging decision tree log ---
manifest manifest
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8:12 ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8:12 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8:12 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8:12 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8:12 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8:12 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8:12 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
package package
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:3:7-27 ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:3:7-27
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
android:versionName android:versionName
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:5:7-34 ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:5:7-34
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
xmlns:android xmlns:android
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:11-69 ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:11-69
android:versionCode android:versionCode
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:4:7-33 ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:4:7-33
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
uses-sdk uses-sdk
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml reason: use-sdk injection requested
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
android:targetSdkVersion android:targetSdkVersion
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:15-44 INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
android:minSdkVersion android:minSdkVersion
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47 ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml

View File

@ -4,5 +4,4 @@
android:versionCode="3480" android:versionCode="3480"
android:versionName="3.4.8"> android:versionName="3.4.8">
<uses-sdk android:targetSdkVersion="21" />
</manifest> </manifest>

View File

@ -2,6 +2,7 @@ package org.opencv.android;
import java.util.List; import java.util.List;
import org.opencv.BuildConfig;
import org.opencv.R; import org.opencv.R;
import org.opencv.core.Mat; import org.opencv.core.Mat;
import org.opencv.core.Size; import org.opencv.core.Size;
@ -10,18 +11,15 @@ import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log; import android.util.Log;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import android.view.SurfaceView; import android.view.SurfaceView;
/** /**
* This is a basic class, implementing the interaction with Camera and OpenCV library. * This is a basic class, implementing the interaction with Camera and OpenCV library.
* The main responsibility of it - is to control when camera can be enabled, process the frame, * The main responsibility of it - is to control when camera can be enabled, process the frame,
@ -381,47 +379,12 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
} }
} }
// Metody updateMatrix i deliverAndDrawFrame zaczerpnięte z https://heartbeat.fritz.ai/working-with-the-opencv-camera-for-android-rotating-orienting-and-scaling-c7006c3e1916
private final Matrix mMatrix = new Matrix();
private void updateMatrix() {
float mw = this.getWidth();
float mh = this.getHeight();
float hw = this.getWidth() / 2.0f;
float hh = this.getHeight() / 2.0f;
float cw = (float)Resources.getSystem().getDisplayMetrics().widthPixels;
float ch = (float)Resources.getSystem().getDisplayMetrics().heightPixels;
float scale = cw / mh;
float scale2 = ch / mw;
if(scale2 > scale){
scale = scale2;
}
mMatrix.reset();
mMatrix.preTranslate(hw, hh);
mMatrix.preRotate(90);
mMatrix.preTranslate(-hw, -hh);
mMatrix.preScale(scale,scale,hw,hh);
}
@Override
public void layout(int l, int t, int r, int b) {
super.layout(l, t, r, b);
updateMatrix();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
updateMatrix();
}
/** /**
* This method shall be called by the subclasses when they have valid * This method shall be called by the subclasses when they have valid
* object and want it to be delivered to external client (via callback) and * object and want it to be delivered to external client (via callback) and
* then displayed on the screen. * then displayed on the screen.
* @param frame - the current frame to be delivered * @param frame - the current frame to be delivered
*/ */
protected void deliverAndDrawFrame(CvCameraViewFrame frame) { protected void deliverAndDrawFrame(CvCameraViewFrame frame) {
Mat modified; Mat modified;
@ -447,26 +410,23 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
Canvas canvas = getHolder().lockCanvas(); Canvas canvas = getHolder().lockCanvas();
if (canvas != null) { if (canvas != null) {
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR); canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
int saveCount = canvas.save(); if (BuildConfig.DEBUG)
canvas.setMatrix(mMatrix); Log.d(TAG, "mStretch value: " + mScale);
if (mScale != 0) { if (mScale != 0) {
canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()), canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2), new Rect((int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2),
(int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2), (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2),
(int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()), (int)((canvas.getWidth() - mScale*mCacheBitmap.getWidth()) / 2 + mScale*mCacheBitmap.getWidth()),
(int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null); (int)((canvas.getHeight() - mScale*mCacheBitmap.getHeight()) / 2 + mScale*mCacheBitmap.getHeight())), null);
} else { } else {
canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()), canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
new Rect((canvas.getWidth() - mCacheBitmap.getWidth()) / 2, new Rect((canvas.getWidth() - mCacheBitmap.getWidth()) / 2,
(canvas.getHeight() - mCacheBitmap.getHeight()) / 2, (canvas.getHeight() - mCacheBitmap.getHeight()) / 2,
(canvas.getWidth() - mCacheBitmap.getWidth()) / 2 + mCacheBitmap.getWidth(), (canvas.getWidth() - mCacheBitmap.getWidth()) / 2 + mCacheBitmap.getWidth(),
(canvas.getHeight() - mCacheBitmap.getHeight()) / 2 + mCacheBitmap.getHeight()), null); (canvas.getHeight() - mCacheBitmap.getHeight()) / 2 + mCacheBitmap.getHeight()), null);
} }
//Restore canvas after draw bitmap
canvas.restoreToCount(saveCount);
if (mFpsMeter != null) { if (mFpsMeter != null) {
mFpsMeter.measure(); mFpsMeter.measure();
mFpsMeter.draw(canvas, 20, 30); mFpsMeter.draw(canvas, 20, 30);

View File

@ -1,3 +1,3 @@
include ':app' include ':app'
rootProject.name='Lookify_robocze' rootProject.name='Lookifyv2'
include ':openCVLibrary348' include ':openCVLibrary348'