ofxPS3EyeGrabber to get two cameras working simultaniously. I already have both images, but now i want to make blob detention on them using
Now i need to get an
ofxCvGrayscaleImage from an
ofTexture. Here is what i have:
What i need is something like this:
But theres no
getPixelsRef() in ofTexture.
a texture is memory in the graphics card and reading it back to an ofPixels which is in the computers memory would be slow. the easiest in your case would be to directly copy the pixels from the grabber to the cv image like:
if you really need to copy the info from a texture into a cv image then you can read it back thoryugh an ofPixels like:
but that’s usually really slow.
I’ve already tried that. But here is what i get:
Some weird noise. Im i missing something important?
Get the same noisy image using ofPixels.
oh, ok yes the image from the video camera is a color image and you are trying to put it in a grayscale one, you need to convert it first. take a look at the openCvExample where it shows how to do this conversion
With a color image i get the same. In that example the only thing it does is:
grayImage = colorImg;
Exactly what i have
I think the problem may be in the
videoGrabber, since it isnt the usually
ofVideoGrabber. Im using ofxPS3EyeGrabber, so what i have is:
std::vector<std::shared_ptr<ofxPS3EyeGrabber> > videoGrabbers;
std::shared_ptr<ofxPS3EyeGrabber> videoGrabber = std::shared_ptr<ofxPS3EyeGrabber>(new ofxPS3EyeGrabber());
Any sugestions on a work around? thanks!
with OfxCV you can use convertColor()
I did not test it but try something like:
convertColor(colorImg.getPixelsRef(), grayImage.getPixelsRef(), CV_RGB2GRAY);
Still with all that noise. My output windows shows this error:
[warning] ofxCvColorImage: copy constructor: source image not allocated
I don’t know why but I got it working with ofImage but not with ofxCvColorImage
Here is a woking example:
ofxCv::convertColor(img.getPixelsRef(), grayImage.getPixelsRef(), CV_RGBA2GRAY);
Just wanted to add that @talaron’s solution worked for me, without much of a performance penalty. Thanks dude. Although, like you, I’m also still confused as to why.
Hi. Following the official document. It works for me.
//in draw method
grayImage = Cam;