beginner question on how to fix the error on this simple program

classic Classic list List threaded Threaded
2 messages Options
s
Reply | Threaded
Open this post in threaded view
|

beginner question on how to fix the error on this simple program

s
I am using the Learning opencv.pdf and try to use the first example on code::blocks 10.05 to try this example, but I get error.

I have install opencv 2.0, and I try the demhist.c sample program ok.

Example 2-1. A simple OpenCV program that loads an image from disk and displays it on the screen
#include "highgui.h"
int main( int argc, char** argv ) {
IplImage* img = cvLoadImage( argv[1] );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
}

here is the error message that I get, what might be wrong.
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|1|error: #include expects "FILENAME" or <FILENAME>|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c||In function 'main':|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|3|error: 'IplImage' undeclared (first use in this function)|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|3|error: (Each undeclared identifier is reported only once|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|3|error: for each function it appears in.)|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|3|error: 'img' undeclared (first use in this function)|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|4|error: stray '\241' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|4|error: stray '\260' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|4|error: stray '\241' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|4|error: stray '\261' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|4|error: 'Example1' undeclared (first use in this function)|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|4|error: 'CV_WINDOW_AUTOSIZE' undeclared (first use in this function)|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|5|error: stray '\241' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|5|error: stray '\260' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|5|error: stray '\241' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|5|error: stray '\261' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|8|error: stray '\241' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|8|error: stray '\260' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|8|error: stray '\241' in program|
C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple image read.c|8|error: stray '\261' in program|
||=== Build finished: 19 errors, 0 warnings ===|

I install the learningopencv sample code in:
c:\opencv2.0\document\learningopencv_code\learningopencv_code


Reply | Threaded
Open this post in threaded view
|

Re: beginner question on how to fix the error on this simple program

Francisco Ares
Em , s <[hidden email]> escreveu:


> I am using the Learning opencv.pdf and try to use the first example on  
> code::blocks 10.05 to try this example, but I get error.

> I have install opencv 2.0, and I try the demhist.c sample program ok.

> Example 2-1. A simple OpenCV program that loads an image from disk and  
> displays it on the screen

> #include "highgui.h"
> int main( int argc, char** argv ) {
> IplImage* img = cvLoadImage( argv[1] );
> cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
> cvShowImage( "Example1", img );
> cvWaitKey(0);
> cvReleaseImage( &img );
> cvDestroyWindow( "Example1" );
> }

> here is the error message that I get, what might be wrong.
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|1|error: #include expects "FILENAME" or |
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c||In function 'main':|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|3|error: 'IplImage' undeclared (first use in this function)|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|3|error: (Each undeclared identifier is reported only once|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|3|error: for each function it appears in.)|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|3|error: 'img' undeclared (first use in this function)|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|4|error: stray '\241' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|4|error: stray '\260' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|4|error: stray '\241' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|4|error: stray '\261' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|4|error: 'Example1' undeclared (first use in this function)|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|4|error: 'CV_WINDOW_AUTOSIZE' undeclared (first use in this  
> function)|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|5|error: stray '\241' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|5|error: stray '\260' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|5|error: stray '\241' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|5|error: stray '\261' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|8|error: stray '\241' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|8|error: stray '\260' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|8|error: stray '\241' in program|
> C:\OpenCV2.0\document\LearningOpenCV_Code\LearningOpenCV_Code\simple  
> image read.c|8|error: stray '\261' in program|
> ||=== Build finished: 19 errors, 0 warnings ===|

> I install the learningopencv sample code in:
> c:\opencv2.0\document\learningopencv_code\learningopencv_code



It seems it is just a matter of your compiler correctly locating the header  
file "highgui.h". The easiest way is to use the full path to that file.

You mentioned that you (as far as I could understand) successfully built  
demhist.c . So you can check how "highgui.h" is included on it. Or, most  
probably, if you used a ready made project, check its properties, you might  
find out that the project caries instructions where to look for headers and  
libraries - also most probably your next problem.

Hope this helps. In the future, please tell us which compiler or IDE you  
are using, which platform, and which OpenCV version you have - perhaps even  
where did you find it.

Francisco