Reputation: 309
I have installed opencv 3.0 and verified that its properly working.Then started a tutorial on Loading and displaying an image which gave me errors stating that ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope.I went through similar posts but were not helpful
and here is the code.Any help is very much appreciated.
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display.
imshow( "Display window", image ); // Show our image inside it.
waitKey(0); // Wait for a keystroke in the window
return 0;
}
Upvotes: 4
Views: 3970
Reputation: 6080
The documentation for OpenCV 3.0 can be found here: http://docs.opencv.org/3.0.0/d4/da8/group__imgcodecs.html
The current enum responsible for imread is:
enum cv::ImreadModes {
cv::IMREAD_UNCHANGED = -1,
cv::IMREAD_GRAYSCALE = 0,
cv::IMREAD_COLOR = 1,
cv::IMREAD_ANYDEPTH = 2,
cv::IMREAD_ANYCOLOR = 4,
cv::IMREAD_LOAD_GDAL = 8
}
This means you need to use cv::IMREAD_COLOR
when using OpenCv 3.0 instead of cv::CV_LOAD_IMAGE_COLOR
.
image = imread(argv[1], IMREAD_COLOR); // Read the file
Upvotes: 4
Reputation: 548
CV_LOAD_IMAGE_COLOR is declared in opencv2/imgcodecs/imgcodecs_c.h. Therefore, you need to add
#include<opencv2/imgcodecs/imgcodecs_c.h>
Besides, you can include just one header file
#include <opencv2/opencv.hpp>
instead of separately include all the header files in opencv.
Upvotes: 0