Conventions used in this article:
This article will start with installation of OpenCV on Debian 5.0 ( Lenny ). Later a reader will be guided through a number of examples on how to use OpenCV to display an image, play a video and use camera to capture the video input stream.Read more...
Here is a small skeleton on how to set /etc/network/interfaces file to connect Debian or Ubuntu to a wireless network. NOTE: Use iwconfig command to find a name of your wireless interface. In this example we use wlan0 as a target network device.
Static network interface:
iface wlan0 inet static
Dynamic dhcp network interface:
iface wlan0 inet dhcp
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:
int main(int argc, char** argv)
IplImage* img = cvLoadImage( argv );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
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'
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 ):
the image should pop up on your screen.