QT OpenCV for ubuntu

来源:http://code.google.com/p/qt-opencv-multithreaded/wiki/Documentation

1. Installation

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

  • Ubuntu 13.04 32-bit
  • OpenCV 2.4.5
  • Qt 5.0.2 for Linux 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. Also, Ubuntu 13.04 comes supplied withpkg-config):

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

Optional packages:

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.

libpng-dev For reading and writing PNG images.

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

$ cd Downloads
$ wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.5/opencv-2.4.5.tar.gz

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

$ tar -xvf opencv-2.4.5.tar.gz
$ cd opencv-2.4.5/

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:

$ make
$ sudo make install

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

$ export LD_LIBRARY_PATH=~/Downloads/opencv-2.4.5/release/lib:$LD_LIBRARY_PATH
$ sudo ldconfig

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

1.2 Installing Qt

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

1. Download the latest version of Qt 5 for Linux 32-bit from the Qt website:http://qt-project.org/downloads

2. Follow the installation instructions on the download page. Installation is typically started with the following:

$ chmod u+x path_to_downloaded_setup_file
$ ./path_to_downloaded_setup_file

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

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

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

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

5. 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 instructionshere.

2. Open qt-opencv-multithreaded.pro in Qt Creator. You may also be asked to setup the project build targets - modify if required.

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

IMPORTANT: If you receive compilation/linking errors such as /usr/bin/ld: cannot find -lGL orGL/gl.h: No such file or directory when using Qt 5, do the following:

$ sudo apt-get install libgl1-mesa-dev

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.

5. Extras

5.1 ARToolKitPlus Installation

Tested with ARToolKitPlus 2.3.0

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

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

$ cd Downloads
$ wget https://launchpad.net/artoolkitplus/trunk/2.3.0/+download/ARToolKitPlus-2.3.0.tar.bz2
$ tar xvjf ARToolKitPlus-2.3.0.tar.bz2
$ cd ARToolKitPlus-2.3.0
$ 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>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
注:下文中的 *** 代表文件名中的组件名称。 # 包含: 中文-英文对照文档:【***-javadoc-API文档-中文(简体)-英语-对照版.zip】 jar包下载地址:【***.jar下载地址(官方地址+国内镜像地址).txt】 Maven依赖:【***.jar Maven依赖信息(可用于项目pom.xml).txt】 Gradle依赖:【***.jar Gradle依赖信息(可用于项目build.gradle).txt】 源代码下载地址:【***-sources.jar下载地址(官方地址+国内镜像地址).txt】 # 本文件关键字: 中文-英文对照文档,中英对照文档,java,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,中文API文档,手册,开发手册,使用手册,参考手册 # 使用方法: 解压 【***.jar中文文档.zip】,再解压其中的 【***-javadoc-API文档-中文(简体)版.zip】,双击 【index.html】 文件,即可用浏览器打开、进行查看。 # 特殊说明: ·本文档为人性化翻译,精心制作,请放心使用。 ·本文档为双语同时展示,一行原文、一行译文,可逐行对照,避免了原文/译文来回切换的麻烦; ·有原文可参照,不再担心翻译偏差误导; ·边学技术、边学英语。 ·只翻译了该翻译的内容,如:注释、说明、描述、用法讲解 等; ·不该翻译的内容保持原样,如:类名、方法名、包名、类型、关键字、代码 等。 # 温馨提示: (1)为了防止解压后路径太长导致浏览器无法打开,推荐在解压时选择“解压到当前文件夹”(放心,自带文件夹,文件不会散落一地); (2)有时,一套Java组件会有多个jar,所以在下载前,请仔细阅读本篇描述,以确保这就是你需要的文件;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值