Merge pull request #119193 from tfmoraes/opencv-4.5.2

opencv-4: 4.3.0 -> 4.5.2
This commit is contained in:
Sandro 2021-04-22 03:18:49 +02:00 committed by GitHub
commit 1d0542c07b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 135 additions and 107 deletions

View file

@ -1,54 +1,91 @@
{ lib, stdenv
, fetchurl, fetchFromGitHub, fetchpatch
, cmake, pkg-config, unzip, zlib, pcre, hdf5
, glog, boost, gflags, protobuf
{ lib
, stdenv
, fetchurl
, fetchFromGitHub
, cmake
, pkg-config
, unzip
, zlib
, pcre
, hdf5
, boost
, gflags
, protobuf
, config
, enableJPEG ? true, libjpeg
, enablePNG ? true, libpng
, enableTIFF ? true, libtiff
, enableWebP ? true, libwebp
, enableEXR ? !stdenv.isDarwin, openexr, ilmbase
, enableEigen ? true, eigen
, enableOpenblas ? true, openblas, blas, lapack
, enableJPEG ? true
, libjpeg
, enablePNG ? true
, libpng
, enableTIFF ? true
, libtiff
, enableWebP ? true
, libwebp
, enableEXR ? !stdenv.isDarwin
, openexr
, ilmbase
, enableEigen ? true
, eigen
, enableOpenblas ? true
, openblas
, enableContrib ? true
, enableCuda ? (config.cudaSupport or false) &&
stdenv.hostPlatform.isx86_64, cudatoolkit, nvidia-optical-flow-sdk
, enableCuda ? (config.cudaSupport or false) && stdenv.hostPlatform.isx86_64
, cudatoolkit
, nvidia-optical-flow-sdk
, enableUnfree ? false
, enableIpp ? false
, enablePython ? false, pythonPackages
, enableGtk2 ? false, gtk2
, enableGtk3 ? false, gtk3
, enableVtk ? false, vtk
, enableFfmpeg ? false, ffmpeg_3
, enableGStreamer ? false, gst_all_1
, enableTesseract ? false, tesseract, leptonica
, enableTbb ? false, tbb
, enableOvis ? false, ogre
, enableGPhoto2 ? false, libgphoto2
, enableDC1394 ? false, libdc1394
, enableDocs ? false, doxygen, graphviz-nox
, enablePython ? false
, pythonPackages
, enableGtk2 ? false
, gtk2
, enableGtk3 ? false
, gtk3
, enableVtk ? false
, vtk
, enableFfmpeg ? true
, ffmpeg_3
, enableGStreamer ? true
, gst_all_1
, enableTesseract ? false
, tesseract
, leptonica
, enableTbb ? false
, tbb
, enableOvis ? false
, ogre
, enableGPhoto2 ? false
, libgphoto2
, enableDC1394 ? false
, libdc1394
, enableDocs ? false
, doxygen
, graphviz-nox
, AVFoundation, Cocoa, VideoDecodeAcceleration, CoreMedia, MediaToolbox, bzip2
, AVFoundation
, Cocoa
, VideoDecodeAcceleration
, CoreMedia
, MediaToolbox
, bzip2
}:
let
version = "4.3.0";
version = "4.5.2";
src = fetchFromGitHub {
owner = "opencv";
repo = "opencv";
rev = version;
sha256 = "1r9bq9p1x99g2y8jvj9428sgqvljz75dm5vrfsma7hh5wjhz9775";
sha256 = "sha256-pxi1VBF4txvRqspdqvCsAQ3XKzl633/o3wyOgD9wid4=";
};
contribSrc = fetchFromGitHub {
owner = "opencv";
repo = "opencv_contrib";
rev = version;
sha256 = "068b4f95rlryab3mffxs2w6dnbmbhrnpsdgl007rxk4bwnz29y49";
sha256 = "sha256-iMenRTY+qeL7WRgnRuQbsHflYDakE7pWWSHeIjrg0Iw=";
};
# Contrib must be built in order to enable Tesseract support:
@ -62,7 +99,7 @@ let
rev = "a56b6ac6f030c312b2dce17430eef13aed9af274";
sha256 = "1msbkc3zixx61rcg6a04i1bcfhw1phgsrh93glq1n80hgsk3nbjq";
} + "/ippicv";
files = let name = platform : "ippicv_2019_${platform}_general_20180723.tgz"; in
files = let name = platform: "ippicv_2019_${platform}_general_20180723.tgz"; in
if stdenv.hostPlatform.system == "x86_64-linux" then
{ ${name "lnx_intel64"} = "c0bd78adb4156bbf552c1dfe90599607"; }
else if stdenv.hostPlatform.system == "i686-linux" then
@ -136,10 +173,27 @@ let
dst = ".cache/ade";
};
# See opencv/modules/wechat_qrcode/CMakeLists.txt
wechat_qrcode = {
src = fetchFromGitHub {
owner = "opencv";
repo = "opencv_3rdparty";
rev = "a8b69ccc738421293254aec5ddb38bd523503252";
sha256 = "sha256-/n6zHwf0Rdc4v9o4rmETzow/HTv+81DnHP+nL56XiTY=";
};
files = {
"detect.caffemodel" = "238e2b2d6f3c18d6c3a30de0c31e23cf";
"detect.prototxt" = "6fb4976b32695f9f5c6305c19f12537d";
"sr.caffemodel" = "cbfcd60361a73beb8c583eea7e8e6664";
"sr.prototxt" = "69db99927a70df953b471daaba03fbef";
};
dst = ".cache/wechat_qrcode";
};
# See opencv/cmake/OpenCVDownload.cmake
installExtraFiles = extra : with lib; ''
installExtraFiles = extra: with lib; ''
mkdir -p "${extra.dst}"
'' + concatStrings (flip mapAttrsToList extra.files (name : md5 : ''
'' + concatStrings (flip mapAttrsToList extra.files (name: md5: ''
ln -s "${extra.src}/${name}" "${extra.dst}/${md5}-${name}"
''));
installExtraFile = extra: ''
@ -149,7 +203,7 @@ let
opencvFlag = name: enabled: "-DWITH_${name}=${printEnabled enabled}";
printEnabled = enabled : if enabled then "ON" else "OFF";
printEnabled = enabled: if enabled then "ON" else "OFF";
in
stdenv.mkDerivation {
@ -178,7 +232,9 @@ stdenv.mkDerivation {
${installExtraFiles vgg}
${installExtraFiles boostdesc}
${installExtraFiles face}
'');
${installExtraFiles wechat_qrcode}
''
);
postConfigure = ''
[ -e modules/core/version_string.inc ]
@ -186,7 +242,7 @@ stdenv.mkDerivation {
'';
buildInputs =
[ zlib pcre hdf5 glog boost gflags protobuf ]
[ zlib pcre hdf5 boost gflags protobuf ]
++ lib.optional enablePython pythonPackages.python
++ lib.optional enableGtk2 gtk2
++ lib.optional enableGtk3 gtk3
@ -274,15 +330,13 @@ stdenv.mkDerivation {
"$out/lib/pkgconfig/opencv4.pc"
'';
hardeningDisable = [ "bindnow" "relro" ];
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
passthru = lib.optionalAttrs enablePython { pythonPath = [ ]; };
meta = with lib; {
description = "Open Computer Vision Library with more than 500 algorithms";
homepage = "https://opencv.org/";
license = with licenses; if enableUnfree then unfree else bsd3;
maintainers = with maintainers; [mdaiter basvandijk];
maintainers = with maintainers; [ mdaiter basvandijk ];
platforms = with platforms; linux ++ darwin;
};
}

View file

@ -1,40 +1,17 @@
From 6d988c08e852379a163ecd20df8639196d84d014 Mon Sep 17 00:00:00 2001
From: Bernardo Meurer <meurerbernardo@gmail.com>
Date: Sun, 26 Apr 2020 14:50:25 -0700
Subject: [PATCH] cmake: don't use OpenCVFindOpenEXR
Use find_package for this.
---
CMakeLists.txt | 2 ++
cmake/OpenCVFindLibsGrfmt.cmake | 15 +++------------
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c0b3880fc..0360469350 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,8 @@ FATAL: In-source builds are not allowed.
")
endif()
+# the future!
+include(FindPkgConfig)
include(cmake/OpenCVMinDepVersions.cmake)
diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake
index 0beaf19317..4c5e46e615 100644
index 23a6ca6959..27e121943a 100644
--- a/cmake/OpenCVFindLibsGrfmt.cmake
+++ b/cmake/OpenCVFindLibsGrfmt.cmake
@@ -227,20 +227,11 @@ endif()
@@ -255,21 +255,12 @@ endif()
# --- OpenEXR (optional) ---
if(WITH_OPENEXR)
ocv_clear_vars(HAVE_OPENEXR)
- if(NOT BUILD_OPENEXR)
- ocv_clear_internal_cache_vars(OPENEXR_INCLUDE_PATHS OPENEXR_LIBRARIES OPENEXR_ILMIMF_LIBRARY OPENEXR_VERSION)
- include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
- endif()
-
+ pkg_check_modules(OPENEXR OpenEXR)
if(OPENEXR_FOUND)
set(HAVE_OPENEXR YES)
- else()
@ -50,6 +27,3 @@ index 0beaf19317..4c5e46e615 100644
endif()
endif()
--
2.26.1