i need to convert an opencv cvMat object (a frame grabbed from a
webcam), to a cairo imagesurface for a video library i'm writing for
I'm using a numpy array as a buffer passed to
the chain of passages includes passing from cvMat to a PIL image, then
to numpy array (after swapping red and blue channels) and finally to
Can someone suggest a smarter/faster way to do it?
Is there a more direct way of transforming a cvMat to numpy array
without passing through PIL?
I think opencv and cairo both use BGR, so it's a bit nonsense to swap
b and r passing to PIL and then back to original scheme for cairo.
I'm trying to optimize my code for speed, but as you have probably
already guessed i'm a sort of newbie, any useful tip?
thanks in advance
this is a test code i'm using in order to pass from opencv to cairo,
actually it seems to basically work, when i use the cairo surface,
image is shown and color channels seem to be right, but values are
altered and totally out of range. what am i doing wrong?
any help would be greatly appreciated.
import opencv, numpy, cairo
from opencv import highgui as hg
im2 = opencv.cvCreateImage(opencv.cvGetSize(im),8, 4)