I successfully installed and linked and included OpenCV. (I know it was successful because I compiled and ran the opencv program found on this site)
So I went back to the OpenCV documentation and tutorials pages. I copied from this page the exact code below.
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
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;
}
//This is the end
(Running codeblocks on fedora20) Using Project >> Set programs' arguments I fed in "/home/Kennedy/Pictures/enterprise.bmp" without the quotes.
Since I'm using a bmp file (supported), and the file path is correct, can anyone suggest why codeblocks is spitting out
/home/Kennedy/Documents/workspace/OpenCVtest/main.cpp|21|error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope|
instead of running a lovely little first program?
For reference, I've read but not found help on this, this, and other Q&As on stackoverflow, codeblocks forum, and anywhere else I could think to look. I also saw this, but I'm not having a problem with WINDOW_AUTOSIZE.
EDIT TO ADD ANOTHER ATTEMPTED SOLUTION: I copied and pasted enterprise.bmp to the folder containing the project, removed the arguments, and replaced argv1 with "enterprise.bmp". This had no effect, I still get the same error.
In order to load an image off of disk and display it using OpenCV, you first need to call the cv2. imread function, passing in the path to your image as the sole argument. Then, a call to cv2. imshow will display your image on your screen.
jpg”, IMREAD_grayscale); imshow(): This function is used to display images and takes the following two arguments: winname or window name: This is the title of the window displaying the image and is of type string. image: This is the image to be displayed.
Read a Transparent PNG or TIFF in OpenCV These images can be read in OpenCV using the IMREAD_UNCHANGED flag.
So, OpenCV can always read JPEGs, PNGs, and TIFFs. On MacOSX, there is also an option to use native MacOSX image readers.
That means you're likely compiling against opencv 3.0. The symbol "CV_LOAD_IMAGE_COLOR" has been replaced with "cv::IMREAD_COLOR". Just edit the file and you should be good. It's the only deprecated symbol used in Caffe.
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