Hi all!
I have a problem trying to set the pixels of a grayscale ofImage to the pixels in a ofxCvGrayscaleImage. Basically, ofImage.setFromPixels doesn’t seem to work for me
Here’s some code that shows my problem (see the comments):
in testApp.h
ofxCvGrayscaleImage imgCv;
ofImage img;
ofTexture tx;
ofxCvColorImage imgColCv;
ofImage imgCol;
int w, h;
in testApp.cpp
//--------------------------------------------------------------
void testApp::setup(){
w = 160;
h = 120;
imgCv.allocate(w, h);
img.allocate(w, h, OF_IMAGE_GRAYSCALE);
tx.allocate(w, h, GL_LUMINANCE);
imgColCv.allocate(w, h);
imgCol.allocate(w, h, OF_IMAGE_COLOR);
}
//--------------------------------------------------------------
void testApp::update(){
// I set my gray image to a whiteish color
imgCv.set(223);
// this setFromPixels doesn't seem to work.
img.setFromPixels(imgCv.getPixels(), w, h, OF_IMAGE_GRAYSCALE);
// but this does work, so I guess the problem is in setFromPixels.
tx.loadData(imgCv.getPixels(), w, h, GL_LUMINANCE);
// this also works ok.
imgColCv.set(255,0,23);
imgCol.setFromPixels(imgColCv.getPixels(), w, h, OF_IMAGE_COLOR);
}
//--------------------------------------------------------------
void testApp::draw(){
imgCv.draw(0,0);
img.draw(w, 0); // this is not right. should be whiteish too.
tx.draw(w*2, 0);
imgColCv.draw(0, h);
imgCol.draw(w, h);
}
And this is the result I am getting.
So if I’m not mistaken, ofxCvGray.getPixels() works because the texture shows ok. and setFromPixels also works with color images…
I won’t dare to mention the word bug because I’m sure it’s some dumbness that I’m doing here…
I’m on Win / of_CB_0.05 FAT
zipped-src
Any help appreciated.
Thanks a lot!