Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems to setup OPENCV2.3.1 with Eclipse C++ for Win7

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.

UPDATE:

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.

like image 349
Jav_Rock Avatar asked Aug 05 '26 08:08

Jav_Rock


1 Answers

Here is how I have setup my working MinGW/Eclipse project... enter image description here

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.

like image 128
mevatron Avatar answered Aug 08 '26 10:08

mevatron