I've been trying to figure out how to go about detecting cards on a table, then extracting images of just the cards. After doing some reading, I figured it's best to use cv.Canny to edge detect since the cards will be the only things on the white table. Then, get the card image from a rectangular cutout of the image according to the edges detected.
But I'm not sure how to get the edge information(coordinates) from the Canny info. I can get the Canny information and store it to an IplImage, but I'm not sure how to get information necessary to create a rectangle around the card and cutout the image.
import cv
cam = cv.CaptureFromCAM(0)
while True:
capture = cv.QueryFrame(cam)
#apply mask to block out white background
grey = cv.CreateImage(cv.GetSize(capture), 8, 1)
masked_image = cv.CreateImage(cv.GetSize(capture), 8, 3)
cv.CvtColor(capture, grey, cv.CV_BGR2GRAY)
cv.Threshold(grey, grey, 100, 255, cv.CV_THRESH_BINARY)
cv.Zero(masked_image)
cv.Not(grey, grey)
cv.Copy(capture, masked_image, grey)
#detect corners
corners = cv.CreateImage(cv.GetSize(masked_image), 8, 1)
#cv.CornerHarris(masked_image, corners, ?)
cv.Canny(grey, corners, 900, 890)
cv.ShowImage('b_window', corners)
cv.WaitKey(2)