Installing OpenCV in Linux Machines

OpenCV is a multiplatform supported, Computer Vision algorithm and library which can be used in programming languages such as C, C++, Python or Java. Its an OpenSource computer vision algorithm collection which can be used under BSD license.

OpenCV in Beagleboard, Embedded Linux

OpenCV and Embedded Linux

The following steps demonstrate the  installation and usage of Opencv in embedded Linux distributions.

The steps are used in BeagleBone running Ubuntu 12.04 and Angstrom Distro.

In Ubuntu type in terminal

sudo apt-get install libopencv-dev  python-opencv build-essential

In Angstrom linux type

opkg install opencv

opkg install gcc

Type below sample code in an editor and same it as main.cpp

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main()
  VideoCapture cap(-1);

  if (!cap.isOpened())
      cout <<"Failed to open camera\n";
      return -1;


  Mat frame;
  while (1)
      cap>> frame;
      if (waitKey(30)>0)break;

  return 0;


And compile using the following command

g++ -Wall -g -o DisplayCamera main.cpp `pkg-config –cflags –libs opencv`

After successful compilation an executable file named DisplayCamera will be created inside the current directory. Plug in a USB camera and execute as follows.

Use ./DisplayCamera         — to run the program

Note: 1) User may need to execute “chmod +x DisplayCamera” to make the file executable.

2) May need pkg-config for finding the library path of opencv dependencies.


4 thoughts on “Installing OpenCV in Linux Machines

      • when i type the command in terminal “opkg install opencv” in angstrom ,i am getting package opencv(2.4.2-r0) installed in root is up to date.But when i compile program like gcc test.c -o out `pkg-config –cflags –libs opencv` i got error like “package opencv was not found in the pkg-config search path. perhaps you should add the directory containing `opencv.pc’ to the PKG_CONFIG_PATH environment variable and also i am getting error highgui.h : No such file or directory compilation terminated. please give me the detail about,how to install library and add environment variable on angstrom os . thank you very much for your reply……………

  1. Use g++ -Wall -g -o DisplayCamera main.cpp -I /usr/include/opencv2 -L /usr/bin -lopencv_core -lopencv_highgui -lopencv_imgproc. for compiling.

    or you should reinstall opencv after updating your angstrom repo.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s