Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Unable to convert color image to grayscale in android opencv

$
0
0
This is the part of code which is not working good. I know this question has been asked earlier, but i have done everything i could do but still couldn't figure out the reason. This is the portion of code Mat imgSource = original_image.clone(); // apply gaussian blur to smoothen lines of dots Log.i(TAG, "Blur"); Imgproc.GaussianBlur(imgSource, imgSource, new Size(5, 5), 5); // convert the image to black and white Log.i(TAG, "B&W"); Log.i(TAG,Integer.toString(imgSource.type())); Log.i(TAG,Integer.toString(imgSource.channels())); Mat gray = new Mat(imgSource.size(),CvType.CV_8UC1); Imgproc.cvtColor(imgSource, gray, Imgproc.COLOR_BGR2GRAY); // convert the image to black and white does (8 bit) Log.i(TAG, "Canny"); Imgproc.Canny(gray, gray, 50, 50); // find the contours List contours = new ArrayList(); Log.i(TAG, "Contours"); Imgproc.findContours(gray, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE); Log.i(TAG,"Contours done"); //if no contours are detected if(contours.size() == 0){ Log.i(TAG,"contour size is 0"); return gray; } In my Logcat i see the message "contour size is 0". When i load the gray mat, i see a coloured image which explains why their were no contours detected. Please suggest something.

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>