Zamień moduł kamery OpenCV na natywny moduł kamery Android, dodaj funkcjonalność robienia i zapisywania zdjęć
This commit is contained in:
parent
6353bd691b
commit
ee078c75d5
@ -1 +1 @@
|
||||
Lookify_robocze
|
||||
Lookifyv2
|
@ -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>
|
@ -4,7 +4,7 @@ android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.2"
|
||||
defaultConfig {
|
||||
applicationId "com.example.lookify_robocze"
|
||||
applicationId "com.example.lookifyv2"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
@ -21,11 +21,10 @@ android {
|
||||
|
||||
dependencies {
|
||||
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'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
implementation project(path: ':openCVLibrary348')
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.test;
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@ -22,6 +22,6 @@ public class ExampleInstrumentedTest {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals("com.example.test", appContext.getPackageName());
|
||||
assertEquals("com.example.lookifyv2", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -1,28 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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-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" />
|
||||
<uses-permission-sdk-23 android:name="android.permission.CAMERA" />
|
||||
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@ -31,9 +12,9 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".About"></activity>
|
||||
<activity android:name=".Scan"></activity>
|
||||
<activity android:name=".Help" />
|
||||
<activity android:name=".OpenCVCamera" />
|
||||
<activity android:name=".About" />
|
||||
<activity android:name=".MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.lookify_robocze;
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.example.lookify_robocze;
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.example.lookify_robocze;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
package com.example.lookifyv2;
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@ -13,41 +15,50 @@ public class MainActivity extends AppCompatActivity {
|
||||
private Button button_help;
|
||||
private Button button_about;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
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_about = findViewById(R.id.about_start_button);
|
||||
|
||||
button_scan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openOpenCVCamera();
|
||||
openScan();
|
||||
}
|
||||
});
|
||||
|
||||
button_help.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openHelp();
|
||||
}
|
||||
});
|
||||
|
||||
button_about.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
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(){
|
||||
Intent intent_OpenCVCamera = new Intent(this, OpenCVCamera.class);
|
||||
startActivity(intent_OpenCVCamera);
|
||||
//Aktywacja przycisku skanowania, jeśli uprawnienia zostały przyznane
|
||||
@Override
|
||||
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(){
|
||||
@ -59,5 +70,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
Intent intent_About = new Intent(this, About.class);
|
||||
startActivity(intent_About);
|
||||
}
|
||||
}
|
||||
|
||||
public void openScan(){
|
||||
Intent intent_Scan = new Intent(this, Scan.class);
|
||||
startActivity(intent_Scan);
|
||||
}
|
||||
}
|
58
Lookify/app/src/main/java/com/example/lookifyv2/Scan.java
Normal file
58
Lookify/app/src/main/java/com/example/lookifyv2/Scan.java
Normal 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
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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 |
@ -16,4 +16,5 @@
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -16,4 +16,5 @@
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -6,9 +6,8 @@
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".MainActivity">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/camera_start_button"
|
||||
android:id="@+id/scan_start_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Scan"
|
||||
@ -28,7 +27,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
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" />
|
||||
|
||||
<Button
|
||||
|
@ -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>
|
20
Lookify/app/src/main/res/layout/activity_scan.xml
Normal file
20
Lookify/app/src/main/res/layout/activity_scan.xml
Normal 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>
|
@ -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>
|
@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">Lookify_robocze</string>
|
||||
<string name="app_name">Lookifyv2</string>
|
||||
</resources>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.example.test;
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#Tue Dec 03 21:31:50 CET 2019
|
||||
#Wed Dec 18 17:40:14 CET 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
@ -1 +0,0 @@
|
||||
o/full
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
o/full
|
@ -1 +0,0 @@
|
||||
i/
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
i/
|
@ -1 +0,0 @@
|
||||
o/full
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1 @@
|
||||
o/classes
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
i/
|
@ -1 +0,0 @@
|
||||
i/
|
@ -1 +0,0 @@
|
||||
o/full
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<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:.*:<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:.*:<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:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\jniLibs"/></dataSet></merger>
|
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<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:.*:<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:.*:<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:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\shaders"/></dataSet></merger>
|
@ -1,2 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:<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:.*:<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:.*:<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:.*:<dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\debug\assets"/></dataSet></merger>
|
@ -1 +1 @@
|
||||
#Fri Dec 06 00:03:49 CET 2019
|
||||
#Wed Dec 18 23:21:27 CET 2019
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?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:.*:<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:.*:<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:.*:<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:.*:<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="integer" name="camera_id">
|
||||
<enum name="any" value="-1"/>
|
||||
<enum name="back" value="99"/>
|
||||
<enum name="front" value="98"/>
|
||||
</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:.*:<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:.*:<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:.*:<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:.*:<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="integer" name="camera_id">
|
||||
<enum name="any" value="-1"/>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -5,10 +5,9 @@
|
||||
5 android:versionName="3.4.8" >
|
||||
6
|
||||
7 <uses-sdk
|
||||
7-->C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47
|
||||
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-->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
|
||||
11</manifest>
|
||||
|
Binary file not shown.
@ -1,37 +1,37 @@
|
||||
-- Merging decision tree log ---
|
||||
manifest
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8: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\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8: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\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:2:1-8: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\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\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7: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\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7: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\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:2:1-7:12
|
||||
package
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\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\Lookify\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:3:7-27
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
android:versionName
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\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\Lookify\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:5:7-34
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
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
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\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\Lookify\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml:4:7-33
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
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\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47
|
||||
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 reason: use-sdk injection requested
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\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\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
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\Lookify\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
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
android:minSdkVersion
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
ADDED from C:\HDD\Moi\Studia\Informatyka\Lookify\openCVLibrary348\src\main\AndroidManifest.xml:7:5-47
|
||||
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\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
INJECTED from C:\HDD\Moi\Studia\Informatyka\Lookifyv2kopia\openCVLibrary348\src\main\AndroidManifest.xml
|
||||
|
@ -4,5 +4,4 @@
|
||||
android:versionCode="3480"
|
||||
android:versionName="3.4.8">
|
||||
|
||||
<uses-sdk android:targetSdkVersion="21" />
|
||||
</manifest>
|
||||
|
@ -2,6 +2,7 @@ package org.opencv.android;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.BuildConfig;
|
||||
import org.opencv.R;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Size;
|
||||
@ -10,18 +11,15 @@ import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@ -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
|
||||
* object and want it to be delivered to external client (via callback) and
|
||||
* then displayed on the screen.
|
||||
* @param frame - the current frame to be delivered
|
||||
*/
|
||||
|
||||
protected void deliverAndDrawFrame(CvCameraViewFrame frame) {
|
||||
Mat modified;
|
||||
|
||||
@ -447,8 +410,8 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
|
||||
Canvas canvas = getHolder().lockCanvas();
|
||||
if (canvas != null) {
|
||||
canvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
|
||||
int saveCount = canvas.save();
|
||||
canvas.setMatrix(mMatrix);
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "mStretch value: " + mScale);
|
||||
|
||||
if (mScale != 0) {
|
||||
canvas.drawBitmap(mCacheBitmap, new Rect(0,0,mCacheBitmap.getWidth(), mCacheBitmap.getHeight()),
|
||||
@ -464,9 +427,6 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
|
||||
(canvas.getHeight() - mCacheBitmap.getHeight()) / 2 + mCacheBitmap.getHeight()), null);
|
||||
}
|
||||
|
||||
//Restore canvas after draw bitmap
|
||||
canvas.restoreToCount(saveCount);
|
||||
|
||||
if (mFpsMeter != null) {
|
||||
mFpsMeter.measure();
|
||||
mFpsMeter.draw(canvas, 20, 30);
|
||||
|
@ -1,3 +1,3 @@
|
||||
include ':app'
|
||||
rootProject.name='Lookify_robocze'
|
||||
rootProject.name='Lookifyv2'
|
||||
include ':openCVLibrary348'
|
||||
|
Loading…
Reference in New Issue
Block a user