hfalk
hfalk

Reputation: 13

Find corner coordinates in image using openCV

I'm new to image processing and hope someone can help/guide me in the right direction.

So I have a picture in black/white and I want to find the corner coordinates of the inner black part of the preprocessed picture. My question is what kind of method/s will yield the most accurate result?

I want something like this (red dots shows the inner corners)

Upvotes: 0

Views: 3323

Answers (3)

Croolman
Croolman

Reputation: 1123

One of the aproaches would be to use just sobel independently in X and Y (in original image). Since you have binary already just find inner edge, which will be easy.

Those edges can be then sampled - take a few points of the edge. And with the help of OpenCV library function cv::fitLine find the line of the edge. Do the same with all the inner edges and compute the intersections. This approach should be fairly accurate since from the fitLine function on you basically compute the corners in sub-pixel accuracy.

Upvotes: 0

valleymanbs
valleymanbs

Reputation: 487

go with cv::goodFeaturesToTrack() and play with params until you get your result.

you can refer to this on why choose this and not cornerHarris: goodFeaturesToTrack vs cornerHarris

and also to this SO answer for an example: opencv-using-cvgoodfeaturestotrack-with-c-mat-variable

of course I assume you are using C++, if you are using python it won't change much...

have luck and try to do a search before asking next time

Upvotes: 2

l0ckky
l0ckky

Reputation: 1

I don't know what language you're using which makes it harder to answer this question but the way I did it my last time was by applying openCV's canny edge detection algorithm. This allows you to see the edges on the image. Next find the contours. With those two functions and a little help from your friend Google, you will be able to figure this out. Good luck!

Upvotes: 0

Related Questions