Friday 21 June 2013

OpenCV configuration and demo programs

So I configured OpenCV as below.

1.  sudo nano /etc/ld.so.conf.d/opencv.conf to add the following line to the empty file.

    /usr/local/lib

2.  sudo nano /etc/bash.bashrc to add the following 2 lines to the end of the file.

    PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig 
    export PKG_CONFIG_PATH


Then I tried to run the programs convexhull and kmeans.  But both warning messages of not being able to open display.

3. pi@raspberrypi ~/fongvision $ cd OpenCV-2.3.1/build/bin

pi@raspberrypi ~/fongvision/OpenCV-2.3.1/build/bin $ sudo ./convexhull

This sample program demonstrates the use of the convexHull() function
Call:

./convexhull

(hull:2647): Gtk-WARNING **: cannot open display:

4. pi@raspberrypi ~/fongvision/OpenCV-2.3.1/build/bin $ sudo ./kmeans

(clusters:2649): Gtk-WARNING **: cannot open display:


.END


Raspberry Pi + OpenCV POSTED BY MICHAEL ON JUN 14, 2012

http://mitchtech.net/raspberry-pi-opencv/

...

*** Configure ***

Finally, we need to make a few configurations for OpenCV. First, open the opencv.conf file with the following code:

sudo nano /etc/ld.so.conf.d/opencv.conf

Add the following line at the end of the file (it may be an empty file, that is ok) and then save it:

/usr/local/lib

Then edit the system-wide bashrc file:

sudo nano /etc/bash.bashrc

Add the following new lines to the end of the file:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig 

export PKG_CONFIG_PATH


*** Comments ***

Pete FEBRUARY 8, 2013

There is a small mistake in the step where you change the system-wide bashrc:
“PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH”

How it should be:

“PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH”

“export” needs to be on the second line otherwise you get a ton of console spam and an error from that bashrc…

...

mrshu MARCH 1, 2013

Also, you need to run `sudo ldconfig` after you add anything to /etc/ld.so.conf.d/opencv.conf


*** C Demos ***

Now that everything is installed and configured, on to the demos!  The C demos are here:

cd ~/opencv/OpenCV-2.3.1/build/bin

C demos in build/bin demos worth checking out (that don’t require a webcam):

convexhull

kmeans

drawing


*** Python demos ***

The python demos are located in samples/python:

cd ~/opencv/OpenCV-2.3.1/build/bin

These demos also don’t require a webcam:

python ./minarea.py

python ./delaunay.py

python ./drawing.py

.END


No comments:

Post a Comment