Need to segment out each card in this image using Python 2.7
Need to segment out each card in this image using Python 2.7
A stack of cards:

I have tried using cv2.contours to no avail. It just shows the entire stack as a contour. I need each of the cards as one object (contour).
cv2.contours
gray = cv2.cvtColor(i, cv2.COLOR_BGR2GRAY)
thresh = cv2.threshold(gray, 20, 255, cv2.THRESH_BINARY)[1]
#find contours in the thresholded image
contours = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
contours[::-1]
contours = contours[0] if imutils.is_cv2() else contours[1]
I turned the image to gray scale, then threshold it. To find the contours, I used cv2.findContours. It returned results of the contour being the entire stack of 3 cards as mentioned. I need each card isolated.
cv2.findContours
Edited with codes and some description. Tq.
– Aureon Ubeso
Jul 2 at 13:05
Have you tried to use straight line detection to determine the card lines and segment your image into sub-images? After you have sub-images, you can iterate over them to detect contours and apply OCR. If you know that the card value will always be in the lower, right-hand section of the card, you can use a bounding-box to narrow your search in a comfortably sized area near the bottom-right of your card (use color or edge detection to determine this area).
– dblclik
Jul 2 at 13:11
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What have you tried? Please post your latest version of the code with output and/or errors when submitting coding questions, along with a description of what is troubling you currently
– dblclik
Jul 2 at 13:01