Open cv…here i have written my code below….

Asked By 0 points N/A Posted on -
qa-featured

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

SHARE
Answered By 5 points N/A #143524

Open cv…here i have written my code below….

qa-featured

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. 

 

 

 

 

 

 

Related Questions