简体   繁体   English

使用Opencv Python检测角点

[英]Detecting corners using Opencv Python

I am trying to find the corners of the 4 pillars which are of yellow in colour and also detecting extreme corners of the board which is of white in colour. 我正在尝试找到黄色的4个支柱的角,并且还要检测白色的木板的极端角。

Basically i want to calculate the area of whole space after subtracting the area of each pillar. 基本上我想减去每个支柱的面积后计算整个空间的面积。 For that first am trying to identifying the corner of pillars to find the area of each pillar. 为此,我首先尝试确定支柱的拐角以找到每个支柱的面积。

输入图像

Here is the code which I tried, I am almost half way through it. 这是我尝试的代码,我几乎完成了一半。

import numpy as np
import cv2

img = cv2.imread('Corner_0.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)

corners = cv2.goodFeaturesToTrack(gray, 100, 0.01, 10)
corners = np.int0(corners)

for corner in corners:
    x,y = corner.ravel()
    cv2.circle(img,(x,y),3,255,-1)

cv2.imwrite('Detected_Corner_0.jpg',img)

我得到的输出图像

I would like to detect corner and calculating the area of the pillar. 我想检测拐角并计算支柱的面积。

When I use Grabcut I am able to apply for one pillar, does this make sense? 使用Grabcut时,我可以申请一个支柱,这有意义吗?

应用Grabcut之后

Corner detectors often cannot be relied on. 拐角检测器通常不能被依靠。 The show extra corners and miss the ones you expect. 显示额外的角落,错过您期望的角落。 What's more, you have to identify an regroup them. 而且,您必须识别出它们的重新组合。

You obtain interesting results by computing a saturation image (S in LSH). 通过计算饱和度图像(LSH中的S),您可以获得有趣的结果。 Then by binarization and blob analysis, you can easily find the areas. 然后通过二值化和斑点分析,您可以轻松找到区域。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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