cv::goodFeaturesToTrack on a contour

asked 2018-02-01 08:27:46 -0500

darioc85 gravatar image

Hi, I am trying to solve the following problem: given a contour found on a binary blob, I want to create a list of ordered corners in order to track them over time. Blobs are quite irregular, and can be convex or concave. I am already taking the n-first corners, among all of the results of the cv::goodFeaturesToTrack function, and they tends to coincide with the most evident corner of the blob (since it orders corners for score instead of position). Thus, I am taking this output and swapping corners by starting with the top-leftmost coordinate, and then order the corner over the contour. Not rotation invariant, but for this first version it can be ok.

The problem is that the pixel positions of the corners, although very close, are not always on a contour pixel (I am taking all of the contour pixels, and not the extrema, by using RETR_EXTERNAL or RETR_CC_COMP). Even if I call cv::cornerSubPix, output will be a closer pixel, but still not necessarily on the contour. I am solving by performing an hand-made local search, substituting my corner with the closest point among the contour. Anyway, such solution "void" all the efforts made with cv::cornerSubPix, giving me some point that lies on the line (very close to the corner, but not in that point). Is there any other solution to solve this problem? Moreover, since ordering a set of points among the contour is quite an easy task... why the output of cv::goodFeaturesToTrack on a contour does not necessarily gives me points lying on the contour? Is there some error I made, or is there any reason that I am ignoring?

Thank you very much for your help.

edit retag flag offensive close merge delete

Comments

Is it real time application?

LBerger gravatar imageLBerger ( 2018-02-01 09:41:49 -0500 )edit

Yes, but considering the small size of the objects (few blobs representing chars in a page), I am not having any problem about performance for the moment.

darioc85 gravatar imagedarioc85 ( 2018-02-01 09:53:27 -0500 )edit

I still have to manually use an algorithm to find, for each corner output of goodFeaturesToTrack, the closest point on the contour. I am wondering if this is an expected behaviour of the function, or my bad usage.

darioc85 gravatar imagedarioc85 ( 2018-06-24 10:57:12 -0500 )edit

^^ @darioc85, not an answer, so please don't post one.

berak gravatar imageberak ( 2018-06-24 11:01:05 -0500 )edit