RSS Subscription
Linux Howtos & Tutorials

Enter your email:

Delivered by


NOTE:New tutorials are from LinuxCareer.com

Poll

Do you own or wish to have iPhone?
 


Linux eBooks FREE Download
A guide to programming Linux kernel modules
Introduction to Linux - A Hands on Guide
A Newbie's Getting Started Guide to Linux

Linux from Scratch - Create Your Own Linux System - Free eBook

Linux: The Hacking Solution (v.3.0)

SQLite 3 with PHP Essential Training – Free Video Training Tutorials

This guide will introduce you to the world of GNU/Linux

The GNU/Linux Advanced Administration

A Complete Beginner's Manual for Ubuntu 10.04 (Lucid Lynx)

Advanced Bash-Scripting Guide

Set up, maintain, and secure a small office email server

Partner Linux Sites:
How-To.LinuxCareer.com
Jobs.LinuxCareer.com
TuxMachines
Monsterb
LinuxBloggers
AdamsInfo
LinuxScrew
All For Linux

101 howto start with opencv and computer vision on ubuntu linux

Recently I was tempted to have a look on OpenCV project and Oreilly’s book “Learning OpenCV” This is a great book and it assumes some basic C programming skills. However, it is not specific to any platform when it comes to compiling and running program examples. Here is a very short start with Ubuntu 9.04

Let’s start with installation of some useful packages into our ubuntu system:

apt-get install libcv1 libcvaux1 libhighgui1 libcv-dev libcvaux-dev libhighgui-dev libavcodec-dev libavformat-dev libavutil-dev libavutil49 pkg-config g++

Once this is done we can start by compiling a first example in the book ( make sure that you have all quotes corect otherwise you will get errors like:
opencv.c:1:10: error: #include expects "FILENAME" or

actual example code:

#include "highgui.h"

int main(int argc, char** argv)
{
IplImage* img = cvLoadImage( argv[1] );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );

exit(0);
}

now it’s time to save this code into file. For example let us save it into myopencv.c file.

to compile this code we can use command:

g++ -ggdb -I/usr/include/opencv -lhighgui myopnecv.c.c -o opencv_example

another way to compile is to use pkg-config
g++ -ggdb `pkg-config opencv --cflags --libs` myopnecv.c.c -o opencv_example
which is exactly the same as
g++ -ggdb -I/usr/include/opencv -lcxcore -lcv -lhighgui -lcvaux -lml myopnecv.c.c -o opencv_example

the library must be included for compilation otherwise this errors would occur:
myopnecv.c:In function `main':
myopnecv.c:(.text+0x25): undefined reference to `cvLoadImage'
myopnecv.c:(.text+0x3c): undefined reference to `cvNamedWindow'
myopnecv.c:(.text+0x4f): undefined reference to `cvShowImage'
myopnecv.c:(.text+0x5b): undefined reference to `cvWaitKey'
myopnecv.c:(.text+0x66): undefined reference to `cvReleaseImage'
myopnecv.c:(.text+0x72): undefined reference to `cvDestroyWindow'

OR

error: too few arguments to function ‘cvLoadImage’

if your compilation was successful a opencv_example binary should appear in your directory. when running this binary supply an argument ( some picture ):

./opencv_example mypicture.jpg

the image should pop up on your screen.

Share this linux post:

Submit 101 howto start with opencv and computer vision on ubuntu linux in Delicious Submit 101 howto start with opencv and computer vision on ubuntu linux in Digg Submit 101 howto start with opencv and computer vision on ubuntu linux in FaceBook Submit 101 howto start with opencv and computer vision on ubuntu linux in Google Bookmarks Submit 101 howto start with opencv and computer vision on ubuntu linux in Stumbleupon Submit 101 howto start with opencv and computer vision on ubuntu linux in Technorati Submit 101 howto start with opencv and computer vision on ubuntu linux in Twitter
 
Comments for this page are closed !!!
Please visit our new Linux Forum for additional help or discussion.


Linux eBooks FREE Download