Commit d9fbb3c2 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Merge branch 'opencv_conda_forge_recipe' into 'master'

opencv conda-forge recipe + BSD3 license

See merge request !455
parents 6c7c4198 e77aea2f
Pipeline #45797 passed with stage
in 25 minutes and 46 seconds
From ad5f6bce0b8ab690bd62fc2e0187dd81670cb38f Mon Sep 17 00:00:00 2001
From: Maksim Shabunin <maksim.shabunin@gmail.com>
Date: Fri, 26 Jul 2019 15:37:28 +0300
Subject: [PATCH] Fix for building with old V4L
---
modules/videoio/src/cap_v4l.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules/videoio/src/cap_v4l.cpp b/modules/videoio/src/cap_v4l.cpp
index 948ba0d576..1922213454 100644
--- a/modules/videoio/src/cap_v4l.cpp
+++ b/modules/videoio/src/cap_v4l.cpp
@@ -262,6 +262,10 @@ typedef uint32_t __u32;
#define V4L2_CID_IRIS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+17)
#endif
+#ifndef V4L2_PIX_FMT_Y10
+#define V4L2_PIX_FMT_Y10 v4l2_fourcc('Y', '1', '0', ' ')
+#endif
+
/* Defaults - If your board can do better, set it here. Set for the most common type inputs. */
#define DEFAULT_V4L_WIDTH 640
#define DEFAULT_V4L_HEIGHT 480
--
2.17.1
From 64e0ff02684e58f059b9da96c8ad048ea91e3660 Mon Sep 17 00:00:00 2001
From: Maksim Shabunin <maksim.shabunin@gmail.com>
Date: Wed, 22 May 2019 17:31:14 +0300
Subject: [PATCH 1/1] cmake: download tries, customizable download parameters
---
cmake/OpenCVDownload.cmake | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/cmake/OpenCVDownload.cmake b/cmake/OpenCVDownload.cmake
index cdc47ad..a5e3581 100644
--- a/cmake/OpenCVDownload.cmake
+++ b/cmake/OpenCVDownload.cmake
@@ -22,6 +22,8 @@ set(OPENCV_DOWNLOAD_PATH "${OpenCV_SOURCE_DIR}/.cache" CACHE PATH "${HELP_OPENCV
set(OPENCV_DOWNLOAD_LOG "${OpenCV_BINARY_DIR}/CMakeDownloadLog.txt")
set(OPENCV_DOWNLOAD_WITH_CURL "${OpenCV_BINARY_DIR}/download_with_curl.sh")
set(OPENCV_DOWNLOAD_WITH_WGET "${OpenCV_BINARY_DIR}/download_with_wget.sh")
+set(OPENCV_DOWNLOAD_TRIES 1 CACHE STRING "List of download tries") # a list
+set(OPENCV_DOWNLOAD_PARAMS INACTIVITY_TIMEOUT 60 TIMEOUT 600 CACHE STRING "Download parameters to be passed to file(DOWNLAOD ...)")
# Init download cache directory and log file and helper scripts
if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}")
@@ -154,11 +156,17 @@ function(ocv_download)
# Download
if(NOT EXISTS "${CACHE_CANDIDATE}")
ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"")
- file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}"
- INACTIVITY_TIMEOUT 60
- TIMEOUT 600
- STATUS status
- LOG __log)
+ foreach(try ${OPENCV_DOWNLOAD_TRIES})
+ ocv_download_log("#try ${try}")
+ file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}"
+ STATUS status
+ LOG __log
+ ${OPENCV_DOWNLOAD_PARAMS})
+ if(status EQUAL 0)
+ break()
+ endif()
+ message(STATUS "Try ${try} failed")
+ endforeach()
if(NOT OPENCV_SKIP_FILE_DOWNLOAD_DUMP) # workaround problem with old CMake versions: "Invalid escape sequence"
string(LENGTH "${__log}" __log_length)
if(__log_length LESS 65536)
--
2.9.2.windows.1
# Mostly follows <opencv>/samples/cpp/example_cmake/CMakeLists.txt
cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR)
project(cmake_build_test)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV library status:")
message(STATUS " config: ${OpenCV_DIR}")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
add_executable(cmake_build_test test.cpp)
target_link_libraries(cmake_build_test LINK_PRIVATE ${OpenCV_LIBS})
BSD 3-clause license
Copyright (c) 2015-2020, conda-forge contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@echo ON
setlocal enabledelayedexpansion
if "%PY3K%" == "0" (
echo "Copying stdint.h for windows"
copy "%LIBRARY_INC%\stdint.h" %SRC_DIR%\modules\calib3d\include\stdint.h
copy "%LIBRARY_INC%\stdint.h" %SRC_DIR%\modules\videoio\include\stdint.h
copy "%LIBRARY_INC%\stdint.h" %SRC_DIR%\modules\highgui\include\stdint.h
)
mkdir build
cd build
for /F "tokens=1,2 delims=. " %%a in ("%PY_VER%") do (
set "PY_MAJOR=%%a"
set "PY_MINOR=%%b"
)
set PY_LIB=python%PY_MAJOR%%PY_MINOR%.lib
:: CMake/OpenCV like Unix-style paths for some reason.
set UNIX_PREFIX=%PREFIX:\=/%
set UNIX_LIBRARY_PREFIX=%LIBRARY_PREFIX:\=/%
set UNIX_LIBRARY_BIN=%LIBRARY_BIN:\=/%
set UNIX_LIBRARY_INC=%LIBRARY_INC:\=/%
set UNIX_LIBRARY_LIB=%LIBRARY_LIB:\=/%
set UNIX_SP_DIR=%SP_DIR:\=/%
set UNIX_SRC_DIR=%SRC_DIR:\=/%
cmake -LAH -G "Ninja" ^
-DCMAKE_BUILD_TYPE="Release" ^
-DCMAKE_INSTALL_PREFIX=%UNIX_LIBRARY_PREFIX% ^
-DCMAKE_PREFIX_PATH=%UNIX_LIBRARY_PREFIX% ^
-DOPENCV_CONFIG_INSTALL_PATH=cmake ^
-DOPENCV_BIN_INSTALL_PATH=bin ^
-DOPENCV_LIB_INSTALL_PATH=lib ^
-DOPENCV_GENERATE_SETUPVARS=OFF ^
-DOPENCV_DOWNLOAD_TRIES=1;2;3;4;5 ^
-DOPENCV_DOWNLOAD_PARAMS=INACTIVITY_TIMEOUT;30;TIMEOUT;180;SHOW_PROGRESS ^
-DWITH_LAPACK=1 ^
-DLAPACK_INCLUDE_DIR=%UNIX_LIBRARY_INC% ^
-DLAPACK_LAPACKE_H=lapacke.h ^
-DLAPACK_CBLAS_H=cblas.h ^
-DLAPACK_LIBRARIES=%UNIX_LIBRARY_LIB%/lapack.lib;%UNIX_LIBRARY_LIB%/cblas.lib ^
-DWITH_EIGEN=1 ^
-DENABLE_CONFIG_VERIFICATION=ON ^
-DENABLE_PRECOMPILED_HEADERS=OFF ^
-DBUILD_TESTS=0 ^
-DBUILD_DOCS=0 ^
-DBUILD_PERF_TESTS=0 ^
-DBUILD_ZLIB=0 ^
-DBUILD_opencv_bioinspired=0 ^
-DBUILD_TIFF=0 ^
-DBUILD_PNG=0 ^
-DBUILD_OPENEXR=1 ^
-DBUILD_JASPER=0 ^
-DWITH_JASPER=1 ^
-DWITH_OPENJPEG=0 ^
-DBUILD_JPEG=0 ^
-DWITH_CUDA=0 ^
-DWITH_OPENCL=0 ^
-DWITH_OPENCLAMDFFT=0 ^
-DWITH_OPENCLAMDBLAS=0 ^
-DWITH_OPENCL_D3D11_NV=0 ^
-DWITH_1394=0 ^
-DWITH_OPENNI=0 ^
-DWITH_FFMPEG=1 ^
-DWITH_TENGINE=0 ^
-DWITH_GSTREAMER=0 ^
-DWITH_VTK=0 ^
-DWITH_QT=5 ^
-DINSTALL_C_EXAMPLES=0 ^
-DOPENCV_EXTRA_MODULES_PATH=%UNIX_SRC_DIR%/opencv_contrib/modules ^
-DPYTHON_EXECUTABLE="" ^
-DPYTHON_INCLUDE_DIR="" ^
-DPYTHON_PACKAGES_PATH="" ^
-DPYTHON_LIBRARY="" ^
-DPYTHON_NUMPY_INCLUDE_DIRS="" ^
-DBUILD_opencv_python2=0 ^
-DPYTHON2_EXECUTABLE="" ^
-DPYTHON2_INCLUDE_DIR="" ^
-DPYTHON2_NUMPY_INCLUDE_DIRS="" ^
-DPYTHON2_LIBRARY="" ^
-DPYTHON2_PACKAGES_PATH="" ^
-DOPENCV_PYTHON2_INSTALL_PATH="" ^
-DBUILD_opencv_python3=0 ^
-DPYTHON_EXECUTABLE=%UNIX_PREFIX%/python ^
-DPYTHON_INCLUDE_DIR=%UNIX_PREFIX%/include ^
-DPYTHON_PACKAGES_PATH=%UNIX_SP_DIR% ^
-DPYTHON_LIBRARY=%UNIX_PREFIX%/libs/%PY_LIB% ^
-DPYTHON_NUMPY_INCLUDE_DIRS=%UNIX_SP_DIR%/numpy/core/include ^
-DBUILD_opencv_python3=1 ^
-DOPENCV_SKIP_PYTHON_LOADER=1 ^
-DPYTHON3_EXECUTABLE=%UNIX_PREFIX%/python ^
-DPYTHON3_INCLUDE_DIR=%UNIX_PREFIX%/include ^
-DPYTHON3_NUMPY_INCLUDE_DIRS=%UNIX_SP_DIR%/numpy/core/include ^
-DPYTHON3_LIBRARY=%UNIX_PREFIX%/libs/%PY_LIB% ^
-DPYTHON3_PACKAGES_PATH=%UNIX_SP_DIR% ^
-DOPENCV_PYTHON3_INSTALL_PATH=%UNIX_SP_DIR% ^
..
if errorlevel 1 exit 1
cmake --build . --target install --config Release
if errorlevel 1 exit 1
exit 0
#!/usr/bin/env bash
set +x
SHORT_OS_STR=$(uname -s)
MACHINE_STR=$(uname -m)
# CMake FindPNG seems to look in libpng not libpng16
# https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/FindPNG.cmake#L55
ln -s $PREFIX/include/libpng16 $PREFIX/include/libpng
QT="5"
V4L="1"
if [ "${SHORT_OS_STR:0:5}" == "Linux" ]; then
OPENMP="-DWITH_OPENMP=1"
# Looks like there's a bug in Opencv 3.2.0 for building with FFMPEG
# with GCC opencv/issues/8097
export CXXFLAGS="$CXXFLAGS -D__STDC_CONSTANT_MACROS"
export CPPFLAGS="${CPPFLAGS//-std=c++17/-std=c++11}"
export CXXFLAGS="${CXXFLAGS//-std=c++17/-std=c++11}"
export LDFLAGS="${LDFLAGS} -Wl,-rpath-link,${PREFIX}/lib"
fi
if [ "${SHORT_OS_STR}" == "Darwin" ]; then
OPENMP=""
QT="0"
V4L="0"
# The old OSX compilers don't know what to do with AVX instructions
# Therefore, we specify what CPU dispatch operations we want explicitely
# for OSX..
# I took this line from the default build flags that get spewed after
# a successful call to cmake without the parameter specified
# The default flag as of OpenCV 3.4.4 are:
# CPU_DISPATCH:STRING=SSE4_1;SSE4_2;AVX;FP16;AVX2;AVX512_SKX
CPU_DISPATCH_FLAGS="-DCPU_DISPATCH=SSE4_1;SSE4_2;AVX;FP16"
# remove -dead_strip_dylibs from LDFLAGS if it exists
export LDFLAGS=${LDFLAGS//"-dead_strip_dylibs"/}
fi
if [ "${MACHINE_STR}" == "aarch64" ] || [ "${MACHINE_STR:0:3}" == "arm" ] || [ "${MACHINE_STR:0:3}" == "ppc" ]; then
QT="0"
fi
CMAKE_TOOLCHAIN_CMD_FLAGS=""
if [ "$c_compiler" = clang ]; then
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_AR=${AR}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_LINKER=${LD}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_NM=${NM}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_RANLIB=${RANLIB}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_STRIP=${STRIP}"
elif [ "$c_compiler" = gcc ]; then
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_AR=${AR}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_LINKER=${LD}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_NM=${NM}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_OBJCOPY=${OBJCOPY}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_OBJDUMP=${OBJDUMP}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_RANLIB=${RANLIB}"
CMAKE_TOOLCHAIN_CMD_FLAGS="${CMAKE_TOOLCHAIN_CMD_FLAGS} -DCMAKE_STRIP=${STRIP}"
fi
mkdir -p build
cd build
if [ $PY3K -eq 1 ]; then
PY_MAJOR=3
PY_UNSET_MAJOR=2
# Python 3.8 now combines the "m" and the "no m" builds in 1.
if [ ${PY_VER} == "3.6" ] || [ ${PY_VER} == "3.7" ]; then
LIB_PYTHON="${PREFIX}/lib/libpython${PY_VER}${SHLIB_EXT}m"
INC_PYTHON="$PREFIX/include/python${PY_VER}m"
else
LIB_PYTHON="${PREFIX}/lib/libpython${PY_VER}${SHLIB_EXT}"
INC_PYTHON="$PREFIX/include/python${PY_VER}"
fi
else
PY_MAJOR=2
PY_UNSET_MAJOR=3
LIB_PYTHON="${PREFIX}/lib/libpython${PY_VER}${SHLIB_EXT}"
INC_PYTHON="$PREFIX/include/python${PY_VER}"
fi
PYTHON_SET_FLAG="-DBUILD_opencv_python${PY_MAJOR}=1"
PYTHON_SET_EXE="-DPYTHON${PY_MAJOR}_EXECUTABLE=${PYTHON}"
PYTHON_SET_INC="-DPYTHON${PY_MAJOR}_INCLUDE_DIR=${INC_PYTHON} "
PYTHON_SET_NUMPY="-DPYTHON${PY_MAJOR}_NUMPY_INCLUDE_DIRS=${SP_DIR}/numpy/core/include"
PYTHON_SET_LIB="-DPYTHON${PY_MAJOR}_LIBRARY=${LIB_PYTHON}"
PYTHON_SET_SP="-DPYTHON${PY_MAJOR}_PACKAGES_PATH=${SP_DIR}"
PYTHON_SET_INSTALL="-DOPENCV_PYTHON${PY_MAJOR}_INSTALL_PATH=${SP_DIR}"
PYTHON_UNSET_FLAG="-DBUILD_opencv_python${PY_UNSET_MAJOR}=0"
PYTHON_UNSET_EXE="-DPYTHON${PY_UNSET_MAJOR}_EXECUTABLE="
PYTHON_UNSET_INC="-DPYTHON${PY_UNSET_MAJOR}_INCLUDE_DIR="
PYTHON_UNSET_NUMPY="-DPYTHON${PY_UNSET_MAJOR}_NUMPY_INCLUDE_DIRS="
PYTHON_UNSET_LIB="-DPYTHON${PY_UNSET_MAJOR}_LIBRARY="
PYTHON_UNSET_SP="-DPYTHON${PY_UNSET_MAJOR}_PACKAGES_PATH="
PYTHON_UNSET_INSTALL="-DOPENCV_PYTHON${PY_UNSET_MAJOR}_INSTALL_PATH=${SP_DIR}"
# FFMPEG building requires pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PREFIX/lib/pkgconfig
cmake -LAH -G "Ninja" \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_PREFIX_PATH=${PREFIX} \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_INSTALL_LIBDIR="lib" \
-DOPENCV_DOWNLOAD_TRIES=1\;2\;3\;4\;5 \
-DOPENCV_DOWNLOAD_PARAMS=INACTIVITY_TIMEOUT\;30\;TIMEOUT\;180\;SHOW_PROGRESS \
$CMAKE_TOOLCHAIN_CMD_FLAGS \
-DOPENCV_GENERATE_PKGCONFIG=ON \
-DENABLE_CONFIG_VERIFICATION=ON \
-DENABLE_PRECOMPILED_HEADERS=OFF \
$CPU_DISPATCH_FLAGS \
$OPENMP \
-DWITH_MKL=ON \
-DWITH_EIGEN=1 \
-DBUILD_TESTS=0 \
-DBUILD_DOCS=0 \
-DBUILD_PERF_TESTS=0 \
-DBUILD_ZLIB=0 \
-DBUILD_TIFF=0 \
-DBUILD_PNG=0 \
-DBUILD_OPENEXR=1 \
-DBUILD_JASPER=0 \
-DWITH_JASPER=1 \
-DWITH_OPENJPEG=0 \
-DBUILD_JPEG=0 \
-DWITH_V4L=$V4L \
-DWITH_CUDA=0 \
-DWITH_CUBLAS=0 \
-DWITH_OPENCL=0 \
-DWITH_OPENCLAMDFFT=0 \
-DWITH_OPENCLAMDBLAS=0 \
-DWITH_OPENCL_D3D11_NV=0 \
-DWITH_1394=0 \
-DWITH_OPENNI=0 \
-DWITH_FFMPEG=1 \
-DWITH_TENGINE=0 \
-DWITH_GSTREAMER=0 \
-DWITH_MATLAB=0 \
-DWITH_VTK=0 \
-DWITH_GTK=0 \
-DWITH_QT=$QT \
-DWITH_GPHOTO2=0 \
-DINSTALL_C_EXAMPLES=0 \
-DOPENCV_EXTRA_MODULES_PATH="../opencv_contrib/modules" \
-DCMAKE_SKIP_RPATH:bool=ON \
-DPYTHON_PACKAGES_PATH=${SP_DIR} \
-DPYTHON_EXECUTABLE=${PYTHON} \
-DPYTHON_INCLUDE_DIR=${INC_PYTHON} \
-DPYTHON_LIBRARY=${LIB_PYTHON} \
-DOPENCV_SKIP_PYTHON_LOADER=1 \
-DZLIB_INCLUDE_DIR=${PREFIX}/include \
-DZLIB_LIBRARY_RELEASE=${PREFIX}/lib/libz${SHLIB_EXT} \
-DJPEG_INCLUDE_DIR=${PREFIX}/include \
-DTIFF_INCLUDE_DIR=${PREFIX}/include \
-DPNG_PNG_INCLUDE_DIR=${PREFIX}/include \
-DPROTOBUF_INCLUDE_DIR=${PREFIX}/include \
-DPROTOBUF_LIBRARIES=${PREFIX}/lib \
$PYTHON_SET_FLAG \
$PYTHON_SET_EXE \
$PYTHON_SET_INC \
$PYTHON_SET_NUMPY \
$PYTHON_SET_LIB \
$PYTHON_SET_SP \
$PYTHON_SET_INSTALL \
$PYTHON_UNSET_FLAG \
$PYTHON_UNSET_EXE \
$PYTHON_UNSET_INC \
$PYTHON_UNSET_NUMPY \
$PYTHON_UNSET_LIB \
$PYTHON_UNSET_SP \
$PYTHON_UNSET_INSTALL \
..
if [ "${MACHINE_STR:0:3}" == "ppc" ]; then
# PPC seems to run out of memory quite often, build with fewer jobs.
NINJA_OPTS=-j2
fi
ninja install -v ${NINJA_OPTS}
# This recipe creates 3 packages
# libopencv, py-opencv, opencv
#
# libopencv actually contains all the files, including the site-packages
# file needed to run opencv with python.
# opencv-dnn seems to change on every patch version, therefore, we pin
# to the patch version x.x.x
#
# py-opencv is a meta package that constrains the python dependencies
# This one is pinned to the minor version. x.x
#
# opencv is a backward compatible package, with no pinnings
#
# This approach is different than the one in defaults. Default's package
# seperates well the files generated with python dependencies, from those
# generated without. Unfortunately, this isn't entirely supported by
# upstream. Their hacks are quite elaborate, making it seem difficult to
# maintain as opencv has been changing their build system recently.
#
# By putting all the generated files in 1 package, this makes the build process
# much easier, at the expense of a few MBs in the 'lib' package.
{% set version = "4.5.0" %}
{% set PY_VER_MAJOR = PY_VER[0] %}
{% set PY_VER_MINOR = PY_VER[2] %}
package:
name: libopencv
version: {{ version }}
source:
- url: https://codeload.github.com/opencv/opencv/tar.gz/{{ version }}
fn: opencv-{{ version }}.tar.gz
sha256: dde4bf8d6639a5d3fe34d5515eab4a15669ded609a1d622350c7ff20dace1907
- url: https://codeload.github.com/opencv/opencv_contrib/tar.gz/{{ version }}
fn: opencv_contrib-{{ version }}.tar.gz
sha256: a65f1f0b98b2c720abbf122c502044d11f427a43212d85d8d2402d7a6339edda
folder: opencv_contrib
# FFMPEG builds only supported on unix platforms
- fn: test.avi # [unix]
url: https://github.com/opencv/opencv_extra/raw/master/testdata/highgui/video/VID00003-20100701-2204.avi # [unix]
sha256: 78884f64b564a3b06dc6ee731ed33b60c6d8cd864cea07f21d94ba0f90c7b310 # [unix]
build:
number: 0
string: py{{ PY_VER_MAJOR }}{{ PY_VER_MINOR }}_{{ PKG_BUILDNUM }}
run_exports:
# https://abi-laboratory.pro/index.php?view=timeline&l=opencv
# Things seem to change every patch versions, mostly the dnn module
- {{ pin_subpackage('libopencv', max_pin='x.x.x') }}
requirements:
build:
# Required to find ffpmeg
- pkg-config # [not win]
- m2-patch # [win]
- cmake
- ninja
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ cdt('mesa-libgl-devel') }} # [linux]
- {{ cdt('mesa-libegl-devel') }} # [linux]
- {{ cdt('mesa-dri-drivers') }} # [linux]
- {{ cdt('libselinux') }} # [linux]
- {{ cdt('libxdamage') }} # [linux]
- {{ cdt('libxfixes') }} # [linux]
- {{ cdt('libxxf86vm') }} # [linux]
- {{ cdt('libxau-devel') }} # [linux]
- {{ cdt('libxext-devel') }} # [linux]
host:
- python {{ python }}
- numpy {{ numpy }}
- mkl-devel {{ mkl }} # [blas_impl == 'mkl']
- openblas-devel {{ openblas }} # [blas_impl == 'openblas']
- nomkl # [blas_impl == 'openblas']
- hdf5 {{ hdf5 }} # [unix]
- eigen 3.3.*
- jasper
- zlib {{ zlib }}
- jpeg {{ jpeg }}
- libtiff {{ libtiff }}
- libwebp {{ libwebp }}
- harfbuzz {{ harfbuzz }} # [unix]
- libpng {{ libpng }}
- ffmpeg {{ ffmpeg }} # [not win]
- qt 5.9.* # [not osx and not aarch64 and not ppc64le]
- freetype {{ freetype }}
- glib {{ glib }} # [unix]
run:
- {{ pin_compatible('harfbuzz') }} # [unix]
# Don't depend on python in the run section
# py-opencv will depend on python
- qt 5.9.* # [not osx and not aarch64 and not ppc64le]
# https://github.com/conda-forge/opencv-feedstock/issues/174
# Seems like the OSX ABI has changed between 2.9 and 2.10???
# That or a dependency wasn't merged in
# Since we don't know the cause, we are choosing this pinning on all platforms.
- {{ pin_compatible('freetype', min_pin='x.x') }}
test:
requires:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- pkg-config # [not win]
- mkl-devel {{ mkl }} # [blas_impl == 'mkl']
- openblas-devel {{ openblas }} # [blas_impl == 'openblas']
- nomkl # [blas_impl == 'openblas']
- cmake
- ninja
- qt 5.9.* # [linux64]
files:
- CMakeLists.txt
- test.cpp
commands:
# Verify dynamic libraries on all systems
{% set win_ver_lib = version|replace(".", "") %}
{% set opencv_libs = [
"aruco",
"bgsegm",
"calib3d",
"ccalib",
"core",
"datasets",
"dnn",
"dpm",
"face",
"features2d",
"flann",
"fuzzy",
"highgui",
"imgcodecs",
"imgproc",
"line_descriptor",
"ml",
"objdetect",
"optflow",
"phase_unwrapping",
"photo",
"plot",
"reg",
"rgbd",
"saliency",
"shape",
"stereo",
"stitching",
"structured_light",
"superres",
"surface_matching",
"text",
"tracking",
"video",
"videoio",
"videostab",
"xfeatures2d",
"ximgproc",
"xobjdetect",
"xphoto"
] %}
- export MACOSX_DEPLOYMENT_TARGET={{ MACOSX_DEPLOYMENT_TARGET }} # [osx]
- export CONDA_BUILD_SYSROOT={{ CONDA_BUILD_SYSROOT }} # [osx]
- OPENCV_FLAGS=`pkg-config --cflags opencv4` # [unix]
- $CXX -std=c++11 $RECIPE_DIR/test.cpp ${OPENCV_FLAGS} -o test # [unix]
- if [[ $(./test) != $PKG_VERSION ]]; then exit 1 ; fi # [unix]
{% for each_opencv_lib in opencv_libs %}
- test -f $PREFIX/lib/libopencv_{{ each_opencv_lib }}${SHLIB_EXT} # [unix]
- if not exist %PREFIX%\\Library\\bin\\opencv_{{ each_opencv_lib }}{{ win_ver_lib }}.dll exit 1 # [win]
{% endfor %}
- test -f $PREFIX/lib/libopencv_bioinspired${SHLIB_EXT} # [unix]
- test -f $PREFIX/lib/libopencv_hdf${SHLIB_EXT} # [unix]
- test -f $PREFIX/lib/libopencv_freetype${SHLIB_EXT} # [unix]
- mkdir -p cmake_build_test && pushd cmake_build_test
- cmake -G "Ninja" ..
- cmake --build . --config Release
- popd
outputs:
- name: libopencv
- name: opencv
requirements:
run:
- {{ pin_subpackage('libopencv', exact=True) }}
- {{ pin_subpackage('py-opencv', exact=True) }}
- name: py-opencv
build:
run_exports:
# Should we even have this???
# don't pin the python version so hard.
# Actually, I have found pretty good compatibility in the python
# package
- {{ pin_subpackage('py-opencv') }}
requirements:
# There is no build script, but I just want it to think
# that it needs python and numpy at build time
host:
- python
- numpy
run:
- python
- {{ pin_compatible('numpy') }}
- {{ pin_subpackage('libopencv', exact=True) }}
test:
requires:
# Test with the two currently supported lapack implementatons
# One test done on different versions of python on each platform
- mkl-devel {{ mkl }} # [blas_impl == 'mkl']
- openblas-devel {{ openblas }} # [blas_impl == 'openblas']
- nomkl # [blas_impl == 'openblas']
imports:
- cv2
- cv2.xfeatures2d
files:
- run_py_test.py
- color_palette_alpha.png
- test_1_c1.jpg
source_files: # [unix]
- test.avi # [unix]
commands:
- python run_py_test.py
- if [[ $($PYTHON -c 'import cv2; print(cv2.__version__)') != $PKG_VERSION ]]; then exit 1; fi # [unix]
- python -c "import cv2; assert 'Unknown' not in cv2.videoio_registry.getBackendName(cv2.CAP_V4L)" # [linux]
- python -c "import cv2, re; assert re.search('Lapack:\s+YES', cv2.getBuildInformation())"
about:
home: http://opencv.org/
license: BSD-3-Clause
license_family: BSD
license_file: LICENSE
summary: Computer vision and machine learning software library.
extra:
recipe-maintainers:
- jakirkham
- msarahan
- patricksnape
- zym1010
- hajapy
- ocefpaf
- hmaarrfk
import unittest
import platform
import numpy as np
import cv2
@unittest.skipIf(platform.system() == 'Windows',
'FFMPEG currently not built on Windows')
class TestVideoRead(unittest.TestCase):
def test_load_avi(self):
cap = cv2.VideoCapture('test.avi')
res, frame = cap.read()
self.assertTrue(res, "Can not read video frame from file")
class TestImageRead(unittest.TestCase):
def test_load_image_png(self):
im = cv2.imread('color_palette_alpha.png')
self.assertIsNotNone(im, "Cannot read png image from file")
def test_load_image_jpg(self):
im = cv2.imread('test_1_c1.jpg')
self.assertIsNotNone(im, "Cannot read jpg image from file")
class TestGEMM(unittest.TestCase):
def test_gemm_big(self):
sz = (500, 500)
a = np.ones(sz, dtype=float)
b = np.eye(sz[0])
c = np.ones(sz, dtype=float)
x = cv2.gemm(a, b, 2, c, 3)
gold = np.full(sz, 5, dtype=float)
self.assertTrue(np.array_equal(gold, x), "Array returned by GEMM is not valid")
if __name__ == '__main__':
unittest.main()
#include <opencv2/opencv.hpp>
#include <iostream>
int main()
{
std::cout << CV_VERSION << std::endl;
return 0;
}
......@@ -67,9 +67,31 @@ zip_keys:
- nodejs # [win]
- geos # [win]
# The dependencies that we link against (host requirements).
ffmpeg:
- 4.2
freetype:
- 2.10
glib:
- 2
harfbuzz:
- 2.4
hdf5:
- 1.10.6
jpeg:
- 9
libpng:
- 1.6.35
- 1.6
libtiff:
- 4.1
libwebp:
- 1.0.0