I've seen from the sample how to display an image from the webcam, but how do I get the image captured as an array?
import cv capture = cv.CaptureFromCAM(0) img = cv.QueryFrame(capture)
img.tostring() gives me weird caracters. Thanks in adv.
I think this is what you're looking for:
img=cv.LoadImage("asd.png") mat=cv.GetMat(img) mat[3,1] (83.0, 88.0, 89.0)
anyway, you should check opencv python cookbook for use with PIL and NUMPY packages.
Be sure to get an opencv with numpy support included. The sequence that works for me is capture an IPL, convert to cvMat, convert to numpy:
import cv, numpy, pylab capture = cv.CaptureFromCAM(0) img = cv.QueryFrame(capture) mat=cv.GetMat(img) a = numpy.asarray(mat) pylab.imshow(a)
Note that the representation of color is different from what pylab assumes. But there comes opencv documentation to your help!