0

I have a code in C language that uses the cvopen Library. Here is the code:

    #include <stdio.h>
#include <opencv2\highgui\highgui_c.h>


int main(void)
{
    int i;
    cvNamedWindow("Display window", CV_WINDOW_AUTOSIZE); //create a window
                                                         //create an image
    IplImage* image = cvLoadImage("C:\\Users\\magshimim\\Desktop\\Mummy.png", 1);
    if (!image)//The image is empty.
    {
        printf("could not open image\n");
    }
    else
    {
        cvShowImage("Display window", image);
        cvWaitKey(0);
        system("pause");
        cvReleaseImage(&image);
    }

    getchar();
    return 0;
}

In line 17 "cvShowImage("Display window", image);" the system throws exception that says:

Exception thrown at 0xAD76406A in Q4.exe: 0xC0000008: An invalid handle was specified

The cvopen pack is fine, and other function works. but this code (which works on other computers) just crushes every time. How can i fix this?

Ma_Name
  • 23
  • 6

1 Answers1

1

cvShowImage is part of the old C-style naming convention in OpenCV. This old convention has been fully depreciated and is not compatible with OpenCV 3.0 and up.

Instead of cvShowImage try using imshow imshow("Display Window", image);

Tahera Tabassum
  • 264
  • 1
  • 9
  • Thank you! The problem was actually in the image i tried to open. cvShowImage worked in with JPG and not PNG. – Ma_Name Jun 14 '18 at 16:04