2016-06-07 15:09:22 +01:00
|
|
|
{ lib, stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig, unzip
|
|
|
|
, zlib
|
2015-09-11 13:32:42 +01:00
|
|
|
, enableIpp ? false
|
2015-09-11 13:48:33 +01:00
|
|
|
, enableContrib ? false
|
2016-06-07 15:09:22 +01:00
|
|
|
, enablePython ? false, pythonPackages
|
|
|
|
, enableGtk2 ? false, gtk2
|
|
|
|
, enableGtk3 ? false, gtk3
|
|
|
|
, enableJPEG ? true, libjpeg
|
|
|
|
, enablePNG ? true, libpng
|
|
|
|
, enableTIFF ? true, libtiff
|
|
|
|
, enableWebP ? true, libwebp
|
|
|
|
, enableEXR ? true, openexr, ilmbase
|
|
|
|
, enableJPEG2K ? true, jasper
|
|
|
|
, enableFfmpeg ? false, ffmpeg
|
|
|
|
, enableGStreamer ? false, gst_all_1
|
|
|
|
, enableEigen ? false, eigen
|
|
|
|
}:
|
2015-09-01 13:53:32 +01:00
|
|
|
|
2015-09-11 13:48:33 +01:00
|
|
|
let
|
2016-06-07 15:09:22 +01:00
|
|
|
version = "3.1.0";
|
2015-09-11 13:48:33 +01:00
|
|
|
|
2016-06-07 15:09:22 +01:00
|
|
|
contribSrc = fetchFromGitHub {
|
|
|
|
owner = "Itseez";
|
|
|
|
repo = "opencv_contrib";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "153yx62f34gl3zd6vgxv0fj3wccwmq78lnawlda1f6xhrclg9bax";
|
2015-09-11 13:48:33 +01:00
|
|
|
};
|
|
|
|
|
2016-06-07 15:09:22 +01:00
|
|
|
opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}";
|
|
|
|
|
2015-09-11 13:48:33 +01:00
|
|
|
in
|
2015-09-01 13:53:32 +01:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2016-06-07 15:09:22 +01:00
|
|
|
name = "opencv-${version}";
|
|
|
|
inherit version;
|
2015-09-01 13:53:32 +01:00
|
|
|
|
2016-06-07 15:09:22 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Itseez";
|
|
|
|
repo = "opencv";
|
|
|
|
rev = version;
|
|
|
|
sha256 = "1l0w12czavgs0wzw1c594g358ilvfg2fn32cn8z7pv84zxj4g429";
|
2015-09-01 13:53:32 +01:00
|
|
|
};
|
|
|
|
|
2015-09-11 13:32:42 +01:00
|
|
|
postPatch =
|
2016-06-07 15:09:22 +01:00
|
|
|
let ippicvVersion = "20151201";
|
|
|
|
ippicvPlatform = if stdenv.system == "x86_64-linux" || stdenv.system == "i686-linux" then "linux"
|
|
|
|
else throw "ICV is not available for this platform (or not yet supported by this package)";
|
|
|
|
ippicvHash = if ippicvPlatform == "linux" then "808b791a6eac9ed78d32a7666804320e"
|
|
|
|
else throw "ippicvHash: impossible";
|
|
|
|
|
|
|
|
ippicvName = "ippicv_${ippicvPlatform}_${ippicvVersion}.tgz";
|
|
|
|
ippicvArchive = "3rdparty/ippicv/downloads/linux-${ippicvHash}/${ippicvName}";
|
|
|
|
ippicv = fetchurl {
|
|
|
|
url = "https://github.com/Itseez/opencv_3rdparty/raw/ippicv/master_${ippicvVersion}/ippicv/${ippicvName}";
|
2015-09-11 13:32:42 +01:00
|
|
|
md5 = ippicvHash;
|
|
|
|
};
|
2016-06-07 15:09:22 +01:00
|
|
|
in lib.optionalString enableIpp
|
2015-09-11 13:32:42 +01:00
|
|
|
''
|
|
|
|
mkdir -p $(dirname ${ippicvArchive})
|
|
|
|
ln -s ${ippicv} ${ippicvArchive}
|
|
|
|
'';
|
|
|
|
|
2015-09-01 13:53:32 +01:00
|
|
|
buildInputs =
|
2016-06-07 15:09:22 +01:00
|
|
|
[ zlib ]
|
2016-06-07 19:26:33 +01:00
|
|
|
++ lib.optional enablePython pythonPackages.python
|
2016-06-07 15:09:22 +01:00
|
|
|
++ lib.optional enableGtk2 gtk2
|
|
|
|
++ lib.optional enableGtk3 gtk3
|
|
|
|
++ lib.optional enableJPEG libjpeg
|
|
|
|
++ lib.optional enablePNG libpng
|
|
|
|
++ lib.optional enableTIFF libtiff
|
|
|
|
++ lib.optional enableWebP libwebp
|
|
|
|
++ lib.optionals enableEXR [ openexr ilmbase ]
|
|
|
|
++ lib.optional enableJPEG2K jasper
|
|
|
|
++ lib.optional enableFfmpeg ffmpeg
|
|
|
|
++ lib.optionals enableGStreamer (with gst_all_1; [ gstreamer gst-plugins-base ])
|
|
|
|
++ lib.optional enableEigen eigen
|
|
|
|
;
|
2015-09-01 13:53:32 +01:00
|
|
|
|
2016-06-07 19:26:33 +01:00
|
|
|
propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
|
|
|
|
|
2016-06-07 15:09:22 +01:00
|
|
|
nativeBuildInputs = [ cmake pkgconfig unzip ];
|
2015-09-01 13:53:32 +01:00
|
|
|
|
2016-09-01 17:11:21 +01:00
|
|
|
NIX_CFLAGS_COMPILE = lib.optional enableEXR "-I${ilmbase.dev}/include/OpenEXR";
|
2015-09-01 13:53:32 +01:00
|
|
|
|
2015-09-11 13:48:33 +01:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DWITH_IPP=${if enableIpp then "ON" else "OFF"}"
|
2016-06-07 15:09:22 +01:00
|
|
|
(opencvFlag "TIFF" enableTIFF)
|
|
|
|
(opencvFlag "JASPER" enableJPEG2K)
|
|
|
|
(opencvFlag "WEBP" enableWebP)
|
|
|
|
(opencvFlag "JPEG" enableJPEG)
|
|
|
|
(opencvFlag "PNG" enablePNG)
|
|
|
|
(opencvFlag "OPENEXR" enableEXR)
|
|
|
|
] ++ lib.optionals enableContrib [ "-DOPENCV_EXTRA_MODULES_PATH=${contribSrc}/modules" ];
|
2015-09-01 21:20:38 +01:00
|
|
|
|
2015-09-01 13:53:32 +01:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "bindnow" "relro" ];
|
2016-02-12 14:15:00 +00:00
|
|
|
|
2016-06-07 15:09:22 +01:00
|
|
|
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
|
|
|
|
|
2015-09-01 13:53:32 +01:00
|
|
|
meta = {
|
|
|
|
description = "Open Computer Vision Library with more than 500 algorithms";
|
|
|
|
homepage = http://opencv.org/;
|
|
|
|
license = stdenv.lib.licenses.bsd3;
|
|
|
|
maintainers = with stdenv.lib.maintainers; [viric flosse];
|
|
|
|
platforms = with stdenv.lib.platforms; linux;
|
|
|
|
};
|
|
|
|
}
|