Skip to content

suzusou/OpenCV-Color-Detection

Repository files navigation

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.

Releases

No releases published

Packages

No packages published