Asked By
pratikzg
0 points
N/A
Posted on - 03/26/2012
sir…here i have written my code below….it's showing no error but it is not showing output image and showing just cmd as shown….
Â
Â
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
 int main()
{
   IplImage *p=cvLoadImage("C:/Users/Pratik/Desktop/Open_CV/exa_2603/peppers.png");
   cvNamedWindow("Exa1", CV_WINDOW_AUTOSIZE);
   cvShowImage("Exa1" ,p);
   cvWaitKey(0);
   cvDestroyWindow("Exa1");
   cvReleaseImage( &p);
// p=cvLoadImage("cameraman.tif");
//Â Â Â IplImage *q=cvCreateImage(cvSize(300,300),IPL_DEPTH_8U, 1);
//Â Â Â cvShowImage( "exa1", q);
//cvWaitKey(0);
return 0;
}
Â
Â
cmd with message like this:
process returned 0
press any key to continue
Open cv…here i have written my code below….
Hi Pratikzg,
Here is my analysis with your code:
Â
Â
  IplImage *p=cvLoadImage("C:/Users/Pratik/Desktop/Open_CV/exa_2603/peppers.png");
   cvNamedWindow("Exa1", CV_WINDOW_AUTOSIZE);
   cvShowImage("Exa1" ,p); // I think this is the function that is used to render the image.
   cvWaitKey(0); // Is this function waiting for an event to happen, like keypress or something?Â
  cvDestroyWindow("Exa1"); – // I'm afraid this function executes before you have the chance to view the image.
   cvReleaseImage( &p); // And so this one.
I suggest you comment out the last three lines of code.
Also, if you are debugging, try to add this code before [return;]; system("pause");. This gives you a chance to make your program halt. Though it is not needed if you are executing from the command line.Â
Â
Â
Â
Â
Â
Â