mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-15 13:37:21 +03:00
opencv3: 3.0.0 -> 3.1.0
Split feature flags; avoid bundled libraries.
This commit is contained in:
parent
cfc7dba1ce
commit
f362f8d223
@ -1,54 +1,99 @@
|
||||
{ lib, stdenv, fetchurl, fetchzip, cmake, gtk, libjpeg, libpng, libtiff, jasper, ffmpeg
|
||||
, fetchpatch, pkgconfig, gstreamer, xineLib, glib, python27, python27Packages, unzip
|
||||
{ lib, stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig, unzip
|
||||
, zlib
|
||||
, enableIpp ? false
|
||||
, enableContrib ? false
|
||||
, enableBloat ? false }:
|
||||
, 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
|
||||
}:
|
||||
|
||||
let
|
||||
v = "3.0.0";
|
||||
version = "3.1.0";
|
||||
|
||||
contribSrc = fetchzip {
|
||||
url = "https://github.com/Itseez/opencv_contrib/archive/3.0.0.tar.gz";
|
||||
sha256 = "1gx7f9v85hmzh37s0zaillg7bs6cy9prm3wl0jb5zc5zrf9d8bm8";
|
||||
name = "opencv-contrib-3.0.0-src";
|
||||
contribSrc = fetchFromGitHub {
|
||||
owner = "Itseez";
|
||||
repo = "opencv_contrib";
|
||||
rev = version;
|
||||
sha256 = "153yx62f34gl3zd6vgxv0fj3wccwmq78lnawlda1f6xhrclg9bax";
|
||||
};
|
||||
|
||||
opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}";
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
name = "opencv-${v}";
|
||||
name = "opencv-${version}";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/Itseez/opencv/archive/${v}.zip";
|
||||
sha256 = "00dh7wvgkflz22liqd10fma8m3395lb3l3rgawnn5wlnz6i4w287";
|
||||
src = fetchFromGitHub {
|
||||
owner = "Itseez";
|
||||
repo = "opencv";
|
||||
rev = version;
|
||||
sha256 = "1l0w12czavgs0wzw1c594g358ilvfg2fn32cn8z7pv84zxj4g429";
|
||||
};
|
||||
|
||||
postPatch =
|
||||
let ippicv = fetchurl {
|
||||
url = "http://sourceforge.net/projects/opencvlibrary/files/3rdparty/ippicv/${ippicvName}";
|
||||
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}";
|
||||
md5 = ippicvHash;
|
||||
};
|
||||
ippicvName = "ippicv_linux_20141027.tgz";
|
||||
ippicvHash = "8b449a536a2157bcad08a2b9f266828b";
|
||||
ippicvArchive = "3rdparty/ippicv/downloads/linux-${ippicvHash}/${ippicvName}";
|
||||
in stdenv.lib.optionalString enableIpp
|
||||
in lib.optionalString enableIpp
|
||||
''
|
||||
mkdir -p $(dirname ${ippicvArchive})
|
||||
ln -s ${ippicv} ${ippicvArchive}
|
||||
'';
|
||||
|
||||
buildInputs =
|
||||
[ unzip libjpeg libpng libtiff ]
|
||||
++ lib.optionals enableBloat [ gtk glib jasper ffmpeg xineLib gstreamer python27 python27Packages.numpy ];
|
||||
[ zlib ]
|
||||
++ lib.optionals enablePython [ pythonPackages.python pythonPackages.numpy ]
|
||||
++ 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
|
||||
;
|
||||
|
||||
nativeBuildInputs = [ cmake pkgconfig ];
|
||||
nativeBuildInputs = [ cmake pkgconfig unzip ];
|
||||
|
||||
NIX_CFLAGS_COMPILE = lib.optional enableEXR "-I${ilmbase}/include/OpenEXR";
|
||||
|
||||
cmakeFlags = [
|
||||
"-DWITH_IPP=${if enableIpp then "ON" else "OFF"}"
|
||||
] ++ stdenv.lib.optionals enableContrib [ "-DOPENCV_EXTRA_MODULES_PATH=${contribSrc}/modules" ];
|
||||
(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" ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
|
||||
|
||||
meta = {
|
||||
description = "Open Computer Vision Library with more than 500 algorithms";
|
||||
homepage = http://opencv.org/;
|
||||
|
Loading…
Reference in New Issue
Block a user