Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.92 KB

README.md

File metadata and controls

60 lines (47 loc) · 1.92 KB

OpenCV logo

OpenCV-Color-Detection

This program uses OpenCV to process CameraX information.

Version

OpenCV Version

OpenCV 3.4.1
compileSdkVersion 31
buildToolsVersion "29.0.2"
minSdkVersion 28
targetSdkVersion 31

Android Version

compileSdkVersion 31
buildToolsVersion "30.0.3"
minSdkVersion 28
targetSdkVersion 31
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8

Setting

MainActivity Path : /app/src/main/java/com/example/opencvcolordetection/

imageAnalysis = new ImageAnalysis.Builder().setTargetResolution(new Size(176, 144))
                            .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST).build();

At setTargetResolution(new Size(x, y)), set the resolution.

    private class MyImageAnalyzer implements ImageAnalysis.Analyzer {
        private Mat matPrevious = null;

        @Override
        public void analyze(@NonNull ImageProxy image) {

            Mat matOrg = getMatFromImage(image);

            Mat mat = fixMatRotation(matOrg);

            if (matPrevious == null) matPrevious = mat;
            matPrevious = mat;

            Bitmap bitmap = Bitmap.createBitmap(matPrevious.cols(), matPrevious.rows(), Bitmap.Config.ARGB_8888);
            Utils.matToBitmap(matPrevious, bitmap);
            
            //Describe the process you want to process in this class

            image.close();
        }

In this case, if you continue to take the average of the RGB, you can see it in the log.  

Difference

Processing speed has been increased by cutting the library files by about one-third.

Finally

For more information, tap the logo above and visit the official website.
If you found this helpful, please give us a star.