How to find endpoints of lines in OpenCV?

前端 未结 4 786
滥情空心
滥情空心 2021-01-19 00:42

I have an image made up of lines; how can I find the endpoints with OpenCV?

The lines are about 20 pixels wide. They turn, branch, and can be at angles (although mos

4条回答
  •  猫巷女王i
    2021-01-19 01:17

    I speak Chinese, while my English is poor.

    So I just post my core steps.

    A general way to find endpoints of lines is:

    1. Binary the gray image.
    2. Find the skeleton of the binary image.
    3. Do hit-miss operation (all end points) or goodFeaturesToTrack(all corners include endpoints) on the skeleton.

    Notice:

    You should select a good skeleton method to make sure that the endpoints wouldn't shrink(while my example does shrink).


    This is the result.

    This is a demo using hit-miss to find special points.

提交回复
热议问题