Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Get OpenCV compiling for the PlayBook

Changes contributed by Ron Pfeifle.
  • Loading branch information...
commit 6eb44c9c2e122dd4cfe4f4147749307245ae734a 1 parent 4800530
@hungc hungc authored
View
20 CMakeLists.txt
@@ -14,7 +14,7 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# Following block can broke build in case of cross-compilng
# but CMAKE_CROSSCOMPILING variable will be set only on project(OpenCV) command
# so we will try to detect crosscompiling by presense of CMAKE_TOOLCHAIN_FILE
-if(NOT CMAKE_TOOLCHAIN_FILE)
+if(NOT CMAKE_TOOLCHAIN_FILE AND NOT QNX)
# Add these standard paths to the search paths for FIND_LIBRARY
# to find libraries from these locations first
if(UNIX)
@@ -31,7 +31,13 @@ if(NOT CMAKE_TOOLCHAIN_FILE)
if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif()
-endif(NOT CMAKE_TOOLCHAIN_FILE)
+endif(NOT CMAKE_TOOLCHAIN_FILE AND NOT QNX)
+
+if(QNX)
+ add_definitions(-D__QNX__)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions -fPIC")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+endif(QNX)
# --------------------------------------------------------------
# Top level OpenCV project
@@ -255,7 +261,7 @@ endif()
# ----------------------------------------------------------------------------
# Detect GNU version:
# ----------------------------------------------------------------------------
-if(CMAKE_COMPILER_IS_GNUCXX)
+if(CMAKE_COMPILER_IS_GNUCXX AND NOT QNX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -588,8 +594,12 @@ if(UNIX)
set(HAVE_CAMV4L2 FALSE)
endif()
- if(ANDROID)
+ if(QNX)
+ set(OPENCV_LINKER_LIBS m)
+ elseif(ANDROID AND NOT QNX)
set(OPENCV_LINKER_LIBS dl m log)
+ elseif(QNX)
+ set(OPENCV_LINKER_LIBS m log)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
set(OPENCV_LINKER_LIBS m pthread)
else()
@@ -1166,7 +1176,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
# We need pthread's
- if(UNIX AND NOT ANDROID)
+ if(UNIX AND NOT ANDROID AND NOT QNX)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -pthread")
endif()
View
47 README.md
@@ -0,0 +1,47 @@
+# Blackberry Port of OpenCV 2.3.1
+
+Officially sanctioned port of OpenCV to the Blackberry/QNX platform. To avoid fragmentation, please do not use any other version of OpenCV.
+
+OpenCV has a CMake-based build system. This port was based on the sources for the Unix variant downloaded from http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.3.1/.
+
+### What's working, what's not?
+
+This is an untested compilation of the OpenCV libraries for PlayBook. Areas that are highly dependent on the support of the operating system, such as the window system and (video) camera input facilities, have not been modified and will not work as-is.
+Basic data types (points, matrices, rectangles, etc..), colour space transformations and the like appear to work, as does the
+source code that provides mean shift based tracking (meanshift and CAMShift), optical flow (good features to track,
+LK pyramids), histograms and back projection. The machine learning components needed for ADABoost and Haar Training also seem to work, as do
+Kalman filters. Other parts of OpenCV have not been looked at in any way.
+
+### Prerequisites
+
+- Blackberry Native SDK (NDK) for Tablet OS
+
+### Instructions for cross-compiling on Linux
+
+1. If not already installed, obtain a native development kit for the BlackBerry PlayBook, and install it.
+ We'll use NDK as the name of the directory where the native development kit is installed.
+2. Open a new command line shell, and invoke the script that initializes critical environment variables. In a BASH shell
+ you would type:
+ > source $NDK/bbndk-env.sh
+3. Create a sub-directory called "build".
+4. Change to the "build" directory, then invoke the configuration script to run CMake for the ARM architecture:
+ > ../configure-qsk arm a9
+
+ The output will report that, for example certain GUI features have been enabled. Other 3rd party libraries are
+ already disabled by default. Also, this will use the GNU STL implementation rather than the default "Dinkum"
+ implementation.
+5. Modify the build options: run the CMake configuration GUI to modify any other compile options that should be
+ disabled at the moment:
+ > ccmake .
+
+ A "curses"-based GUI will appear, and you can ensure that many options have been turned off. Make the following changes:
+ - Disable BUILD_DOCS, BUILD_NEW_PYTHON_SUPPORT, BUILD_PACKAGE, BUILD_TESTS
+ - Disable all WITH_something options (like WITH_1394, WITH_CUDA, WITH_EIGEN, WITH_FFMPEG, ... etc..)
+ The arrow keys take you between options. The "enter" key toggles between "ON" and "OFF"
+
+ After all the changes have been made, press "c" to modify the configuration. One error message may appear with respect
+ to "sphinx". It is safe to ignore it. Press "g" to generate and exit.
+
+6. Compile the libraries using "make". If it makes sense, use "make -j" to accelerate the compile.
+ > make -j4
+ Both static and dynamic libraries will be built. They can be found in build/lib.
View
108 configure-qsk
@@ -0,0 +1,108 @@
+#!/bin/bash
+
+CPU="$1$2"
+if [ "$2" == "v7le" ]; then
+ CPUDIR="$1le-v7"
+ BUSUFFIX="$1v7"
+elif [ "$2" == "a9" ]; then
+ CPUDIR="$1le-v7"
+ CPU="$1v7le"
+ BUSUFFIX="$1v7"
+ CPUGEN="a9"
+else
+ CPUDIR="$CPU"
+ BUSUFFIX="$1"
+fi
+
+if [ "$QCONF_OVERRIDE" != "" ]; then
+ cp -p $QCONF_OVERRIDE /tmp/owbqsk$$.mk
+ echo "all:" >>/tmp/owbqsk$$.mk
+ echo ' echo $(INSTALL_ROOT_nto)' >>/tmp/owbqsk$$.mk
+ STAGE_DIR=`make -s -f /tmp/owbqsk$$.mk`
+ rm /tmp/owbqsk$$.mk
+fi
+
+if [ "$STAGE_DIR" == "" ]; then
+ STAGE_DIR="$HOME/stage/nto"
+ echo Staging directory could not be determined. Using: $STAGE_DIR
+else
+ echo Using staging directory: $STAGE_DIR
+fi
+
+if [ ! -z "$USE_ICECC" ] ; then
+ CC_COMMAND=icecc
+ echo "Using icecream for distributed compiling"
+else
+ CC_COMMAND=$QNX_HOST/usr/bin/qcc
+fi
+
+if [ -z "$BUILDTYPE" ] ; then
+ BUILDTYPE="Release"
+fi
+
+if [ ! -z "$PROFILE" ] ; then
+ PROFILER_FLAGS="-p"
+else
+ PROFILER_FLAGS=""
+fi
+
+STAGE_LIB="$STAGE_DIR/$CPUDIR/lib"
+STAGE_USR_LIB="$STAGE_DIR/$CPUDIR/usr/lib"
+STAGE_INC="$STAGE_DIR/usr/include"
+TARGET_LIB="$QNX_TARGET/lib"
+TARGET_USR_LIB="$QNX_TARGET/usr/lib"
+TARGET_INC="$QNX_TARGET/usr/include"
+
+COMP_PATHS=" \
+ -Wl,-rpath-link,$STAGE_LIB \
+ -Wl,-rpath-link,$STAGE_USR_LIB \
+ -L$STAGE_LIB \
+ -L$STAGE_USR_LIB \
+ -L$TARGET_LIB \
+ -L$TARGET_USR_LIB \
+ -I$STAGE_INC \
+ -I$STAGE_INC/freetype2 \
+ -I$TARGET_INC"
+
+if [ "$CCWRAP" ] ; then
+ CMAKE_EXTRA_OPTIONS=" \
+ -DCMAKE_C_COMPILER_ARG1=qcc \
+ -DCMAKE_CXX_COMPILER_ARG1=qcc"
+ CC_COMMAND="$CCWRAP"
+fi
+
+if [ "$CPUGEN" == "a9" ] ; then
+ CMAKE_EXTRA_OPTIONS=" \
+ -DTARGET_IS_WINCHESTER=1 \
+ $CMAKE_EXTRA_OPTIONS"
+fi
+
+if [ `uname` == "Darwin" ] ; then
+ CMAKE_EXTRA_OPTIONS=" \
+ -DCMAKE_SKIP_RPATH='ON' \
+ $CMAKE_EXTRA_OPTIONS"
+fi
+
+cmake \
+ -DCMAKE_SYSTEM_PROCESSOR="$CPUDIR" \
+ -DCMAKE_SYSTEM_NAME="QNX" \
+ -DCMAKE_SYSTEM_VERSION="1" \
+ -DCMAKE_BUILD_TYPE="$BUILDTYPE" \
+ -DCMAKE_C_COMPILER="$CC_COMMAND" \
+ -DCMAKE_CXX_COMPILER="$CC_COMMAND" \
+ -DCMAKE_C_FLAGS="-Vgcc_nto$CPU -fpic -g $COMP_PATHS $PROFILER_FLAGS" \
+ -DCMAKE_CXX_FLAGS="-Vgcc_nto${CPU} -Y_gpp -fpic -g -lang-c++ $COMP_PATHS $PROFILER_FLAGS" \
+ -DCMAKE_INCLUDE_PATH="$STAGE_INC;$STAGE_INC/skia" \
+ -DCMAKE_LIBRARY_PATH="$STAGE_LIB;$STAGE_USR_LIB" \
+ -DCMAKE_INSTALL_PREFIX="$STAGE_DIR" \
+ -DCMAKE_OPENCV_GCC_VERSION="42" \
+ -DCMAKE_OPENCV_GCC_VERSION_NUM="402" \
+ -DCMAKE_AR="$QNX_HOST/usr/bin/nto$BUSUFFIX-ar" \
+ -DCMAKE_RANLIB="$QNX_HOST/usr/bin/nto$BUSUFFIX-ranlib" \
+ -DCMAKE_LD="$QNX_HOST/usr/bin/nto$BUSUFFIX-ld" \
+ -DCMAKE_LINKER="$QNX_HOST/usr/bin/nto$BUSUFFIX-ld" \
+ -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE \
+ -DQNX=1 \
+ -G"Eclipse CDT4 - Unix Makefiles" \
+ $CMAKE_EXTRA_OPTIONS \
+ $3 ../
View
6 modules/core/include/opencv2/core/operations.hpp
@@ -3403,7 +3403,13 @@ template<typename _Tp> inline ptrdiff_t operator - (const SeqIterator<_Tp>& a,
const SeqIterator<_Tp>& b)
{
ptrdiff_t delta = a.index - b.index, n = a.seq->total;
+#if defined(__QNX__)
+ // No long std::abs(long) in QNX
+ long absdelta = (delta < 0) ? -delta : delta;
+ if( absdelta > n )
+#else
if( std::abs(static_cast<long>(delta)) > n )
+#endif
delta += delta < 0 ? n : -n;
return delta;
}
View
3  modules/traincascade/imagestorage.h
@@ -2,6 +2,9 @@
#define _OPENCV_IMAGESTORAGE_H_
#include "highgui.h"
+#if defined(__QNX__)
+#include "stdio.h"
+#endif
using namespace cv;
Please sign in to comment.
Something went wrong with that request. Please try again.