My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Documentation  
Updated May 4, 2012 by nickdad...@gmail.com

1. Installation

The installation procedures detailed below have been tested and verified using:

  • Ubuntu 12.04 LTS ("fresh" install)
  • OpenCV 2.4.0
  • Qt SDK version 1.2.1 for Linux/X11 32-bit

1.1 Installing OpenCV

1. Open Terminal: Press Control-Alt T to open a Terminal instance.

2. Download and install CMake and other required dependencies (Note: qt-opencv-multithreaded requires V4L):

$ sudo apt-get update
$ sudo apt-get install build-essential cmake libv4l-dev

Optional packages:

pkg-config See Step 9

libgtk2.0-dev The default GUI backend for highgui on OSes other than Windows and MacOSX.

libtiff4-dev For reading and writing TIFF images.

libjasper-dev Library for the coding and manipulation of images (e.g. JPEG-2000 format).

libavformat-dev Library containing demuxers and muxers for audio/video container formats.

libswscale-dev Library containing video image scaling and colorspace/pixelformat conversion routines.

libavcodec-dev Library containing all the FFmpeg audio/video encoders and decoders.

libjpeg-dev For reading and writing JPEG images.

3. Download OpenCV 2.4.0 (choose a folder where you wish to download the file to: e.g. home/Downloads):

$ cd Downloads
$ wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.0/OpenCV-2.4.0.tar.bz2

4. Unpack archive and navigate to the newly created folder containing the OpenCV source:

$ tar -xvf OpenCV-2.4.0.tar.bz2
$ cd OpenCV-2.4.0/

5. Create a new folder and navigate to it (the build files generated by CMake will go into this folder):

$ mkdir release	
$ cd release

6. Use CMake to generate the makefile:

Note: Remember to specify the source folder as the last argument while invoking cmake.

$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

7. Compile and install OpenCV:

$ sudo make install

8. Point system to generated libraries (change path if different):

$ export LD_LIBRARY_PATH=~/Downloads/OpenCV-2.4.0/release/lib:$LD_LIBRARY_PATH
$ sudo ldconfig

9. (Optional) Use pkg-config to simplify the "making/building" of your OpenCV projects:

$ pkg-config opencv --libs

OpenCV dependencies can now be linked with simply: `pkg-config opencv --cflags --libs`

10. Restart Ubuntu to complete installation.

1.2 Installing Qt

Note: Steps 5 and 6 explain how to configure Qt Creator for use with the OpenCV libraries.

1. Download the latest version of the Qt SDK for Linux/X11 from the Nokia Qt website: http://qt.nokia.com/downloads/

2. Follow the installation instructions on the download page.

3. (Optional) Install Qt Designer (used for GUI designing).

$ sudo apt-get install qt4-designer

4. Restart Ubuntu to complete installation.

5. In Qt Creator, add the following to the .PRO file after creating a project:

LIBS += -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann

OR, if pkg-config is being used:

LIBS += `pkg-config opencv --cflags --libs`

6. Include the OpenCV header files in your C/C++ source file(s). For example:

#include <opencv/cv.h>
#include <opencv/highgui.h>

7. Your Qt-based OpenCV project can now be built and run using Qt Creator!

1.3 Compiling & running the application

1. Download the latest stable release of qt-opencv-multithreaded and unpack the downloaded archive: Downloads

OR

Get the "cutting-edge" version from the SVN repository (requires a SVN client): See instructions here.

2. Unpack the downloaded archive and open qt-opencv-multithreaded.pro in Qt Creator. You may also be asked to setup the project targets - modify if required and click "Finish".

3. The application can be now be simply modified, compiled and run within Qt Creator!

2. Using the Application

Coming soon.

3. Modifying the Source

Coming soon.

4. Hardware

Please see the OpenCV site for a list of supported cameras.

4.1 Playstation Eye

Changing the frame rate

The default frame rate can be changed by modifying and re-building the driver source (ov534.c).

Note: The following procedure is based on: http://wiki.tekkotsu.org/index.php/Sony_PlayStation_Eye_driver_install_instructions

1. Get the Linux kernel source:

$ sudo -s
$ cd /usr/src
$ apt-get update
$ apt-get install -y kernel-package build-essential linux-source
$ tar --bzip2 -xvf linux-source-*.tar.bz2
$ ln -s `find . -type d -name "linux-source-*"` linux

2. Replace the driver source. This version of the driver has been patched to make 640x480 @ 60 fps the default.

$ cd /usr/src/linux/drivers/media/video/gspca
$ mv ov534.c ov534.c.old
$ wget http://qt-opencv-multithreaded.googlecode.com/files/ov534.c

3. Rebuild the driver modules ov534, gspca_ov534, and gspca-main:

$ cd /usr/src
$ cp -p linux-headers-$(uname -r)/Module.symvers linux

$ cd /usr/src/linux
$ make oldconfig
$ make modules_prepare
$ make SUBDIRS=drivers/media/video/gspca modules 

4. Install the new gspca_ov534 driver, which also requires replacing gspca_main:

$ cd /usr/src/linux
$ cp -p drivers/media/video/gspca/gspca_main.ko /lib/modules/$(uname -r)/kernel/drivers/media/video/gspca
$ cp -p drivers/media/video/gspca/gspca_ov534.ko /lib/modules/$(uname -r)/kernel/drivers/media/video/gspca
$ depmod

5. Remove the old drivers, then load the new ones (gspca_main will load automatically):

modprobe -r gspca_ov534 gspca_main
modprobe gspca_ov534

6. Test using qt-opencv-multithreaded.

Note: This patched driver seems to suffer from flickering issues during heavy image processing. If using qt-opencv-multithreaded, select "Drop frame if image buffer is full" when connecting to the camera to eliminate this problem. If anyone knows a driver fix, please let me know.

5. Extras

5.1 ARToolKitPlus Installation

Tested with ARToolKitPlus 2.2.1

1. Open Terminal: Applications->Accessories->Terminal

2. Download ARToolKitPlus, unpack and install (default system installation path is /usr/):

$ cd Downloads
$ wget https://launchpad.net/artoolkitplus/trunk/2.2.1/+download/ARToolKitPlus-2.2.1.tar.bz2
$ tar xvjf ARToolKitPlus-2.2.1.tar.bz2
$ cd ARToolKitPlus-2.2.1
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install

3. Add the following to the Qt .PRO file:

LIBS += -lARToolKitPlus

4. Include the ARToolKitPlus header files in your C/C++ source file(s). For example:

#include <ARToolKitPlus/TrackerSingleMarker.h>
#include <ARToolKitPlus/TrackerMultiMarker.h>

5.2 QSerialDevice Installation

1. In Terminal (requires GIT):

$ git clone git://gitorious.org/qserialdevice/qserialdevice.git

2. Compile source:

Note: This step requires udev:

sudo apt-get install libudev-dev
$ cd qserialdevice
$ qmake BuildLibrary.pro
$ make

3. Copy compiled static library to /usr/lib:

$ cd src/build/release
$ sudo cp libqserialdevice.a /usr/lib

4. Copy header files to /usr/include/qserialdevice:

$ sudo mkdir /usr/include/qserialdevice
$ cd ../../qserialdevice
$ sudo cp * /usr/include/qserialdevice

5. Copy global header file to /usr/include:

cd .. && sudo cp qserialdevice_global.h /usr/include/

6. Add the following to the Qt .PRO file:

LIBS += -lqserialdevice

7. Include the following header file to your C/C++ source file(s):

#include <qserialdevice/abstractserial.h>
Comment by tawnkramer, Jul 22, 2011

Thanks for the playstation eye tips. I did update V4L and now all my ps3 eye cams will only capture at 320x240. Is there a runtime switch to change to 640x480? And seriously, recompile the driver just to change the framerate... sheesh.

Comment by project member nickdad...@gmail.com, Jul 23, 2011

If I may ask, what was your reason for applying the modified driver? Were you experiencing flickering issues or did you just want to change the frame rate? Did you comment out the correct lines of code? If you were after a solution which is able to change the settings without recompiling the entire driver, see here: http://bear24rw.blogspot.com/2009/11/ps3-eye-driver-patch.html

Comment by tawnkramer, Jul 24, 2011

With a clean install of ubuntu 11.04 and opencv 2.1 from synaptic, I was seeing 640x480 60fps from two playstation eye cameras. When I tried to add a third, I was seeing video corruption. I removed ubuntu blessed opencv 2.1 and built it from the latest in svn. Then I was getting 320x240 resolution from all cameras. I was trying to get the latest 4vl and build it hoping to get back to working place. So basically I'm just flailing about not really sure where to look.

I tried your mod and when I make I don't really see it descending into linux/drivers/media/video/gspca when I make. I'm wondering if it built that edit? I'm not seeing any change.

Comment by tawnkramer, Jul 24, 2011

Thanks for that link. I hadn't seen guvc before and I installed that. The controls for resolution did work correctly. So is there some way to tell opencv to use 640x480 or to set this as the system default?

Comment by project member nickdad...@gmail.com, Jul 25, 2011

Interesting... A few months ago I experienced a similar frame corruption problem with the PS3 Eye camera which was due to a FTDI USB->UART device being connected on the same USB bus. Out of curiosity, are all the cameras on different USB buses? Check with lsusb - ensuring that they are may solve your frame corruption issues.

Also, the above procedure definitely does load in the modified ov534 driver (just re-did it then to check).

With that link I gave you, it looks like he uses the following (for example) to change resolutions and frame rates:

$ modprobe -r gspca-ov534
$ modprobe gspca-ov534 videomode=10

I guess it's definitely quicker than recompiling the entire driver! Anyway, I hope you are somehow able to get your 3 cameras working all together! If I get time, I'll look into providing a better method to change the PS3 Eye camera resolutions and frame rates.

Comment by tawnkramer, Jul 25, 2011

I found another post that gives similar advice about how to change the video mode: http://kaswy.free.fr/?q=node/42.

I've tried this a few times. Each time ''modprobe gspca-ov534 videomode=10'' results in :

FATAL:Error inserting gspca_ov534 (path to module): Unknown symbol in module, or unknown parameter ( see dmesg)

dmesg says: gspca_ov534: Unknown parameter 'videomode'

I'm running Ubuntu 11.04 with kernel 2.6.30-10.

Comment by project member nickdad...@gmail.com, Jul 25, 2011

From that error, it seems like the modified source wasn't actually installed? Try using my above method, but instead replace ov534.c with the modified file from that site. Let me know how that goes.

Comment by tawnkramer, Jul 26, 2011

Following http://bear24rw.blogspot.com/2009/11/ps3-eye-driver-patch.html I definitely changed the driver. But I got my system to hang now when I try to access the ps3 eye.

There were some compile errors with gspca_frame_add with kernel src for 2.6.38. Seems as if it used to take a frame pointer and return the next? I don't know. But there was an extra frame argument that didn't match the header anymore. I diffed the original and his edits and there were quite a lot of changes. I will see if I can sort it out.

Comment by tawnkramer, Jul 26, 2011

It looks as if in 2.6.38 most of the edits have been folded into the mainline. Except, of course, the added module parameters for video mode. Go figure. Anyway, it was easiest to for me to integrate just the video mode parameter and supporting functions into the latest driver. That built and works perfectly! Thanks for your help. Now I don't need to recompile to change default resolution or frame rate.

Seriously though, guvcview does this at runtime. So there must be a reason they didn't add the module params. They must want you to set them via v4l or fnctl. But this does it for me!

Comment by dimitri....@gmail.com, Nov 17, 2011

I was wondering if you knew how easy or difficult it would be to make this work on Windows ?

Comment by walmsl...@gmail.com, Dec 22, 2011

Just in case anyone has the same troubles I did, on oneiric, this wasn't working for me - the ov534 module wouldn't compile because of some incorrect usage of the gspca_frame_add function: I got it working for myself, and you can find my modified ov534.c here: http://www.mediafire.com/?a0yngcag0rl3lo9

(sorry for using a crappy ad-ridden free upload website, I hope the file stays up there for a while)

Comment by qil...@gmail.com, Jan 10, 2012

really nice job!!


Sign in to add a comment
Powered by Google Project Hosting