I have tried to build the sample program from OpenCV documentation, but i have encountered a problem:
error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope
Source of program:
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
I think that CV_WINDOW_AUTOSIZE
constants have been contained in a certain header file, but I can't find the necessary header file.
CV_WINDOW_AUTOSIZE
actually really is found in highgui.h
, BUT, as @berak pointed out in the comments, that's part of the obsolete c-api. You should instead do one of two things:
WINDOW_AUTOSIZE
instead, which is part of the C++ API. You don't need to change anything else to make this work, not even #include anything that isn't already #included in the example.namedWindow( "Display Image" )
instead, since namedWindow uses WINDOW_AUTOSIZE
by default and so you don't even have to include it as an argument.Tested for OpenCV 3.0.0
It appears that in OpenCV 3.1 you need to use cv::WindowFlags::WINDOW_AUTOSIZE
which is located in <opencv2/highgui.hpp>
.
For opencv 4, it is defined in <opencv2/highgui/highgui_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