From ada47c5600508637453b41d37a08f82a74d675e9 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 23 Mar 2016 17:21:05 +0100 Subject: [PATCH 01/20] Initial commit of the OpenCV 2.x recipe from Menpo Haven't fully verified the Windows build yet as I changed the DLL outpath to LIBRARY_BIN. --- opencv/bld.bat | 62 ++++++++++++++++++++++++++++++++++++++++++ opencv/build.sh | 45 ++++++++++++++++++++++++++++++ opencv/meta.yaml | 36 ++++++++++++++++++++++++ opencv/osx_rpath.patch | 12 ++++++++ 4 files changed, 155 insertions(+) create mode 100644 opencv/bld.bat create mode 100644 opencv/build.sh create mode 100644 opencv/meta.yaml create mode 100644 opencv/osx_rpath.patch diff --git a/opencv/bld.bat b/opencv/bld.bat new file mode 100644 index 0000000000000..d8d71f8757b71 --- /dev/null +++ b/opencv/bld.bat @@ -0,0 +1,62 @@ +@echo off + +mkdir build +cd build + +rem Python 3.x not supported by OpenCV 2.x +if %ARCH%==32 ( + if %PY_VER% LSS 3 ( + set CMAKE_GENERATOR="Visual Studio 9 2008" + set CMAKE_CONFIG="Release" + set OPENCV_ARCH=x86 + set OPENCV_VC=vc9 + ) +) +if %ARCH%==64 ( + if %PY_VER% LSS 3 ( + set CMAKE_GENERATOR="Visual Studio 9 2008 Win64" + set CMAKE_CONFIG="Release" + set OPENCV_ARCH=x64 + set OPENCV_VC=vc9 + ) +) + +rem I had to take out the PNG_LIBRARY because it included +rem a Windows path which caused it to be wrongly escaped +rem and thus an error. Somehow though, CMAKE still finds +rem the correct png library... +cmake .. -G%CMAKE_GENERATOR% ^ + -DBUILD_TESTS=0 ^ + -DBUILD_DOCS=0 ^ + -DBUILD_PERF_TESTS=0 ^ + -DBUILD_ZLIB=1 ^ + -DBUILD_TIFF=1 ^ + -DBUILD_PNG=1 ^ + -DBUILD_OPENEXR=1 ^ + -DBUILD_JASPER=1 ^ + -DBUILD_JPEG=1 ^ + -DPYTHON_EXECUTABLE="%PYTHON%" ^ + -DPYTHON_INCLUDE_PATH="%PREFIX%\include" ^ + -DPYTHON_LIBRARY="%PREFIX%\libs\python27.lib" ^ + -DPYTHON_PACKAGES_PATH="%SP_DIR%" ^ + -DWITH_CUDA=0 ^ + -DWITH_OPENCL=0 ^ + -DWITH_OPENNI=0 ^ + -DWITH_FFMPEG=1 ^ + -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" + +cmake --build . --config %CMAKE_CONFIG% --target ALL_BUILD +cmake --build . --config %CMAKE_CONFIG% --target INSTALL + +if errorlevel 1 exit 1 + +rem Let's just move the files around to a more sane structure (flat) +move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\bin\*.dll" "%LIBRARY_BIN%" +move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\bin\*.exe" "%LIBRARY_BIN%" +move "%LIBRARY_PREFIX%\%OPENCV_ARCH%\%OPENCV_VC%\lib\*.lib" "%LIBRARY_LIB%" +rmdir "%LIBRARY_PREFIX%\%OPENCV_ARCH%" /S /Q + +rem By default cv.py is installed directly in site-packages +rem Therefore, we have to copy all of the dlls directly into it! +xcopy "%LIBRARY_BIN%\opencv*.dll" "%SP_DIR%" + diff --git a/opencv/build.sh b/opencv/build.sh new file mode 100644 index 0000000000000..9e6ee7cccded6 --- /dev/null +++ b/opencv/build.sh @@ -0,0 +1,45 @@ +#!/bin/bash +mkdir build +cd build + + +if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + DYNAMIC_EXT="so" + TBB="" + OPENMP="-DWITH_OPENMP=1" + IS_OSX=0 +fi +if [ "$(uname -s)" == "Darwin" ]; then + IS_OSX=1 + DYNAMIC_EXT="dylib" + OPENMP="" + TBB="-DWITH_TBB=1 -DTBB_LIB_DIR=$PREFIX/lib -DTBB_INCLUDE_DIRS=$PREFIX/include -DTBB_STDDEF_PATH=$PREFIX/include/tbb/tbb_stddef.h" +fi + +cmake .. \ + $TBB \ + $OPENMP \ + -DCMAKE_SKIP_RPATH=1 \ + -DWITH_EIGEN=1 \ + -DBUILD_opencv_apps=0 \ + -DBUILD_TESTS=0 \ + -DBUILD_DOCS=0 \ + -DBUILD_PERF_TESTS=0 \ + -DBUILD_ZLIB=1 \ + -DBUILD_TIFF=1 \ + -DBUILD_PNG=1 \ + -DBUILD_OPENEXR=1 \ + -DBUILD_JASPER=1 \ + -DBUILD_JPEG=1 \ + -DPYTHON_EXECUTABLE=$PREFIX/bin/python${PY_VER} \ + -DPYTHON_INCLUDE_PATH=$PREFIX/include/python${PY_VER} \ + -DPYTHON_LIBRARY=$PREFIX/lib/libpython${PY_VER}.$DYNAMIC_EXT \ + -DPYTHON_PACKAGES_PATH=$SP_DIR \ + -DWITH_CUDA=0 \ + -DWITH_OPENCL=0 \ + -DWITH_OPENNI=0 \ + -DWITH_FFMPEG=0 \ + -DCMAKE_INSTALL_PREFIX=$PREFIX +make -j${CPU_COUNT} +make install + diff --git a/opencv/meta.yaml b/opencv/meta.yaml new file mode 100644 index 0000000000000..9832d505bb081 --- /dev/null +++ b/opencv/meta.yaml @@ -0,0 +1,36 @@ +package: + name: opencv + version: 2.4.11 + +source: + fn: opencv-2.4.11.zip + url: http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.11/opencv-2.4.11.zip/download + sha1: d6e3048416d42213c204f89b9dfe39742f9a708c + + patches: + - osx_rpath.patch # [osx] + +build: + number: 0 + +requirements: + build: + - cmake + - numpy + - eigen 3.* + - tbb 4.* # [osx] + + run: + - python + - numpy + - tbb 4.* # [osx] + +test: + imports: + - cv2 + - cv2.cv + +about: + home: http://opencv.org/ + license: BSD + diff --git a/opencv/osx_rpath.patch b/opencv/osx_rpath.patch new file mode 100644 index 0000000000000..b69983d356b96 --- /dev/null +++ b/opencv/osx_rpath.patch @@ -0,0 +1,12 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -345,8 +345,6 @@ + endif() + endif() + +-set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}") +-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + if(INSTALL_TO_MANGLED_PATHS) + set(OPENCV_INCLUDE_INSTALL_PATH ${OPENCV_INCLUDE_INSTALL_PATH}/opencv-${OPENCV_VERSION}) + From d55d0c0ed112e165e08a5589d5cfedeffc3f7248 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 23 Mar 2016 18:00:23 +0100 Subject: [PATCH 02/20] Use VC features - Python 2.x only --- opencv/meta.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index 9832d505bb081..7c30fea6c8543 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -13,15 +13,19 @@ source: build: number: 0 + features: + - vc9 # [win and py27] + requirements: build: - cmake - numpy + - python 2.x - eigen 3.* - tbb 4.* # [osx] run: - - python + - python 2.x - numpy - tbb 4.* # [osx] From 52103b88aeec749f80913be2fad10a0e33a96ee9 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 23 Mar 2016 18:05:49 +0100 Subject: [PATCH 03/20] Skip non Python 2 Thanks @jakirkham! --- opencv/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index 7c30fea6c8543..6624e14f61e67 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -12,7 +12,7 @@ source: build: number: 0 - + skip: true # [not py27] features: - vc9 # [win and py27] From 444fb86e52998fbb3840632622b7c8f70166b5ae Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 23 Mar 2016 18:47:15 +0100 Subject: [PATCH 04/20] Add x.x for numpy Remove features since we already rely on Python which means we don't require the features. --- opencv/meta.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index 6624e14f61e67..8fb42e2d2d4b3 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -13,20 +13,18 @@ source: build: number: 0 skip: true # [not py27] - features: - - vc9 # [win and py27] requirements: build: - cmake - - numpy + - numpy x.x - python 2.x - eigen 3.* - tbb 4.* # [osx] run: - python 2.x - - numpy + - numpy x.x - tbb 4.* # [osx] test: From bf92f5a4dfdf660e40bab80744efac435e142c0a Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 23 Mar 2016 18:57:21 +0100 Subject: [PATCH 05/20] Remove Python constraints, handled by skip Thanks @jakirkham. --- opencv/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index 8fb42e2d2d4b3..f98519b4d98ab 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -18,12 +18,12 @@ requirements: build: - cmake - numpy x.x - - python 2.x + - python - eigen 3.* - tbb 4.* # [osx] run: - - python 2.x + - python - numpy x.x - tbb 4.* # [osx] From 35cd0c0d7261553ebf17f88b4d5f00077154ebcf Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Wed, 23 Mar 2016 19:02:14 +0100 Subject: [PATCH 06/20] Add summary --- opencv/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index f98519b4d98ab..1dcce72a6915c 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -35,4 +35,5 @@ test: about: home: http://opencv.org/ license: BSD + summary: Computer vision and machine learning software library. From e5c12fbc134a879111da83dab3f5e9847ac342b3 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 24 Mar 2016 08:07:04 +0100 Subject: [PATCH 07/20] BSD 3-clause - clarify license --- opencv/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index 1dcce72a6915c..959f30ebb61e7 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -34,6 +34,6 @@ test: about: home: http://opencv.org/ - license: BSD + license: BSD 3-clause summary: Computer vision and machine learning software library. From 0624aea7c475f4ac9a635314bcd6a43359629b9c Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 24 Mar 2016 08:08:58 +0100 Subject: [PATCH 08/20] Add maintainers @jakirkham and I --- opencv/meta.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index 959f30ebb61e7..baf10be80e6d1 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -37,3 +37,8 @@ about: license: BSD 3-clause summary: Computer vision and machine learning software library. +extra: + recipe-maintainers: + - jakirkham + - patricksnape + From a20f9ce5c032dbc5ba9b6ce26bb3b9f86d46d5f7 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 24 Mar 2016 08:14:33 +0100 Subject: [PATCH 09/20] Use version and filename Jinja templates --- opencv/meta.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/opencv/meta.yaml b/opencv/meta.yaml index baf10be80e6d1..f2c3a94d5da72 100644 --- a/opencv/meta.yaml +++ b/opencv/meta.yaml @@ -1,10 +1,13 @@ +{% set version = "2.4.11" %} +{% set filename = "opencv-%s.zip" % version %} + package: name: opencv - version: 2.4.11 + version: {{ version }} source: - fn: opencv-2.4.11.zip - url: http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.11/opencv-2.4.11.zip/download + fn: {{ filename }} + url: http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/{{ version }}/{{ filename }}/download sha1: d6e3048416d42213c204f89b9dfe39742f9a708c patches: From 37b12abc5193184c01263a6ee5816d50ffc913d5 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 24 Mar 2016 08:15:43 +0100 Subject: [PATCH 10/20] Move into recipes directory - whoops! --- {opencv => recipes/opencv}/bld.bat | 0 {opencv => recipes/opencv}/build.sh | 0 {opencv => recipes/opencv}/meta.yaml | 0 {opencv => recipes/opencv}/osx_rpath.patch | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {opencv => recipes/opencv}/bld.bat (100%) rename {opencv => recipes/opencv}/build.sh (100%) rename {opencv => recipes/opencv}/meta.yaml (100%) rename {opencv => recipes/opencv}/osx_rpath.patch (100%) diff --git a/opencv/bld.bat b/recipes/opencv/bld.bat similarity index 100% rename from opencv/bld.bat rename to recipes/opencv/bld.bat diff --git a/opencv/build.sh b/recipes/opencv/build.sh similarity index 100% rename from opencv/build.sh rename to recipes/opencv/build.sh diff --git a/opencv/meta.yaml b/recipes/opencv/meta.yaml similarity index 100% rename from opencv/meta.yaml rename to recipes/opencv/meta.yaml diff --git a/opencv/osx_rpath.patch b/recipes/opencv/osx_rpath.patch similarity index 100% rename from opencv/osx_rpath.patch rename to recipes/opencv/osx_rpath.patch From 87fd47904de7b4e9a947c57ee1d361d65e19d0c1 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 24 Mar 2016 11:15:40 +0100 Subject: [PATCH 11/20] Remove FFMPEG from Windows --- recipes/opencv/bld.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/opencv/bld.bat b/recipes/opencv/bld.bat index d8d71f8757b71..fe3ec24a80f04 100644 --- a/recipes/opencv/bld.bat +++ b/recipes/opencv/bld.bat @@ -42,7 +42,7 @@ cmake .. -G%CMAKE_GENERATOR% ^ -DWITH_CUDA=0 ^ -DWITH_OPENCL=0 ^ -DWITH_OPENNI=0 ^ - -DWITH_FFMPEG=1 ^ + -DWITH_FFMPEG=0 ^ -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" cmake --build . --config %CMAKE_CONFIG% --target ALL_BUILD From a715849df6b17072ae0c87d49e295314e303a718 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 24 Mar 2016 11:16:27 +0100 Subject: [PATCH 12/20] Add testing At the moment this is copying the file locally because its 600MB and its killing my bandwidth. We may need a better way of getting this test data if we want to test! --- recipes/opencv/bld.bat | 1 - recipes/opencv/build.sh | 28 ++++++++++++++++++++++------ recipes/opencv/meta.yaml | 21 ++++++++++++++++++++- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/recipes/opencv/bld.bat b/recipes/opencv/bld.bat index fe3ec24a80f04..1f81e52f62c05 100644 --- a/recipes/opencv/bld.bat +++ b/recipes/opencv/bld.bat @@ -59,4 +59,3 @@ rmdir "%LIBRARY_PREFIX%\%OPENCV_ARCH%" /S /Q rem By default cv.py is installed directly in site-packages rem Therefore, we have to copy all of the dlls directly into it! xcopy "%LIBRARY_BIN%\opencv*.dll" "%SP_DIR%" - diff --git a/recipes/opencv/build.sh b/recipes/opencv/build.sh index 9e6ee7cccded6..b2fba35e2962b 100644 --- a/recipes/opencv/build.sh +++ b/recipes/opencv/build.sh @@ -1,28 +1,26 @@ #!/bin/bash + mkdir build cd build - if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then DYNAMIC_EXT="so" TBB="" OPENMP="-DWITH_OPENMP=1" - IS_OSX=0 fi if [ "$(uname -s)" == "Darwin" ]; then - IS_OSX=1 DYNAMIC_EXT="dylib" OPENMP="" TBB="-DWITH_TBB=1 -DTBB_LIB_DIR=$PREFIX/lib -DTBB_INCLUDE_DIRS=$PREFIX/include -DTBB_STDDEF_PATH=$PREFIX/include/tbb/tbb_stddef.h" fi -cmake .. \ +cmake -LAH .. \ $TBB \ $OPENMP \ -DCMAKE_SKIP_RPATH=1 \ -DWITH_EIGEN=1 \ -DBUILD_opencv_apps=0 \ - -DBUILD_TESTS=0 \ + -DBUILD_TESTS=1 \ -DBUILD_DOCS=0 \ -DBUILD_PERF_TESTS=0 \ -DBUILD_ZLIB=1 \ @@ -40,6 +38,24 @@ cmake .. \ -DWITH_OPENNI=0 \ -DWITH_FFMPEG=0 \ -DCMAKE_INSTALL_PREFIX=$PREFIX + make -j${CPU_COUNT} -make install +# Before installing - ensure that tests run. First things first, +# download the test data: +#curl -L -o test_data.tar.gz https://github.com/Itseez/opencv_extra/archive/$PKG_VERSION.tar.gz +cp $RECIPE_DIR/test_data.tar.gz ./test_data.tar.gz +tar -xvf test_data.tar.gz opencv_extra-$PKG_VERSION/testdata +export OPENCV_TEST_DATA_PATH=$SRC_DIR/build/opencv_extra-$PKG_VERSION/testdata + +# This is before the RPATH has been rectified by conda - so +# we shim it here using LD_LIBRARY_PATH on Linux and +# DYLD_LIBRARY_PATH on OSX. +if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SRC_DIR/build/lib $PYTHON ../modules/ts/misc/run.py -a $SRC_DIR/build +fi +if [ "$(uname -s)" == "Darwin" ]; then + DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$SRC_DIR/build/lib $PYTHON ../modules/ts/misc/run.py -a $SRC_DIR/build +fi + +make install diff --git a/recipes/opencv/meta.yaml b/recipes/opencv/meta.yaml index f2c3a94d5da72..0a3597ad3be98 100644 --- a/recipes/opencv/meta.yaml +++ b/recipes/opencv/meta.yaml @@ -20,6 +20,7 @@ build: requirements: build: - cmake + - curl - numpy x.x - python - eigen 3.* @@ -34,6 +35,25 @@ test: imports: - cv2 - cv2.cv + commands: + # Test that dynamic libraries exist + - test -f $PREFIX/lib/libopencv_core.dylib # [osx] + - test -f $PREFIX/lib/libopencv_flann.dylib # [osx] + - test -f $PREFIX/lib/libopencv_imgproc.dylib # [osx] + - test -f $PREFIX/lib/libopencv_highgui.dylib # [osx] + - test -f $PREFIX/lib/libopencv_features2d.dylib # [osx] + - test -f $PREFIX/lib/libopencv_calib3d.dylib # [osx] + - test -f $PREFIX/lib/libopencv_ml.dylib # [osx] + - test -f $PREFIX/lib/libopencv_video.dylib # [osx] + - test -f $PREFIX/lib/libopencv_legacy.dylib # [osx] + - test -f $PREFIX/lib/libopencv_objdetect.dylib # [osx] + - test -f $PREFIX/lib/libopencv_photo.dylib # [osx] + - test -f $PREFIX/lib/libopencv_gpu.dylib # [osx] + - test -f $PREFIX/lib/libopencv_nonfree.dylib # [osx] + - test -f $PREFIX/lib/libopencv_contrib.dylib # [osx] + - test -f $PREFIX/lib/libopencv_stitching.dylib # [osx] + - test -f $PREFIX/lib/libopencv_superres.dylib # [osx] + - test -f $PREFIX/lib/libopencv_videostab.dylib # [osx] about: home: http://opencv.org/ @@ -44,4 +64,3 @@ extra: recipe-maintainers: - jakirkham - patricksnape - From 77455b4651a89eebf8e8055cf03ba0fc9751d389 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Thu, 24 Mar 2016 11:17:04 +0100 Subject: [PATCH 13/20] Upgrade to OpenCV 2.4.12 from Github Use Github rather than SourceForge --- recipes/opencv/meta.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/opencv/meta.yaml b/recipes/opencv/meta.yaml index 0a3597ad3be98..cd841858d7b1c 100644 --- a/recipes/opencv/meta.yaml +++ b/recipes/opencv/meta.yaml @@ -1,5 +1,5 @@ -{% set version = "2.4.11" %} -{% set filename = "opencv-%s.zip" % version %} +{% set version = "2.4.12" %} +{% set filename = "%s.zip" % version %} package: name: opencv @@ -7,8 +7,8 @@ package: source: fn: {{ filename }} - url: http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/{{ version }}/{{ filename }}/download - sha1: d6e3048416d42213c204f89b9dfe39742f9a708c + url: https://github.com/Itseez/opencv/archive/{{ filename }} + sha1: 2225768a48dbf99426bf77451a433ed432f54d8e patches: - osx_rpath.patch # [osx] From 521767b5864e5a78fdd385dae53a795985d3a73d Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Fri, 25 Mar 2016 16:57:15 +0100 Subject: [PATCH 14/20] Add testing on Linux and OSX for dynamic libraries Steal from the boost recipe by @jakirkham --- recipes/opencv/meta.yaml | 42 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/recipes/opencv/meta.yaml b/recipes/opencv/meta.yaml index cd841858d7b1c..707c709aecef8 100644 --- a/recipes/opencv/meta.yaml +++ b/recipes/opencv/meta.yaml @@ -36,24 +36,30 @@ test: - cv2 - cv2.cv commands: - # Test that dynamic libraries exist - - test -f $PREFIX/lib/libopencv_core.dylib # [osx] - - test -f $PREFIX/lib/libopencv_flann.dylib # [osx] - - test -f $PREFIX/lib/libopencv_imgproc.dylib # [osx] - - test -f $PREFIX/lib/libopencv_highgui.dylib # [osx] - - test -f $PREFIX/lib/libopencv_features2d.dylib # [osx] - - test -f $PREFIX/lib/libopencv_calib3d.dylib # [osx] - - test -f $PREFIX/lib/libopencv_ml.dylib # [osx] - - test -f $PREFIX/lib/libopencv_video.dylib # [osx] - - test -f $PREFIX/lib/libopencv_legacy.dylib # [osx] - - test -f $PREFIX/lib/libopencv_objdetect.dylib # [osx] - - test -f $PREFIX/lib/libopencv_photo.dylib # [osx] - - test -f $PREFIX/lib/libopencv_gpu.dylib # [osx] - - test -f $PREFIX/lib/libopencv_nonfree.dylib # [osx] - - test -f $PREFIX/lib/libopencv_contrib.dylib # [osx] - - test -f $PREFIX/lib/libopencv_stitching.dylib # [osx] - - test -f $PREFIX/lib/libopencv_superres.dylib # [osx] - - test -f $PREFIX/lib/libopencv_videostab.dylib # [osx] + # Verify dynamic libraries. + {% set opencv_libs = [ + "core", + "flann", + "imgproc", + "highgui", + "features2d", + "calib3d", + "ml", + "video", + "legacy", + "objdetect", + "photo", + "gpu", + "nonfree", + "contrib", + "stitching", + "superres", + "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] + {% endfor %} about: home: http://opencv.org/ From 2bee9b78fff827681f10fbed735577ea23e88282 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Sun, 27 Mar 2016 18:26:57 +0200 Subject: [PATCH 15/20] Trying to add Windows black magic Still need to test on Windows. --- recipes/opencv/bld.bat | 50 +++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/recipes/opencv/bld.bat b/recipes/opencv/bld.bat index 1f81e52f62c05..7f7bd1a7ba596 100644 --- a/recipes/opencv/bld.bat +++ b/recipes/opencv/bld.bat @@ -3,22 +3,42 @@ mkdir build cd build -rem Python 3.x not supported by OpenCV 2.x -if %ARCH%==32 ( - if %PY_VER% LSS 3 ( - set CMAKE_GENERATOR="Visual Studio 9 2008" - set CMAKE_CONFIG="Release" - set OPENCV_ARCH=x86 - set OPENCV_VC=vc9 - ) +set CMAKE_CONFIG="Release" + +:: Set the right msvc version according to Python version +REM write a temporary batch file to map cl.exe version to visual studio version +echo @echo 15=9 > msvc_versions.bat +echo @echo 16=10 >> msvc_versions.bat +echo @echo 17=11 >> msvc_versions.bat +echo @echo 18=12 >> msvc_versions.bat +echo @echo 19=14 >> msvc_versions.bat + +REM Run cl.exe to find which version our compiler is +for /f "delims=" %%A in ('cl /? 2^>^&1 ^| findstr /C:"Version"') do set "CL_TEXT=%%A" +FOR /F "tokens=1,2 delims==" %%i IN ('msvc_versions.bat') DO echo %CL_TEXT% | findstr /C:"Version %%i" > nul && set VSTRING=%%j && goto FOUND +EXIT 1 +:FOUND + +call :TRIM VSTRING %VSTRING% + +set OPENCV_ARCH=x86 +if "%VSTRING%" == "9" ( + set GENERATOR=Visual Studio 9 2008 + set OPENCV_VC=vc9 ) -if %ARCH%==64 ( - if %PY_VER% LSS 3 ( - set CMAKE_GENERATOR="Visual Studio 9 2008 Win64" - set CMAKE_CONFIG="Release" - set OPENCV_ARCH=x64 - set OPENCV_VC=vc9 - ) +if "%VSTRING%" == "10" ( + set GENERATOR=Visual Studio 10 2010 + set OPENCV_VC=vc10 +) +if "%VSTRING%" == "14" ( + set GENERATOR=Visual Studio 14 2015 + set OPENCV_VC=vc14 +) +if not defined GENERATOR EXIT 1 + +if %ARCH% EQU 64 ( + set GENERATOR=%GENERATOR% Win64 + set OPENCV_ARCH=x64 ) rem I had to take out the PNG_LIBRARY because it included From 2a1b47e1976bd0522b59bab652c0aa5cbef5133c Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Sun, 27 Mar 2016 18:34:23 +0100 Subject: [PATCH 16/20] Fix Windows builds with the black magic Windows builds seem to work --- recipes/opencv/bld.bat | 16 ++++++++++++++-- recipes/opencv/meta.yaml | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/recipes/opencv/bld.bat b/recipes/opencv/bld.bat index 7f7bd1a7ba596..83f80b6fdb52c 100644 --- a/recipes/opencv/bld.bat +++ b/recipes/opencv/bld.bat @@ -45,7 +45,7 @@ rem I had to take out the PNG_LIBRARY because it included rem a Windows path which caused it to be wrongly escaped rem and thus an error. Somehow though, CMAKE still finds rem the correct png library... -cmake .. -G%CMAKE_GENERATOR% ^ +cmake .. -G"%GENERATOR%" ^ -DBUILD_TESTS=0 ^ -DBUILD_DOCS=0 ^ -DBUILD_PERF_TESTS=0 ^ @@ -59,8 +59,8 @@ cmake .. -G%CMAKE_GENERATOR% ^ -DPYTHON_INCLUDE_PATH="%PREFIX%\include" ^ -DPYTHON_LIBRARY="%PREFIX%\libs\python27.lib" ^ -DPYTHON_PACKAGES_PATH="%SP_DIR%" ^ + -DWITH_EIGEN=1 ^ -DWITH_CUDA=0 ^ - -DWITH_OPENCL=0 ^ -DWITH_OPENNI=0 ^ -DWITH_FFMPEG=0 ^ -DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" @@ -79,3 +79,15 @@ rmdir "%LIBRARY_PREFIX%\%OPENCV_ARCH%" /S /Q rem By default cv.py is installed directly in site-packages rem Therefore, we have to copy all of the dlls directly into it! xcopy "%LIBRARY_BIN%\opencv*.dll" "%SP_DIR%" + +goto :eof + +:TRIM + SetLocal EnableDelayedExpansion + Call :TRIMSUB %%%1%% + EndLocal & set %1=%tempvar% + GOTO :eof + + :TRIMSUB + set tempvar=%* + GOTO :eof \ No newline at end of file diff --git a/recipes/opencv/meta.yaml b/recipes/opencv/meta.yaml index 707c709aecef8..1dea2300204b9 100644 --- a/recipes/opencv/meta.yaml +++ b/recipes/opencv/meta.yaml @@ -1,5 +1,5 @@ {% set version = "2.4.12" %} -{% set filename = "%s.zip" % version %} +{% set filename = "opencv2-%s.zip" % version %} package: name: opencv @@ -7,7 +7,7 @@ package: source: fn: {{ filename }} - url: https://github.com/Itseez/opencv/archive/{{ filename }} + url: https://github.com/Itseez/opencv/archive/{{ version }}.zip sha1: 2225768a48dbf99426bf77451a433ed432f54d8e patches: From b1a7226814b2bcf87424a3d0bca8f003eb28f637 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Tue, 29 Mar 2016 18:33:15 +0200 Subject: [PATCH 17/20] Dynamically link to JPEG, PNG, TIFF and ZLIB on Unix Also, steal tests from Homebrew rather than running the OpenCV tests because there is far too much data to download for the tests. Finally, remove TBB for now to get the recipe in --- recipes/opencv/build.sh | 35 ++++++++--------------------------- recipes/opencv/meta.yaml | 10 ++++++++-- recipes/opencv/run_test.sh | 5 +++++ recipes/opencv/test.cpp | 7 +++++++ 4 files changed, 28 insertions(+), 29 deletions(-) create mode 100755 recipes/opencv/run_test.sh create mode 100644 recipes/opencv/test.cpp diff --git a/recipes/opencv/build.sh b/recipes/opencv/build.sh index b2fba35e2962b..350355a27e134 100644 --- a/recipes/opencv/build.sh +++ b/recipes/opencv/build.sh @@ -5,30 +5,28 @@ cd build if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then DYNAMIC_EXT="so" - TBB="" OPENMP="-DWITH_OPENMP=1" fi if [ "$(uname -s)" == "Darwin" ]; then DYNAMIC_EXT="dylib" OPENMP="" - TBB="-DWITH_TBB=1 -DTBB_LIB_DIR=$PREFIX/lib -DTBB_INCLUDE_DIRS=$PREFIX/include -DTBB_STDDEF_PATH=$PREFIX/include/tbb/tbb_stddef.h" fi cmake -LAH .. \ - $TBB \ $OPENMP \ -DCMAKE_SKIP_RPATH=1 \ -DWITH_EIGEN=1 \ -DBUILD_opencv_apps=0 \ - -DBUILD_TESTS=1 \ + -DBUILD_TESTS=0 \ -DBUILD_DOCS=0 \ -DBUILD_PERF_TESTS=0 \ - -DBUILD_ZLIB=1 \ - -DBUILD_TIFF=1 \ - -DBUILD_PNG=1 \ + -DBUILD_ZLIB=0 \ + -DZLIB_LIBRARY=$PREFIX/lib/libz.$DYNAMIC_EXT \ + -DBUILD_TIFF=0 \ + -DBUILD_PNG=0 \ -DBUILD_OPENEXR=1 \ -DBUILD_JASPER=1 \ - -DBUILD_JPEG=1 \ + -DBUILD_JPEG=0 \ -DPYTHON_EXECUTABLE=$PREFIX/bin/python${PY_VER} \ -DPYTHON_INCLUDE_PATH=$PREFIX/include/python${PY_VER} \ -DPYTHON_LIBRARY=$PREFIX/lib/libpython${PY_VER}.$DYNAMIC_EXT \ @@ -39,23 +37,6 @@ cmake -LAH .. \ -DWITH_FFMPEG=0 \ -DCMAKE_INSTALL_PREFIX=$PREFIX -make -j${CPU_COUNT} - -# Before installing - ensure that tests run. First things first, -# download the test data: -#curl -L -o test_data.tar.gz https://github.com/Itseez/opencv_extra/archive/$PKG_VERSION.tar.gz -cp $RECIPE_DIR/test_data.tar.gz ./test_data.tar.gz -tar -xvf test_data.tar.gz opencv_extra-$PKG_VERSION/testdata -export OPENCV_TEST_DATA_PATH=$SRC_DIR/build/opencv_extra-$PKG_VERSION/testdata - -# This is before the RPATH has been rectified by conda - so -# we shim it here using LD_LIBRARY_PATH on Linux and -# DYLD_LIBRARY_PATH on OSX. -if [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SRC_DIR/build/lib $PYTHON ../modules/ts/misc/run.py -a $SRC_DIR/build -fi -if [ "$(uname -s)" == "Darwin" ]; then - DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$SRC_DIR/build/lib $PYTHON ../modules/ts/misc/run.py -a $SRC_DIR/build -fi - +make make install + diff --git a/recipes/opencv/meta.yaml b/recipes/opencv/meta.yaml index 1dea2300204b9..8a3d960080722 100644 --- a/recipes/opencv/meta.yaml +++ b/recipes/opencv/meta.yaml @@ -24,12 +24,18 @@ requirements: - numpy x.x - python - eigen 3.* - - tbb 4.* # [osx] + - zlib # [unix] + - jpeg # [unix] + - libtiff # [unix] + - libpng # [unix] run: - python - numpy x.x - - tbb 4.* # [osx] + - zlib # [unix] + - jpeg # [unix] + - libtiff # [unix] + - libpng # [unix] test: imports: diff --git a/recipes/opencv/run_test.sh b/recipes/opencv/run_test.sh new file mode 100755 index 0000000000000..f4eaa7da8d78b --- /dev/null +++ b/recipes/opencv/run_test.sh @@ -0,0 +1,5 @@ +g++ $RECIPE_DIR/test.cpp -I$PREFIX/include -L$PREFIX/lib -o test +[ $(./test) != "$PKG_VERSION" ] && exit 1 + +[ $(python -c 'import cv2; print(cv2.__version__)') != "$PKG_VERSION" ] && exit 1 + diff --git a/recipes/opencv/test.cpp b/recipes/opencv/test.cpp new file mode 100644 index 0000000000000..11e9239b79b6f --- /dev/null +++ b/recipes/opencv/test.cpp @@ -0,0 +1,7 @@ +#include +#include +int main() +{ + std::cout << CV_VERSION << std::endl; + return 0; +} From 5fa5c33077565c2e365e9d69b124629e9e36373d Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Fri, 1 Apr 2016 08:53:46 +0200 Subject: [PATCH 18/20] Cleaning up recipes style wise Also, use Jasper from the feedstocks on Unix --- recipes/opencv/bld.bat | 2 +- recipes/opencv/build.sh | 3 +-- recipes/opencv/meta.yaml | 33 +++++++++++++++++---------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/recipes/opencv/bld.bat b/recipes/opencv/bld.bat index 83f80b6fdb52c..13526e2b9260f 100644 --- a/recipes/opencv/bld.bat +++ b/recipes/opencv/bld.bat @@ -90,4 +90,4 @@ goto :eof :TRIMSUB set tempvar=%* - GOTO :eof \ No newline at end of file + GOTO :eof diff --git a/recipes/opencv/build.sh b/recipes/opencv/build.sh index 350355a27e134..2c7297171be5f 100644 --- a/recipes/opencv/build.sh +++ b/recipes/opencv/build.sh @@ -25,7 +25,7 @@ cmake -LAH .. \ -DBUILD_TIFF=0 \ -DBUILD_PNG=0 \ -DBUILD_OPENEXR=1 \ - -DBUILD_JASPER=1 \ + -DBUILD_JASPER=0 \ -DBUILD_JPEG=0 \ -DPYTHON_EXECUTABLE=$PREFIX/bin/python${PY_VER} \ -DPYTHON_INCLUDE_PATH=$PREFIX/include/python${PY_VER} \ @@ -39,4 +39,3 @@ cmake -LAH .. \ make make install - diff --git a/recipes/opencv/meta.yaml b/recipes/opencv/meta.yaml index 8a3d960080722..2fa9278a3ee6f 100644 --- a/recipes/opencv/meta.yaml +++ b/recipes/opencv/meta.yaml @@ -11,7 +11,7 @@ source: sha1: 2225768a48dbf99426bf77451a433ed432f54d8e patches: - - osx_rpath.patch # [osx] + - osx_rpath.patch # [osx] build: number: 0 @@ -19,23 +19,24 @@ build: requirements: build: - - cmake - - curl - - numpy x.x - - python - - eigen 3.* - - zlib # [unix] - - jpeg # [unix] - - libtiff # [unix] - - libpng # [unix] + - cmake + - python + - numpy x.x + - eigen 3.* + - jasper # [unix] + - zlib # [unix] + - jpeg # [unix] + - libtiff # [unix] + - libpng # [unix] run: - - python - - numpy x.x - - zlib # [unix] - - jpeg # [unix] - - libtiff # [unix] - - libpng # [unix] + - python + - numpy x.x + - jasper # [unix] + - zlib # [unix] + - jpeg # [unix] + - libtiff # [unix] + - libpng # [unix] test: imports: From 82f3d86749be3ae58b7040590451d0202edf3b07 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Fri, 1 Apr 2016 08:54:29 +0200 Subject: [PATCH 19/20] Use $PYTHON in test rather than python But this seems to fail on my Mac because $PYTHON points to _build rather than _test !!?? --- recipes/opencv/run_test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/opencv/run_test.sh b/recipes/opencv/run_test.sh index f4eaa7da8d78b..73d5f185541a4 100755 --- a/recipes/opencv/run_test.sh +++ b/recipes/opencv/run_test.sh @@ -1,5 +1,4 @@ g++ $RECIPE_DIR/test.cpp -I$PREFIX/include -L$PREFIX/lib -o test [ $(./test) != "$PKG_VERSION" ] && exit 1 -[ $(python -c 'import cv2; print(cv2.__version__)') != "$PKG_VERSION" ] && exit 1 - +[ $($PYTHON -c 'import cv2; print(cv2.__version__)') != "$PKG_VERSION" ] && exit 1 From a95f88c21c2d12992e1011d141fb3b8e950d9a29 Mon Sep 17 00:00:00 2001 From: Patrick Snape Date: Fri, 1 Apr 2016 18:00:35 +0200 Subject: [PATCH 20/20] Undo tab indenting in bld.bat --- recipes/opencv/bld.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/opencv/bld.bat b/recipes/opencv/bld.bat index 13526e2b9260f..f71f0d31b8b0f 100644 --- a/recipes/opencv/bld.bat +++ b/recipes/opencv/bld.bat @@ -59,7 +59,7 @@ cmake .. -G"%GENERATOR%" ^ -DPYTHON_INCLUDE_PATH="%PREFIX%\include" ^ -DPYTHON_LIBRARY="%PREFIX%\libs\python27.lib" ^ -DPYTHON_PACKAGES_PATH="%SP_DIR%" ^ - -DWITH_EIGEN=1 ^ + -DWITH_EIGEN=1 ^ -DWITH_CUDA=0 ^ -DWITH_OPENNI=0 ^ -DWITH_FFMPEG=0 ^