Merge pull request #33783 from LumiGuide/opencv-3.3.1-release-17.09

Opencv 3.3.1 release 17.09
This commit is contained in:
Joachim F
2018-02-17 08:49:49 +00:00
committed by GitHub
5 changed files with 134 additions and 82 deletions

View File

@@ -1,4 +1,4 @@
{ stdenv, stdenv_gcc5, lib, fetchurl, boost, cmake, ffmpeg, gettext, glew
{ stdenv, lib, fetchurl, boost, cmake, ffmpeg, gettext, glew
, ilmbase, libXi, libX11, libXext, libXrender
, libjpeg, libpng, libsamplerate, libsndfile
, libtiff, mesa, openal, opencolorio, openexr, openimageio, openjpeg_1, python
@@ -10,7 +10,7 @@
with lib;
(if cudaSupport then stdenv_gcc5 else stdenv).mkDerivation rec {
stdenv.mkDerivation rec {
name = "blender-2.79";
src = fetchurl {

View File

@@ -1,4 +1,7 @@
{ lib, stdenv, fetchurl, fetchpatch, fetchFromGitHub, cmake, pkgconfig, unzip, zlib
{ lib, stdenv
, fetchurl, fetchFromGitHub
, cmake, pkgconfig, unzip, zlib, pcre, hdf5
, config
, enableJPEG ? true, libjpeg
, enablePNG ? true, libpng
@@ -6,93 +9,130 @@
, enableWebP ? true, libwebp
, enableEXR ? (!stdenv.isDarwin), openexr, ilmbase
, enableJPEG2K ? true, jasper
, enableEigen ? true, eigen
, enableOpenblas ? true, openblas
, enableCuda ? (config.cudaSupport or false), cudatoolkit
, enableIpp ? false
, enableContrib ? false, protobuf3_1
, enableContrib ? false #, caffe, glog, boost, google-gflags
, enablePython ? false, pythonPackages
, enableGtk2 ? false, gtk2
, enableGtk3 ? false, gtk3
, enableFfmpeg ? false, ffmpeg
, enableGStreamer ? false, gst_all_1
, enableEigen ? false, eigen
, enableOpenblas ? false, openblas
, enableCuda ? false, cudatoolkit, gcc5
, enableTesseract ? false, tesseract, leptonica
, enableDocs ? false, doxygen, graphviz-nox
, AVFoundation, Cocoa, QTKit
}:
let
version = "3.2.0";
version = "3.3.1";
src = fetchFromGitHub {
owner = "opencv";
repo = "opencv";
rev = version;
sha256 = "0f59g0dvhp5xg1xa3r4lp351a7x0k03i77ylgcf69ns3y47qd16p";
sha256 = "1jq8nny78gp54yjgsnb2rdp5rwhp78b3r2i36b2vyx6xk6h6wwji";
};
contribSrc = fetchFromGitHub {
owner = "opencv";
repo = "opencv_contrib";
rev = version;
sha256 = "1lynpbxz1jay3ya5y45zac5v8c6ifgk4ssn8d1chfdk3spi691jj";
};
# This fixes the build on macOS.
# See: https://github.com/opencv/opencv_contrib/pull/926
contribOSXFix = fetchpatch {
url = "https://github.com/opencv/opencv_contrib/commit/abf44fcccfe2f281b7442dac243e37b7f436d961.patch";
sha256 = "11dsq8dwh1k6f7zglbc26xwsjw184ggf2531mhf7v77kd72k19fm";
sha256 = "0q5vsa8dpa3mdhzas0ckagwh2sbckpm1kxsp0i3yfknsr5ampyi2";
};
# Contrib must be built in order to enable Tesseract support:
buildContrib = enableContrib || enableTesseract;
vggFiles = fetchFromGitHub {
owner = "opencv";
repo = "opencv_3rdparty";
rev = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d";
sha256 = "0r9fam8dplyqqsd3qgpnnfgf9l7lj44di19rxwbm8mxiw0rlcdvy";
# See opencv/3rdparty/ippicv/ippicv.cmake
ippicv = {
src = fetchFromGitHub {
owner = "opencv";
repo = "opencv_3rdparty";
rev = "dfe3162c237af211e98b8960018b564bc209261d";
sha256 = "1k5xiwdi5r2y3fs5g70lpknxqi4pj32w6l311gfwng3q1cb2crif";
} + "/ippicv";
files = let name = platform : "ippicv_2017u3_${platform}_general_20170822.tgz"; in
if stdenv.system == "x86_64-linux" then
{ ${name "lnx_intel64"} = "4e0352ce96473837b1d671ce87f17359"; }
else if stdenv.system == "i686-linux" then
{ ${name "lnx_ia32"} = "dcdb0ba4b123f240596db1840cd59a76"; }
else if stdenv.system == "x86_64-darwin" then
{ ${name "mac_intel64"} = "c1ebb5dfa5b7f54b0c44e1917805a463"; }
else
throw "ICV is not available for this platform (or not yet supported by this package)";
dst = ".cache/ippicv";
};
bootdescFiles = fetchFromGitHub {
owner = "opencv";
repo = "opencv_3rdparty";
rev = "34e4206aef44d50e6bbcd0ab06354b52e7466d26";
sha256 = "13yig1xhvgghvxspxmdidss5lqiikpjr0ddm83jsi0k85j92sn62";
# See opencv_contrib/modules/xfeatures2d/cmake/download_vgg.cmake
vgg = {
src = fetchFromGitHub {
owner = "opencv";
repo = "opencv_3rdparty";
rev = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d";
sha256 = "0r9fam8dplyqqsd3qgpnnfgf9l7lj44di19rxwbm8mxiw0rlcdvy";
};
files = {
"vgg_generated_48.i" = "e8d0dcd54d1bcfdc29203d011a797179";
"vgg_generated_64.i" = "7126a5d9a8884ebca5aea5d63d677225";
"vgg_generated_80.i" = "7cd47228edec52b6d82f46511af325c5";
"vgg_generated_120.i" = "151805e03568c9f490a5e3a872777b75";
};
dst = ".cache/xfeatures2d/vgg";
};
# See opencv_contrib/modules/xfeatures2d/cmake/download_boostdesc.cmake
boostdesc = {
src = fetchFromGitHub {
owner = "opencv";
repo = "opencv_3rdparty";
rev = "34e4206aef44d50e6bbcd0ab06354b52e7466d26";
sha256 = "13yig1xhvgghvxspxmdidss5lqiikpjr0ddm83jsi0k85j92sn62";
};
files = {
"boostdesc_bgm.i" = "0ea90e7a8f3f7876d450e4149c97c74f";
"boostdesc_bgm_bi.i" = "232c966b13651bd0e46a1497b0852191";
"boostdesc_bgm_hd.i" = "324426a24fa56ad9c5b8e3e0b3e5303e";
"boostdesc_binboost_064.i" = "202e1b3e9fec871b04da31f7f016679f";
"boostdesc_binboost_128.i" = "98ea99d399965c03d555cef3ea502a0b";
"boostdesc_binboost_256.i" = "e6dcfa9f647779eb1ce446a8d759b6ea";
"boostdesc_lbgm.i" = "0ae0675534aa318d9668f2a179c2a052";
};
dst = ".cache/xfeatures2d/boostdesc";
};
# See opencv/cmake/OpenCVDownload.cmake
installExtraFiles = extra : with lib; ''
mkdir -p "${extra.dst}"
'' + concatStrings (mapAttrsToList (name : md5 : ''
ln -s "${extra.src}/${name}" "${extra.dst}/${md5}-${name}"
'') extra.files);
# See opencv_contrib/modules/dnn_modern/CMakeLists.txt
tinyDnn = rec {
src = fetchurl {
url = "https://github.com/tiny-dnn/tiny-dnn/archive/${name}";
sha256 = "12x1b984cn0psn6kz1fy75zljgzqvkdyjy8i292adfnyqpl1rip2";
};
name = "v1.0.0a3.tar.gz";
md5 = "adb1c512e09ca2c7a6faef36f9c53e59";
dst = ".cache/tiny_dnn";
};
opencvFlag = name: enabled: "-DWITH_${name}=${if enabled then "ON" else "OFF"}";
in
stdenv.mkDerivation rec {
name = "opencv-${version}";
inherit version src;
postUnpack =
(lib.optionalString buildContrib ''
cp --no-preserve=mode -r "${contribSrc}/modules" "$NIX_BUILD_TOP/opencv_contrib"
# This fixes the build on macOS.
patch -d "$NIX_BUILD_TOP/opencv_contrib" -p2 < "${contribOSXFix}"
for name in vgg_generated_48.i \
vgg_generated_64.i \
vgg_generated_80.i \
vgg_generated_120.i; do
ln -s "${vggFiles}/$name" "$NIX_BUILD_TOP/opencv_contrib/xfeatures2d/src/$name"
done
for name in boostdesc_bgm.i \
boostdesc_bgm_bi.i \
boostdesc_bgm_hd.i \
boostdesc_binboost_064.i \
boostdesc_binboost_128.i \
boostdesc_binboost_256.i \
boostdesc_lbgm.i; do
ln -s "${bootdescFiles}/$name" "$NIX_BUILD_TOP/opencv_contrib/xfeatures2d/src/$name"
done
'');
postUnpack = lib.optionalString buildContrib ''
cp --no-preserve=mode -r "${contribSrc}/modules" "$NIX_BUILD_TOP/opencv_contrib"
'';
# This prevents cmake from using libraries in impure paths (which
# causes build failure on non NixOS)
@@ -105,29 +145,19 @@ stdenv.mkDerivation rec {
'';
preConfigure =
(let version = "20151201";
md5 = "808b791a6eac9ed78d32a7666804320e";
sha256 = "1nph0w0pdcxwhdb5lxkb8whpwd9ylvwl97hn0k425amg80z86cs3";
rev = "81a676001ca8075ada498583e4166079e5744668";
platform = 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)";
name = "ippicv_${platform}_${version}.tgz";
ippicv = fetchurl {
url = "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${rev}/ippicv/${name}";
inherit sha256;
};
dir = "3rdparty/ippicv/downloads/${platform}-${md5}";
in lib.optionalString enableIpp ''
mkdir -p "${dir}"
ln -s "${ippicv}" "${dir}/${name}"
''
) +
(lib.optionalString buildContrib ''
installExtraFiles ippicv + (
lib.optionalString buildContrib ''
cmakeFlagsArray+=("-DOPENCV_EXTRA_MODULES_PATH=$NIX_BUILD_TOP/opencv_contrib")
${installExtraFiles vgg}
${installExtraFiles boostdesc}
mkdir -p "${tinyDnn.dst}"
ln -s "${tinyDnn.src}" "${tinyDnn.dst}/${tinyDnn.md5}-${tinyDnn.name}"
'');
buildInputs =
[ zlib ]
[ zlib pcre hdf5 ]
++ lib.optional enablePython pythonPackages.python
++ lib.optional enableGtk2 gtk2
++ lib.optional enableGtk3 gtk3
@@ -145,9 +175,14 @@ stdenv.mkDerivation rec {
# simply enabled automatically if contrib is built, and it detects
# tesseract & leptonica.
++ lib.optionals enableTesseract [ tesseract leptonica ]
++ lib.optionals enableCuda [ cudatoolkit gcc5 ]
++ lib.optional buildContrib protobuf3_1
++ lib.optionals stdenv.isDarwin [ AVFoundation Cocoa QTKit ];
++ lib.optional enableCuda cudatoolkit
# These are only needed for the currently disabled
# cnn_3dobj and dnn_modern modules
# ++ lib.optionals buildContrib [ caffe glog boost google-gflags ]
++ lib.optionals stdenv.isDarwin [ AVFoundation Cocoa QTKit ]
++ lib.optionals enableDocs [ doxygen graphviz-nox ];
propagatedBuildInputs = lib.optional enablePython pythonPackages.numpy;
@@ -156,7 +191,8 @@ stdenv.mkDerivation rec {
NIX_CFLAGS_COMPILE = lib.optional enableEXR "-I${ilmbase.dev}/include/OpenEXR";
cmakeFlags = [
"-DWITH_IPP=${if enableIpp then "ON" else "OFF"} -DWITH_OPENMP=ON"
"-DWITH_OPENMP=ON"
(opencvFlag "IPP" enableIpp)
(opencvFlag "TIFF" enableTIFF)
(opencvFlag "JASPER" enableJPEG2K)
(opencvFlag "WEBP" enableWebP)
@@ -165,12 +201,27 @@ stdenv.mkDerivation rec {
(opencvFlag "OPENEXR" enableEXR)
(opencvFlag "CUDA" enableCuda)
(opencvFlag "CUBLAS" enableCuda)
] ++ lib.optionals enableCuda [ "-DCUDA_FAST_MATH=ON" ]
++ lib.optional buildContrib "-DBUILD_PROTOBUF=off"
] ++ lib.optionals enableCuda [
"-DCUDA_FAST_MATH=ON"
"-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc"
] ++ lib.optionals buildContrib [
# the cnn_3dobj module fails to build
"-DBUILD_opencv_cnn_3dobj=OFF"
# the dnn_modern module causes:
# https://github.com/opencv/opencv_contrib/issues/823
#
# On OS X its dependency tiny-dnn-1.0.0a3 also fails to build.
"-DBUILD_opencv_dnn_modern=OFF"
]
++ lib.optionals stdenv.isDarwin ["-DWITH_OPENCL=OFF" "-DWITH_LAPACK=OFF"];
enableParallelBuilding = true;
postBuild = lib.optionalString enableDocs ''
make doxygen
'';
hardeningDisable = [ "bindnow" "relro" ];
passthru = lib.optionalAttrs enablePython { pythonPath = []; };
@@ -179,7 +230,7 @@ stdenv.mkDerivation rec {
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 mdaiter];
maintainers = with stdenv.lib.maintainers; [viric mdaiter basvandijk];
platforms = with stdenv.lib.platforms; linux ++ darwin;
};
}

View File

@@ -9,7 +9,7 @@
, enableJPEG2K ? true, jasper
, enableFfmpeg ? false, ffmpeg
, enableGStreamer ? false, gst_all
, enableEigen ? false, eigen
, enableEigen ? true, eigen
, darwin
}:

View File

@@ -1,9 +1,9 @@
{ lib, stdenv, stdenv_gcc5, fetchurl, fetchFromGitHub, cmake, pkgconfig, xorg, mesa_glu
{ lib, stdenv, fetchurl, fetchFromGitHub, cmake, pkgconfig, xorg, mesa_glu
, mesa_noglu, glew, ocl-icd, python3
, cudaSupport ? false, cudatoolkit
}:
(if cudaSupport then stdenv_gcc5 else stdenv).mkDerivation rec {
stdenv.mkDerivation rec {
name = "opensubdiv-${version}";
version = "3.2.0";

View File

@@ -9976,6 +9976,7 @@ with pkgs;
};
opencv3 = callPackage ../development/libraries/opencv/3.x.nix {
enableCuda = config.cudaSupport or false;
inherit (darwin.apple_sdk.frameworks) AVFoundation Cocoa QTKit;
};
@@ -10038,7 +10039,7 @@ with pkgs;
};
opensubdiv = callPackage ../development/libraries/opensubdiv {
stdenv_gcc5 = overrideCC stdenv gcc5;
cudaSupport = config.cudaSupport or false;
cmake = cmake_2_8;
};
@@ -13778,7 +13779,7 @@ with pkgs;
bleachbit = callPackage ../applications/misc/bleachbit { };
blender = callPackage ../applications/misc/blender {
stdenv_gcc5 = overrideCC stdenv gcc5;
cudaSupport = config.cudaSupport or false;
python = python35;
};