I’ve a case where scalintoMe (ofxCvColorImage) is giving back just black pixels.
Basically I’m using Spout2 to receive some pixels from another App and scale it down and draw it. I’m doing it in this way:
spoutReceiver.getTexture().readToPixels(imageColorVideo.getPixels()); // saving my pixels into imageColorVideo
Previously all images are dynamically allocated at first frame spout dims are detected:
Then at Draw is showing black for the scaled image:
imageColorVideoScaled.draw(ofGetMouseX(), ofGetMouseY()); //This draw Black Image
Any idea why is this happening?
pd: I’m on windows, with OF9.8 to receiving Spout to scale it and sending sput from from Of1.0.
Ok, that was the typical problem about texture to pixels… A lot of questions in the forum about this.
I was doing bad just using the texture of the ofxCvColorImage. Was useful if I wanted to simple drawing but to to manipulate internal data as was trying to do by scaling pixels.
The basic case:
(Spout , fbo, … ) ofTexture --> ofxCvColorImage
Most efficient was I find to do it is: Using getPixelsRef(). Only ofImage has this method. So If use an extra Image ( already declared with the right dimensions and image type ) then that can be done like this:
myCvColorImg = myImage;
//now I can scale down without issues
Also not really necessary to use scaleIntoMe…
Using one more FBO to capture desired new size is faster.
//method FBO Drawing Scaled in the desired new size
ofClear(0, 0, 0, 255);
fbo.draw(0, 0, fboScaledDown.getWidth(), fboScaledDown.getHeight());
myVideoImgScaleDown = myFboImageScaleDown;