Difference between revisions of "OpenCV"

From ArmadeusWiki
Jump to: navigation, search
m (Adjust links)
(Add OpenCV patch and runtime details)
Line 13: Line 13:
 
# Grab the source archive <source lang="bash">
 
# Grab the source archive <source lang="bash">
 
cd opencv-on-armadeus/src && wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.1/OpenCV-2.1.0.tar.bz2/dowload && tar xvvjf OpenCV-2.1.0.tar.bz2
 
cd opencv-on-armadeus/src && wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.1/OpenCV-2.1.0.tar.bz2/dowload && tar xvvjf OpenCV-2.1.0.tar.bz2
 +
</source>
 +
# Here, you'll have to apply [[#OpenCV-2.1.0.patch| this patch]] to avoid compilation failed: <source lang="bash">
 +
patch -p0 < OpenCV-2.1.0.patch
 
</source>
 
</source>
 
# Run CMake (generate Makefiles)
 
# Run CMake (generate Makefiles)
 
## <source lang="bash">
 
## <source lang="bash">
cd ../build && cmake -DCMAKE_TOOLCHAIN_FILE:PATH=/path/to/toolchain.cmake ../src/OpenCV-2.1.0
+
cd ~/opencv-on-armadeus/build && cmake -DCMAKE_TOOLCHAIN_FILE:PATH=/path/to/toolchain.cmake ../src/OpenCV-2.1.0
 
</source>
 
</source>
 
##It will certainly complain about unfound libraries and some other things, so adjust these things running:<source lang="bash">
 
##It will certainly complain about unfound libraries and some other things, so adjust these things running:<source lang="bash">
Line 35: Line 38:
  
  
== Available features ==
+
=== Available features ===
 
CMake looks for all required tool in the path specified in [[CMake#The_toolchain_file| toolchain.cmake file]] toolchain.cmake file; therefore, some options, targets, libraries, ... are not available:
 
CMake looks for all required tool in the path specified in [[CMake#The_toolchain_file| toolchain.cmake file]] toolchain.cmake file; therefore, some options, targets, libraries, ... are not available:
  
Line 54: Line 57:
  
 
{{Note|You may need to enable some packages in your Armadeus configuration to get some libraries (libjpeg, libpng and libtiff) found by CMake.}}
 
{{Note|You may need to enable some packages in your Armadeus configuration to get some libraries (libjpeg, libpng and libtiff) found by CMake.}}
 +
 +
== Run OpenCV applications on your APF-board ==
 +
# In the ''build'' directory, you should find a ''bin'' and a ''lib'' sub-directories. Copy them (at least the ''lib'' directory) on your target.
 +
# <source lang="bash">
 +
export LD_LIBRARY_PATH=/path/to/the/OpenCVlibdir
 +
</source>
 +
# Run your application. You can try ''cvtest'' (some tests may fail because of missing resources),  it will take a while... a long while ;)
  
 
== See also ==
 
== See also ==
 
* [http://opencv.willowgarage.com/wiki/InstallGuide| OpenCV install guide]
 
* [http://opencv.willowgarage.com/wiki/InstallGuide| OpenCV install guide]
 +
 +
== Appendices ==
 +
=== OpenCV-2.1.0.patch ===
 +
<source lang="diff">
 +
--- OpenCV-2.1.0/3rdparty/flann/constants.h.origin 2010-06-08 01:14:22.171416516 +0200
 +
+++ OpenCV-2.1.0/3rdparty/flann/constants.h 2010-06-08 01:15:06.912417891 +0200
 +
@@ -41,7 +41,7 @@ enum flann_algorithm_t {
 +
KMEANS = 2,
 +
COMPOSITE = 3,
 +
SAVED = 254,
 +
- AUTOTUNED = 255,
 +
+ AUTOTUNED = 255
 +
};
 +
 +
enum flann_centers_init_t {
 +
--- OpenCV-2.1.0/3rdparty/flann/flann.h.origin 2010-06-08 01:14:32.588443815 +0200
 +
+++ OpenCV-2.1.0/3rdparty/flann/flann.h 2010-06-08 01:15:06.912417891 +0200
 +
@@ -267,7 +267,7 @@ LIBSPEC int flann_compute_cluster_center
 +
 +
 +
#ifdef __cplusplus
 +
-};
 +
+}
 +
 +
 +
#include "flann.hpp"
 +
--- OpenCV-2.1.0/3rdparty/include/flann/constants.h.origin 2010-06-08 01:14:54.503416676 +0200
 +
+++ OpenCV-2.1.0/3rdparty/include/flann/constants.h 2010-06-08 01:15:06.912417891 +0200
 +
@@ -41,7 +41,7 @@ enum flann_algorithm_t {
 +
KMEANS = 2,
 +
COMPOSITE = 3,
 +
SAVED = 254,
 +
- AUTOTUNED = 255,
 +
+ AUTOTUNED = 255
 +
};
 +
 +
enum flann_centers_init_t {
 +
--- OpenCV-2.1.0/3rdparty/include/flann/flann.h.origin 2010-06-08 01:14:44.672417690 +0200
 +
+++ OpenCV-2.1.0/3rdparty/include/flann/flann.h 2010-06-08 01:15:06.912417891 +0200
 +
@@ -267,7 +267,7 @@ LIBSPEC int flann_compute_cluster_center
 +
 +
 +
#ifdef __cplusplus
 +
-};
 +
+}
 +
 +
 +
#include "flann.hpp"
 +
</source>
 +
 +
[[Category: Software]]
 +
[[Category: Video]]

Revision as of 00:37, 8 June 2010

Page under construction... Construction.png Informations on this page are not guaranteed !!

Forewords

This page explains how to (cross-)compile OpenCV 2.1.0 for your APF-board.

Pre-requisite

You need to have CMake >=2.6 installed on your system.

Build OpenCV

  1. Edit your toolchain.cmake file
  2. Create source and build directories
    mkdir -pv opencv-on-armadeus/{src,build}
    
  3. Grab the source archive
    cd opencv-on-armadeus/src && wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.1/OpenCV-2.1.0.tar.bz2/dowload && tar xvvjf OpenCV-2.1.0.tar.bz2
    
  4. Here, you'll have to apply this patch to avoid compilation failed:
    patch -p0 < OpenCV-2.1.0.patch
    
  5. Run CMake (generate Makefiles)
    1. cd ~/opencv-on-armadeus/build && cmake -DCMAKE_TOOLCHAIN_FILE:PATH=/path/to/toolchain.cmake ../src/OpenCV-2.1.0
      
    2. It will certainly complain about unfound libraries and some other things, so adjust these things running:
      cmake-gui
      
  6. Compile OpenCV libraries
    VERBOSE=1 make
    


Note Note: cmake-gui
  • Click twice on Configure when you change something.
  • When configuring exit without any error, click on Generate to generate Makefiles.
  • If your configuration is too messy, reset it by deleting the cache (File/Delete Cache) or remove the CMakeCache.txt file in the build directory. Don't hesitate to do so if something (eg. paths) is wrong ;)
  • To see the cmake-command that corresponds to the configuration you have just set in cmake-gui: Tools/Show my changes


Available features

CMake looks for all required tool in the path specified in toolchain.cmake file toolchain.cmake file; therefore, some options, targets, libraries, ... are not available:

  • Build:
    • Latex Doc  : Not available in Buildroot
    • New Python support  : Not available (require Python >=2.6, Buildroot provides Python 2.4)
    • Swing Python support : Not available (require Python >=2.6, Buildroot provides Python 2.4)
    • Octave support  : Not available in Buildroot
  • Python
    • Executable  : Not found (require Python >=2.6, Buildroot provides Python 2.4)
    • Include dirs.  : Found
    • Library  : Not found (require Python >=2.6, Buildroot provides Python 2.4)
  • With
    • V4L  : Disable it (Buildroot provides it, but linker failed)
  • OpenCV
    • 3rd party libs.  : You can enable it.


Note Note: You may need to enable some packages in your Armadeus configuration to get some libraries (libjpeg, libpng and libtiff) found by CMake.


Run OpenCV applications on your APF-board

  1. In the build directory, you should find a bin and a lib sub-directories. Copy them (at least the lib directory) on your target.
  2. export LD_LIBRARY_PATH=/path/to/the/OpenCVlibdir
    
  3. Run your application. You can try cvtest (some tests may fail because of missing resources), it will take a while... a long while ;)

See also

Appendices

OpenCV-2.1.0.patch

--- OpenCV-2.1.0/3rdparty/flann/constants.h.origin	2010-06-08 01:14:22.171416516 +0200
+++ OpenCV-2.1.0/3rdparty/flann/constants.h	2010-06-08 01:15:06.912417891 +0200
@@ -41,7 +41,7 @@ enum flann_algorithm_t {
 	KMEANS = 2,
 	COMPOSITE = 3,
 	SAVED = 254,
-	AUTOTUNED = 255,
+	AUTOTUNED = 255
 };
 
 enum flann_centers_init_t {
--- OpenCV-2.1.0/3rdparty/flann/flann.h.origin	2010-06-08 01:14:32.588443815 +0200
+++ OpenCV-2.1.0/3rdparty/flann/flann.h	2010-06-08 01:15:06.912417891 +0200
@@ -267,7 +267,7 @@ LIBSPEC int flann_compute_cluster_center
 
 
 #ifdef __cplusplus
-};
+}
 
 
 #include "flann.hpp"
--- OpenCV-2.1.0/3rdparty/include/flann/constants.h.origin	2010-06-08 01:14:54.503416676 +0200
+++ OpenCV-2.1.0/3rdparty/include/flann/constants.h	2010-06-08 01:15:06.912417891 +0200
@@ -41,7 +41,7 @@ enum flann_algorithm_t {
 	KMEANS = 2,
 	COMPOSITE = 3,
 	SAVED = 254,
-	AUTOTUNED = 255,
+	AUTOTUNED = 255
 };
 
 enum flann_centers_init_t {
--- OpenCV-2.1.0/3rdparty/include/flann/flann.h.origin	2010-06-08 01:14:44.672417690 +0200
+++ OpenCV-2.1.0/3rdparty/include/flann/flann.h	2010-06-08 01:15:06.912417891 +0200
@@ -267,7 +267,7 @@ LIBSPEC int flann_compute_cluster_center
 
 
 #ifdef __cplusplus
-};
+}
 
 
 #include "flann.hpp"