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 { lib
, fetchurl, fetchFromGitHub, fetchpatch , stdenv
, cmake, pkg-config, unzip, zlib, pcre, hdf5 , fetchurl
, glog, boost, gflags, protobuf , fetchFromGitHub
, cmake
, pkg-config
, unzip
, zlib
, pcre
, hdf5
, boost
, gflags
, protobuf
, config , config
, enableJPEG ? true, libjpeg , enableJPEG ? true
, enablePNG ? true, libpng , libjpeg
, enableTIFF ? true, libtiff , enablePNG ? true
, enableWebP ? true, libwebp , libpng
, enableEXR ? !stdenv.isDarwin, openexr, ilmbase , enableTIFF ? true
, enableEigen ? true, eigen , libtiff
, enableOpenblas ? true, openblas, blas, lapack , enableWebP ? true
, libwebp
, enableEXR ? !stdenv.isDarwin
, openexr
, ilmbase
, enableEigen ? true
, eigen
, enableOpenblas ? true
, openblas
, enableContrib ? true , enableContrib ? true
, enableCuda ? (config.cudaSupport or false) && , enableCuda ? (config.cudaSupport or false) && stdenv.hostPlatform.isx86_64
stdenv.hostPlatform.isx86_64, cudatoolkit, nvidia-optical-flow-sdk , cudatoolkit
, nvidia-optical-flow-sdk
, enableUnfree ? false , enableUnfree ? false
, enableIpp ? false , enableIpp ? false
, enablePython ? false, pythonPackages , enablePython ? false
, enableGtk2 ? false, gtk2 , pythonPackages
, enableGtk3 ? false, gtk3 , enableGtk2 ? false
, enableVtk ? false, vtk , gtk2
, enableFfmpeg ? false, ffmpeg_3 , enableGtk3 ? false
, enableGStreamer ? false, gst_all_1 , gtk3
, enableTesseract ? false, tesseract, leptonica , enableVtk ? false
, enableTbb ? false, tbb , vtk
, enableOvis ? false, ogre , enableFfmpeg ? true
, enableGPhoto2 ? false, libgphoto2 , ffmpeg_3
, enableDC1394 ? false, libdc1394 , enableGStreamer ? true
, enableDocs ? false, doxygen, graphviz-nox , 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 let
version = "4.3.0"; version = "4.5.2";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "opencv"; owner = "opencv";
repo = "opencv"; repo = "opencv";
rev = version; rev = version;
sha256 = "1r9bq9p1x99g2y8jvj9428sgqvljz75dm5vrfsma7hh5wjhz9775"; sha256 = "sha256-pxi1VBF4txvRqspdqvCsAQ3XKzl633/o3wyOgD9wid4=";
}; };
contribSrc = fetchFromGitHub { contribSrc = fetchFromGitHub {
owner = "opencv"; owner = "opencv";
repo = "opencv_contrib"; repo = "opencv_contrib";
rev = version; rev = version;
sha256 = "068b4f95rlryab3mffxs2w6dnbmbhrnpsdgl007rxk4bwnz29y49"; sha256 = "sha256-iMenRTY+qeL7WRgnRuQbsHflYDakE7pWWSHeIjrg0Iw=";
}; };
# Contrib must be built in order to enable Tesseract support: # Contrib must be built in order to enable Tesseract support:
@ -62,7 +99,7 @@ let
rev = "a56b6ac6f030c312b2dce17430eef13aed9af274"; rev = "a56b6ac6f030c312b2dce17430eef13aed9af274";
sha256 = "1msbkc3zixx61rcg6a04i1bcfhw1phgsrh93glq1n80hgsk3nbjq"; sha256 = "1msbkc3zixx61rcg6a04i1bcfhw1phgsrh93glq1n80hgsk3nbjq";
} + "/ippicv"; } + "/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 if stdenv.hostPlatform.system == "x86_64-linux" then
{ ${name "lnx_intel64"} = "c0bd78adb4156bbf552c1dfe90599607"; } { ${name "lnx_intel64"} = "c0bd78adb4156bbf552c1dfe90599607"; }
else if stdenv.hostPlatform.system == "i686-linux" then else if stdenv.hostPlatform.system == "i686-linux" then
@ -136,10 +173,27 @@ let
dst = ".cache/ade"; 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 # See opencv/cmake/OpenCVDownload.cmake
installExtraFiles = extra : with lib; '' installExtraFiles = extra: with lib; ''
mkdir -p "${extra.dst}" 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}" ln -s "${extra.src}/${name}" "${extra.dst}/${md5}-${name}"
'')); ''));
installExtraFile = extra: '' installExtraFile = extra: ''
@ -149,7 +203,7 @@ let
opencvFlag = name: enabled: "-DWITH_${name}=${printEnabled enabled}"; opencvFlag = name: enabled: "-DWITH_${name}=${printEnabled enabled}";
printEnabled = enabled : if enabled then "ON" else "OFF"; printEnabled = enabled: if enabled then "ON" else "OFF";
in in
stdenv.mkDerivation { stdenv.mkDerivation {
@ -178,7 +232,9 @@ stdenv.mkDerivation {
${installExtraFiles vgg} ${installExtraFiles vgg}
${installExtraFiles boostdesc} ${installExtraFiles boostdesc}
${installExtraFiles face} ${installExtraFiles face}
''); ${installExtraFiles wechat_qrcode}
''
);
postConfigure = '' postConfigure = ''
[ -e modules/core/version_string.inc ] [ -e modules/core/version_string.inc ]
@ -186,7 +242,7 @@ stdenv.mkDerivation {
''; '';
buildInputs = buildInputs =
[ zlib pcre hdf5 glog boost gflags protobuf ] [ zlib pcre hdf5 boost gflags protobuf ]
++ lib.optional enablePython pythonPackages.python ++ lib.optional enablePython pythonPackages.python
++ lib.optional enableGtk2 gtk2 ++ lib.optional enableGtk2 gtk2
++ lib.optional enableGtk3 gtk3 ++ lib.optional enableGtk3 gtk3
@ -274,15 +330,13 @@ stdenv.mkDerivation {
"$out/lib/pkgconfig/opencv4.pc" "$out/lib/pkgconfig/opencv4.pc"
''; '';
hardeningDisable = [ "bindnow" "relro" ]; passthru = lib.optionalAttrs enablePython { pythonPath = [ ]; };
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
meta = with lib; { meta = with lib; {
description = "Open Computer Vision Library with more than 500 algorithms"; description = "Open Computer Vision Library with more than 500 algorithms";
homepage = "https://opencv.org/"; homepage = "https://opencv.org/";
license = with licenses; if enableUnfree then unfree else bsd3; license = with licenses; if enableUnfree then unfree else bsd3;
maintainers = with maintainers; [mdaiter basvandijk]; maintainers = with maintainers; [ mdaiter basvandijk ];
platforms = with platforms; linux ++ darwin; 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 diff --git a/cmake/OpenCVFindLibsGrfmt.cmake b/cmake/OpenCVFindLibsGrfmt.cmake
index 0beaf19317..4c5e46e615 100644 index 23a6ca6959..27e121943a 100644
--- a/cmake/OpenCVFindLibsGrfmt.cmake --- a/cmake/OpenCVFindLibsGrfmt.cmake
+++ b/cmake/OpenCVFindLibsGrfmt.cmake +++ b/cmake/OpenCVFindLibsGrfmt.cmake
@@ -227,20 +227,11 @@ endif() @@ -255,21 +255,12 @@ endif()
# --- OpenEXR (optional) --- # --- OpenEXR (optional) ---
if(WITH_OPENEXR) if(WITH_OPENEXR)
ocv_clear_vars(HAVE_OPENEXR) ocv_clear_vars(HAVE_OPENEXR)
- if(NOT BUILD_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") - include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindOpenEXR.cmake")
- endif() - endif()
-
+ pkg_check_modules(OPENEXR OpenEXR) + pkg_check_modules(OPENEXR OpenEXR)
if(OPENEXR_FOUND) if(OPENEXR_FOUND)
set(HAVE_OPENEXR YES) set(HAVE_OPENEXR YES)
- else() - else()
@ -50,6 +27,3 @@ index 0beaf19317..4c5e46e615 100644
endif() endif()
endif() endif()
--
2.26.1