Reputation: 1141
I am looking to pass an IplImage* to a function and display the image in that function. My code is as follows.
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <cv.h>
#include <highgui.h>
IplImage* doPyrDown(IplImage* in) {
cvNamedWindow( "Debug", CV_WINDOW_AUTOSIZE );
cvShowImage("Debug", in );
cvWaitKey(0);
cvReleaseImage(&in );
IplImage* out = 0;
return( out );
}
int main(int argc, char *argv[])
{
cvNamedWindow( "Example6-in", CV_WINDOW_AUTOSIZE );
IplImage* imgIN = 0;
IplImage* imgOUT = 0;
imgIN = cvLoadImage("image.jpg");
cvShowImage("Example6-in", imgIN );
cvWaitKey(0);
cvReleaseImage(&imgIN );
imgOUT = doPyrDown(imgIN);
return 0;
}
The original image is displayed in the main function. But the image isn't getting displayed in the doPyrDown function. An empty window is getting created called "Debug".
Please help.
Upvotes: 0
Views: 2385
Reputation: 13421
You do a cvReleaseImage
on imgIN
before passing it into doPyrDown
. I'm not familiar with opencv but I would not expect cvShowImage to work after that.
Upvotes: 1