{% set version = "4.5.4" %}
{% set build_num = "2" %}
package:
  name: opencv-suite
  version: {{ version }}

source:
  {% if USE_GIT|default(False) %}
  - git_url: https://github.com/opencv/opencv
    git_tag: {{ version }}
    git_depth: 10
{% else %}
  - url: https://github.com/opencv/opencv/archive/{{ version }}.zip
    fn: opencv-{{ version }}.zip
    sha256: 5deac7f7341faf4b23c38d65f8f89dbf5b4b30d345390a60853640967a2bf61b
{% endif %}
  - url: https://github.com/opencv/opencv_contrib/archive/{{ version }}.tar.gz
    fn: opencv_contrib-{{ version }}.tar.gz
    sha256: ad74b440b4539619dc9b587995a16b691246023d45e34097c73e259f72de9f81
    folder: opencv_contrib-{{ version }}

build:
  number: {{ build_num }}
  # Python 2.7 is not supported on Windows
  # Package not supported on s390x
  skip: True  # [win32 or (win and py27) or s390x or (aarch64 and py>39)]
  ignore_run_exports:
    - openblas-devel # [x86_64 and not win]
    - _openmp_mutex # [linux64 or aarch64]
    - python

requirements:

  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - msinttypes            # [win and py<35]
    - ninja
    - pkg-config
    - {{ cdt('mesa-libGL-devel') }}         # [aarch64]
    - {{ cdt('mesa-libEGL-devel') }}        # [aarch64]
  host:
    - cmake
    - eigen
    - ffmpeg                # [linux64]
    - freetype              # [not win]
    - glib                  # [not ppc64le]
    - gst-plugins-base      # [not (win or ppc64le)]
    - gstreamer             # [not (win or ppc64le)]
    - gst-plugins-base ==1.18.5      # [win]
    - gstreamer ==1.18.5             # [win]
    - harfbuzz              # [not win]
    - hdf5
    - jpeg                  # [not win]
    - openjpeg              # [not (win or arm64)]
    - openblas-devel        # [x86_64 and not win]
    - libpng
    - libprotobuf  ==3.5.1  # [linux64 or win]
    - libtiff
    - libwebp-base          # [win or linux64]
    - numpy {{ numpy }}
    - python
    - qt ==5.9.7            # [(x86_64 or win) and not ppc64le]
    - qt ==5.15.2           # [arm64 or aarch64]
    - zlib
  run:
    - _openmp_mutex         # [linux64 or aarch64]
    - eigen
    - ffmpeg                # [linux64]
    - freetype              # [not win]
    - glib                  # [not ppc64le]
    - gst-plugins-base      # [not (win or ppc64le)]
    - gstreamer             # [not (win or ppc64le)]
    - gst-plugins-base ==1.18.5      # [win]
    - gstreamer ==1.18.5             # [win]
    - harfbuzz              # [not win]
    - hdf5
    - jpeg                  # [not win]
    - openjpeg              # [not (win or arm64)]
    - libopenblas           # [x86_64 and not win]
    - libpng
    - libprotobuf ==3.5.1   # [linux64 or win]
    - libtiff
    - libwebp-base          # [win or linux64]
    - numpy {{ numpy }}
    - python
    - qt ==5.9.7            # [(x86_64 or win) and not ppc64le]
    - qt ==5.15.2           # [arm64 or aarch64]
    - zlib


outputs:
  - name: opencv
    script: install.sh                           # [not win]
    script: install.bat                          # [win]
    build:
      ignore_run_exports:
        - openblas-devel # [x86_64 and not win]

    requirements:

      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - ninja
        - pkg-config
        - {{ cdt('mesa-libGL-devel') }}         # [aarch64]
        - {{ cdt('mesa-libEGL-devel') }}        # [aarch64]
      host:
        - cmake
        - _openmp_mutex         # [linux64 or aarch64]
        - eigen
        - ffmpeg                # [linux64]
        - freetype              # [not win]
        - glib                  # [not ppc64le]
        - gst-plugins-base      # [not (win or ppc64le)]
        - gstreamer             # [not (win or ppc64le)]
        - gst-plugins-base ==1.18.5      # [win]
        - gstreamer ==1.18.5             # [win]
        - harfbuzz              # [not win]
        - hdf5
        - jpeg                  # [not win]
        - openjpeg              # [not (arm64 or win)]
        - openblas-devel        # [x86_64 and not win]
        - libpng
        - libprotobuf  ==3.5.1  # [linux64 or win]
        - libtiff
        - libwebp-base          # [win or linux64]
        - numpy {{ numpy }}
        - python
        - qt ==5.9.7            # [(x86_64 or win) and not ppc64le]
        - qt ==5.15.2           # [arm64 or aarch64]
        - zlib
      run:
        - _openmp_mutex         # [linux64 or aarch64]
        - eigen
        - ffmpeg                # [linux64]
        - freetype              # [not win]
        - glib                  # [not ppc64le]
        - gst-plugins-base      # [not (win or ppc64le)]
        - gstreamer             # [not (win or ppc64le)]
        - gst-plugins-base ==1.18.5      # [win]
        - gstreamer ==1.18.5             # [win]
        - harfbuzz              # [not win]
        - hdf5
        - jpeg                  # [not win]
        - openjpeg              # [not (arm64 or win)]
        - libopenblas           # [x86_64 and not win]
        - libpng
        - libprotobuf ==3.5.1   # [linux64 or win]
        - libtiff
        - libwebp-base          # [win or linux64]
        - numpy {{ numpy }}
        - python
        - qt ==5.9.7            # [(x86_64 or win) and not ppc64le]
        - qt ==5.15.2           # [arm64 or aarch64]
        - zlib
    test:
      requires:
        - {{ compiler('cxx') }}
        - cmake
        - python
        - numpy
        - ninja
        - {{ cdt('libselinux-devel') }}      # [linux]
        - {{ cdt('libx11-devel') }}          # [linux]
        - {{ cdt('libxau-devel') }}          # [linux]
        - {{ cdt('libxcb') }}                # [linux]
        - {{ cdt('libxdamage-devel') }}      # [linux]
        - {{ cdt('libxext-devel') }}         # [linux]
        - {{ cdt('libxfixes-devel') }}       # [linux]
        - {{ cdt('libxi-devel') }}           # [linux]
        - {{ cdt('libxrender-devel') }}      # [linux]
        - {{ cdt('libxxf86vm') }}            # [linux]
        - {{ cdt('mesa-dri-drivers') }}      # [linux]
        - {{ cdt('mesa-libgl-devel') }}      # [linux]
        - {{ cdt('xorg-x11-proto-devel') }}  # [linux]
      files:
        - test-cmake/CMakeLists.txt
        - test-cmake/DisplayImage.cpp
        - test.cpp
      commands:
        - pushd test-cmake
        - cmake . -GNinja -DCMAKE_BUILD_TYPE=Release
        - cmake --build . --verbose
        - popd
        # Verify dynamic libraries.
        # "bioinspired", Not working in 3.1.0
        {% set opencv_libs = [
             "aruco",
             "bgsegm",
             "calib3d",
             "ccalib",
             "core",
             "datasets",
             "dpm",                               # [linux64]
             "face",                              # [linux64]
             "features2d",
             "flann",
             "fuzzy",
             "highgui",
             "imgcodecs",
             "imgproc",
             "line_descriptor",
             "ml",
             "objdetect",                        # [linux64]
             "optflow",
             "phase_unwrapping",
             "photo",
             "plot",
             "reg",
             "rgbd",
             "saliency",
             "shape",
             "stereo",
             "stitching",
             "structured_light",
             "superres",
             "surface_matching",
             "text",                             # [linux64]
             "tracking",
             "video",
             "videoio",
             "videostab",
             "xfeatures2d",
             "ximgproc",
             "xobjdetect",                       # [linux64]
             "xphoto",
        ] %}
        {% for each_opencv_lib in opencv_libs %}
        - test -f ${CONDA_PREFIX}/lib/libopencv_{{ each_opencv_lib }}.dylib                        # [osx]
        - test -f ${CONDA_PREFIX}/lib/libopencv_{{ each_opencv_lib }}.so                           # [linux]
        - if not exist %CONDA_PREFIX%\\Library\\bin\\opencv_{{ each_opencv_lib }}{{ version|replace(".","") }}.dll exit 1 # [win]
        {% endfor %}

  # This recipe has merged the outputs for the compiled libraries with the
  # python bindings that used to be vendored as libopencv and py-opencv. This
  # was done to try to improve maintainibility. The following two output
  # sections provide no files other than those already in the opencv package.
  # These "virtual" packages provide backwards compatibility with recipes
  # depending on either of the two old packages.
  - name: libopencv
    script: install-nothing.sh                  # [not win]
    script: install-nothing.bat                 # [win]
    version: {{ version }}
    build:
      number: {{ build_num }}
      skip: True  # [(win and py27) or s390x or (aarch64 and py>39)]
    requirements:
      host:
        - {{ pin_subpackage('opencv', max_pin='x.x.x') }}
      run:
        - {{ pin_subpackage('opencv', max_pin='x.x.x') }}



  - name: py-opencv
    script: install-nothing.sh                  # [not win]
    script: install-nothing.bat                 # [win]
    version: {{ version }}
    build:
      number: {{ build_num }}
      skip: True  # [(win and py27) or s390x or (aarch64 and py>39)]
    requirements:
      host:
        - {{ pin_subpackage('opencv', max_pin='x') }}
      run:
        - {{ pin_subpackage('opencv', max_pin='x') }}


about:
  home: https://opencv.org/
  license: Apache-2.0
  license_family: Apache
  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: https://docs.opencv.org/
  doc_source_url: https://github.com/opencv/opencv/tree/master/doc
  dev_url: https://github.com/opencv/opencv/


