Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
opencv: Fixes from internal repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mingwandroid committed Jun 9, 2017
1 parent 92c500c commit f9b7042
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 43 deletions.
118 changes: 97 additions & 21 deletions opencv/build.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,104 @@
#!/bin/bash

if [ `uname` == Darwin ]; then
PY_LIB="libpython2.7.dylib"
else
PY_LIB="libpython2.7.so"
SHORT_OS_STR=$(uname -s)

if [ "${SHORT_OS_STR:0:5}" == "Linux" ]; then
DYNAMIC_EXT="so"
OPENMP="-DWITH_OPENMP=1"
CMAKE_OSX_DEPLOYMENT_TARGET=""
fi
if [ "${SHORT_OS_STR}" == "Darwin" ]; then
DYNAMIC_EXT="dylib"
OPENMP=""
CMAKE_OSX_DEPLOYMENT_TARGET="-DCMAKE_OSX_DEPLOYMENT_TARGET="
fi

INC_PYTHON="${PREFIX}/include/python${PY_VER}"

curl -L -O "https://github.com/opencv/opencv_contrib/archive/$PKG_VERSION.tar.gz"
test `openssl sha256 $PKG_VERSION.tar.gz | awk '{print $2}'` = "1e2bb6c9a41c602904cc7df3f8fb8f98363a88ea564f2a087240483426bf8cbe"
tar -zxf $PKG_VERSION.tar.gz

mkdir build
cd build
cmake \
-DPYTHON_EXECUTABLE=$PREFIX/bin/python \
-DPYTHON_INCLUDE_DIR=$PREFIX/include/python2.7/ \
-DPYTHON_LIBRARY=$PREFIX/lib/$PY_LIB \
-DPYTHON_PACKAGES_PATH=$PREFIX/lib/python2.7/site-packages/ \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DWITH_CUDA=OFF \
-DWITH_AVFOUNDATION=OFF \
-DWITH_FFMPEG=OFF \
-DJPEG_INCLUDE_DIR:PATH=$PREFIX/include \
-DJPEG_LIBRARY:FILEPATH=$PREFIX/lib/libjpeg.so \
-DPNG_PNG_INCLUDE_DIR:PATH=$PREFIX/include \
-DPNG_LIBRARY:FILEPATH=$PREFIX/lib/libpng.so \
-DZLIB_INCLUDE_DIR:PATH=$PREFIX/include \
-DZLIB_LIBRARY:FILEPATH=$PREFIX/lib/libz.so \
..
make

# For some reason OpenCV just won't see hdf5.h without updating the CFLAGS
export CFLAGS="$CFLAGS -I$PREFIX/include"
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"

IFS='.' read -ra PY_VER_ARR <<< "${PY_VER}"
PY_MAJOR="${PY_VER_ARR[0]}"

if [ $PY3K -eq 1 ]; then
LIB_PYTHON="${PREFIX}/lib/libpython${PY_VER}m.${DYNAMIC_EXT}"
INC_PYTHON="$PREFIX/include/python${PY_VER}m"
else
LIB_PYTHON="${PREFIX}/lib/libpython${PY_VER}.${DYNAMIC_EXT}"
INC_PYTHON="$PREFIX/include/python${PY_VER}"
fi

cmake .. -LAH \
$OPENMP \
-DWITH_EIGEN=1 \
-DBUILD_TESTS=0 \
-DBUILD_DOCS=0 \
-DBUILD_PERF_TESTS=0 \
-DBUILD_ZLIB=0 \
-DZLIB_LIBRARY_RELEASE=$PREFIX/lib/libz.$DYNAMIC_EXT \
-DZLIB_INCLUDE_DIR=$PREFIX/include \
-DHDF5_LIBRARY_RELEASE=$PREFIX/lib/libz.$DYNAMIC_EXT \
-DPNG_INCLUDE_DIR=$PREFIX/include \
-DPNG_LIBRARY_RELEASE=$PREFIX/lib/libpng.$DYNAMIC_EXT \
-DBUILD_TIFF=0 \
-DBUILD_PNG=0 \
-DBUILD_OPENEXR=1 \
-DBUILD_JPEG=0 \
-DWITH_CUDA=0 \
-DWITH_OPENCL=0 \
-DWITH_GTK=0 \
-DWITH_OPENNI=0 \
-DWITH_FFMPEG=1 \
-DWITH_MATLAB=0 \
-DWITH_VTK=0 \
-DINSTALL_C_EXAMPLES=0 \
-DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib-$PKG_VERSION/modules" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_SKIP_RPATH:bool=ON \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DBUILD_opencv_python2=0 \
-DPYTHON2_EXECUTABLE="" \
-DPYTHON2_INCLUDE_DIR="" \
-DPYTHON2_NUMPY_INCLUDE_DIRS="" \
-DPYTHON2_LIBRARY="" \
-DPYTHON_INCLUDE_DIR2="" \
-DPYTHON2_PACKAGES_PATH="" \
-DBUILD_opencv_python3=0 \
-DPYTHON3_EXECUTABLE="" \
-DPYTHON3_NUMPY_INCLUDE_DIRS="" \
-DPYTHON3_INCLUDE_DIR="" \
-DPYTHON3_LIBRARY="" \
-DPYTHON3_PACKAGES_PATH="" \
-DPYTHON_INCLUDE_DIR="" \
-DPYTHON_EXECUTABLE="${PYTHON}" \
-DPYTHON_INCLUDE_DIR="${INC_PYTHON}" \
-DPYTHON_LIBRARY="${LIB_PYTHON}" \
-DPYTHON_PACKAGES_PATH="${SP_DIR}" \
-DBUILD_opencv_python${PY_MAJOR}=1 \
-DPYTHON${PY_MAJOR}_EXECUTABLE=${PYTHON} \
-DPYTHON${PY_MAJOR}_INCLUDE_DIR=${INC_PYTHON} \
-DPYTHON${PY_MAJOR}_NUMPY_INCLUDE_DIRS=${SP_DIR}/numpy/core/include \
-DPYTHON${PY_MAJOR}_LIBRARY=${LIB_PYTHON} \
-DPYTHON${PY_MAJOR}_PACKAGES_PATH=${SP_DIR} \
-DBUILD_LIBPROTOBUF_FROM_SOURCES=0 \
-DBUILD_PROTOBUF=0 \
-DPROTOBUF_INCLUDE_DIR=${PREFIX}/include \
-DPROTOBUF_LIBRARIES=${PREFIX}/lib \
${CMAKE_OSX_DEPLOYMENT_TARGET}

if [[ ! $? ]]; then
echo "configure failed with $?"
exit 1
fi

make -j6
make install
131 changes: 109 additions & 22 deletions opencv/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,121 @@
# Tested on Mac OS X 10.9 using clang compiler provided by XCode
{% set version = "3.2.0" %}

package:
name: opencv
version: 2.4.9
name: opencv
version: {{ version }}

source:
fn: opencv-2.4.9.zip
url: http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
git_url: https://github.com/opencv/opencv
git_tag: {{ version }}
# url: https://github.com/opencv/opencv/archive/{{ version }}.zip
patches:
- 0001-Win32-CONDA_BUILD-Do-not-use-bundled-ffmpeg.patch
- 0002-VS2008-does-not-support-C-11-std-vector-data.patch
- 0003-Add-static-inline-double-round-double-for-VC2008.patch
- 0004-Specify-template-overload-for-abs-for-VC2008.patch

build:
number: 0
number: 0
features:
- nomkl [nomkl]

requirements:
build:
- cmake
- numpy
- jpeg
- zlib
- libpng
- python
run:
- python
- numpy
- jpeg
- zlib
- libpng
build:
- python
# For sha256 comparisons of opencv_contrib
- openssl 1.0.* [unix]
# For downloading opencv_contrib
- curl
# For applying patches
- m2-git [win]
- m2-filesystem [win]
- m2w64-pkg-config [win]
- libprotobuf 3.2.*
- git [not win]
- jom [win]
- cmake
- numpy x.x
- hdf5 >=1.8.17,<1.9 [unix]
- eigen 3.*
- zlib 1.2.*
- jpeg 9.*
- libtiff 4.0.*
- libpng >=1.6.21,<1.7
- ffmpeg 2.8.*
- msinttypes [win and py<35]

run:
- python
- numpy x.x
- hdf5 >=1.8.17,<1.9 [unix]
- zlib 1.2.*
- jpeg 9.*
- libtiff 4.0.*
- libpng >=1.6.21,<1.7
- ffmpeg 2.8.*

test:
imports:
- cv2
- cv2.cv
- cv2.xfeatures2d

commands:
# Verify dynamic libraries.
# "bioinspired", Not working in 3.1.0
{% set opencv_libs = [
"xfeatures2d",
"ximgproc",
"xobjdetect",
"xphoto",
"aruco",
"bgsegm",
"calib3d",
"ccalib",
"core",
"datasets",
"dnn",
"dpm",
"face",
"features2d",
"flann",
"fuzzy",
"highgui",
"imgcodecs",
"imgproc",
"line_descriptor",
"ml",
"objdetect",
"optflow",
"photo",
"plot",
"reg",
"rgbd",
"saliency",
"shape",
"stereo",
"stitching",
"structured_light",
"superres",
"surface_matching",
"text",
"tracking",
"video",
"videoio",
"videostab"
] %}
{% for each_opencv_lib in opencv_libs %}
- test -f $PREFIX/lib/libopencv_{{ each_opencv_lib }}.dylib [osx]
- test -f $PREFIX/lib/libopencv_{{ each_opencv_lib }}.so [linux]
- if not exist %PREFIX%\\Library\\bin\\opencv_{{ each_opencv_lib }}320.dll exit 1 [win]
{% endfor %}

about:
home: http://opencv.org/
license: BSD
home: http://opencv.org/
license: BSD 3-clause
license_family: BSD
summary: Computer vision and machine learning software library.
description: |
OpenCV (Open Source Computer Vision Library) includes several hundreds of computer vision algorithms.
It has a modular structure,which means that the package includes several shared or static libraries.
doc_url: http://docs.opencv.org/
doc_source_url: https://github.com/opencv/opencv/tree/master/doc

0 comments on commit f9b7042

Please sign in to comment.