about summary refs log tree commit diff
path: root/pkgs/applications/video/obs-studio/plugins/obs-backgroundremoval/default.nix
blob: 79a3f82fec87d1499064735b19bb2b5ac8a4f539 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ lib
, stdenv
, fetchFromGitHub
, cmake
, obs-studio
, onnxruntime
, opencv
}:

stdenv.mkDerivation rec {
  pname = "obs-backgroundremoval";
  version = "unstable-2022-05-02";

  src = fetchFromGitHub {
    owner = "royshil";
    repo = "obs-backgroundremoval";
    rev = "cc9d4a5711f9388ed110230f9f793bb071577a23";
    hash = "sha256-xkVZ4cB642p4DvZAPwI2EVhkfVl5lJhgOQobjNMqpec=";
  };

  patches = [
    # Fix c++ include directives
    ./includes.patch

    # Use CPU backend instead of CUDA/DirectML
    ./use-cpu-backend.patch
  ];

  nativeBuildInputs = [ cmake ];
  buildInputs = [ obs-studio onnxruntime opencv ];

  dontWrapQtApps = true;

  cmakeFlags = [
    "-DLIBOBS_INCLUDE_DIR=${obs-studio.src}/libobs"
    "-DOnnxruntime_INCLUDE_DIRS=${onnxruntime.dev}/include/onnxruntime/core/session"
  ];


  prePatch = ''
    sed -i 's/version_from_git()/set(VERSION "0.4.0")/' CMakeLists.txt
  '';

  meta = with lib; {
    description = "OBS plugin to replace the background in portrait images and video";
    homepage = "https://github.com/royshil/obs-backgroundremoval";
    maintainers = with maintainers; [ puffnfresh ];
    license = licenses.mit;
    platforms = [ "x86_64-linux" "i686-linux" ];
  };
}