14

I already have OpenCV2.4.2 installed as part of ROS(Fuerte) in my computer(installed from Ubuntu Software Center, something due to ROS). How should I install OpenCV as a standalone?

I went through this guide and downloaded the opencv package from here. I am not quite clear as how to proceed. Can anyone give short list of steps to install? I want to use an IDE for my projects, so which IDE is proper for C++ and how to install the proper IDE and configure it correctly?

Also how to check if certain tools are installed?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Karthik Murugan
  • 1,595
  • 4
  • 19
  • 26

4 Answers4

5

This link which you also mentioned describes the necessary steps to compile OpenCV on your machine. The version of OpenCV you install this way will be newer than the one installed with the ROS package, they usually have some delay. (Maybe not with Fuerte.)

Using multiple versions of the same library on a machine might cause problems with linking and it will create a bit of headache for you so I would avoid it.

Try running pkg-config opencv --libs to see if the ROS version pulled by Fuerte is available and you can use this with your projects later on.

For a starter IDE I would recommend Qt Creator. The easy way to set OpenCV up with your project in Qt Creator is the following:

  1. Create a project
  2. Open the .pro file of the project
  3. Run pkg-config opencv --cflags
  4. Add this to the .pro file: INCLUDEPATH += __result__of__above
  5. pkg-config opencv --libs
  6. Add this to the .pro file: LIBS += __result__of__above

In the end what you add should look something like this:

INCLUDEPATH += -I/opt/ros/fuerte/include

LIBS += -L/opt/ros/fuerte/lib -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_nonfree -lopencv_objdetect -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_video -lopencv_videostab

  • I added to .pro file as you said... when I tried a opencv program and Build it ,an error says /home/karthik/Desktop/Qt/Hello_World-build-desktop-Qt_4_8_1_in_PATH__System__Release/../Hello_World/main.cpp:6: **error: opencv2/opencv.hpp: No such file or directory**.. any suggestions?? – Karthik Murugan Feb 22 '13 at 10:25
2

To install OpenCV using the terminal on Ubuntu:

$ su -
# apt-get update
# apt-get install build-essential
# apt-get install libavformat-dev
# apt-get install x264 v4l-utils ffmpeg
# apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev

OpenCV should be installed in /usr/local/ Installation Directory

You may also want to compile and view examples

$ cp -r /usr/share/doc/opencv-doc/examples .
$ cd examples
$ cd c
$ sh build_all.sh

You can read the complete article about How to install OpenCV on Ubuntu from Nam Huy Linux Blog at http://namhuy.net/1205/how-to-install-opencv-on-ubuntu.html

1

This github user has compiled all the installation steps using a shell script. You can install any OpenCV version you want by running the appropriate shell script inside.

$ git clone https://github.com/jayrambhia/Install-OpenCV.git
$ cd Ubuntu
$ chmod +x * 
$ ./opencv_latest.sh
ritz301
  • 351
  • 2
  • 8
0

There is an installer for Ubuntu 16.04, and it may work well on Ubuntu 12.04, you could have a try. I have used it to install on Ubuntu 16.04 and it succeed!

An interactive installing script for install openCV on Ubuntu 16.04 LTS

orange
  • 1
  • 2