Getting corners from convex points

痞子三分冷 提交于 2019-12-06 06:18:52

问题


I have written algorithm to extract the points shown in the image. They form convex shape and I know order of them. How do I extract corners (top 3 and bottom 3) from such points? I'm using opencv.


回答1:


if you already have the convex hull of the object, and that hull includes the corner points, then all you need to to do is simplify the hull until it only has 6 points.

There are many ways to simplify polygons, for example you could just use this simple algorithm used in this answer: How to find corner coordinates of a rectangle in an image

do
   for each point P on the convex hull: 
       measure its distance to the line AB _ 
       between the point A before P and the point B after P, 
   remove the point with the smallest distance 
repeat until 6 points left

If you do not know the exact number of points, then you could remove points until the minimum distance rises above a certain threshold

you could also do Ramer-Douglas-Peucker to simplify the polygon, openCV already has that implemented in cv::approxPolyDP.

Just modify the openCV squares sample to use 6 points instead of 4




回答2:


Instead of trying to directly determine which of your feature points correspond to corners, how about applying an corner detection algorithm on the entire image then looking for which of your feature points appear close to peaks in the corner detector?

I'd suggest starting with a Harris corner detector. The OpenCV implementation is cv::cornerHarris.

Essentially, the Harris algorithm applies both a horizontal and a vertical Sobel filter to the image (or some other approximation of the partial derivatives of the image in the x and y directions).

It then constructs a 2 by 2 structure matrix at each image pixel, looks at the eigenvalues of that matrix, and calls points corners if both eigenvalues are above some threshold.



来源:https://stackoverflow.com/questions/10261479/getting-corners-from-convex-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!