使用OPENCV改善边缘检测
因此,我正在研究一个项目来扫描模拟照片。该程序应自动检测边缘和裁剪。为此,我正在使用Python和OpenCV。我的问题是,有时我的程序由于间隙而无法将照片视为整个矩形。这是一个示例:
这是我使用Canny的代码台:
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # convert the image to gray scale
blur = cv2.GaussianBlur(gray, (1, 1), 0) # Add Gaussian blur to remove noise
edged = cv2.Canny(blur, 75, 200) # Apply the Canny algorithm to find the edges
我还注意到调整模糊参数仅使其与查找边缘更加不准确。
当照片边界的颜色与表面不同时,该程序似乎起作用。
有什么方法可以改进代码,因此检测照片边缘的更准确性?
so I am working on a project to scan analog photos. The program should detect the edges and crop it automatically. For that I am using Python and OpenCV. My problem is that sometimes my program can not detect the photo as a whole rectangle due to gaps. Here is an example:
This is the codepart where I am using canny:
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # convert the image to gray scale
blur = cv2.GaussianBlur(gray, (1, 1), 0) # Add Gaussian blur to remove noise
edged = cv2.Canny(blur, 75, 200) # Apply the Canny algorithm to find the edges
I also noticed that tweaking up the blur parameters only makes it more inaccurate with finding the edges.
The program seems to work when the colour at the border of the photo is different compared to the surface.
Is there any way to improve the code so it is way more accurate in detecting the edges of a photo?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论