meta.yaml 7.99 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
# 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:
27
  name: libopencv
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
  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:
Vincent POLLET's avatar
Vincent POLLET committed
44
  number: 1
45 46 47 48
  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
49
    - {{ pin_subpackage('libopencv', max_pin='x.x.x') }}
50 51 52 53 54 55 56 57 58 59 60

requirements:
  build:
    # Required to find ffpmeg
    - pkg-config                     # [not win]
    - m2-patch                       # [win]
    - cmake
    - ninja
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - {{ cdt('mesa-libgl-devel') }}  # [linux]
61
    - {{ cdt('mesa-libegl-devel') }} # [linux]
62 63 64 65
    - {{ cdt('mesa-dri-drivers') }}  # [linux]
    - {{ cdt('libselinux') }}        # [linux]
    - {{ cdt('libxdamage') }}        # [linux]
    - {{ cdt('libxfixes') }}         # [linux]
66
    - {{ cdt('libxxf86vm') }}        # [linux]
67 68
    - {{ cdt('libxau-devel') }}      # [linux]
    - {{ cdt('libxext-devel') }}     # [linux]
Vincent POLLET's avatar
Vincent POLLET committed
69

70
  host:
71 72 73
    - python {{ python }}
    - numpy {{ numpy }}
    - mkl-devel {{ mkl }}            # [blas_impl == 'mkl']
74
    - openblas-devel {{ openblas }}  # [blas_impl == 'openblas']
75 76
    - nomkl                          # [blas_impl == 'openblas']
    - hdf5 {{ hdf5 }}                # [unix]
77
    - eigen 3.3.*
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
78
    - jasper {{ jasper }}
79 80 81 82 83 84
    - zlib {{ zlib }}
    - jpeg {{ jpeg }}
    - libtiff {{ libtiff }}
    - harfbuzz {{ harfbuzz }}        # [unix]
    - libpng {{ libpng }}
    - ffmpeg {{ ffmpeg }}            # [not win]
Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
85
    - qt 5.9.*                       # [not osx and not aarch64 and not ppc64le]
86 87
    - freetype {{ freetype }}
    - glib {{ glib }}                # [unix]
88 89 90
  run:
    # Don't depend on python in the run section
    # py-opencv will depend on python
91

Amir MOHAMMADI's avatar
Amir MOHAMMADI committed
92 93
    - {{ pin_compatible('harfbuzz') }} # [unix]

94 95

test:
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
    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
170 171 172 173 174 175

outputs:
  - name: libopencv
  - name: opencv
    requirements:
      run:
176 177
        - {{ pin_subpackage('libopencv', exact=True) }}
        - {{ pin_subpackage('py-opencv', exact=True) }}
178 179 180 181

  - name: py-opencv
    build:
      run_exports:
182 183 184 185 186
        # 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') }}
187 188 189 190
    requirements:
      # There is no build script, but I just want it to think
      # that it needs python and numpy at build time
      host:
191 192
        - python
        - numpy
193 194 195 196 197 198 199 200
      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
201
        - mkl-devel {{ mkl }}  # [blas_impl == 'mkl']
202
        - openblas-devel {{ openblas }}  # [blas_impl == 'openblas']
203
        - nomkl  # [blas_impl == 'openblas']
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
      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