如何求桌子腿的数量
我真的很困惑,我有这张图片 我需要找到腿的数量。这意味着,当我执行代码时,输出会给我“4” 我尝试了两种方法,其中一种使用边缘检测器
# import the required library
import numpy as np
import cv2
from matplotlib import pyplot as plt
class Point:
x = 0
y = 0
# read the image
img = cv2.imread('Table.png')
# convert image to gray scale image
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# detect corners with the goodFeaturesToTrack function.
corners = cv2.goodFeaturesToTrack(gray, 27, 0.01, 10)
corners = np.int0(corners)
# we iterate through each corner,
# making a circle at each point that we think is a corner.
for i in corners:
x, y = i.ravel()
print("x: " + str(x) + " y: " + str(y))
cv2.circle(img, (x, y), 3, 255, -1)
plt.imshow(img), plt.show()
我编写了这段代码并得到了这个结果
但我不知道之后我会做什么。你们能给我一条路线吗?但在完成我的问题之前,我还尝试了精明算法,它绘制所有表格并给我一个“1”结果。如果我可以将桌子的所有部分分开,也许可以找到桌腿的数量。无论如何我仍然很困惑。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论