Corner detection in Image processing Opencv Python

你离开我真会死。 提交于 2019-12-03 08:21:52

I wouldn't say I have reached the best solution, but after quite a lot of coding I was able to obtain the following:

To obtain this I followed the following steps:

1. First: Obtain the edges of the box

  • I performed bilateral filtering on the grayscale image.
  • Found the edges using Canny edge detection.
  • Enhanced the edges using morphological dilation.

This is the result of the above:

Now when I did Corner detection, I was not at all satisfied:

So what did I do?

2. Finding desired corners

  • I blurred the dilated image using a window of size 9x9.
  • Then applied Harris corner detection to this blurred image.

As a result I was able to obtain this:

I know it is not perfect but it can always be fine tuned.

Here is the code for corner detection:

dst = cv2.cornerHarris(dilate,2,3,0.04)
#----result is dilated for marking the corners, not important-------------
dst = cv2.dilate(dst,None) 
#----Threshold for an optimal value, it may vary depending on the image---
img[dst>0.01*dst.max()]=[0,0,255]

@Jeru Luke. Why not Harriscornering based on the result data from your step1?

  1. I performed bilateral filtering on the grayscale image.
  2. Found the edges using Canny edge detection.
  3. Enhanced the edges using morphological dilation.

If you do that the painting on the corners would be neat and fit within the lines, right?

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