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

Find rectangle from image in android?

$
0
0
hello, i want to find four black cornered rectangle from below image ![image description](/upfiles/14659135153971174.png) how to find those four border rectangle from this image? i have tried with this code Mat rgbMat=ImageUtils.bitmapToMat(resultBitmap); Mat grayMat = new Mat(resultBitmap.getHeight(), resultBitmap.getWidth(),CvType.CV_8U, new Scalar(1)); Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY, 2); Imgproc.threshold(grayMat, grayMat, 100, 255, Imgproc.THRESH_BINARY); Core.bitwise_not(grayMat, grayMat); List contours = new ArrayList(); Mat hierarchy = new Mat(); Imgproc.findContours(grayMat, contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); List pointList=new ArrayList(); for(int i=0; i 100) { Imgproc.drawContours(rgbMat, contours, i, new Scalar(255, 0, 0), 3); } } resultBitmap = ImageUtils.matToBitmap(rgbMat); Thanks in advance

Viewing all articles
Browse latest Browse all 19555

Trending Articles



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