Skip to content

Recipe for OpenCV #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions recipes/opencv/patches/p4a_build-2.4.10.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake
index 31c2c1e..c890917 100644
--- a/cmake/OpenCVDetectPython.cmake
+++ b/cmake/OpenCVDetectPython.cmake
@@ -36,7 +36,7 @@ if(PYTHON_EXECUTABLE)
unset(PYTHON_VERSION_FULL)
endif()

- if(NOT ANDROID AND NOT IOS)
+ if(P4A OR NOT ANDROID AND NOT IOS)
ocv_check_environment_variables(PYTHON_LIBRARY PYTHON_INCLUDE_DIR)
if(CMAKE_CROSSCOMPILING)
find_host_package(PythonLibs ${PYTHON_VERSION_MAJOR_MINOR})
@@ -51,7 +51,7 @@ if(PYTHON_EXECUTABLE)
endif()
endif()

- if(NOT ANDROID AND NOT IOS)
+ if(P4A OR NOT ANDROID AND NOT IOS)
if(CMAKE_HOST_UNIX)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_lib()"
RESULT_VARIABLE PYTHON_CVPY_PROCESS
@@ -117,7 +117,7 @@ if(PYTHON_EXECUTABLE)
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
- endif(NOT ANDROID AND NOT IOS)
+ endif(P4A OR NOT ANDROID AND NOT IOS)

if(BUILD_DOCS)
find_host_program(SPHINX_BUILD sphinx-build)
diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt
index 3c0f2fd..7ba234a 100644
--- a/modules/python/CMakeLists.txt
+++ b/modules/python/CMakeLists.txt
@@ -5,7 +5,7 @@
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
ocv_module_disable(python)
endif()
-if(ANDROID OR IOS OR NOT PYTHONLIBS_FOUND OR NOT PYTHON_USE_NUMPY)
+if(ANDROID AND NOT P4A OR IOS OR NOT PYTHONLIBS_FOUND OR NOT PYTHON_USE_NUMPY)
ocv_module_disable(python)
endif()

diff --git a/modules/androidcamera/src/camera_activity.cpp b/modules/androidcamera/src/camera_activity.cpp
index 84db3e1..4222526 100644
--- a/modules/androidcamera/src/camera_activity.cpp
+++ b/modules/androidcamera/src/camera_activity.cpp
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
#include <algorithm>
+#include <stdlib.h>
#include <opencv2/core/version.hpp>
#include "camera_activity.hpp"
#include "camera_wrapper.h"
@@ -342,6 +343,8 @@ std::string CameraWrapperConnector::getPathLibFolder()

char* pathEnd = strrchr(pathBegin, '/');
pathEnd[1] = 0;
+ pathBegin = realpath((std::string(pathBegin)+"../../../../lib").c_str(), lineBuf);
+ pathBegin = strcat(pathBegin, "/");

LOGD("Libraries folder found: %s", pathBegin);

57 changes: 57 additions & 0 deletions recipes/opencv/recipe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

VERSION_opencv=${VERSION_opencv:-2.4.10.1}
URL_opencv=https://github.com/Itseez/opencv/archive/$VERSION_opencv.zip

DEPS_opencv=(numpy python)
MD5_opencv=e6667a39c33aa2c63defb9beb94e84ca
BUILD_opencv=$BUILD_PATH/opencv/$(get_directory $URL_opencv)
RECIPE_opencv=$RECIPES_PATH/opencv

_cvsrc=$BUILD_opencv
_cvbuild=$BUILD_opencv/build_p4a
_pyroot=$(dirname `dirname $HOSTPYTHON`)

function prebuild_opencv() {
cd $BUILD_opencv

if [ -f .patched ]; then
return
fi

try patch -p1 < $RECIPE_opencv/patches/p4a_build-2.4.10.1.patch
touch .patched
}

function shouldbuild_opencv() {
if [ -f "$SITEPACKAGES_PATH/cv2.so" ]; then
DO_BUILD=0
fi
}

function build_opencv() {

try mkdir -p $_cvbuild
cd $_cvbuild

push_arm
#try set > opencv_p4y_env.log # check env vars for debugging

export ANDROID_NDK=$ANDROIDNDK
try cmake -DP4A=ON -DANDROID_ABI=$ARCH -DCMAKE_TOOLCHAIN_FILE=$_cvsrc/platforms/android/android.toolchain.cmake \
-DPYTHON_INCLUDE_PATH=$_pyroot/include/python2.7 -DPYTHON_LIBRARY=$_pyroot/lib/libpython2.7.so \
-DPYTHON_NUMPY_INCLUDE_DIR=$SITEPACKAGES_PATH/numpy/core/include \
-DANDROID_EXECUTABLE=$ANDROIDSDK/tools/android \
-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_ANDROID_EXAMPLES=OFF \
-DPYTHON_PACKAGES_PATH=$SITEPACKAGES_PATH \
$_cvsrc
try make -j8 opencv_python
try cmake -DCOMPONENT=python -P ./cmake_install.cmake
try cp -a $_cvbuild/lib/$ARCH/lib*.so $LIBS_PATH

pop_arm
}

function postbuild_opencv() {
true
}