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

How to detect colored rectangle from image in android?

$
0
0
hello all, i want detect specific colored rectangle from paper sheet which indicate border of paper.so i want detect that rectangle and crop it so i can do further operation on sheet. i tried this code.. Mat rgbMat = new Mat(); Utils.bitmapToMat(resultBitmap1, rgbMat); Mat grayMat = new Mat(resultBitmap1.getHeight(), resultBitmap1.getWidth(), CvType.CV_8U, new Scalar(1)); List contours = new ArrayList(); Mat hierarchy = new Mat(); Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY, 2); Imgproc.threshold(grayMat, grayMat, 100, 255, Imgproc.THRESH_BINARY); Core.bitwise_not(grayMat, grayMat); Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); pointList=new ArrayList(); for(int i=0; i

Viewing all articles
Browse latest Browse all 19555

Trending Articles