Ask Your Question
0

OpenCV installation into eclipse

asked 2016-01-04 17:42:37 -0600

patrickhuie19 gravatar image

updated 2016-01-06 20:31:38 -0600

General Note: I'm using Ubuntu 14.04.3 I am following the standard tutorial for installing OpenCV with eclipse cdt : http://docs.opencv.org/2.4/doc/tutori...

I installed all the libraries, exactly as directed. I checked where all of the libraries were installed in the terminal. However, eclipse tells me that it doesn't recognize the printf function.

Also in the tutorial, it says if you look in the folder, you'll find an executable. All I have that looks remotely runnable is a .o file. (I called my file test2.cpp, so this file is called test2.o) Is this the executable? Nothing in the Release folder looks like it could be run.

I actually had the same problem in another tutorial - this one by Rodrigo Berriel. http://rodrigoberriel.com/2014/10/usi... This one is different, because most of the work done is in the terminal.

With both tutorials, the results are the same. I get all the libraries installed, but for some reason, there isn't a clear executable. In the case of Berriel's tutorial, we went into the Release folder from the terminal, and the executable is supposed to be clearly marked(because it is coloured in the Linux terminal), but nothing like that was there. I've asked him why, and we are still working on it. When I do the step in the tutorial that goes into run configurations, and then presses on the c++ application tab, my Release folder comes up, instead of the file names. (test.cpp is for Berriel's tutorial, test2.cpp is for the standard one).

Specifically: C/C++ Application Machine Vision CPP Release C/C++ Container Launcher

Note that my whole project is called Machine Vision CPP. I don't think my Release folder is an executable. Even then, I don't get the Debug keyword at the end.

What should I do? Help? (note that i would really appreciate detailed instructions because i've followed 3 tutorials now, all with extremely clear and simple steps, and it still doesn't work me!)

Here is the code I'm trying to run: file: test.cpp

 #include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char** argv) {
    Mat inputImage = imread(argv[1]);
    imshow("Input Image", inputImage);

    waitKey(0);
    return 0;
}

file test2.cpp

#include <cv.h>
#include <highgui.h>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
  Mat image;
  image = imread( argv[1], 1 );

  if( argc != 2 || !image.data )
    {
      printf("No image data \n");
      cout <<  "No image data";
  return -1;
    }

  namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
  imshow( "Display Image", image );

  waitKey(0);

  return 0;
}
edit retag flag offensive close merge delete

Comments

OpenCV is not something you execute.. it is a library for you to link against and use its functionalities.

Check if you have the openCV libraries in your system:

If you installed the static library you should find files like libopencv_core.a, libopencv_imgproc.a in your system. If you installed the dynamic library, you should find libopencv_core.so, etc.

Either way, you have to link this libraries in Eclipse project properties in order to write opencv code.

Pedro Batista gravatar imagePedro Batista ( 2016-01-05 05:18:00 -0600 )edit

Hi Pedro, I am aware that OpenCV is a library. As stated above, I did follow the tutorial, including the link on installing the OpenCV libraries. If I had not done so, then all of the object types like Mat would be giving me issues as well. I did the pkg config command on the terminal to find where my opencv libraries were stored, and they were stored under usr/lib .

patrickhuie19 gravatar imagepatrickhuie19 ( 2016-01-05 12:50:54 -0600 )edit

Can you please tell me what is your problem, then? It might not be something in the installation, it may be something wrong with how you set your project in Eclipse.

Is it a compilation problem? What is it?

Pedro Batista gravatar imagePedro Batista ( 2016-01-06 08:33:40 -0600 )edit

An executable is not being made in the release folder, so there is nothing for me to run. As well, eclipse doesn't recognize the printf function (or cout for that matter) even though I've included all the libraries and iostream.

patrickhuie19 gravatar imagepatrickhuie19 ( 2016-01-06 08:38:52 -0600 )edit

whats the content of you Release folder after a successful compilation? Can you also please post the code you are trying to compile?

Pedro Batista gravatar imagePedro Batista ( 2016-01-06 08:46:13 -0600 )edit

whats the content of your Release folder after a successful compilation? Can you also please post the code you are trying to compile?

Pedro Batista gravatar imagePedro Batista ( 2016-01-06 08:46:40 -0600 )edit

As for the printf/cout, are you using their namespace?

Either call the function with std::cout or add "using namespace std;" in the beggining of your code

Pedro Batista gravatar imagePedro Batista ( 2016-01-06 08:51:49 -0600 )edit

patrickhuie19@UbuntuS55:~/workspace/Machine Vision CPP/Release$ ls

Machine Vision CPP objects.mk subdir.mk test2.o test.o makefile sources.mk test2.d test.d

those are the contents of my release folder. I will the post the code I'm trying to compile in the question.

patrickhuie19 gravatar imagepatrickhuie19 ( 2016-01-06 20:25:57 -0600 )edit

as well, once I added "using namespace std", cout no longer gave me any problems- so thanks!

patrickhuie19 gravatar imagepatrickhuie19 ( 2016-01-06 20:32:16 -0600 )edit

however, printf still does and no executable is formed in the release folder.

patrickhuie19 gravatar imagepatrickhuie19 ( 2016-01-06 20:32:45 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
1

answered 2016-01-12 06:33:01 -0600

tomnjerry gravatar image

You can check this out: link

It explains and mentions every details you might need to get OpenCV working with Eclipse CDT. It has steps for linking your code to the OpenCV libraries without which your OpenCV dependent code will throw multiple errors.To further simplify the things for users like us, it also includes screenshots of various stages during setup process. A working example to make sure setup was successful is included at the end.

Follow this tutorial till the end and you shall be able to successfully run OpenCV code. Hope this helps!!

edit flag offensive delete link more
0

answered 2016-01-05 08:36:42 -0600

Cabezon667 gravatar image

Hi:

Check this pdf: http://projects.i-ctm.eu/sites/defaul... is the way that I configure OpenCV in Eclipse.

Try to follow the last images, the last part. Tell me if its works in the end or not.

edit flag offensive delete link more

Comments

I'm a bit confused. I don't think the pdf you sent me had any openCV in it. Is openCV included with openGL??

patrickhuie19 gravatar imagepatrickhuie19 ( 2016-01-05 12:57:57 -0600 )edit

Check the last part of the PDF, when you need to configure OpenCV in Eclipse. You can see the images to give you an idea. Remenber, the last part!

Cabezon667 gravatar imageCabezon667 ( 2016-01-05 14:53:21 -0600 )edit

Hi Cabezon, Sorry about missing the last part. I thought it didn't apply to openCV because it was for something else. That is actually exactly how I attempted to do it. I hadn't done the runtime variable before, but the result is the same - there is still no executable for me to run.

patrickhuie19 gravatar imagepatrickhuie19 ( 2016-01-05 17:26:13 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-01-04 17:42:37 -0600

Seen: 474 times

Last updated: Jan 12 '16