ScaleIntoMe drawing black pixels. Pixels from Spout2

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:

at update:

spoutReceiver.getTexture().readToPixels(imageColorVideo.getPixels()); // saving my pixels into imageColorVideo
imageColorVideoScaled.scaleIntoMe(imageColorVideo); 

Previously all images are dynamically allocated at first frame spout dims are detected:

	imageColorVideoScaled.allocate(sensorWidth*scaleFactor, sensorHeight*scaleFactor);
	imageColorVideo.allocate(sensorWidth, sensorHeight);

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:


myTextureImage.readToPixels(myImage.getPixelsRef());
myCvColorImg = myImage;
//now I can scale down without issues
myCvImgScaleDown.scaleIntoMe(myCvColorImg );

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
		fboScaledDown.begin();
		ofClear(0, 0, 0, 255);
		fbo.draw(0, 0, fboScaledDown.getWidth(), fboScaledDown.getHeight());
		fboScaledDown.end();

		fboScaledDown.readToPixels(myFboImageScaleDown.getPixelsRef());
		myVideoImgScaleDown = myFboImageScaleDown;
		myVideoImgScaleDown.updateTexture();