This might have been answered but I desperately need an answer for this. I want to find the largest square or rectangle in an image using OpenCV in Android. All of the solutions that I found are C++ and I tried converting it but it doesn't work and I do not know where I'm wrong. privateMatfindLargestRectangle(Matoriginal_image){MatimgSource=original_image;Imgproc.cvtColor(imgSource,imgSource,Imgproc.COLOR_BGR2GRAY);Imgproc.Canny(imgSource,imgSource,100,100);//I don't know what to do in herereturnimgSource;}
What I am trying to accomplish in here is to create a new image that is based on the largest square found in the original image (return value Mat image).
This is what I want to happen:
It's also okay that I just get the four points of the largest square and I think I can take it from there. But it would be better if I can just return the cropped image.