我在用OpenCV.3开发Python3.6。 我正在尝试自动找到一张纸的轮廓,以将其裁剪为正确的大小,下面是示例:
我看过很多关于同一主题的帖子,但最终还是没有什么真正适合我的。在
我使用的代码是:
orig = cv2.imread("Image.jpg")
cv2.imshow('result', imutils.resize(orig, height=600))
cv2.waitKey(0)
img = cv2.cvtColor(orig, cv2.COLOR_BGR2GRAY)
cv2.GaussianBlur(img, (3,3), 0, img)
edges = cv2.Canny(img,10,20,apertureSize = 3)
cv2.imshow('result', imutils.resize(edges, height=600))
cv2.waitKey(0)
这是输出:
所以现在我试着用HougLines或HougLines概率来找到countours。在
^{pr2}$但我没有任何有用的东西。。(如果我在这里有更多的名声,我可以加上我得到的) 我不知道我是否不需要使用HoughLines,或者只是无法获得正确的参数。。 我已经看过角点检测,但问题是一样的。在
有什么想法吗?在
好吧,我找到了一些很好的东西,给那些即将来到这一页的人。在
首先,找出所有的轮廓线,然后在一张黑色图片上画出来。(我把它们画得更大,就像OpenCv找到的轮廓之间有空间,你不会感到烦恼)
contours
^{pr2}$再次应用canny&find contour。这一步其实只是为了能够找到一个真正的轮廓,如果你的图像不完美。在
final
颜色比你想象的要不同。在
平展图像的亮度以校正照明伪影,然后使像素比背景更接近纸张的颜色。在
相关问题 更多 >
编程相关推荐