Ask Your Question

Keehnel's profile - activity

2017-05-11 22:48:58 -0600 commented question New to OpenCV, can't load an image

I did build opencv with samples, and most of them don't work. How does cmake affect VS recognizing what functions are a part of the cv namespace? I can't even get my program to compile.

@berak: I'm pretty sure there aren't any VS 2017 prebuilt packages, I wish there were!! :)

2017-05-10 03:01:43 -0600 commented question New to OpenCV, can't load an image

Thank you! Yes I did, I used cmake and VS 2017

2017-05-10 02:48:08 -0600 asked a question New to OpenCV, can't load an image

Hi! I am new to OpenCV and trying to follow the tutorial to load an image. However, Mat image, namedWindow, imshow, WINDOW_AUTOSIZE, and waitKey are not found in the cv namespace.

I have #included opencv\core.hpp, opencv2\imgcodecs.hpp, opencv2\highgui.hpp, opencv2\opencv.hpp, and opencv2\cv.hpp.

So far I have tried linking $(OPENCV_DIR)\lib, using namespace cv, and adding " CV_ ", " cv:: " and " cv_ " before each command.

The tutorial says to use this code:

Mat image;
image = imread(imageName.c_str(), IMREAD_COLOR);

if( image.empty() ) 
{
     cout <<  "Could not open or find the image" << std::endl ;
     return -1;
}
namedWindow( "Display window", WINDOW_AUTOSIZE );
imshow( "Display window", image );               

waitKey(0);

//I have found that this code will fix all but the " image " problem:

Mat image = imread(imageName.c_str(), IMREAD_COLOR);// " Mat " must be on the same line as " imread "

if( image.empty() )         // " image " is underlined here
{
     cout <<  "Could not open or find the image" << std::endl ;
     return -1;
}
const std::string& windowName("Display Window");      // Must be declared first to work
void namedWindow(int windowName, int WINDOW_AUTOSIZE );// Must have the "void" and "int" types defined
void imshow(int windowName, int image );            // Also must have types, and " image " is ok here

int waitKey(0);                              // Must have int type

I am using OpenCV 3.2 on a clean Windows 10 computer with VS 2017 Enterprise.

Thanks for your help!!