Failed to load image

Hi, I tried to run the following code in Visual Studio 2010 C++ but then it give an error: fatal error LNK1120: 6 unresolved externals

May I know what happen actually? TQ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
using namespace std;
int main(int argc, char* argv[])
{
printf("Hello world\n");
IplImage *img = cvLoadImage("C:\Users\128A5S5\Desktop\21.jpg");
// Create a window
cvNamedWindow( "result",
CV_WINDOW_AUTOSIZE // allow window to resize to fit image true size
);
cvShowImage( "result", img ); // Show image in window already created
// Wait for a keystroke. If a positive argument is given, it will wait for
// that number of milliseconds and then continue. If 0 is given, the
// program will wait indefinitely for a keypress.
cvWaitKey(0);
// Clean up (not really necessary, but good programming practice)
cvReleaseImage( &img );
cvDestroyWindow("result");
system("PAUSE");
return EXIT_SUCCESS;
}
\ is used for escape characters like \n. Replace \ with / or \\ in the path.
Hi peter, thanks for the details on how to use \, now I change the code to the following, but the error still the same as above~~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
using namespace std;
int main(int argc, char* argv[])
{
printf("Hello world\n");
IplImage *img = cvLoadImage("C:/Users/128A5S5/Desktop/21.jpg");
// Create a window
cvNamedWindow( "result",
CV_WINDOW_AUTOSIZE // allow window to resize to fit image true size
);
cvShowImage( "result", img ); // Show image in window already created
// Wait for a keystroke. If a positive argument is given, it will wait for
// that number of milliseconds and then continue. If 0 is given, the
// program will wait indefinitely for a keypress.
cvWaitKey(0);
// Clean up (not really necessary, but good programming practice)
cvReleaseImage( &img );
cvDestroyWindow("result");
system("PAUSE");
return EXIT_SUCCESS;
}
Last edited on
I need an advice from u guy too, now I'm doing the project related to image processing, which library u think is the best and easiest to do with image? Open CV in C++? Or just a normal C++? Thanks...
Topic archived. No new replies allowed.