From 761dddc926b7a5ddadb2b2d343d67b314715824d Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Mon, 3 Apr 2023 09:45:35 +0200 Subject: [PATCH] Update obs-backgroundremoval --- .../cmake_fix_opencv_link.patch | 23 +++++++++++++++ pkgs/obs-backgroundremoval/default.nix | 28 +++++++++++++------ pkgs/onnx-runtime/default.nix | 14 ++++++---- 3 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 pkgs/obs-backgroundremoval/cmake_fix_opencv_link.patch diff --git a/pkgs/obs-backgroundremoval/cmake_fix_opencv_link.patch b/pkgs/obs-backgroundremoval/cmake_fix_opencv_link.patch new file mode 100644 index 0000000..9cb001c --- /dev/null +++ b/pkgs/obs-backgroundremoval/cmake_fix_opencv_link.patch @@ -0,0 +1,23 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3bcbad2..cd79570 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -73,9 +73,6 @@ set(USE_SYSTEM_OPENCV + if(USE_SYSTEM_OPENCV) + if(OS_LINUX) + find_package(OpenCV REQUIRED COMPONENTS core imgproc) +- add_library(OpenCV SHARED IMPORTED) +- set_target_properties(OpenCV PROPERTIES IMPORTED_LOCATION ${OpenCV_LIBRARIES}) +- set_target_properties(OpenCV PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OpenCV_INCLUDE_DIRS}") + else() + message(FATAL_ERROR "System OpenCV is only supported on Linux!") + endif() +@@ -86,7 +83,7 @@ endif() + if(OS_WINDOWS) + install(IMPORTED_RUNTIME_ARTIFACTS Onnxruntime::DirectML DESTINATION "${OBS_PLUGIN_DESTINATION}") + endif() +-target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Onnxruntime OpenCV) ++target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Onnxruntime ${OpenCV_LIBRARIES}) + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin|iOS") + foreach(flags CMAKE_CXX_FLAGS CMAKE_OBJC_FLAGS CMAKE_OBJCXX_FLAGS) + string(APPEND ${flags} " -fvisibility=hidden -fvisibility-inlines-hidden") diff --git a/pkgs/obs-backgroundremoval/default.nix b/pkgs/obs-backgroundremoval/default.nix index 259880c..d9027c6 100644 --- a/pkgs/obs-backgroundremoval/default.nix +++ b/pkgs/obs-backgroundremoval/default.nix @@ -4,23 +4,33 @@ , obs-studio , opencv , onnx-runtime -, git -, }: -stdenv.mkDerivation rec { +stdenv.mkDerivation { pname = "obs-backgroundremoval"; - version = "0.4.0"; + version = "0.5.14"; src = fetchFromGitHub { owner = "royshil"; repo = "obs-backgroundremoval"; - rev = "4f0348a15103cd4e516d94b629851208280cd4d4"; - sha256 = "TI1FlhE0+JL50gAZCSsI+g8savX8GRQkH3jYli/66hQ="; + rev = "a42c888ed578e026b31813fc5103ebfe48befebb"; + sha256 = "wCuvWn8BCzi/OrQnfXeUO2oJbw/wH1SUz1d2E/m8u9c="; }; - cmakeFlags = [ "-DGIT_TAG=v${version}" ]; - patches = [ ./cmake_set_version.patch ]; + # cmakeFlags = [ "-DGIT_TAG=v${version}" ]; + cmakeFlags = [ + "-DUSE_SYSTEM_ONNXRUNTIME=ON" + "-DUSE_SYSTEM_OPENCV=ON" + ]; + patches = [ ./cmake_fix_opencv_link.patch ]; - nativeBuildInputs = [ cmake git ]; + installPhase = '' + mkdir -p $out/lib/obs-plugins + cp rundir/Release/obs-plugins/64bit/obs-backgroundremoval.so $out/lib/obs-plugins/ + + mkdir -p $out/share/obs/obs-plugins/obs-backgroundremoval + cp -r rundir/Release/data/obs-plugins/obs-backgroundremoval/data/* $out/share/obs/obs-plugins/obs-backgroundremoval/ + ''; + + nativeBuildInputs = [ cmake ]; buildInputs = [ opencv onnx-runtime obs-studio ]; } diff --git a/pkgs/onnx-runtime/default.nix b/pkgs/onnx-runtime/default.nix index 89ef24a..4b22d60 100644 --- a/pkgs/onnx-runtime/default.nix +++ b/pkgs/onnx-runtime/default.nix @@ -1,16 +1,20 @@ { stdenv }: stdenv.mkDerivation { pname = "onnx-runtime"; - version = "1.7.0"; + version = "1.14.1"; # phases = [ "unpackPhase" "installPhase" ]; src = builtins.fetchTarball { - url = "https://github.com/microsoft/onnxruntime/releases/download/v1.7.0/onnxruntime-linux-x64-1.7.0.tgz"; - sha256 = "1zzgxn6867g4l9814dgpkc3jsz1qq32j6pjfhn3zv0qyw9cdnvn4"; + url = "https://github.com/microsoft/onnxruntime/releases/download/v1.14.1/onnxruntime-linux-x64-gpu-1.14.1.tgz"; + sha256 = "1hcxyhldxy5q0x50f96ni3p9v1n5qljarx7fvs63r6sk6j4yr2kv"; }; installPhase = '' - mkdir $out - cp -r include lib $out/ + mkdir -p $out/include/onnxruntime/core/session + mkdir -p $out/include/onnxruntime/core/providers/cpu + mkdir -p $out/include/onnxruntime/core/providers/gpu + + cp -r lib $out/ + cp -r include/ $out/ ''; }