3

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.

Community
  • 1
  • 1
Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
  • Lazy answer: download a free copy of Visual Studio Express and follow this tutorial: http://stackoverflow.com/questions/7011238/opencv-2-3-c-visual-studio-2010/7014918#7014918 – karlphillip Dec 20 '11 at 16:27
  • Post some screenshots of your C++ Build Settings for the include directories, library directories, and library link names. – mevatron Dec 20 '11 at 16:40

1 Answers1

2

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.

mevatron
  • 13,911
  • 4
  • 55
  • 72