Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving the result of harris corner detector

Ive been reading about feature detection and wanted to try harris corner detector. I realize that it is achieved by calling

void cornerHarris(InputArray src, OutputArray dst, int blockSize, int ksize, double k, int borderType=BORDER_DEFAULT )

where the dst is an image of floats containing corner strengths at each pixel.

I wanted to see it work so I wanted to apply it to the following picture:

pic of a laptop

The result produced was this:

corners not detected

As you can tell the results are not good. It looks to me that it just picked up noise, the main corners were not even detected.

Here is the code I used to print corners on the image, I used threshold and set any arbitrary value for threshold.

int _tmain(int argc, _TCHAR* argv[])
{

Mat img, dst, threshed;
img = imread("c:\\laptop.jpg",0);

dst = Mat::zeros(img.size(), CV_32FC1);

cornerHarris(img, dst, 2, 3, 0.04, BORDER_DEFAULT);



threshold(dst, threshed, 0.00001, 255, THRESH_BINARY_INV);

namedWindow("meh", CV_WINDOW_AUTOSIZE);
imshow("meh", threshed);
//imwrite("harris.jpg", threshed);
waitKey(0);

return 0;

If I reduce threshold the result is white with just a few black dots (detections) Increasing threshold just produces a more noisy like image.

Am I missing something? How can I improve the quality of this function?

Thank you

like image 448
StuckInPhDNoMore Avatar asked Jan 16 '23 03:01

StuckInPhDNoMore


1 Answers

You can try a goodFeaturesToTrack function. It is built on top of Harris corner detector but filters our the noise and returns only strong corners.

like image 110
Andrey Kamaev Avatar answered Jan 17 '23 17:01

Andrey Kamaev