简体   繁体   中英

displaying image in opencv

I am writing a simple program for displaying image in a window, but when running it is not loading the image. I am not getting why this is happening?

#include<opencv/cvaux.h>
#include<opencv/highgui.h>
#include<opencv/cxcore.h>
#include<opencv/cv.h>


#include<stdio.h>
#include<stdlib.h>


int main(int argc, CHAR* argv[])
{
  IplImage* img = cvLoadImage("C:\Users\jai guru umesh\Desktop\6.jpg");

  if (!img)
  {
    printf("Image can NOT Load!!!\n");
    return 1;
  }

  cvNamedWindow("myfirstwindow");
  cvShowImage("myfirstwindow", img);

  cvWaitKey(0);
  cvReleaseImage(&img);

return 0;
}

\\ is an escape character.

Change

IplImage* img = cvLoadImage("C:\Users\jai guru umesh\Desktop\6.jpg");

to

IplImage* img = cvLoadImage("C:\\Users\\jai guru umesh\\Desktop\\6.jpg");

or

IplImage* img = cvLoadImage("C:/Users/jai guru umesh/Desktop/6.jpg");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM