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.
| Get FREE complimentary Linux Guides |
|
The GNU/Linux Advanced Administration
The GNU/Linux systems have reached an important level of maturity, allowing to integrate them in almost any kind of work environment, from a desktop PC to the sever facilities of a big company.
In this ebook “The GNU/Linux Operating System”, the main contents are related with system administration. You will learn how to install and configure several computer services, and how to optimize and synchronize the resources using GNU/Linux.
The topics covered in this 500+ page eBook include Linux network, server and data administration, Linux kernel, security, clustering, configuration, tuning, optimization, migration and coexistence with non-Linux systems. A must read for any serious Linux system admin.
|
|
A Newbie’s Getting Started Guide to Linux
Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you’re a complete Linux newbie and looking for a quick and easy guide to get you started this is it.
You’ve probably heard about Linux, the free, open-source operating system that’s been pushing up against Microsoft. It’s way cheaper, faster, safer, and has a far bigger active community than Windows, so why aren’t you on it? Don’t worry, Makeuseof.com understands. Like many things, venturing off into a completely unknown world can seem rather scary, and also be pretty difficult in the beginning. It’s while adapting to the unknown, that one needs a guiding, and caring hand. This guide will tell you all you need to know in 20 illustrated pages, helping you to take your first steps. Let your curiosity take you hostage and start discovering Linux today, with this manual as your guide! Don’t let Makeuseof.com keep you any longer, and download the Newbie’s Initiation to Linux. With this free guide you will also receive daily updates on new cool websites and programs in your email for free courtesy of MakeUseOf.
|

|
A Complete Beginner’s Manual for Ubuntu 10.04 (Lucid Lynx)
Getting Started with Ubuntu 10.04 (Lucid Lynx) is a comprehensive beginners guide for the Ubuntu operating system; it features comprehensive guides, How Tos and information on anything you need to know after first installing Ubuntu.
Designed to be as user-friendly and easy to follow as possible, it should provide the first point of reference to any Ubuntu newcomer with lots of information. The manual has step by step instructions and includes lots of screenshots to show you how to do tasks. It also includes a Troubleshooting section to help you solve common Ubuntu problems quickly. Download this 160+ page manual today.
|
Filed under: C, Computer Vision, Linux, OpenCV, Programming | Comments Off