2021-01-19 06:50:56 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, unzip
|
2016-06-07 14:08:20 +00:00
|
|
|
, zlib
|
|
|
|
, enablePython ? false, pythonPackages
|
|
|
|
, enableGtk2 ? false, gtk2
|
|
|
|
, enableJPEG ? true, libjpeg
|
|
|
|
, enablePNG ? true, libpng
|
|
|
|
, enableTIFF ? true, libtiff
|
2017-04-20 21:46:11 +00:00
|
|
|
, enableEXR ? (!stdenv.isDarwin), openexr, ilmbase
|
2020-06-07 12:39:09 +00:00
|
|
|
, enableFfmpeg ? false, ffmpeg_3
|
2018-05-04 01:51:07 +00:00
|
|
|
, enableGStreamer ? false, gst_all_1
|
2017-10-16 00:37:37 +00:00
|
|
|
, enableEigen ? true, eigen
|
2019-06-19 18:14:17 +00:00
|
|
|
, Cocoa, QTKit
|
2016-06-07 14:08:20 +00:00
|
|
|
}:
|
2011-09-24 20:40:58 +00:00
|
|
|
|
2016-06-07 14:08:20 +00:00
|
|
|
let
|
|
|
|
opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}";
|
|
|
|
|
|
|
|
in
|
2010-01-16 21:26:10 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "opencv";
|
2020-11-05 11:50:18 +00:00
|
|
|
version = "2.4.13.7";
|
2010-01-16 21:26:10 +00:00
|
|
|
|
2016-06-07 14:08:20 +00:00
|
|
|
src = fetchFromGitHub {
|
2020-11-05 11:50:18 +00:00
|
|
|
owner = "opencv";
|
2016-06-07 14:08:20 +00:00
|
|
|
repo = "opencv";
|
|
|
|
rev = version;
|
2020-11-05 11:50:18 +00:00
|
|
|
sha256 = "062js7zhh4ixi2wk61wyi23qp9zsk5vw24iz2i5fab2hp97y5zq3";
|
2010-01-16 21:26:10 +00:00
|
|
|
};
|
|
|
|
|
2016-10-02 17:22:02 +00:00
|
|
|
patches =
|
|
|
|
[ # Don't include a copy of the CMake status output in the
|
|
|
|
# build. This causes a runtime dependency on GCC.
|
|
|
|
./no-build-info.patch
|
|
|
|
];
|
|
|
|
|
2017-05-15 20:45:52 +00:00
|
|
|
# This prevents cmake from using libraries in impure paths (which causes build failure on non NixOS)
|
|
|
|
postPatch = ''
|
|
|
|
sed -i '/Add these standard paths to the search paths for FIND_LIBRARY/,/^\s*$/{d}' CMakeLists.txt
|
|
|
|
'';
|
|
|
|
|
2016-10-02 17:22:02 +00:00
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2014-07-22 10:01:01 +00:00
|
|
|
buildInputs =
|
2016-06-07 14:08:20 +00:00
|
|
|
[ zlib ]
|
2016-06-07 18:26:33 +00:00
|
|
|
++ lib.optional enablePython pythonPackages.python
|
2016-06-07 14:08:20 +00:00
|
|
|
++ lib.optional enableGtk2 gtk2
|
|
|
|
++ lib.optional enableJPEG libjpeg
|
|
|
|
++ lib.optional enablePNG libpng
|
|
|
|
++ lib.optional enableTIFF libtiff
|
|
|
|
++ lib.optionals enableEXR [ openexr ilmbase ]
|
2020-06-07 12:39:09 +00:00
|
|
|
++ lib.optional enableFfmpeg ffmpeg_3
|
2018-05-04 01:51:07 +00:00
|
|
|
++ lib.optionals enableGStreamer (with gst_all_1; [ gstreamer gst-plugins-base ])
|
2016-06-07 14:08:20 +00:00
|
|
|
++ lib.optional enableEigen eigen
|
2019-06-19 18:14:17 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [ Cocoa QTKit ]
|
2016-06-07 14:08:20 +00:00
|
|
|
;
|
|
|
|
|
2016-06-07 18:26:33 +00:00
|
|
|
propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
|
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ cmake pkg-config unzip ];
|
2011-09-24 20:40:58 +00:00
|
|
|
|
2019-10-30 01:29:30 +00:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString enableEXR "-I${ilmbase.dev}/include/OpenEXR";
|
2016-06-07 14:08:20 +00:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
(opencvFlag "TIFF" enableTIFF)
|
|
|
|
(opencvFlag "JPEG" enableJPEG)
|
|
|
|
(opencvFlag "PNG" enablePNG)
|
|
|
|
(opencvFlag "OPENEXR" enableEXR)
|
2018-05-04 01:51:07 +00:00
|
|
|
(opencvFlag "GSTREAMER" enableGStreamer)
|
2016-06-07 14:08:20 +00:00
|
|
|
];
|
2010-01-16 21:26:10 +00:00
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "bindnow" "relro" ];
|
2016-02-07 19:18:57 +00:00
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
# Fix pkg-config file that gets broken with multiple outputs
|
2016-10-20 13:38:02 +00:00
|
|
|
postFixup = ''
|
|
|
|
sed -i $dev/lib/pkgconfig/opencv.pc -e "s|includedir_old=.*|includedir_old=$dev/include/opencv|"
|
|
|
|
sed -i $dev/lib/pkgconfig/opencv.pc -e "s|includedir_new=.*|includedir_new=$dev/include|"
|
|
|
|
'';
|
|
|
|
|
2016-06-07 14:08:20 +00:00
|
|
|
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
|
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2010-01-16 21:26:10 +00:00
|
|
|
description = "Open Computer Vision Library with more than 500 algorithms";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://opencv.org/";
|
2017-04-20 21:46:11 +00:00
|
|
|
license = licenses.bsd3;
|
2018-07-22 19:50:19 +00:00
|
|
|
maintainers = with maintainers; [ ];
|
2019-06-06 03:45:27 +00:00
|
|
|
platforms = platforms.linux;
|
2010-01-16 21:26:10 +00:00
|
|
|
};
|
|
|
|
}
|