OpenCV Python find contour point closest to a given point -


in opencv, given point (x,y), best way find point closest belongs known contour cnt? (i assume point lies outside contour.)

dist = cv2.pointpolygontest(cnt,(x,y),true) 

pointpolygontest returns distance of closest contour point not see way actual point.

of course, loop on list of contour points , recalculate distance finding 1 minimum distance. (a couple of questions on explain more sophisticated ways finding closest point out of list of points given point.)

alternatively, draw circle radius dist , see circle , contour touch.

both options seem little clunky, wonder if missing more straight forward.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -