First the code:
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( "MyPic.jpg", CV_LOAD_IMAGE_GRAYSCALE );
if( !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE);
imshow( "Display Image", image );
waitKey(0);
return 0;
}
A simple program that just loads an image with then name "MyPic.jpg" , this is an example that I found on the open CV website documentation (with small changes). It gives me these two error:
‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
‘CV_WINDOW_AUTOSIZE’ was not declared in this scope
Why is it not working? What's wrong?
I am putting my comment as answer so that others who face this issue can find the solution easily.
Are you using the trunk or the release version of OpenCV? If it is the former, then you are supposed to use IMREAD_GRAYSCALE
and WINDOW_AUTOSIZE
instead. The new documentation, including changes in function calls, etc. can be found in this link.
HTH
Solved this by doing the following:
using namespace cv;
CV_LOAD_IMAGE_GRAYSCALE
, try doing: cv::IMREAD_GRAYSCALE
alternatives:
Going through the opencv project you can also attempt to run a quick search with your constant and provide a numerical value instead. For example, in the case of CV_LOAD_IMAGE_GRAYSCALE
, it was found to correspond to the value of 0 within the code (specifically within the file constants_c.h
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With