Hello again
I have some troubles converting an IplImage that is used as a depth image from cvFindStereoCorrespondence to ofxcvgrayscaleimage, which is very convenient in order to use the draw function afterwards
I convert using the = operator, but I get this error : “images need to match in size, channels, and depth”
In my header file I have declared :
ofxCvGrayscaleImage depthimg;
IplImage* depthImage;
At my .cpp file the code that concerns my problem is:
depthImage = cvCreateImage(cvSize(image1->width,image1->height), IPL_DEPTH_8U, 1);
image1_wrp = cvCreateImage(cvSize(image1->width,image1->height),image1->depth,1);
image2_wrp = cvCreateImage(cvSize(image2->width,image2->height),image2->depth,1);
// warp the source image using the homography
cvWarpPerspective( image1, image1_wrp ,homography_out1);
cvWarpPerspective( image2 , image2_wrp,homography_out1);
// compute the disparity map
cvFindStereoCorrespondence(image1_wrp , image2_wrp, CV_DISPARITY_BIRCHFIELD, depthImage,50, 15, 3, 6, 8, 15);
//convert
depthimg = depthImage;
I know that the = operator is using the ofxcvImage = operator function which is this one:
void ofxCvImage::operator = ( const IplImage* mom ) {
if( mom->width == width && mom->height == height &&
mom->nChannels == cvImage->nChannels &&
mom->depth == cvImage->depth )
{
cvCopy( mom, cvImage );
flagImageChanged();
} else {
ofLog(OF_LOG_ERROR, "in =, images need to match in size, channels, and depth");
}
}
How can I set the width, height, depth and channels so that I won’t get this error?
Thank you very much!