I am trying to use CornerHarris method of openCV in my android application to detect the four corners of the image that I pass in. I have managed to pass the the image into CornerHarris. But I need to indicate the four corners of the image by circles. This is the code that I have written so far:
private Mat findCorners(Mat original_image) {
Mat imgSource = original_image;
// Mat untouched = original_image.clone();
// convert the image to black and white
Imgproc.cvtColor(imgSource, imgSource, Imgproc.COLOR_BGR2GRAY);
// convert the image to black and white does (8 bit)
Imgproc.Canny(imgSource, imgSource, 200, 200);
Imgproc.cornerHarris(imgSource, imgSource, 2, 3, 0.04, 1);
for(int y = 0; y < imgSource.height(); y++){
for(int x = 0; x < imgSource.width(); x++){
//need to complete here.
}
}
Highgui.imwrite(baseDir + "/mediaAppPhotos/harris.png", imgSource);
}
Following are the tutorials I followed (in python and C++):
I need to to know how to complete this code and get it working. Any help is appreciated!
EDIT
I want to find corners of this kind of an image like this:
解决方案
Various techniques to find edges in the image.
Extract the white colour with HSV inrange()
Use Hough lines transform to detect the lines.
Use the angles of the detected lines to find the corners.