Skip to content
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

OpenCV 2.x #189

Merged
merged 20 commits into from
Apr 1, 2016
Merged
Show file tree
Hide file tree
Changes from 5 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
62 changes: 62 additions & 0 deletions opencv/bld.bat
Original file line number Diff line number Diff line change
@@ -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%"

45 changes: 45 additions & 0 deletions opencv/build.sh
Original file line number Diff line number Diff line change
@@ -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 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some of these libraries here also ship with conda (e.g libpng, zlib, libtiff, libjpeg and others). We should definitely include these as build and runtime requirements. For any of these that are not here (e.g. OpenEXR), we might want to disable for now, but add a note that we need to add a recipe for them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. If my GIT history is correct this is actually problematic. OpenCV is notoriously poor at properly supporting Python (particularly VS 2008) and if you try and link against external libraries then the OpenCV CMake setup is not able to correctly rectify the correct headers with the correct libraries. For example, I had a comment in my original repo that I turned to building everything because OpenCV was using the shipped Windows LIBPNG headers but linking against conda LIBPNG, causing a segfault at run time.

-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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we run some sort of make check, make test, or ctest command here? Whatever happens to be available and does a decent job of testing the library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will have to look into that as I've never run the tests before!

Edit: Looks like its kind of a pain - Need to download the test data and then run a Python script (OPENCV_TEST_DATA_PATH=/path/to/above/zip $PYTHON modules/ts/misc/run.py -a build) from the recipe root. OpenCV does not use ctest/make test/make check.


38 changes: 38 additions & 0 deletions opencv/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package:
name: opencv
version: 2.4.11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to set this with jinja templates so it is easy to update. Here is a simple example.


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the following would ensure Python 2.7 builds only.

skip: true  # [not py27]

skip: true # [not py27]

requirements:
build:
- cmake
- numpy x.x
- python
- eigen 3.*
- tbb 4.* # [osx]

run:
- python
- numpy x.x
- tbb 4.* # [osx]

test:
imports:
- cv2
- cv2.cv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be nice to check that the libraries landed ok. Doing some test -f ... or similar would work great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do - but need to ensure everything actually builds before I'm able to list all the libraries - OpenCV is similar to BOOST in that there are a lot of libraries produced!


about:
home: http://opencv.org/
license: BSD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a summary field. Just a short description.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we like to specify license version just to clarify anything. So, I believe OpenCV is BSD 3-Clause. Though you could say BSD New or BSD Simplified. Whatever will allow for an easy Google to clarify. 😄


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a special field here at conda-forge to note recipe maintainers. Just add your GitHub handle like so. Also, feel free to add me on this one too. 😄 Generally, I have done this in alphabetical order, but I don't believe there is any hard and fast rule for this (at least not one I am aware of). Here is an example.

extra:
    recipe-maintainers:
        - jakirkham
        - patricksnape

12 changes: 12 additions & 0 deletions opencv/osx_rpath.patch
Original file line number Diff line number Diff line change
@@ -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})