convertToGrayscalePlanarImages not working?

Hi openframeworks mates!

I just downloaded the 006 version and I am having an issue with convertToGrayscalePlanarImages from ofxOpenCv addon.

I have this code that used to work fine on 005, but not now. The thing is that when I draw hueImg, satImg, briImg (that come from convertToGrayscalePlanarImages(hueImg, satImg, briImg))I get nothing, everything is black and looks like is doing nothing.

Here is the code:

testApp.cpp

  
  
#include "testApp.h"  
#include "stdio.h"  
  
//--------------------------------------------------------------  
testApp::testApp(){  
  
}  
  
//--------------------------------------------------------------  
void testApp::setup(){	   
  
    camWidth = 320;  
    camHeight = 240;  
  
    colorImg.allocate(camWidth,camHeight);  
  
    colorImgHSV.allocate(camWidth,camHeight);  
  
    hueImg.allocate(camWidth,camHeight);         
    satImg.allocate(camWidth,camHeight);        
    briImg.allocate(camWidth,camHeight);         
  
    vidGrabber.initGrabber(camWidth, camHeight);      
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
    vidGrabber.grabFrame();                                                   
    colorImg.setFromPixels(vidGrabber.getPixels(), camWidth, camHeight);     
  
    colorImgHSV = colorImg;                                                   
    colorImgHSV.convertRgbToHsv();                                            
    colorImgHSV.convertToGrayscalePlanarImages(hueImg, satImg, briImg);       
	  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
  
    ofBackground(0,0,0);           
  
    ofSetColor(0xffffff);   
                 
    vidGrabber.draw(0,0);  
    colorImgHSV.draw(camWidth, 0);  
    hueImg.draw(0, camHeight);  
}  
  
  

testApp.h

  
  
#ifndef _TEST_APP  
#define _TEST_APP  
  
#include "ofMain.h"  
#include "ofxOpenCv.h"  
  
class testApp : public ofBaseApp{  
  
	public:  
  
		testApp();  
		void setup();  
		void update();  
		void draw();  
  
		ofVideoGrabber vidGrabber;		  
		int camWidth;					  
		int camHeight;					  
			  
		ofxCvColorImage colorImg;			  
		ofxCvColorImage colorImgHSV;		  
	  
		ofxCvGrayscaleImage hueImg;			  
		ofxCvGrayscaleImage satImg;			  
		ofxCvGrayscaleImage briImg;			  
};  
  
#endif  
  

Is this an error or am I doing something wrong?

Thank you!

first 0.06 bug :oops: –

can you add the following lines of code to the convertToGrayscalePlanarImages :

  
  
cvCvtPixToPlane(cvImage, NULL, red.getCvImage(), green.getCvImage(),  
blue.getCvImage());  
  
// this is needed to update the texure of the grayscale images:  
red.flagImageChanged();  
green.flagImageChanged();  
ablue.flagImageChanged();  
  

we’ll get this into the svn and check and see if there any other flagImageChanged() missing.

hope that helps !

zach

Thanks!

Now works pretty good! :smiley:

I committed a fix to the addon svn. Will be fixed in the 0061 release.

Wow, I just spent 4 hours pulling my hair out finding this bug. I think from now I will have to use more up to date code. =]