I have been trying this for the whole day and I managed to make it work openCV but not , and now that I am able to use (cout<<, for example) the compiler doesn´t find the OpenCV libraries. I am trying with a test program:
//
// AR_openCV.cpp
//
// Created on: Dec 20, 2011
// Author: jbarbadillo
///
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "iostream"
#include "stdio.h"
using namespace cv;
using namespace std;
int main()
{
cout << "!!!Hello OpenCV!!!" <<endl;
IplImage* img = 0;
img=cvLoadImage("C:/Users/jbarbadillo/Desktop/1.jpg"); // carica l'immagine
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); // crea la finestra
cvShowImage("mainWin", img ); // mostra l'immagine
cvWaitKey(0); // wait for a key
cvReleaseImage(&img ); //rilascia l'immagine
waitKey(0);
return 0;
}
I have linked the OpenCV includes in C++ compiler and the libraries in the C++ linker. Also the environment variables are checked.
What else can I check? I have followed many tutorials on this but still getting errors on compilation.
Thanks.
The problem was that though thew libraries were linked to the project the werent to the src.cpp. Now they are and i can compile. The problem now is that I build the program but I don't get any image.
Here is how I have setup my working MinGW/Eclipse project...

Note how the full library name is required with MinGW; unlike on Linux where you can just say opencv_core, etc. Also, make sure that either the "%OPENCV_INSTALL_DIR%\bin" is either in the path, or copy the necessary DLLs into the same directory as your executable (e.g., lib_opencv231.dll, etc...).
EDIT :
Try this code to see if it works (the C++ interface is so much nicer as well :)
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
Mat test = imread("C:/Users/jbarbadillo/Desktop/1.jpg");
imshow("test", test);
waitKey();
return 0;
}
Hope that helps.
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