简体   繁体   中英

How to detect lines in this pic using opencv?

在此处输入图片说明

I don't know why opencv can't find out the lines using HoughLines, the result is follow,

在此处输入图片说明

But if I use another picture from the internet, 在此处输入图片说明

voila. Any ideas?

It seems that Hough detect the lines extremities. A gradient is probably computed during the process.

A solution would be to:

  1. Binarize the image
  2. Compute the black region skeleton
  3. Skeleton pruning
  4. Apply the Hough Transform.

Doing that, each line will be reduced to 1 pixel width.

[EDIT] Here is an example:

  1. The test image binarized
  2. The skeleton (simple thinning).
  3. The result (I skipped the pruning).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM