I\'m doing computer vision project for automatic card detection. I need to separate the card from the background. I have applied the canny edge detection, using automatic parame
There are multiple possible solutions.
The simplest one may be:
low_threshold
, until you find a closed contour. If the closed contour has roughly the right size and shape, it is a card. The answer linked by Haris explains how to check whether a contour is closedAnother rather simple solution:
FindContours does not need an edge image, it is usually executed with a thresholded image. I don't know your source image, so I cannot say how good this would work, but you would definitely avoid the problem of holes in the shape.
If the source image does not allow this, then the following may help:
cv:watershed()
.If the background in that image is the same color as the card, then the previous two methods may not work so well. In that case, your best bet may be the solution suggested by Micka: