'Improve edge detection using opencv
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|