├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ └── windows-build.yml ├── .editorconfig ├── thirdparty └── NuiSensorLib │ └── lib │ └── x64 │ └── NuiSensorLib.lib ├── xmake-repo └── packages │ ├── k │ ├── k4abt-headers │ │ └── xmake.lua │ ├── kinect-sdk1 │ │ └── xmake.lua │ ├── kinect-sdk2 │ │ └── xmake.lua │ ├── k4a │ │ └── xmake.lua │ └── kinect-sdk1-toolkit │ │ └── xmake.lua │ └── l │ └── libfreenect │ └── xmake.lua ├── data └── obs-plugins │ └── obs-kinect │ ├── color_multiplier.effect │ ├── alpha_mask.effect │ ├── visibility_mask.effect │ ├── texture_lerp.effect │ ├── gaussian_blur.effect │ ├── locale │ ├── ko-KR.ini │ ├── en-US.ini │ ├── de-DE.ini │ ├── cs-CZ.ini │ ├── fr-FR.ini │ └── pl-PL.ini │ └── greenscreen_filter.effect ├── src ├── obs-kinect-core │ ├── KinectPluginImpl.cpp │ ├── Helper.cpp │ ├── Enums.cpp │ └── KinectDeviceAccess.cpp ├── obs-kinect-azuresdk │ ├── AzureHelper.hpp │ ├── Export.cpp │ ├── AzureKinectPlugin.hpp │ ├── AzureKinectDevice.hpp │ ├── AzureKinectBodyTrackingDynFuncs.cpp │ ├── AzureKinectPlugin.cpp │ └── AzureKinectBodyTrackingDynFuncs.hpp ├── obs-kinect-sdk20 │ ├── Sdk20Helper.hpp │ ├── Export.cpp │ ├── KinectSdk20Plugin.cpp │ ├── KinectSdk20Plugin.hpp │ ├── KinectSdk20Device.hpp │ └── NuiSensorLibHelper.hpp ├── obs-kinect-freenect │ ├── FreenectHelper.hpp │ ├── Export.cpp │ ├── FreenectDevice.hpp │ ├── FreenectPlugin.hpp │ └── FreenectPlugin.cpp ├── obs-kinect-freenect2 │ ├── Freenect2Helper.hpp │ ├── Export.cpp │ ├── Freenect2Device.hpp │ ├── Freenect2Plugin.cpp │ └── Freenect2Plugin.hpp ├── obs-kinect-sdk10 │ ├── Export.cpp │ ├── Sdk10Helper.hpp │ ├── KinectSdk10Plugin.hpp │ ├── KinectSdk10Plugin.cpp │ └── KinectSdk10Device.hpp └── obs-kinect │ ├── Shaders │ ├── AlphaMaskShader.hpp │ ├── VisibilityMaskShader.hpp │ ├── TextureLerpShader.hpp │ ├── GaussianBlurShader.hpp │ ├── ConvertDepthIRToColorShader.hpp │ ├── GreenScreenFilterShader.inl │ ├── AlphaMaskShader.cpp │ ├── VisibilityMaskShader.cpp │ ├── ConvertDepthIRToColorShader.cpp │ ├── TextureLerpShader.cpp │ ├── GreenScreenFilterShader.hpp │ ├── GaussianBlurShader.cpp │ └── GreenScreenFilterShader.cpp │ ├── GreenscreenEffects │ ├── RemoveBackgroundEffect.cpp │ ├── RemoveBackgroundEffect.hpp │ ├── BlurBackgroundEffect.hpp │ ├── ReplaceBackgroundEffect.hpp │ ├── BlurBackgroundEffect.cpp │ └── ReplaceBackgroundEffect.cpp │ ├── KinectPlugin.hpp │ ├── GreenscreenEffects.hpp │ ├── KinectPlugin.cpp │ ├── KinectDeviceRegistry.hpp │ ├── KinectDeviceRegistry.cpp │ └── KinectSource.hpp ├── config.lua.default └── include └── obs-kinect-core ├── KinectPluginImpl.hpp ├── Enums.hpp ├── KinectDeviceAccess.hpp ├── Win32Helper.hpp ├── KinectFrame.hpp ├── Helper.hpp └── KinectDevice.hpp /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [SirLynix] 2 | custom: ['https://paypal.me/sirlynixvanfrietjes'] 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | indent_style = tab 8 | -------------------------------------------------------------------------------- /thirdparty/NuiSensorLib/lib/x64/NuiSensorLib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SirLynix/obs-kinect/HEAD/thirdparty/NuiSensorLib/lib/x64/NuiSensorLib.lib -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /xmake-repo/packages/k/k4abt-headers/xmake.lua: -------------------------------------------------------------------------------- 1 | package("k4abt-headers") 2 | set_kind("library", {headeronly = true}) 3 | set_homepage("https://Azure.com/Kinect") 4 | set_description("Headers of the Azure Kinect Body Tracking SDK") 5 | set_license("MIT") 6 | 7 | add_versions("v1.4.1", "") 8 | 9 | on_fetch("windows", function (package) 10 | -- KINECTSDKAZUREBT_DIR is not an official Microsoft env 11 | local defaultInstallPath = os.getenv("KINECTSDKAZUREBT_DIR") or path.join(os.getenv("ProgramFiles"), "Azure Kinect Body Tracking SDK", "sdk") 12 | if os.isdir(defaultInstallPath) then 13 | local result = {} 14 | result.includedirs = { defaultInstallPath .. "/include" } 15 | 16 | return result 17 | end 18 | end) 19 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/color_multiplier.effect: -------------------------------------------------------------------------------- 1 | uniform float4x4 ViewProj; 2 | uniform texture2d ColorImage; 3 | uniform float ColorMultiplier; 4 | 5 | sampler_state textureSampler { 6 | Filter = Linear; 7 | AddressU = Clamp; 8 | AddressV = Clamp; 9 | }; 10 | 11 | struct VertData { 12 | float4 pos : POSITION; 13 | float2 uv : TEXCOORD0; 14 | }; 15 | 16 | VertData VSDefault(VertData vert_in) 17 | { 18 | VertData vert_out; 19 | vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 20 | vert_out.uv = vert_in.uv; 21 | return vert_out; 22 | } 23 | 24 | float4 PSColorFilterRGBA(VertData vert_in) : TARGET 25 | { 26 | float color = ColorImage.Sample(textureSampler, vert_in.uv).r; 27 | color *= ColorMultiplier; 28 | 29 | return float4(color, color, color, 1.0); 30 | } 31 | 32 | technique Draw 33 | { 34 | pass 35 | { 36 | vertex_shader = VSDefault(vert_in); 37 | pixel_shader = PSColorFilterRGBA(vert_in); 38 | } 39 | } -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/alpha_mask.effect: -------------------------------------------------------------------------------- 1 | uniform float4x4 ViewProj; 2 | uniform texture2d ColorImage; 3 | uniform texture2d MaskImage; 4 | 5 | sampler_state textureSampler { 6 | Filter = Linear; 7 | AddressU = Clamp; 8 | AddressV = Clamp; 9 | }; 10 | 11 | struct VertData { 12 | float4 pos : POSITION; 13 | float2 uv : TEXCOORD0; 14 | }; 15 | 16 | VertData VSDefault(VertData vert_in) 17 | { 18 | VertData vert_out; 19 | vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 20 | vert_out.uv = vert_in.uv; 21 | return vert_out; 22 | } 23 | 24 | float4 PSColorFilterRGBA(VertData vert_in) : TARGET 25 | { 26 | float4 color = ColorImage.Sample(textureSampler, vert_in.uv); 27 | float alpha = MaskImage.Sample(textureSampler, vert_in.uv).r; 28 | color.a *= alpha; 29 | 30 | return color; 31 | } 32 | 33 | technique Draw 34 | { 35 | pass 36 | { 37 | vertex_shader = VSDefault(vert_in); 38 | pixel_shader = PSColorFilterRGBA(vert_in); 39 | } 40 | } -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/visibility_mask.effect: -------------------------------------------------------------------------------- 1 | uniform float4x4 ViewProj; 2 | uniform texture2d FilterImage; 3 | uniform texture2d MaskImage; 4 | 5 | sampler_state textureSampler { 6 | Filter = Linear; 7 | AddressU = Clamp; 8 | AddressV = Clamp; 9 | }; 10 | 11 | struct VertData { 12 | float4 pos : POSITION; 13 | float2 uv : TEXCOORD0; 14 | }; 15 | 16 | VertData VSDefault(VertData vert_in) 17 | { 18 | VertData vert_out; 19 | vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 20 | vert_out.uv = vert_in.uv; 21 | return vert_out; 22 | } 23 | 24 | float4 PSDepthMask(VertData vert_in) : TARGET 25 | { 26 | float currentFilter = FilterImage.Sample(textureSampler, vert_in.uv).r; 27 | float4 mask = MaskImage.Sample(textureSampler, vert_in.uv); 28 | 29 | float value = lerp(currentFilter, mask.r, mask.a); 30 | return float4(value, value, value, value); 31 | } 32 | 33 | technique Draw 34 | { 35 | pass 36 | { 37 | vertex_shader = VSDefault(vert_in); 38 | pixel_shader = PSDepthMask(vert_in); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/obs-kinect-core/KinectPluginImpl.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | 20 | KinectPluginImpl::~KinectPluginImpl() = default; 21 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/texture_lerp.effect: -------------------------------------------------------------------------------- 1 | uniform float4x4 ViewProj; 2 | uniform texture2d FromImage; 3 | uniform texture2d ToImage; 4 | uniform texture2d FactorImage; 5 | 6 | sampler_state textureSampler { 7 | Filter = Linear; 8 | AddressU = Clamp; 9 | AddressV = Clamp; 10 | }; 11 | 12 | struct VertData { 13 | float4 pos : POSITION; 14 | float2 uv : TEXCOORD0; 15 | }; 16 | 17 | VertData VSDefault(VertData vert_in) 18 | { 19 | VertData vert_out; 20 | vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 21 | vert_out.uv = vert_in.uv; 22 | return vert_out; 23 | } 24 | 25 | float4 PSColorFilterRGBA(VertData vert_in) : TARGET 26 | { 27 | float4 color1 = FromImage.Sample(textureSampler, vert_in.uv); 28 | float4 color2 = ToImage.Sample(textureSampler, vert_in.uv); 29 | float alpha = FactorImage.Sample(textureSampler, vert_in.uv).r; 30 | 31 | return lerp(color1, color2, alpha); 32 | } 33 | 34 | technique Draw 35 | { 36 | pass 37 | { 38 | vertex_shader = VSDefault(vert_in); 39 | pixel_shader = PSColorFilterRGBA(vert_in); 40 | } 41 | } -------------------------------------------------------------------------------- /config.lua.default: -------------------------------------------------------------------------------- 1 | -- Example config, copy to config.lua before building 2 | 3 | -- Where is libobs located (found in OBS repository) 4 | LibObs = { 5 | Include = "../obs-studio/libobs", 6 | Lib32 = "../obs-studio/build32/libobs", 7 | Lib64 = "../obs-studio/build64/libobs", 8 | } 9 | 10 | ObsFolder = { 11 | Debug32 = "../obs-studio/build32/rundir/Debug", 12 | Debug64 = "../obs-studio/build64/rundir/Debug", 13 | Release32 = "../obs-studio/build32/rundir/Release", 14 | Release64 = "../obs-studio/build64/rundir/Release" 15 | } 16 | 17 | -- Where to copy generated plugin file after a successful build (depending on configuration/arch) 18 | -- If you don't want the plugin to be copied, just comment out/delete thoses lines 19 | --CopyToDebug32 = [[C:\Projets\obs-kinect\obs-studio\build32\rundir\Debug\obs-plugins\32bit]] 20 | CopyToDebug64 = [[C:\Projets\obs-kinect\obs-studio\build64\rundir\Debug\obs-plugins\64bit]] 21 | --CopyToRelease32 = [[C:\Projets\obs-kinect\obs-studio\build32\rundir\Release\obs-plugins\32bit]] 22 | CopyToRelease64 = [[C:\Projets\obs-kinect\obs-studio\build64\rundir\Release\obs-plugins\64bit]] 23 | 24 | -- You shouldn't have to change anything under this line 25 | -------------------------------------------------------------------------------- /src/obs-kinect-azuresdk/AzureHelper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_HELPER_AZUREKINECT 21 | #define OBS_KINECT_PLUGIN_HELPER_AZUREKINECT 22 | 23 | #ifdef OBS_KINECT_PLUGIN_HELPER 24 | #error "This file must be included before Helper.hpp" 25 | #endif 26 | 27 | #define logprefix "[obs-kinect] [azure] " 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/obs-kinect-core/Helper.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | 20 | TranslateSig translateFunction = nullptr; 21 | 22 | void SetTranslateFunction(TranslateSig translateFunc) 23 | { 24 | translateFunction = translateFunc; 25 | } 26 | 27 | const char* Translate(const char* key) 28 | { 29 | if (!translateFunction) 30 | return key; 31 | 32 | return translateFunction(key); 33 | } 34 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk20/Sdk20Helper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_HELPER_KINECTDEVICESDK20 21 | #define OBS_KINECT_PLUGIN_HELPER_KINECTDEVICESDK20 22 | 23 | #ifdef OBS_KINECT_PLUGIN_HELPER 24 | #error "This file must be included before Helper.hpp" 25 | #endif 26 | 27 | #define logprefix "[obs-kinect] [sdk20] " 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect/FreenectHelper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_HELPER_KINECTDEVICEFREENECT 21 | #define OBS_KINECT_PLUGIN_HELPER_KINECTDEVICEFREENECT 22 | 23 | #ifdef OBS_KINECT_PLUGIN_HELPER 24 | #error "This file must be included before Helper.hpp" 25 | #endif 26 | 27 | #define logprefix "[obs-kinect] [freenect] " 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect2/Freenect2Helper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_HELPER_KINECTDEVICEFREENECT2 21 | #define OBS_KINECT_PLUGIN_HELPER_KINECTDEVICEFREENECT2 22 | 23 | #ifdef OBS_KINECT_PLUGIN_HELPER 24 | #error "This file must be included before Helper.hpp" 25 | #endif 26 | 27 | #define logprefix "[obs-kinect] [freenect2] " 28 | 29 | #include 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/obs-kinect-azuresdk/Export.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "AzureKinectPlugin.hpp" 19 | 20 | extern "C" 21 | { 22 | OBSKINECT_EXPORT KinectPluginImpl* ObsKinect_CreatePlugin(std::uint32_t version) 23 | { 24 | if (version != OBSKINECT_VERSION) 25 | { 26 | warnlog("Kinect plugin incompatibilities (obs-kinect version: %d, plugin version: %d)", OBSKINECT_VERSION, version); 27 | return nullptr; 28 | } 29 | 30 | return new AzureKinectPlugin; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect/Export.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "FreenectPlugin.hpp" 19 | 20 | extern "C" 21 | { 22 | OBSKINECT_EXPORT KinectPluginImpl* ObsKinect_CreatePlugin(std::uint32_t version) 23 | { 24 | if (version != OBSKINECT_VERSION) 25 | { 26 | warnlog("Kinect plugin incompatibilities (obs-kinect version: %d, plugin version: %d)", OBSKINECT_VERSION, version); 27 | return nullptr; 28 | } 29 | 30 | return new KinectFreenectPlugin; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk10/Export.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "KinectSdk10Plugin.hpp" 19 | 20 | extern "C" 21 | { 22 | OBSKINECT_EXPORT KinectPluginImpl* ObsKinect_CreatePlugin(std::uint32_t version) 23 | { 24 | if (version != OBSKINECT_VERSION) 25 | { 26 | warnlog("Kinect plugin incompatibilities (obs-kinect version: %d, plugin version: %d)", OBSKINECT_VERSION, version); 27 | return nullptr; 28 | } 29 | 30 | return new KinectSdk10Plugin; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk20/Export.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "KinectSdk20Plugin.hpp" 19 | 20 | extern "C" 21 | { 22 | OBSKINECT_EXPORT KinectPluginImpl* ObsKinect_CreatePlugin(std::uint32_t version) 23 | { 24 | if (version != OBSKINECT_VERSION) 25 | { 26 | warnlog("Kinect plugin incompatibilities (obs-kinect version: %d, plugin version: %d)", OBSKINECT_VERSION, version); 27 | return nullptr; 28 | } 29 | 30 | return new KinectSdk20Plugin; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect2/Export.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "Freenect2Plugin.hpp" 19 | 20 | extern "C" 21 | { 22 | OBSKINECT_EXPORT KinectPluginImpl* ObsKinect_CreatePlugin(std::uint32_t version) 23 | { 24 | if (version != OBSKINECT_VERSION) 25 | { 26 | warnlog("Kinect plugin incompatibilities (obs-kinect version: %d, plugin version: %d)", OBSKINECT_VERSION, version); 27 | return nullptr; 28 | } 29 | 30 | return new KinectFreenect2Plugin; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /xmake-repo/packages/k/kinect-sdk1/xmake.lua: -------------------------------------------------------------------------------- 1 | package("kinect-sdk1") 2 | set_homepage("https://www.microsoft.com/en-us/download/details.aspx?id=40278") 3 | set_description("The Kinect for Windows Software Development Kit (SDK) enables developers to create applications that support gesture and voice recognition, using Kinect sensor technology.") 4 | 5 | on_fetch("windows", function (package) 6 | if package:config("shared") then 7 | os.raise("Kinect for Windows SDK is only available in static mode") 8 | end 9 | 10 | local sdk10dir = os.getenv("KINECTSDK10_DIR") 11 | if sdk10dir and os.isdir(sdk10dir) then 12 | local libFolder = package:is_arch("x86") and "x86" or "amd64" 13 | 14 | local result = {} 15 | result.includedirs = { sdk10dir .. "/inc" } 16 | result.linkdirs = { sdk10dir .. "/lib/" .. libFolder } 17 | result.links = { "Kinect10" } 18 | 19 | return result 20 | end 21 | end) 22 | 23 | on_install(function () 24 | os.raise("Due to its license, the Kinect for Windows SDK cannot be automatically installed, please download and install it yourself from https://www.microsoft.com/en-us/download/details.aspx?id=40278") 25 | end) 26 | 27 | on_test(function (package) 28 | assert(package:has_cfuncs("NuiInitialize", {includes = "NuiApi.h"})) 29 | end) 30 | -------------------------------------------------------------------------------- /xmake-repo/packages/k/kinect-sdk2/xmake.lua: -------------------------------------------------------------------------------- 1 | package("kinect-sdk2") 2 | set_homepage("https://www.microsoft.com/en-us/download/details.aspx?id=44561") 3 | set_description("The Kinect for Windows Software Development Kit (SDK) 2.0 enables developers to create applications that support gesture and voice recognition, using Kinect sensor technology.") 4 | 5 | on_fetch("windows", function (package) 6 | if package:config("shared") then 7 | os.raise("Kinect for Windows SDK is only available in static mode") 8 | end 9 | 10 | local sdk20dir = os.getenv("KINECTSDK20_DIR") 11 | if sdk20dir and os.isdir(sdk20dir) then 12 | local libFolder = package:is_arch("x86") and "x86" or "x64" 13 | 14 | local result = {} 15 | result.includedirs = { sdk20dir .. "/inc" } 16 | result.linkdirs = { sdk20dir .. "/lib/" .. libFolder } 17 | result.links = { "Kinect20" } 18 | 19 | return result 20 | end 21 | end) 22 | 23 | on_install(function () 24 | os.raise("Due to its license, the Kinect for Windows SDK 2 cannot be automatically installed, please download and install it yourself from https://www.microsoft.com/en-us/download/details.aspx?id=44561") 25 | end) 26 | 27 | on_test(function (package) 28 | assert(package:has_cfuncs("NuiInitialize", {includes = "NuiApi.h"})) 29 | end) 30 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk10/Sdk10Helper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_HELPER_KINECTDEVICESDK10 21 | #define OBS_KINECT_PLUGIN_HELPER_KINECTDEVICESDK10 22 | 23 | #ifdef OBS_KINECT_PLUGIN_HELPER 24 | #error "This file must be included before Helper.hpp" 25 | #endif 26 | 27 | #define logprefix "[obs-kinect] [sdk10] " 28 | 29 | #include 30 | 31 | enum class BacklightCompensation 32 | { 33 | AverageBrightness, 34 | CenterPriority, 35 | LowLightsPriority, 36 | CenterOnly 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/AlphaMaskShader.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_ALPHAMASKSHADER 21 | #define OBS_KINECT_PLUGIN_ALPHAMASKSHADER 22 | 23 | #include 24 | #include 25 | 26 | class AlphaMaskShader 27 | { 28 | public: 29 | AlphaMaskShader(); 30 | ~AlphaMaskShader(); 31 | 32 | gs_texture_t* Filter(gs_texture_t* color, gs_texture_t* mask); 33 | 34 | private: 35 | gs_effect_t* m_effect; 36 | gs_eparam_t* m_params_ColorImage; 37 | gs_eparam_t* m_params_MaskImage; 38 | gs_technique_t* m_tech_Draw; 39 | gs_texrender_t* m_workTexture; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk20/KinectSdk20Plugin.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "KinectSdk20Plugin.hpp" 19 | #include "KinectSdk20Device.hpp" 20 | 21 | std::string KinectSdk20Plugin::GetUniqueName() const 22 | { 23 | return "KinectV2"; 24 | } 25 | 26 | std::vector> KinectSdk20Plugin::Refresh() const 27 | { 28 | std::vector> devices; 29 | 30 | try 31 | { 32 | // We have only one device: the default one 33 | devices.emplace_back(std::make_unique()); 34 | } 35 | catch (const std::exception& e) 36 | { 37 | warnlog("%s", e.what()); 38 | } 39 | 40 | return devices; 41 | } 42 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/VisibilityMaskShader.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_VISIBILITYMASKSHADER 21 | #define OBS_KINECT_PLUGIN_VISIBILITYMASKSHADER 22 | 23 | #include 24 | #include 25 | 26 | class VisibilityMaskShader 27 | { 28 | public: 29 | VisibilityMaskShader(); 30 | ~VisibilityMaskShader(); 31 | 32 | gs_texture_t* Mask(gs_texture_t* filter, gs_texture_t* mask); 33 | 34 | private: 35 | gs_effect_t* m_effect; 36 | gs_eparam_t* m_params_FilterImage; 37 | gs_eparam_t* m_params_MaskImage; 38 | gs_technique_t* m_tech_Draw; 39 | gs_texrender_t* m_workTexture; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/TextureLerpShader.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_TEXTURELERPSHADER 21 | #define OBS_KINECT_PLUGIN_TEXTURELERPSHADER 22 | 23 | #include 24 | #include 25 | 26 | class TextureLerpShader 27 | { 28 | public: 29 | TextureLerpShader(); 30 | ~TextureLerpShader(); 31 | 32 | gs_texture_t* Lerp(gs_texture_t* from, gs_texture_t* to, gs_texture_t* factor); 33 | 34 | private: 35 | gs_effect_t* m_effect; 36 | gs_eparam_t* m_params_FactorImage; 37 | gs_eparam_t* m_params_FromImage; 38 | gs_eparam_t* m_params_ToImage; 39 | gs_technique_t* m_tech_Draw; 40 | gs_texrender_t* m_workTexture; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/obs-kinect/GreenscreenEffects/RemoveBackgroundEffect.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | gs_texture_t* RemoveBackgroundEffect::Apply(const Config& /*config*/, gs_texture_t* sourceTexture, gs_texture_t* filterTexture) 24 | { 25 | return m_alphaMaskFilter.Filter(sourceTexture, filterTexture); 26 | } 27 | 28 | obs_properties_t* RemoveBackgroundEffect::BuildProperties() 29 | { 30 | return nullptr; 31 | } 32 | 33 | void RemoveBackgroundEffect::SetDefaultValues(obs_data_t* /*settings*/) 34 | { 35 | } 36 | 37 | auto RemoveBackgroundEffect::ToConfig(obs_data_t* /*settings*/) -> Config 38 | { 39 | return {}; 40 | } 41 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/GaussianBlurShader.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_GAUSSIANBLURSHADER 21 | #define OBS_KINECT_PLUGIN_GAUSSIANBLURSHADER 22 | 23 | #include 24 | #include 25 | 26 | class GaussianBlurShader 27 | { 28 | public: 29 | GaussianBlurShader(gs_color_format colorFormat); 30 | ~GaussianBlurShader(); 31 | 32 | gs_texture_t* Blur(gs_texture_t* source, std::size_t count); 33 | 34 | private: 35 | gs_effect_t* m_effect; 36 | gs_eparam_t* m_blurEffect_Filter; 37 | gs_eparam_t* m_blurEffect_Image; 38 | gs_eparam_t* m_blurEffect_InvImageSize; 39 | gs_technique_t* m_blurEffect_DrawTech; 40 | gs_texrender_t* m_workTextureA; 41 | gs_texrender_t* m_workTextureB; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/ConvertDepthIRToColorShader.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_CONVERTDEPTHIRTOCOLORSHADER 21 | #define OBS_KINECT_PLUGIN_CONVERTDEPTHIRTOCOLORSHADER 22 | 23 | #include 24 | #include 25 | 26 | class ConvertDepthIRToColorShader 27 | { 28 | public: 29 | ConvertDepthIRToColorShader(); 30 | ~ConvertDepthIRToColorShader(); 31 | 32 | gs_texture_t* Convert(std::uint32_t width, std::uint32_t height, gs_texture_t* source, float averageValue, float standardDeviation); 33 | 34 | private: 35 | gs_effect_t* m_effect; 36 | gs_eparam_t* m_params_ColorImage; 37 | gs_eparam_t* m_params_ColorMultiplier; 38 | gs_technique_t* m_tech_Draw; 39 | gs_texrender_t* m_workTexture; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/gaussian_blur.effect: -------------------------------------------------------------------------------- 1 | uniform float4x4 ViewProj; 2 | uniform texture2d Image; 3 | uniform float2 Filter; 4 | uniform float2 InvImageSize; 5 | 6 | sampler_state textureSampler { 7 | Filter = Linear; 8 | AddressU = Clamp; 9 | AddressV = Clamp; 10 | }; 11 | 12 | struct VertData { 13 | float4 pos : POSITION; 14 | float2 uv : TEXCOORD0; 15 | }; 16 | 17 | VertData VSDefault(VertData vert_in) 18 | { 19 | VertData vert_out; 20 | vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 21 | vert_out.uv = vert_in.uv; 22 | return vert_out; 23 | } 24 | 25 | float4 PSColorFilterRGBA(VertData vert_in) : TARGET 26 | { 27 | #ifdef _OPENGL 28 | const float KernelOffsets[3] = float[3](0.0f, 1.3846153846f, 3.2307692308f); 29 | const float BlurWeights[3] = float[3](0.2270270270f, 0.3162162162f, 0.0702702703f); 30 | #else 31 | static const float KernelOffsets[3] = { 0.0f, 1.3846153846f, 3.2307692308f }; 32 | static const float BlurWeights[3] = { 0.2270270270f, 0.3162162162f, 0.0702702703f }; 33 | #endif 34 | 35 | /* Grab the current pixel to perform operations on. */ 36 | float3 color = Image.Sample(textureSampler, vert_in.uv).xyz * BlurWeights[0]; 37 | 38 | for (int i = 1; i < 3; ++i) 39 | { 40 | float2 offset = InvImageSize * Filter * KernelOffsets[i]; 41 | color += BlurWeights[i] * (Image.Sample(textureSampler, vert_in.uv + offset).xyz + 42 | Image.Sample(textureSampler, vert_in.uv - offset).xyz); 43 | } 44 | 45 | return float4(color, 1.0); 46 | } 47 | 48 | technique Draw 49 | { 50 | pass 51 | { 52 | vertex_shader = VSDefault(vert_in); 53 | pixel_shader = PSColorFilterRGBA(vert_in); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /include/obs-kinect-core/KinectPluginImpl.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTPLUGINIMPL 21 | #define OBS_KINECT_PLUGIN_KINECTPLUGINIMPL 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class KinectDevice; 29 | 30 | class OBSKINECT_API KinectPluginImpl 31 | { 32 | public: 33 | KinectPluginImpl() = default; 34 | KinectPluginImpl(const KinectPluginImpl&) = delete; 35 | KinectPluginImpl(KinectPluginImpl&&) = delete; 36 | virtual ~KinectPluginImpl(); 37 | 38 | virtual std::string GetUniqueName() const = 0; 39 | 40 | virtual std::vector> Refresh() const = 0; 41 | 42 | KinectPluginImpl& operator=(const KinectPluginImpl&) = delete; 43 | KinectPluginImpl& operator=(KinectPluginImpl&&) = delete; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk20/KinectSdk20Plugin.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTSDK20PLUGIN 21 | #define OBS_KINECT_PLUGIN_KINECTSDK20PLUGIN 22 | 23 | #include "Sdk20Helper.hpp" 24 | #include 25 | #include 26 | 27 | class KinectSdk20Plugin : public KinectPluginImpl 28 | { 29 | public: 30 | KinectSdk20Plugin() = default; 31 | KinectSdk20Plugin(const KinectSdk20Plugin&) = delete; 32 | KinectSdk20Plugin(KinectSdk20Plugin&&) = delete; 33 | ~KinectSdk20Plugin() = default; 34 | 35 | std::string GetUniqueName() const override; 36 | 37 | std::vector> Refresh() const override; 38 | 39 | KinectSdk20Plugin& operator=(const KinectSdk20Plugin&) = delete; 40 | KinectSdk20Plugin& operator=(KinectSdk20Plugin&&) = delete; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/obs-kinect/GreenscreenEffects/RemoveBackgroundEffect.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_REMOVEBACKGROUNDEFFECT 21 | #define OBS_KINECT_PLUGIN_REMOVEBACKGROUNDEFFECT 22 | 23 | #include 24 | 25 | class RemoveBackgroundEffect 26 | { 27 | public: 28 | struct Config; 29 | 30 | RemoveBackgroundEffect() = default; 31 | ~RemoveBackgroundEffect() = default; 32 | 33 | gs_texture_t* Apply(const Config& config, gs_texture_t* sourceTexture, gs_texture_t* filterTexture); 34 | 35 | static obs_properties_t* BuildProperties(); 36 | static void SetDefaultValues(obs_data_t* settings); 37 | static Config ToConfig(obs_data_t* settings); 38 | 39 | struct Config 40 | { 41 | using Effect = RemoveBackgroundEffect; 42 | }; 43 | 44 | private: 45 | AlphaMaskShader m_alphaMaskFilter; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect/FreenectDevice.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTFREENECTDEVICE 21 | #define OBS_KINECT_PLUGIN_KINECTFREENECTDEVICE 22 | 23 | #include "FreenectHelper.hpp" 24 | #include 25 | #include 26 | 27 | class KinectFreenectDevice final : public KinectDevice 28 | { 29 | public: 30 | KinectFreenectDevice(freenect_device* device, const char* serial); 31 | ~KinectFreenectDevice(); 32 | 33 | private: 34 | void ThreadFunc(std::condition_variable& cv, std::mutex& m, std::exception_ptr& exceptionPtr) override; 35 | 36 | /*static ColorFrameData RetrieveColorFrame(const libfreenect2::Frame* frame); 37 | static DepthFrameData RetrieveDepthFrame(const libfreenect2::Frame* frame); 38 | static InfraredFrameData RetrieveInfraredFrame(const libfreenect2::Frame* frame);*/ 39 | 40 | freenect_context* m_context; 41 | freenect_device* m_device; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect2/Freenect2Device.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTFREENECT2DEVICE 21 | #define OBS_KINECT_PLUGIN_KINECTFREENECT2DEVICE 22 | 23 | #include "Freenect2Helper.hpp" 24 | #include 25 | 26 | namespace libfreenect2 27 | { 28 | class Freenect2Device; 29 | class Frame; 30 | } 31 | 32 | class KinectFreenect2Device final : public KinectDevice 33 | { 34 | public: 35 | KinectFreenect2Device(libfreenect2::Freenect2Device* device); 36 | ~KinectFreenect2Device(); 37 | 38 | private: 39 | void ThreadFunc(std::condition_variable& cv, std::mutex& m, std::exception_ptr& exceptionPtr) override; 40 | 41 | static ColorFrameData RetrieveColorFrame(const libfreenect2::Frame* frame); 42 | static DepthFrameData RetrieveDepthFrame(const libfreenect2::Frame* frame); 43 | static InfraredFrameData RetrieveInfraredFrame(const libfreenect2::Frame* frame); 44 | 45 | libfreenect2::Freenect2Device* m_device; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect2/Freenect2Plugin.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "Freenect2Plugin.hpp" 19 | #include "Freenect2Device.hpp" 20 | 21 | std::string KinectFreenect2Plugin::GetUniqueName() const 22 | { 23 | return "KinectV2-Freenect2"; 24 | } 25 | 26 | std::vector> KinectFreenect2Plugin::Refresh() const 27 | { 28 | std::vector> devices; 29 | 30 | try 31 | { 32 | int deviceCount = m_freenect.enumerateDevices(); 33 | for (int i = 0; i < deviceCount; ++i) 34 | { 35 | try 36 | { 37 | if (libfreenect2::Freenect2Device* device = m_freenect.openDevice(i)) 38 | devices.emplace_back(std::make_unique(device)); 39 | else 40 | warnlog("failed to open Kinect #%d", i); 41 | } 42 | catch (const std::exception& e) 43 | { 44 | warnlog("failed to open Kinect #%d: %s", i, e.what()); 45 | } 46 | } 47 | } 48 | catch (const std::exception& e) 49 | { 50 | warnlog("%s", e.what()); 51 | } 52 | 53 | return devices; 54 | } 55 | -------------------------------------------------------------------------------- /xmake-repo/packages/l/libfreenect/xmake.lua: -------------------------------------------------------------------------------- 1 | package("libfreenect") 2 | set_homepage("https://github.com/OpenKinect/libfreenect") 3 | set_description("Drivers and libraries for the Xbox Kinect device on Windows, Linux, and OS X") 4 | set_license("GPL-2.0") 5 | 6 | set_urls("https://github.com/SirLynix/libfreenect.git") 7 | add_versions("v0.6.4", "5058631f5c87f0f671c3a68daed0f9eec642e9b4") 8 | 9 | add_deps("cmake >=3.12.4") 10 | if is_plat("windows") then 11 | add_deps("libusb >=1.0.22") 12 | else 13 | add_deps("libusb >=1.0.18") 14 | end 15 | 16 | set_policy("package.cmake_generator.ninja", false) 17 | 18 | on_install("windows", "linux", "macosx", function (package) 19 | io.replace("CMakeLists.txt", "find_package(libusb-1.0 REQUIRED)", "", {plain = true}) 20 | 21 | local configs = {} 22 | table.insert(configs, "-DBUILD_C_SYNC=OFF") 23 | table.insert(configs, "-DBUILD_EXAMPLES=OFF") 24 | table.insert(configs, "-DBUILD_FAKENECT=OFF") 25 | table.insert(configs, "-DBUILD_PYTHON=OFF") 26 | table.insert(configs, "-DBUILD_REDIST_PACKAGE=ON") -- prevents executing fwfetcher.py 27 | table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) 28 | table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) 29 | 30 | if package:config("pic") ~= false then 31 | table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON") 32 | end 33 | 34 | import("package.tools.cmake").install(package, configs, {packagedeps = "libusb"}) 35 | end) 36 | 37 | on_test(function (package) 38 | assert(package:has_cfuncs("freenect_init", {includes = "libfreenect/libfreenect.h"})) 39 | assert(package:has_cfuncs("freenect_map_depth_to_rgb", {includes = "libfreenect/libfreenect_registration.h"})) 40 | end) 41 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect2/Freenect2Plugin.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTFREENECT2PLUGIN 21 | #define OBS_KINECT_PLUGIN_KINECTFREENECT2PLUGIN 22 | 23 | #include "Freenect2Helper.hpp" 24 | #include 25 | #include 26 | #include 27 | 28 | class KinectFreenect2Plugin : public KinectPluginImpl 29 | { 30 | public: 31 | KinectFreenect2Plugin() = default; 32 | KinectFreenect2Plugin(const KinectFreenect2Plugin&) = delete; 33 | KinectFreenect2Plugin(KinectFreenect2Plugin&&) = delete; 34 | ~KinectFreenect2Plugin() = default; 35 | 36 | std::string GetUniqueName() const override; 37 | 38 | std::vector> Refresh() const override; 39 | 40 | KinectFreenect2Plugin& operator=(const KinectFreenect2Plugin&) = delete; 41 | KinectFreenect2Plugin& operator=(KinectFreenect2Plugin&&) = delete; 42 | 43 | private: 44 | mutable libfreenect2::Freenect2 m_freenect; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/obs-kinect/GreenscreenEffects/BlurBackgroundEffect.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_BLURBACKGROUNDEFFECT 21 | #define OBS_KINECT_PLUGIN_BLURBACKGROUNDEFFECT 22 | 23 | #include 24 | #include 25 | 26 | class BlurBackgroundEffect 27 | { 28 | public: 29 | struct Config; 30 | 31 | BlurBackgroundEffect(); 32 | ~BlurBackgroundEffect() = default; 33 | 34 | gs_texture_t* Apply(const Config& config, gs_texture_t* sourceTexture, gs_texture_t* filterTexture); 35 | 36 | static obs_properties_t* BuildProperties(); 37 | static void SetDefaultValues(obs_data_t* settings); 38 | static Config ToConfig(obs_data_t* settings); 39 | 40 | struct Config 41 | { 42 | using Effect = BlurBackgroundEffect; 43 | 44 | bool reversed = false; 45 | std::size_t backgroundBlurPassCount = 30; 46 | }; 47 | 48 | private: 49 | GaussianBlurShader m_backgroundBlur; 50 | TextureLerpShader m_textureLerp; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/obs-kinect/KinectPlugin.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTPLUGIN 21 | #define OBS_KINECT_PLUGIN_KINECTPLUGIN 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class KinectDevice; 30 | 31 | class KinectPlugin 32 | { 33 | public: 34 | KinectPlugin() = default; 35 | KinectPlugin(const KinectPlugin&) = delete; 36 | KinectPlugin(KinectPlugin&&) noexcept = default; 37 | ~KinectPlugin(); 38 | 39 | void Close(); 40 | 41 | const std::string& GetUniqueName() const; 42 | 43 | bool IsOpen() const; 44 | 45 | bool Open(const std::string& path); 46 | 47 | std::vector> Refresh() const; 48 | 49 | KinectPlugin& operator=(const KinectPlugin&) = delete; 50 | KinectPlugin& operator=(KinectPlugin&&) noexcept = default; 51 | 52 | private: 53 | std::unique_ptr m_impl; 54 | std::string m_uniqueName; 55 | ObsLibPtr m_lib; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/obs-kinect/GreenscreenEffects/ReplaceBackgroundEffect.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_REPLACEBACKGROUNDEFFECT 21 | #define OBS_KINECT_PLUGIN_REPLACEBACKGROUNDEFFECT 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class ReplaceBackgroundEffect 28 | { 29 | public: 30 | struct Config; 31 | 32 | ReplaceBackgroundEffect(); 33 | ~ReplaceBackgroundEffect() = default; 34 | 35 | gs_texture_t* Apply(const Config& config, gs_texture_t* sourceTexture, gs_texture_t* filterTexture); 36 | 37 | static obs_properties_t* BuildProperties(); 38 | static void SetDefaultValues(obs_data_t* settings); 39 | static Config ToConfig(obs_data_t* settings); 40 | 41 | struct Config 42 | { 43 | using Effect = ReplaceBackgroundEffect; 44 | 45 | std::string replacementTexturePath; 46 | }; 47 | 48 | private: 49 | std::string m_texturePath; 50 | std::uint64_t m_lastTextureTick; 51 | ObsImageFilePtr m_imageFile; 52 | TextureLerpShader m_textureLerp; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/obs-kinect-azuresdk/AzureKinectPlugin.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_AZUREKINECT 21 | #define OBS_KINECT_PLUGIN_AZUREKINECT 22 | 23 | #include "AzureHelper.hpp" 24 | #include 25 | #include 26 | 27 | #if __has_include() 28 | #define HAS_BODY_TRACKING 1 29 | #include "AzureKinectBodyTrackingDynFuncs.hpp" 30 | #else 31 | #define HAS_BODY_TRACKING 0 32 | #endif 33 | 34 | class AzureKinectPlugin : public KinectPluginImpl 35 | { 36 | public: 37 | AzureKinectPlugin(); 38 | AzureKinectPlugin(const AzureKinectPlugin&) = delete; 39 | AzureKinectPlugin(AzureKinectPlugin&&) = delete; 40 | ~AzureKinectPlugin(); 41 | 42 | std::string GetUniqueName() const override; 43 | 44 | std::vector> Refresh() const override; 45 | 46 | AzureKinectPlugin& operator=(const AzureKinectPlugin&) = delete; 47 | AzureKinectPlugin& operator=(AzureKinectPlugin&&) = delete; 48 | 49 | private: 50 | #if HAS_BODY_TRACKING 51 | ObsLibPtr m_bodyTrackingLib; 52 | #endif 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect/FreenectPlugin.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTFREENECTPLUGIN 21 | #define OBS_KINECT_PLUGIN_KINECTFREENECTPLUGIN 22 | 23 | #include "FreenectHelper.hpp" 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | class KinectFreenectPlugin : public KinectPluginImpl 31 | { 32 | public: 33 | KinectFreenectPlugin(); 34 | KinectFreenectPlugin(const KinectFreenectPlugin&) = delete; 35 | KinectFreenectPlugin(KinectFreenectPlugin&&) = delete; 36 | ~KinectFreenectPlugin(); 37 | 38 | std::string GetUniqueName() const override; 39 | 40 | std::vector> Refresh() const override; 41 | 42 | KinectFreenectPlugin& operator=(const KinectFreenectPlugin&) = delete; 43 | KinectFreenectPlugin& operator=(KinectFreenectPlugin&&) = delete; 44 | 45 | private: 46 | freenect_context* m_context; 47 | std::atomic_bool m_contextThreadRunning; 48 | std::thread m_contextThread; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/obs-kinect/GreenscreenEffects.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_GREENSCREENEFFECTS 21 | #define OBS_KINECT_PLUGIN_GREENSCREENEFFECTS 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | using GreenscreenEffects = std::variant; 29 | 30 | // Build a std::variant from std::variant 31 | template 32 | struct GreenscreenEffectConfigVariantGen; 33 | 34 | template 35 | struct GreenscreenEffectConfigVariantGen> 36 | { 37 | template 38 | struct ToConfig 39 | { 40 | using R = typename T::Config; 41 | }; 42 | 43 | template 44 | using ToConfig_t = typename ToConfig::R; 45 | 46 | using Type = std::variant...>; 47 | }; 48 | 49 | using GreenscreenEffectConfigs = typename GreenscreenEffectConfigVariantGen::Type; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /include/obs-kinect-core/Enums.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_ENUMS 21 | #define OBS_KINECT_PLUGIN_ENUMS 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | enum EnabledSources 28 | { 29 | Source_BackgroundRemoval = 1 << 0, 30 | Source_Body = 1 << 1, 31 | Source_Color = 1 << 2, 32 | Source_ColorMappedBody = 1 << 3, 33 | Source_ColorMappedDepth = 1 << 4, 34 | Source_ColorToDepthMapping = 1 << 5, 35 | Source_Depth = 1 << 6, 36 | Source_Infrared = 1 << 7 37 | }; 38 | 39 | using SourceFlags = std::uint32_t; 40 | 41 | enum class ExposureControl 42 | { 43 | FullyAuto, 44 | SemiAuto, 45 | Manual 46 | }; 47 | 48 | enum class PowerlineFrequency 49 | { 50 | Disabled, 51 | Freq50, 52 | Freq60 53 | }; 54 | 55 | enum class ProcessPriority 56 | { 57 | Normal = 0, 58 | AboveNormal = 1, 59 | High = 2 60 | }; 61 | 62 | enum class WhiteBalanceMode 63 | { 64 | Auto, 65 | Manual, 66 | Unknown 67 | }; 68 | 69 | OBSKINECT_API std::string EnabledSourceToString(SourceFlags flags); 70 | OBSKINECT_API const char* ProcessPriorityToString(ProcessPriority priority); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /include/obs-kinect-core/KinectDeviceAccess.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTDEVICEACCESS 21 | #define OBS_KINECT_PLUGIN_KINECTDEVICEACCESS 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class OBSKINECT_API KinectDeviceAccess 29 | { 30 | friend KinectDevice; 31 | 32 | public: 33 | KinectDeviceAccess(const KinectDeviceAccess&) = delete; 34 | KinectDeviceAccess(KinectDeviceAccess&& access) noexcept; 35 | ~KinectDeviceAccess(); 36 | 37 | const KinectDevice& GetDevice() const; 38 | SourceFlags GetEnabledSourceFlags() const; 39 | 40 | KinectFrameConstPtr GetLastFrame(); 41 | 42 | void SetEnabledSourceFlags(SourceFlags enabledSources); 43 | 44 | void UpdateDeviceParameters(obs_data_t* settings); 45 | 46 | KinectDeviceAccess& operator=(const KinectDeviceAccess&) = delete; 47 | KinectDeviceAccess& operator=(KinectDeviceAccess&& access) noexcept; 48 | 49 | private: 50 | KinectDeviceAccess(KinectDevice& owner, KinectDevice::AccessData* accessData); 51 | 52 | KinectDevice* m_owner; 53 | KinectDevice::AccessData* m_data; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/obs-kinect-core/Enums.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | 20 | std::string EnabledSourceToString(SourceFlags flags) 21 | { 22 | std::string str; 23 | str.reserve(64); 24 | if (flags & Source_BackgroundRemoval) 25 | str += "BackgroundRemoval | "; 26 | 27 | if (flags & Source_Body) 28 | str += "Body | "; 29 | 30 | if (flags & Source_Color) 31 | str += "Color | "; 32 | 33 | if (flags & Source_ColorMappedBody) 34 | str += "ColorMappedBody | "; 35 | 36 | if (flags & Source_ColorMappedDepth) 37 | str += "ColorMappedDepth | "; 38 | 39 | if (flags & Source_ColorToDepthMapping) 40 | str += "ColorToDepth | "; 41 | 42 | if (flags & Source_Depth) 43 | str += "Depth | "; 44 | 45 | if (flags & Source_Infrared) 46 | str += "Infrared | "; 47 | 48 | if (!str.empty()) 49 | str.resize(str.size() - 3); 50 | else 51 | str = ""; 52 | 53 | return str; 54 | } 55 | 56 | const char* ProcessPriorityToString(ProcessPriority priority) 57 | { 58 | switch (priority) 59 | { 60 | case ProcessPriority::Normal: return "Normal"; 61 | case ProcessPriority::AboveNormal: return "AboveNormal"; 62 | case ProcessPriority::High: return "High"; 63 | } 64 | 65 | return ""; 66 | } 67 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk10/KinectSdk10Plugin.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTSDK10PLUGIN 21 | #define OBS_KINECT_PLUGIN_KINECTSDK10PLUGIN 22 | 23 | #include "Sdk10Helper.hpp" 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #if __has_include() 30 | #define HAS_BACKGROUND_REMOVAL 1 31 | #include 32 | #else 33 | #define HAS_BACKGROUND_REMOVAL 0 34 | #endif 35 | 36 | namespace Dyn 37 | { 38 | #if HAS_BACKGROUND_REMOVAL 39 | using NuiCreateBackgroundRemovedColorStreamPtr = decltype(&::NuiCreateBackgroundRemovedColorStream); 40 | 41 | extern NuiCreateBackgroundRemovedColorStreamPtr NuiCreateBackgroundRemovedColorStream; 42 | #endif 43 | } 44 | 45 | class KinectSdk10Plugin : public KinectPluginImpl 46 | { 47 | public: 48 | KinectSdk10Plugin(); 49 | KinectSdk10Plugin(const KinectSdk10Plugin&) = delete; 50 | KinectSdk10Plugin(KinectSdk10Plugin&&) = delete; 51 | ~KinectSdk10Plugin(); 52 | 53 | std::string GetUniqueName() const override; 54 | 55 | std::vector> Refresh() const override; 56 | 57 | KinectSdk10Plugin& operator=(const KinectSdk10Plugin&) = delete; 58 | KinectSdk10Plugin& operator=(KinectSdk10Plugin&&) = delete; 59 | 60 | private: 61 | #if HAS_BACKGROUND_REMOVAL 62 | ObsLibPtr m_backgroundRemovalLib; 63 | #endif 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /include/obs-kinect-core/Win32Helper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_WIN32HELPER 21 | #define OBS_KINECT_PLUGIN_WIN32HELPER 22 | 23 | #include 24 | #include 25 | 26 | #ifndef WIN32_LEAN_AND_MEAN 27 | #define WIN32_LEAN_AND_MEAN 28 | #endif 29 | 30 | #ifndef NOMINMAX 31 | #define NOMINMAX 32 | #endif 33 | 34 | #include 35 | 36 | struct CloseHandleDeleter 37 | { 38 | void operator()(HANDLE handle) const 39 | { 40 | if (handle != INVALID_HANDLE_VALUE) 41 | CloseHandle(handle); 42 | } 43 | }; 44 | 45 | using HandlePtr = std::unique_ptr, CloseHandleDeleter>; 46 | 47 | template 48 | struct CloseDeleter 49 | { 50 | void operator()(Interface* handle) const 51 | { 52 | handle->Close(); 53 | } 54 | }; 55 | 56 | template 57 | struct ReleaseDeleter 58 | { 59 | void operator()(Interface* handle) const 60 | { 61 | handle->Release(); 62 | } 63 | }; 64 | 65 | template using ClosePtr = std::unique_ptr>; 66 | template using ReleasePtr = std::unique_ptr>; 67 | 68 | // Kinect v1 sensor deleter (after NuiInitialize call) 69 | template 70 | struct SensorDeleter 71 | { 72 | void operator()(NuiSensor* handle) const 73 | { 74 | handle->NuiShutdown(); 75 | } 76 | }; 77 | 78 | template using InitializedNuiSensorPtr = std::unique_ptr>; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/obs-kinect-core/KinectDeviceAccess.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | 20 | KinectDeviceAccess::KinectDeviceAccess(KinectDevice& owner, KinectDevice::AccessData* accessData) : 21 | m_owner(&owner), 22 | m_data(accessData) 23 | { 24 | } 25 | 26 | KinectDeviceAccess::KinectDeviceAccess(KinectDeviceAccess&& access) noexcept 27 | { 28 | m_owner = access.m_owner; 29 | m_data = access.m_data; 30 | 31 | access.m_owner = nullptr; 32 | access.m_data = nullptr; 33 | } 34 | 35 | KinectDeviceAccess::~KinectDeviceAccess() 36 | { 37 | if (m_owner) 38 | m_owner->ReleaseAccess(m_data); 39 | } 40 | 41 | const KinectDevice& KinectDeviceAccess::GetDevice() const 42 | { 43 | assert(m_owner); 44 | return *m_owner; 45 | } 46 | 47 | SourceFlags KinectDeviceAccess::GetEnabledSourceFlags() const 48 | { 49 | return m_data->enabledSources; 50 | } 51 | 52 | KinectFrameConstPtr KinectDeviceAccess::GetLastFrame() 53 | { 54 | assert(m_owner); 55 | return m_owner->GetLastFrame(); 56 | } 57 | 58 | void KinectDeviceAccess::SetEnabledSourceFlags(SourceFlags enabledSources) 59 | { 60 | m_data->enabledSources = enabledSources; 61 | m_owner->UpdateEnabledSources(); 62 | } 63 | 64 | void KinectDeviceAccess::UpdateDeviceParameters(obs_data_t* settings) 65 | { 66 | m_owner->UpdateDeviceParameters(m_data, settings); 67 | } 68 | 69 | KinectDeviceAccess& KinectDeviceAccess::operator=(KinectDeviceAccess&& access) noexcept 70 | { 71 | std::swap(m_owner, access.m_owner); 72 | std::swap(m_data, access.m_data); 73 | 74 | return *this; 75 | } 76 | -------------------------------------------------------------------------------- /src/obs-kinect-azuresdk/AzureKinectDevice.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_AZUREKINECTDEVICE 21 | #define OBS_KINECT_PLUGIN_AZUREKINECTDEVICE 22 | 23 | #include "AzureHelper.hpp" 24 | #include 25 | #include 26 | 27 | enum class ColorResolution 28 | { 29 | R1280x720 = 0, 30 | R1920x1080 = 1, 31 | R2560x1440 = 2, 32 | R2048x1536 = 3, 33 | R3840x2160 = 4, 34 | R4096x3072 = 5 35 | }; 36 | 37 | enum class DepthMode 38 | { 39 | Passive = 0, 40 | NFOVUnbinned = 1, 41 | NFOV2x2Binned = 2, 42 | WFOVUnbinned = 3, 43 | WFOV2x2Binned = 4 44 | }; 45 | 46 | class AzureKinectDevice final : public KinectDevice 47 | { 48 | public: 49 | AzureKinectDevice(std::uint32_t deviceIndex); 50 | ~AzureKinectDevice(); 51 | 52 | obs_properties_t* CreateProperties() const; 53 | 54 | private: 55 | void HandleBoolParameterUpdate(const std::string& parameterName, bool value); 56 | void HandleIntParameterUpdate(const std::string& parameterName, long long value); 57 | void ThreadFunc(std::condition_variable& cv, std::mutex& m, std::exception_ptr& exceptionPtr) override; 58 | 59 | static BodyIndexFrameData ToBodyIndexFrame(const k4a::image& image); 60 | static ColorFrameData ToColorFrame(const k4a::image& image); 61 | static DepthFrameData ToDepthFrame(const k4a::image& image); 62 | static InfraredFrameData ToInfraredFrame(const k4a::image& image); 63 | 64 | k4a::device m_device; 65 | std::atomic m_colorResolution; 66 | std::atomic m_depthMode; 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /xmake-repo/packages/k/k4a/xmake.lua: -------------------------------------------------------------------------------- 1 | package("k4a") 2 | set_homepage("https://Azure.com/Kinect") 3 | set_description("A cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device.") 4 | set_license("MIT") 5 | 6 | set_urls("https://github.com/microsoft/Azure-Kinect-Sensor-SDK.git") 7 | add_versions("v1.4.1", "73106554449c64aff6b068078f0eada50c4474e99945b5ceb6ea4aab9a68457f") 8 | 9 | add_deps("cmake") 10 | 11 | if is_plat("linux", "macosx") then 12 | add_deps("libx11", "libxrandr", "libxrender", "libxinerama", "libxfixes", "libxcursor", "libxi", "libxext") 13 | end 14 | 15 | on_fetch("windows", function (package) 16 | -- KINECTSDKAZURE_DIR is not an official Microsoft env 17 | local defaultInstallPath = os.getenv("KINECTSDKAZURE_DIR") or path.join(os.getenv("ProgramFiles"), "Azure Kinect SDK v1.4.1", "sdk") 18 | if os.isdir(defaultInstallPath) then 19 | local archFolder = package:is_arch("x86") and "x86" or "amd64" 20 | 21 | local platformFolder = path.join(defaultInstallPath, "windows-desktop", archFolder, "release") 22 | 23 | local result = {} 24 | result.includedirs = { defaultInstallPath .. "/include" } 25 | result.linkdirs = { platformFolder .. "/lib/" } 26 | 27 | result.links = { "k4a" } 28 | result.libfiles = { 29 | platformFolder .. "/bin/depthengine_2_0.dll", 30 | platformFolder .. "/bin/k4a.dll" 31 | } 32 | 33 | return result 34 | end 35 | end) 36 | 37 | on_install("windows", "linux", "macosx", function (package) 38 | -- There's no option to disable examples, tests or tool building 39 | io.replace("CMakeLists.txt", "add_subdirectory(examples)", "", {plain = true}) 40 | io.replace("CMakeLists.txt", "add_subdirectory(tests)", "", {plain = true}) 41 | io.replace("CMakeLists.txt", "add_subdirectory(tools)", "", {plain = true}) 42 | 43 | local configs = {} 44 | table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) 45 | table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) 46 | import("package.tools.cmake").install(package, configs) 47 | end) 48 | 49 | on_test(function (package) 50 | assert(package:has_cfuncs("k4a_device_get_installed_count", {includes = "k4a/k4a.h"})) 51 | end) 52 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/GreenScreenFilterShader.inl: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | 20 | template 21 | void GreenScreenFilterShader::SetBodyParams(const Params& params) 22 | { 23 | std::uint32_t bodyIndexWidth = gs_texture_get_width(params.bodyIndexTexture); 24 | std::uint32_t bodyIndexHeight = gs_texture_get_height(params.bodyIndexTexture); 25 | 26 | vec2 invDepthSize = { 1.f / bodyIndexWidth, 1.f / bodyIndexHeight }; 27 | 28 | gs_effect_set_vec2(m_params_InvDepthImageSize, &invDepthSize); 29 | gs_effect_set_texture(m_params_BodyIndexImage, params.bodyIndexTexture); 30 | gs_effect_set_texture(m_params_DepthMappingImage, params.colorToDepthTexture); 31 | } 32 | 33 | template 34 | void GreenScreenFilterShader::SetDepthParams(const Params& params) 35 | { 36 | std::uint32_t depthWidth = gs_texture_get_width(params.depthTexture); 37 | std::uint32_t depthHeight = gs_texture_get_height(params.depthTexture); 38 | 39 | vec2 invDepthSize = { 1.f / depthWidth, 1.f / depthHeight }; 40 | 41 | constexpr float maxDepthValue = 0xFFFF; 42 | constexpr float invMaxDepthValue = 1.f / maxDepthValue; 43 | 44 | gs_effect_set_vec2(m_params_InvDepthImageSize, &invDepthSize); 45 | gs_effect_set_texture(m_params_DepthImage, params.depthTexture); 46 | gs_effect_set_texture(m_params_DepthMappingImage, params.colorToDepthTexture); 47 | gs_effect_set_float(m_params_InvDepthProgressive, maxDepthValue / params.progressiveDepth); 48 | gs_effect_set_float(m_params_MaxDepth, params.maxDepth * invMaxDepthValue); 49 | gs_effect_set_float(m_params_MinDepth, params.minDepth * invMaxDepthValue); 50 | } 51 | -------------------------------------------------------------------------------- /src/obs-kinect/KinectPlugin.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | KinectPlugin::~KinectPlugin() 23 | { 24 | Close(); 25 | } 26 | 27 | void KinectPlugin::Close() 28 | { 29 | m_impl.reset(); 30 | m_lib.reset(); 31 | } 32 | 33 | const std::string& KinectPlugin::GetUniqueName() const 34 | { 35 | return m_uniqueName; 36 | } 37 | 38 | bool KinectPlugin::IsOpen() const 39 | { 40 | return m_impl != nullptr; 41 | } 42 | 43 | bool KinectPlugin::Open(const std::string& path) 44 | { 45 | void* libPtr = os_dlopen(path.c_str()); 46 | #ifndef _WIN32 47 | if (!libPtr) 48 | { 49 | libPtr = os_dlopen(("./" + path).c_str()); 50 | if (!libPtr) 51 | libPtr = os_dlopen(("/app/plugins/lib/obs-plugins/" + path).c_str()); 52 | } 53 | #endif 54 | 55 | ObsLibPtr lib(libPtr); 56 | if (!lib) 57 | return false; 58 | 59 | using CreatePlugin = KinectPluginImpl * (*)(std::uint32_t version); 60 | 61 | CreatePlugin createImpl = reinterpret_cast(os_dlsym(lib.get(), "ObsKinect_CreatePlugin")); 62 | if (!createImpl) 63 | { 64 | warnlog("failed to get ObsKinect_CreatePlugin symbol, dismissing %s", path.c_str()); 65 | return false; 66 | } 67 | 68 | m_impl.reset(createImpl(OBSKINECT_VERSION)); 69 | if (!m_impl) 70 | { 71 | warnlog("failed to get plugin implementation for %s, dismissing", path.c_str()); 72 | return false; 73 | } 74 | 75 | m_lib = std::move(lib); 76 | m_uniqueName = m_impl->GetUniqueName(); 77 | 78 | return true; 79 | } 80 | 81 | std::vector> KinectPlugin::Refresh() const 82 | { 83 | assert(IsOpen()); 84 | 85 | return m_impl->Refresh(); 86 | } 87 | -------------------------------------------------------------------------------- /src/obs-kinect/KinectDeviceRegistry.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTDEVICEREGISTRY 21 | #define OBS_KINECT_PLUGIN_KINECTDEVICEREGISTRY 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | class KinectSource; 32 | 33 | class KinectDeviceRegistry 34 | { 35 | friend KinectSource; 36 | 37 | public: 38 | using Callback = std::function; 39 | 40 | KinectDeviceRegistry() = default; 41 | KinectDeviceRegistry(const KinectDeviceRegistry&) = delete; 42 | KinectDeviceRegistry(KinectDeviceRegistry&&) = delete; 43 | ~KinectDeviceRegistry() = default; 44 | 45 | void ForEachDevice(const Callback& callback) const; 46 | 47 | KinectDevice* GetDevice(const std::string& deviceName) const; 48 | 49 | void Refresh(); 50 | 51 | bool RegisterPlugin(const std::string& path); 52 | 53 | KinectDeviceRegistry& operator=(const KinectDeviceRegistry&) = delete; 54 | KinectDeviceRegistry& operator=(KinectDeviceRegistry&&) = delete; 55 | 56 | private: 57 | void RegisterSource(KinectSource* source); 58 | void UnregisterSource(KinectSource* source); 59 | 60 | struct PluginData 61 | { 62 | struct Device 63 | { 64 | std::string uniqueName; 65 | std::unique_ptr device; 66 | }; 67 | 68 | KinectPlugin plugin; 69 | std::vector devices; //< Order matters 70 | }; 71 | 72 | std::unordered_map m_deviceByName; 73 | std::unordered_set m_sources; 74 | std::vector m_plugins; 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk10/KinectSdk10Plugin.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "KinectSdk10Plugin.hpp" 19 | #include "KinectSdk10Device.hpp" 20 | 21 | KinectSdk10Plugin::KinectSdk10Plugin() 22 | { 23 | #if HAS_BACKGROUND_REMOVAL 24 | #ifdef _WIN64 25 | m_backgroundRemovalLib.reset(os_dlopen("KinectBackgroundRemoval180_64")); 26 | #else 27 | m_backgroundRemovalLib.reset(os_dlopen("KinectBackgroundRemoval180_32")); 28 | #endif 29 | 30 | if (m_backgroundRemovalLib) 31 | Dyn::NuiCreateBackgroundRemovedColorStream = reinterpret_cast(os_dlsym(m_backgroundRemovalLib.get(), "NuiCreateBackgroundRemovedColorStream")); 32 | else 33 | Dyn::NuiCreateBackgroundRemovedColorStream = nullptr; 34 | #endif 35 | } 36 | 37 | KinectSdk10Plugin::~KinectSdk10Plugin() 38 | { 39 | #if HAS_BACKGROUND_REMOVAL 40 | Dyn::NuiCreateBackgroundRemovedColorStream = nullptr; 41 | #endif 42 | } 43 | 44 | std::string KinectSdk10Plugin::GetUniqueName() const 45 | { 46 | return "KinectV1"; 47 | } 48 | 49 | std::vector> KinectSdk10Plugin::Refresh() const 50 | { 51 | std::vector> devices; 52 | try 53 | { 54 | int count; 55 | if (FAILED(NuiGetSensorCount(&count))) 56 | throw std::runtime_error("NuiGetSensorCount failed"); 57 | 58 | for (int i = 0; i < count; ++i) 59 | { 60 | try 61 | { 62 | devices.emplace_back(std::make_unique(i)); 63 | } 64 | catch (const std::exception& e) 65 | { 66 | warnlog("failed to open Kinect #%d: %s", i, e.what()); 67 | } 68 | } 69 | } 70 | catch (const std::exception& e) 71 | { 72 | warnlog("%s", e.what()); 73 | } 74 | 75 | return devices; 76 | } 77 | 78 | namespace Dyn 79 | { 80 | #if HAS_BACKGROUND_REMOVAL 81 | NuiCreateBackgroundRemovedColorStreamPtr NuiCreateBackgroundRemovedColorStream = nullptr; 82 | #endif 83 | } 84 | -------------------------------------------------------------------------------- /src/obs-kinect-azuresdk/AzureKinectBodyTrackingDynFuncs.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #if __has_include() 19 | 20 | #include "AzureKinectBodyTrackingDynFuncs.hpp" 21 | #include "AzureHelper.hpp" 22 | #include 23 | #include 24 | 25 | namespace 26 | { 27 | bool s_bodyTrackingSdkLoaded = false; 28 | } 29 | 30 | bool LoadBodyTrackingSdk(void* obsModule) 31 | { 32 | auto LoadFunc = [&](auto& funcPtr, const char* name) 33 | { 34 | funcPtr = reinterpret_cast>(os_dlsym(obsModule, name)); 35 | if (!funcPtr) 36 | throw std::runtime_error("failed to load " + std::string(name)); 37 | }; 38 | 39 | try 40 | { 41 | #define OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC(Ret, Name, ...) LoadFunc(Name, #Name); 42 | OBS_KINECT_AZURE_SDK_BODY_TRACKING_FOREACH_FUNC(OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC) 43 | #undef OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC 44 | } 45 | catch (const std::exception& e) 46 | { 47 | errorlog("failed to load Azure Kinect Body Tracking SDK: %s", e.what()); 48 | UnloadBodyTrackingSdk(); //< reset every function pointer to nullptr 49 | return false; 50 | } 51 | 52 | s_bodyTrackingSdkLoaded = true; 53 | 54 | return true; 55 | } 56 | 57 | bool IsBodyTrackingSdkLoaded() 58 | { 59 | return s_bodyTrackingSdkLoaded; 60 | } 61 | 62 | void UnloadBodyTrackingSdk() 63 | { 64 | #define OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC(Ret, Name, ...) Name = nullptr; 65 | OBS_KINECT_AZURE_SDK_BODY_TRACKING_FOREACH_FUNC(OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC) 66 | #undef OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC 67 | 68 | s_bodyTrackingSdkLoaded = false; 69 | } 70 | 71 | #define OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC(Ret, Name, ...) Ret (*Name)(__VA_ARGS__) = nullptr; 72 | OBS_KINECT_AZURE_SDK_BODY_TRACKING_FOREACH_FUNC(OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC) 73 | #undef OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/obs-kinect/GreenscreenEffects/BlurBackgroundEffect.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | BlurBackgroundEffect::BlurBackgroundEffect() : 24 | m_backgroundBlur(GS_RGBA) 25 | { 26 | } 27 | 28 | gs_texture_t* BlurBackgroundEffect::Apply(const Config& config, gs_texture_t* sourceTexture, gs_texture_t* filterTexture) 29 | { 30 | if (config.backgroundBlurPassCount == 0) 31 | return sourceTexture; 32 | 33 | gs_texture_t* blurredBackground = m_backgroundBlur.Blur(sourceTexture, config.backgroundBlurPassCount); 34 | gs_texture_t* from = blurredBackground; 35 | gs_texture_t* to = sourceTexture; 36 | if (config.reversed) 37 | std::swap(from, to); 38 | 39 | return m_textureLerp.Lerp(from, to, filterTexture); 40 | } 41 | 42 | obs_properties_t* BlurBackgroundEffect::BuildProperties() 43 | { 44 | obs_properties_t* properties = obs_properties_create(); 45 | 46 | obs_properties_add_int_slider(properties, "blurbackground_blurstrength", obs_module_text("ObsKinect.BlurBackground.Strength"), 0, 50, 1); 47 | obs_properties_add_bool(properties, "blurbackground_reversed", obs_module_text("ObsKinect.BlurBackground.Reversed")); 48 | 49 | return properties; 50 | } 51 | 52 | void BlurBackgroundEffect::SetDefaultValues(obs_data_t* settings) 53 | { 54 | Config defaultValues; 55 | obs_data_set_default_int(settings, "blurbackground_blurstrength", defaultValues.backgroundBlurPassCount); 56 | obs_data_set_default_bool(settings, "blurbackground_reversed", defaultValues.reversed); 57 | } 58 | 59 | auto BlurBackgroundEffect::ToConfig(obs_data_t* settings) -> Config 60 | { 61 | Config config; 62 | config.backgroundBlurPassCount = obs_data_get_int(settings, "blurbackground_blurstrength"); 63 | config.reversed = obs_data_get_bool(settings, "blurbackground_reversed"); 64 | 65 | return config; 66 | } 67 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk20/KinectSdk20Device.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTDEVICESDK20 21 | #define OBS_KINECT_PLUGIN_KINECTDEVICESDK20 22 | 23 | #include "Sdk20Helper.hpp" 24 | #include 25 | #include 26 | #include "NuiSensorLibHelper.hpp" 27 | #include 28 | 29 | class KinectSdk20Device final : public KinectDevice 30 | { 31 | public: 32 | KinectSdk20Device(); 33 | ~KinectSdk20Device(); 34 | 35 | obs_properties_t* CreateProperties() const override; 36 | 37 | bool MapColorToDepth(const std::uint16_t* depthValues, std::size_t valueCount, std::size_t colorPixelCount, DepthMappingFrameData::DepthCoordinates* depthCoordinatesOut) const; 38 | 39 | static void SetServicePriority(ProcessPriority priority); 40 | 41 | private: 42 | void HandleDoubleParameterUpdate(const std::string& parameterName, double value) override; 43 | void HandleIntParameterUpdate(const std::string& parameterName, long long value) override; 44 | void ThreadFunc(std::condition_variable& cv, std::mutex& m, std::exception_ptr& exceptionPtr) override; 45 | 46 | static BodyIndexFrameData RetrieveBodyIndexFrame(IMultiSourceFrame* multiSourceFrame); 47 | static ColorFrameData RetrieveColorFrame(IMultiSourceFrame* multiSourceFrame); 48 | static DepthFrameData RetrieveDepthFrame(IMultiSourceFrame* multiSourceFrame); 49 | static DepthMappingFrameData RetrieveDepthMappingFrame(const KinectSdk20Device& device, const ColorFrameData& colorFrame, const DepthFrameData& depthFrame); 50 | static InfraredFrameData RetrieveInfraredFrame(IMultiSourceFrame* multiSourceFrame); 51 | 52 | ReleasePtr m_kinectSensor; 53 | ReleasePtr m_coordinateMapper; 54 | ClosePtr m_openedKinectSensor; 55 | 56 | #if HAS_NUISENSOR_LIB 57 | NuiSensorHandle m_nuiHandle; 58 | #endif 59 | 60 | static ProcessPriority s_servicePriority; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /xmake-repo/packages/k/kinect-sdk1-toolkit/xmake.lua: -------------------------------------------------------------------------------- 1 | package("kinect-sdk1-toolkit") 2 | set_homepage("https://www.microsoft.com/en-us/download/details.aspx?id=40276") 3 | set_description("The Kinect for Windows Developer Toolkit contains updated and new source code samples, Kinect Fusion, Kinect Interactions, Kinect Studio, and other resources to simplify developing Kinect for Windows applications.") 4 | 5 | add_configs("background_removal", { description = "Enable background removal support.", default = true, type = "boolean"}) 6 | add_configs("facetrack", { description = "Enables facetracking support.", default = true, type = "boolean"}) 7 | add_configs("fusion", { description = "Enable fusion support.", default = true, type = "boolean"}) 8 | add_configs("interaction", { description = "Enable interaction support.", default = true, type = "boolean"}) 9 | 10 | on_fetch("windows", function (package, opt) 11 | if not package:config("shared") then 12 | os.raise("Kinect for Windows Developer Toolkit is only available in shared mode") 13 | end 14 | 15 | local toolkitDir = os.getenv("KINECT_TOOLKIT_DIR") 16 | if toolkitDir and os.isdir(toolkitDir) then 17 | local libFolder = package:is_arch("x86") and "x86" or "amd64" 18 | local libSuffix = package:is_arch("x86") and "_32" or "_64" 19 | 20 | local result = {} 21 | result.includedirs = { toolkitDir .. "/inc" } 22 | result.linkdirs = { toolkitDir .. "/lib/" .. libFolder } 23 | result.links = {} 24 | result.libfiles = {} 25 | 26 | local function AddLib(name) 27 | table.insert(result.libfiles, toolkitDir .. "/Redist/" .. libFolder .. "/" .. name .. ".dll") 28 | table.insert(result.links, name) 29 | end 30 | 31 | if package:config("background_removal") then 32 | AddLib("KinectBackgroundRemoval180" .. libSuffix) 33 | end 34 | if package:config("facetrack") then 35 | AddLib("FaceTrackLib") 36 | end 37 | if package:config("fusion") then 38 | AddLib("KinectFusion180" .. libSuffix) 39 | end 40 | if package:config("interaction") then 41 | AddLib("KinectInteraction180" .. libSuffix) 42 | end 43 | 44 | return result 45 | end 46 | end) 47 | 48 | on_install(function () 49 | os.raise("Due to its license, the Kinect for Windows Developer Toolkit cannot be automatically installed, please download and install it yourself from https://www.microsoft.com/en-us/download/details.aspx?id=40276") 50 | end) 51 | 52 | on_test(function (package) 53 | assert(package:has_cfuncs("NuiCreateBackgroundRemovedColorStream", {includes = "KinectBackgroundRemoval.h"})) 54 | end) 55 | -------------------------------------------------------------------------------- /include/obs-kinect-core/KinectFrame.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTFRAME 21 | #define OBS_KINECT_PLUGIN_KINECTFRAME 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | struct FrameData 30 | { 31 | std::uint32_t width; 32 | std::uint32_t height; 33 | std::uint32_t pitch; 34 | std::vector memory; //< TODO: Reuse memory 35 | }; 36 | 37 | // A8 (alpha frame) 38 | struct BackgroundRemovalFrameData : FrameData 39 | { 40 | ObserverPtr ptr; 41 | }; 42 | 43 | // R8 (body index frame, 0 is player one, 1 is player two, etc. and 255 is no player) 44 | struct BodyIndexFrameData : FrameData 45 | { 46 | ObserverPtr ptr; 47 | }; 48 | 49 | // Color frame (custom format) 50 | struct ColorFrameData : FrameData 51 | { 52 | gs_color_format format; 53 | ObserverPtr ptr; 54 | }; 55 | 56 | // R16 depth frame (depth in millimeters) 57 | struct DepthFrameData : FrameData 58 | { 59 | ObserverPtr ptr; 60 | }; 61 | 62 | // R16 infrared frame 63 | struct InfraredFrameData : FrameData 64 | { 65 | ObserverPtr ptr; 66 | }; 67 | 68 | // RG16F depth mapping frame 69 | struct DepthMappingFrameData : FrameData 70 | { 71 | struct DepthCoordinates 72 | { 73 | float x; 74 | float y; 75 | }; 76 | 77 | ObserverPtr ptr; 78 | }; 79 | 80 | struct KinectFrame 81 | { 82 | std::optional backgroundRemovalFrame; 83 | std::optional bodyIndexFrame; 84 | std::optional colorMappedBodyFrame; 85 | std::optional colorFrame; 86 | std::optional colorMappedDepthFrame; 87 | std::optional depthFrame; 88 | std::optional depthMappingFrame; 89 | std::optional infraredFrame; 90 | std::uint64_t frameIndex; 91 | }; 92 | 93 | using KinectFramePtr = std::shared_ptr; 94 | using KinectFrameConstPtr = std::shared_ptr; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/AlphaMaskShader.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | AlphaMaskShader::AlphaMaskShader() 24 | { 25 | ObsMemoryPtr effectFilename(obs_module_file("alpha_mask.effect")); 26 | 27 | ObsGraphics gfx; 28 | 29 | char* errStr = nullptr; 30 | m_effect = gs_effect_create_from_file(effectFilename.get(), &errStr); 31 | ObsMemoryPtr errStrOwner(errStr); 32 | 33 | if (m_effect) 34 | { 35 | m_params_ColorImage = gs_effect_get_param_by_name(m_effect, "ColorImage"); 36 | m_params_MaskImage = gs_effect_get_param_by_name(m_effect, "MaskImage"); 37 | m_tech_Draw = gs_effect_get_technique(m_effect, "Draw"); 38 | 39 | m_workTexture = gs_texrender_create(GS_RGBA, GS_ZS_NONE); 40 | } 41 | else 42 | { 43 | std::string err("failed to create effect: "); 44 | err.append((errStr) ? errStr : "shader error"); 45 | 46 | throw std::runtime_error(err); 47 | } 48 | } 49 | 50 | AlphaMaskShader::~AlphaMaskShader() 51 | { 52 | ObsGraphics gfx; 53 | 54 | gs_effect_destroy(m_effect); 55 | gs_texrender_destroy(m_workTexture); 56 | } 57 | 58 | gs_texture_t* AlphaMaskShader::Filter(gs_texture_t* color, gs_texture_t* mask) 59 | { 60 | std::uint32_t colorWidth = gs_texture_get_width(color); 61 | std::uint32_t colorHeight = gs_texture_get_height(color); 62 | 63 | gs_texrender_reset(m_workTexture); 64 | if (!gs_texrender_begin(m_workTexture, colorWidth, colorHeight)) 65 | return nullptr; 66 | 67 | vec4 black = { 0.f, 0.f, 0.f, 0.f }; 68 | gs_clear(GS_CLEAR_COLOR, &black, 0.f, 0); 69 | gs_ortho(0.0f, float(colorWidth), 0.0f, float(colorHeight), -100.0f, 100.0f); 70 | 71 | gs_effect_set_texture(m_params_ColorImage, color); 72 | gs_effect_set_texture(m_params_MaskImage, mask); 73 | 74 | gs_technique_begin(m_tech_Draw); 75 | gs_technique_begin_pass(m_tech_Draw, 0); 76 | gs_draw_sprite(nullptr, 0, colorWidth, colorHeight); 77 | gs_technique_end_pass(m_tech_Draw); 78 | gs_technique_end(m_tech_Draw); 79 | 80 | gs_texrender_end(m_workTexture); 81 | 82 | return gs_texrender_get_texture(m_workTexture); 83 | } 84 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/VisibilityMaskShader.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | VisibilityMaskShader::VisibilityMaskShader() 24 | { 25 | ObsMemoryPtr effectFilename(obs_module_file("visibility_mask.effect")); 26 | 27 | ObsGraphics gfx; 28 | 29 | char* errStr = nullptr; 30 | m_effect = gs_effect_create_from_file(effectFilename.get(), &errStr); 31 | ObsMemoryPtr errStrOwner(errStr); 32 | 33 | if (m_effect) 34 | { 35 | m_params_FilterImage = gs_effect_get_param_by_name(m_effect, "FilterImage"); 36 | m_params_MaskImage = gs_effect_get_param_by_name(m_effect, "MaskImage"); 37 | m_tech_Draw = gs_effect_get_technique(m_effect, "Draw"); 38 | 39 | m_workTexture = gs_texrender_create(GS_R8, GS_ZS_NONE); 40 | } 41 | else 42 | { 43 | std::string err("failed to create effect: "); 44 | err.append((errStr) ? errStr : "shader error"); 45 | 46 | throw std::runtime_error(err); 47 | } 48 | } 49 | 50 | VisibilityMaskShader::~VisibilityMaskShader() 51 | { 52 | ObsGraphics gfx; 53 | 54 | gs_effect_destroy(m_effect); 55 | gs_texrender_destroy(m_workTexture); 56 | } 57 | 58 | gs_texture_t* VisibilityMaskShader::Mask(gs_texture_t* filter, gs_texture_t* mask) 59 | { 60 | std::uint32_t colorWidth = gs_texture_get_width(filter); 61 | std::uint32_t colorHeight = gs_texture_get_height(filter); 62 | 63 | gs_texrender_reset(m_workTexture); 64 | if (!gs_texrender_begin(m_workTexture, colorWidth, colorHeight)) 65 | return nullptr; 66 | 67 | vec4 black = { 0.f, 0.f, 0.f, 0.f }; 68 | gs_clear(GS_CLEAR_COLOR, &black, 0.f, 0); 69 | gs_ortho(0.0f, float(colorWidth), 0.0f, float(colorHeight), -100.0f, 100.0f); 70 | 71 | gs_effect_set_texture(m_params_FilterImage, filter); 72 | gs_effect_set_texture(m_params_MaskImage, mask); 73 | 74 | gs_technique_begin(m_tech_Draw); 75 | gs_technique_begin_pass(m_tech_Draw, 0); 76 | gs_draw_sprite(nullptr, 0, colorWidth, colorHeight); 77 | gs_technique_end_pass(m_tech_Draw); 78 | gs_technique_end(m_tech_Draw); 79 | 80 | gs_texrender_end(m_workTexture); 81 | 82 | return gs_texrender_get_texture(m_workTexture); 83 | } 84 | -------------------------------------------------------------------------------- /src/obs-kinect/GreenscreenEffects/ReplaceBackgroundEffect.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | ReplaceBackgroundEffect::ReplaceBackgroundEffect() : 23 | m_lastTextureTick(0) 24 | { 25 | } 26 | 27 | gs_texture_t* ReplaceBackgroundEffect::Apply(const Config& config, gs_texture_t* sourceTexture, gs_texture_t* filterTexture) 28 | { 29 | if (m_texturePath != config.replacementTexturePath) 30 | { 31 | if (!m_imageFile) 32 | m_imageFile.reset(new gs_image_file_t); 33 | 34 | m_texturePath = config.replacementTexturePath; 35 | gs_image_file_init(m_imageFile.get(), m_texturePath.data()); 36 | 37 | ObsGraphics gfx; 38 | gs_image_file_init_texture(m_imageFile.get()); 39 | } 40 | 41 | if (!m_imageFile || !m_imageFile->texture) 42 | return sourceTexture; 43 | 44 | // Tick the texture if it's animated 45 | std::uint64_t now = obs_get_video_frame_time(); 46 | if (m_lastTextureTick == 0) 47 | m_lastTextureTick = now; 48 | 49 | if (gs_image_file_tick(m_imageFile.get(), now - m_lastTextureTick)) 50 | { 51 | ObsGraphics gfx; 52 | gs_image_file_update_texture(m_imageFile.get()); 53 | } 54 | 55 | m_lastTextureTick = now; 56 | 57 | // Do the lerp 58 | return m_textureLerp.Lerp(m_imageFile->texture, sourceTexture, filterTexture); 59 | } 60 | 61 | obs_properties_t* ReplaceBackgroundEffect::BuildProperties() 62 | { 63 | obs_properties_t* properties = obs_properties_create(); 64 | 65 | std::string filter = obs_module_text("BrowsePath.Images"); 66 | filter += " (*.bmp *.jpg *.jpeg *.tga *.gif *.png);;"; 67 | filter += obs_module_text("BrowsePath.AllFiles"); 68 | filter += " (*.*)"; 69 | 70 | obs_properties_add_path(properties, "replacebackground_path", obs_module_text("ObsKinect.ReplaceBackground.Path"), OBS_PATH_FILE, filter.data(), nullptr); 71 | 72 | return properties; 73 | } 74 | 75 | void ReplaceBackgroundEffect::SetDefaultValues(obs_data_t* /*settings*/) 76 | { 77 | } 78 | 79 | auto ReplaceBackgroundEffect::ToConfig(obs_data_t* settings) -> Config 80 | { 81 | Config config; 82 | config.replacementTexturePath = obs_data_get_string(settings, "replacebackground_path"); 83 | 84 | return config; 85 | } 86 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/ConvertDepthIRToColorShader.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | ConvertDepthIRToColorShader::ConvertDepthIRToColorShader() 24 | { 25 | ObsMemoryPtr effectFilename(obs_module_file("color_multiplier.effect")); 26 | 27 | ObsGraphics gfx; 28 | 29 | char* errStr = nullptr; 30 | m_effect = gs_effect_create_from_file(effectFilename.get(), &errStr); 31 | ObsMemoryPtr errStrOwner(errStr); 32 | 33 | if (m_effect) 34 | { 35 | m_params_ColorImage = gs_effect_get_param_by_name(m_effect, "ColorImage"); 36 | m_params_ColorMultiplier = gs_effect_get_param_by_name(m_effect, "ColorMultiplier"); 37 | m_tech_Draw = gs_effect_get_technique(m_effect, "Draw"); 38 | 39 | m_workTexture = gs_texrender_create(GS_RGBA, GS_ZS_NONE); 40 | } 41 | else 42 | { 43 | std::string err("failed to create effect: "); 44 | err.append((errStr) ? errStr : "shader error"); 45 | 46 | throw std::runtime_error(err); 47 | } 48 | } 49 | 50 | ConvertDepthIRToColorShader::~ConvertDepthIRToColorShader() 51 | { 52 | ObsGraphics gfx; 53 | 54 | gs_effect_destroy(m_effect); 55 | gs_texrender_destroy(m_workTexture); 56 | } 57 | 58 | gs_texture_t* ConvertDepthIRToColorShader::Convert(std::uint32_t width, std::uint32_t height, gs_texture_t* source, float averageValue, float standardDeviation) 59 | { 60 | gs_texrender_reset(m_workTexture); 61 | if (!gs_texrender_begin(m_workTexture, width, height)) 62 | return nullptr; 63 | 64 | vec4 black = { 0.f, 0.f, 0.f, 0.f }; 65 | gs_clear(GS_CLEAR_COLOR, &black, 0.f, 0); 66 | gs_ortho(0.0f, float(width), 0.0f, float(height), -100.0f, 100.0f); 67 | 68 | gs_effect_set_texture(m_params_ColorImage, source); 69 | gs_effect_set_float(m_params_ColorMultiplier, float(1.0 / (double(averageValue) * double(standardDeviation)))); 70 | 71 | gs_technique_begin(m_tech_Draw); 72 | gs_technique_begin_pass(m_tech_Draw, 0); 73 | gs_draw_sprite(nullptr, 0, width, height); 74 | gs_technique_end_pass(m_tech_Draw); 75 | gs_technique_end(m_tech_Draw); 76 | 77 | gs_texrender_end(m_workTexture); 78 | 79 | return gs_texrender_get_texture(m_workTexture); 80 | } 81 | -------------------------------------------------------------------------------- /src/obs-kinect/KinectDeviceRegistry.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | void KinectDeviceRegistry::ForEachDevice(const Callback& callback) const 23 | { 24 | for (const auto& pluginData : m_plugins) 25 | { 26 | const std::string& pluginName = pluginData.plugin.GetUniqueName(); 27 | for (const auto& deviceData : pluginData.devices) 28 | { 29 | if (!callback(pluginName, deviceData.uniqueName, *deviceData.device)) 30 | return; 31 | } 32 | } 33 | } 34 | 35 | KinectDevice* KinectDeviceRegistry::GetDevice(const std::string& deviceName) const 36 | { 37 | auto it = m_deviceByName.find(deviceName); 38 | if (it == m_deviceByName.end()) 39 | return nullptr; 40 | 41 | return it->second; 42 | } 43 | 44 | void KinectDeviceRegistry::Refresh() 45 | { 46 | for (KinectSource* source : m_sources) 47 | source->ClearDeviceAccess(); 48 | 49 | m_deviceByName.clear(); 50 | 51 | for (auto& pluginData : m_plugins) 52 | { 53 | pluginData.devices.clear(); 54 | 55 | for (auto& devicePtr : pluginData.plugin.Refresh()) 56 | { 57 | auto& deviceData = pluginData.devices.emplace_back(); 58 | deviceData.device = std::move(devicePtr); 59 | deviceData.uniqueName = pluginData.plugin.GetUniqueName() + "_" + deviceData.device->GetUniqueName(); 60 | 61 | assert(m_deviceByName.find(deviceData.uniqueName) == m_deviceByName.end()); 62 | m_deviceByName.emplace(deviceData.uniqueName, deviceData.device.get()); 63 | } 64 | } 65 | 66 | for (KinectSource* source : m_sources) 67 | source->RefreshDeviceAccess(); 68 | } 69 | 70 | bool KinectDeviceRegistry::RegisterPlugin(const std::string& path) 71 | { 72 | KinectPlugin newPlugin; 73 | if (!newPlugin.Open(path)) 74 | return false; 75 | 76 | auto& pluginEntry = m_plugins.emplace_back(); 77 | pluginEntry.plugin = std::move(newPlugin); 78 | 79 | return true; 80 | } 81 | 82 | void KinectDeviceRegistry::RegisterSource(KinectSource* source) 83 | { 84 | assert(m_sources.find(source) == m_sources.end()); 85 | m_sources.insert(source); 86 | } 87 | 88 | void KinectDeviceRegistry::UnregisterSource(KinectSource* source) 89 | { 90 | assert(m_sources.find(source) != m_sources.end()); 91 | m_sources.erase(source); 92 | } 93 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/TextureLerpShader.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | TextureLerpShader::TextureLerpShader() 24 | { 25 | ObsMemoryPtr effectFilename(obs_module_file("texture_lerp.effect")); 26 | 27 | ObsGraphics gfx; 28 | 29 | char* errStr = nullptr; 30 | m_effect = gs_effect_create_from_file(effectFilename.get(), &errStr); 31 | ObsMemoryPtr errStrOwner(errStr); 32 | 33 | if (m_effect) 34 | { 35 | m_params_FactorImage = gs_effect_get_param_by_name(m_effect, "FactorImage"); 36 | m_params_FromImage = gs_effect_get_param_by_name(m_effect, "FromImage"); 37 | m_params_ToImage = gs_effect_get_param_by_name(m_effect, "ToImage"); 38 | m_tech_Draw = gs_effect_get_technique(m_effect, "Draw"); 39 | 40 | m_workTexture = gs_texrender_create(GS_RGBA, GS_ZS_NONE); 41 | } 42 | else 43 | { 44 | std::string err("failed to create effect: "); 45 | err.append((errStr) ? errStr : "shader error"); 46 | 47 | throw std::runtime_error(err); 48 | } 49 | } 50 | 51 | TextureLerpShader::~TextureLerpShader() 52 | { 53 | ObsGraphics gfx; 54 | 55 | gs_effect_destroy(m_effect); 56 | gs_texrender_destroy(m_workTexture); 57 | } 58 | 59 | gs_texture_t* TextureLerpShader::Lerp(gs_texture_t* from, gs_texture_t* to, gs_texture_t* factor) 60 | { 61 | std::uint32_t colorWidth = gs_texture_get_width(to); 62 | std::uint32_t colorHeight = gs_texture_get_height(to); 63 | 64 | gs_texrender_reset(m_workTexture); 65 | if (!gs_texrender_begin(m_workTexture, colorWidth, colorHeight)) 66 | return nullptr; 67 | 68 | vec4 black = { 0.f, 0.f, 0.f, 0.f }; 69 | gs_clear(GS_CLEAR_COLOR, &black, 0.f, 0); 70 | gs_ortho(0.0f, float(colorWidth), 0.0f, float(colorHeight), -100.0f, 100.0f); 71 | 72 | gs_effect_set_texture(m_params_FactorImage, factor); 73 | gs_effect_set_texture(m_params_FromImage, from); 74 | gs_effect_set_texture(m_params_ToImage, to); 75 | 76 | gs_technique_begin(m_tech_Draw); 77 | gs_technique_begin_pass(m_tech_Draw, 0); 78 | gs_draw_sprite(nullptr, 0, colorWidth, colorHeight); 79 | gs_technique_end_pass(m_tech_Draw); 80 | gs_technique_end(m_tech_Draw); 81 | 82 | gs_texrender_end(m_workTexture); 83 | 84 | return gs_texrender_get_texture(m_workTexture); 85 | } 86 | -------------------------------------------------------------------------------- /src/obs-kinect-azuresdk/AzureKinectPlugin.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "AzureKinectPlugin.hpp" 19 | #include "AzureKinectDevice.hpp" 20 | #include 21 | 22 | void ErrorCallback(void* /*context*/, k4a_log_level_t level, const char* file, const int line, const char* message) 23 | { 24 | switch (level) 25 | { 26 | case K4A_LOG_LEVEL_CRITICAL: 27 | case K4A_LOG_LEVEL_ERROR: 28 | errorlog("SDK error: %s (in %s:%d)", message, file, line); 29 | break; 30 | 31 | case K4A_LOG_LEVEL_WARNING: 32 | warnlog("SDK warning: %s (in %s:%d)", message, file, line); 33 | break; 34 | 35 | case K4A_LOG_LEVEL_INFO: 36 | case K4A_LOG_LEVEL_TRACE: 37 | infolog("SDK info: %s (in %s:%d)", message, file, line); 38 | break; 39 | 40 | case K4A_LOG_LEVEL_OFF: 41 | default: 42 | break; 43 | } 44 | } 45 | 46 | 47 | AzureKinectPlugin::AzureKinectPlugin() 48 | { 49 | #ifdef DEBUG 50 | k4a_log_level_t logLevel = K4A_LOG_LEVEL_INFO; 51 | #else 52 | k4a_log_level_t logLevel = K4A_LOG_LEVEL_WARNING; 53 | #endif 54 | 55 | k4a_set_debug_message_handler(&ErrorCallback, nullptr, logLevel); 56 | 57 | #if HAS_BODY_TRACKING 58 | ObsLibPtr bodyTrackingLib(os_dlopen("k4abt")); 59 | 60 | if (bodyTrackingLib) 61 | { 62 | if (LoadBodyTrackingSdk(bodyTrackingLib.get())) 63 | m_bodyTrackingLib = std::move(bodyTrackingLib); 64 | } 65 | #endif 66 | } 67 | 68 | AzureKinectPlugin::~AzureKinectPlugin() 69 | { 70 | k4a_set_debug_message_handler(nullptr, nullptr, K4A_LOG_LEVEL_OFF); 71 | } 72 | 73 | std::string AzureKinectPlugin::GetUniqueName() const 74 | { 75 | return "Azure Kinect"; 76 | } 77 | 78 | std::vector> AzureKinectPlugin::Refresh() const 79 | { 80 | std::vector> devices; 81 | try 82 | { 83 | std::uint32_t deviceCount = k4a::device::get_installed_count(); 84 | 85 | for (std::uint32_t i = 0; i < deviceCount; ++i) 86 | { 87 | try 88 | { 89 | devices.emplace_back(std::make_unique(i)); 90 | } 91 | catch (const std::exception& e) 92 | { 93 | warnlog("failed to open Azure Kinect #%d: %s", i, e.what()); 94 | } 95 | } 96 | } 97 | catch (const std::exception& e) 98 | { 99 | warnlog("%s", e.what()); 100 | } 101 | 102 | return devices; 103 | } 104 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk20/NuiSensorLibHelper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_NUISENSORLIBHELPER 21 | #define OBS_KINECT_PLUGIN_NUISENSORLIBHELPER 22 | 23 | #if __has_include() 24 | #define HAS_NUISENSOR_LIB 1 25 | #include 26 | #include 27 | #else 28 | #define HAS_NUISENSOR_LIB 0 29 | #endif 30 | 31 | #if HAS_NUISENSOR_LIB 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | struct NuiSensorHandleDeleter 40 | { 41 | void operator()(NUISENSOR_HANDLE handle) const 42 | { 43 | NuiSensor_Shutdown(handle); 44 | } 45 | }; 46 | 47 | using NuiSensorHandle = std::unique_ptr, NuiSensorHandleDeleter>; 48 | 49 | BOOL ColorChangeCameraSettingsSync(NUISENSOR_HANDLE nuiSensorHandle, void* scratchBuffer, DWORD scratchBufferSize, NUISENSOR_RGB_CHANGE_STREAM_SETTING* settings, DWORD settingsSizeInBytes, NUISENSOR_RGB_CHANGE_STREAM_SETTING_REPLY* replies, DWORD replySizeInBytes); 50 | 51 | class NuiSensorColorCameraSettings 52 | { 53 | public: 54 | NuiSensorColorCameraSettings(); 55 | ~NuiSensorColorCameraSettings() = default; 56 | 57 | void AddCommand(NUISENSOR_RGB_COMMAND_TYPE command); 58 | void AddCommand(NUISENSOR_RGB_COMMAND_TYPE command, std::uint32_t data); 59 | void AddCommandFloat(NUISENSOR_RGB_COMMAND_TYPE command, float data); 60 | 61 | bool Execute(NUISENSOR_HANDLE sensor); 62 | bool ExecuteAndReset(NUISENSOR_HANDLE sensor); 63 | 64 | std::size_t GetCommandCount() const; 65 | std::optional GetReplyData(std::size_t commandIndex) const; 66 | std::optional GetReplyDataFloat(std::size_t commandIndex) const; 67 | bool GetReplyStatus(std::size_t commandIndex) const; 68 | 69 | void Reset(); 70 | 71 | private: 72 | NUISENSOR_RGB_CHANGE_STREAM_SETTING* GetSettings(); 73 | const NUISENSOR_RGB_CHANGE_STREAM_SETTING* GetSettings() const; 74 | NUISENSOR_RGB_CHANGE_STREAM_SETTING_REPLY* GetReplies(); 75 | const NUISENSOR_RGB_CHANGE_STREAM_SETTING_REPLY* GetReplies() const; 76 | const NUISENSOR_RGB_CHANGE_STREAM_SETTING_REPLY_STATUS& GetReplyStatusInternal(std::size_t commandIndex) const; 77 | 78 | std::array m_settingBuffer; 79 | std::array m_replyBuffer; 80 | 81 | static std::atomic_uint32_t s_sequenceId; 82 | }; 83 | 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/obs-kinect-azuresdk/AzureKinectBodyTrackingDynFuncs.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_AZUREKINECTBODYTRACKINGFUNCTIONS 21 | #define OBS_KINECT_PLUGIN_AZUREKINECTBODYTRACKINGFUNCTIONS 22 | 23 | // We're loading Body Tracking SDK dynamically, can't include k4abt.h but must define its functions globally to use k4abt.hpp 24 | // TODO: Find a better way to do this, if possible (maybe suggest something to Microsoft to help this?) 25 | #ifdef K4ABT_H 26 | #error This header must be included before k4abt.h 27 | #endif 28 | 29 | #define K4ABT_H 30 | 31 | #include 32 | #include 33 | 34 | bool LoadBodyTrackingSdk(void* obsModule); 35 | bool IsBodyTrackingSdkLoaded(); 36 | void UnloadBodyTrackingSdk(); 37 | 38 | // Updated for Azure Kinect Body Tracking SDK 1.01 39 | #define OBS_KINECT_AZURE_SDK_BODY_TRACKING_FOREACH_FUNC(cb) \ 40 | cb(k4a_result_t, k4abt_tracker_create, const k4a_calibration_t* sensor_calibration, k4abt_tracker_configuration_t config, k4abt_tracker_t* tracker_handle) \ 41 | cb(void, k4abt_tracker_destroy, k4abt_tracker_t tracker_handle) \ 42 | cb(void, k4abt_tracker_set_temporal_smoothing, k4abt_tracker_t tracker_handle, float smoothing_factor) \ 43 | cb(k4a_wait_result_t, k4abt_tracker_enqueue_capture, k4abt_tracker_t tracker_handle, k4a_capture_t sensor_capture_handle, int32_t timeout_in_ms) \ 44 | cb(k4a_wait_result_t, k4abt_tracker_pop_result, k4abt_tracker_t tracker_handle, k4abt_frame_t* body_frame_handle, int32_t timeout_in_ms) \ 45 | cb(void, k4abt_tracker_shutdown, k4abt_tracker_t tracker_handle) \ 46 | cb(void, k4abt_frame_release, k4abt_frame_t body_frame_handle) \ 47 | cb(void, k4abt_frame_reference, k4abt_frame_t body_frame_handle) \ 48 | cb(uint32_t, k4abt_frame_get_num_bodies, k4abt_frame_t body_frame_handle) \ 49 | cb(k4a_result_t, k4abt_frame_get_body_skeleton, k4abt_frame_t body_frame_handle, uint32_t index, k4abt_skeleton_t* skeleton) \ 50 | cb(uint32_t, k4abt_frame_get_body_id, k4abt_frame_t body_frame_handle, uint32_t index) \ 51 | cb(uint64_t, k4abt_frame_get_device_timestamp_usec, k4abt_frame_t body_frame_handle) \ 52 | cb(k4a_image_t, k4abt_frame_get_body_index_map, k4abt_frame_t body_frame_handle) \ 53 | cb(k4a_capture_t, k4abt_frame_get_capture, k4abt_frame_t body_frame_handle) \ 54 | cb(uint64_t, k4abt_frame_get_system_timestamp_nsec, k4abt_frame_t body_frame_handle) \ 55 | 56 | #define OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC(Ret, Name, ...) extern Ret (*Name)(__VA_ARGS__); 57 | OBS_KINECT_AZURE_SDK_BODY_TRACKING_FOREACH_FUNC(OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC) 58 | #undef OBS_KINECT_AZURE_SDK_BODY_TRACKING_FUNC 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/obs-kinect-sdk10/KinectSdk10Device.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTDEVICESDK10 21 | #define OBS_KINECT_PLUGIN_KINECTDEVICESDK10 22 | 23 | #include "Sdk10Helper.hpp" 24 | #include 25 | #include "KinectSdk10Plugin.hpp" 26 | #include 27 | 28 | class KinectSdk10Device final : public KinectDevice 29 | { 30 | public: 31 | KinectSdk10Device(int sensorId); 32 | ~KinectSdk10Device(); 33 | 34 | obs_properties_t* CreateProperties() const override; 35 | 36 | INuiSensor* GetSensor() const; 37 | 38 | private: 39 | void ElevationThreadFunc(); 40 | void HandleBoolParameterUpdate(const std::string& parameterName, bool value) override; 41 | void HandleDoubleParameterUpdate(const std::string& parameterName, double value) override; 42 | void HandleIntParameterUpdate(const std::string& parameterName, long long value) override; 43 | void RegisterParameters(); 44 | void StartElevationThread(); 45 | void ThreadFunc(std::condition_variable& cv, std::mutex& m, std::exception_ptr& exceptionPtr) override; 46 | 47 | DepthMappingFrameData BuildDepthMappingFrame(INuiSensor* sensor, const ColorFrameData& colorFrame, const DepthFrameData& depthFrame, std::vector& tempMemory); 48 | 49 | using ImageFrameCallback = std::function; 50 | 51 | static BodyIndexFrameData BuildBodyFrame(const DepthFrameData& depthFrame); 52 | #if HAS_BACKGROUND_REMOVAL 53 | static BackgroundRemovalFrameData RetrieveBackgroundRemovalFrame(INuiBackgroundRemovedColorStream* backgroundRemovalStream, std::int64_t* timestamp); 54 | static DWORD ChooseSkeleton(const NUI_SKELETON_FRAME& skeletonFrame, DWORD currentSkeleton); 55 | #endif 56 | static ColorFrameData RetrieveColorFrame(INuiSensor* sensor, HANDLE colorStream, std::int64_t* timestamp, const ImageFrameCallback& rawFrameOp = {}); 57 | static DepthFrameData RetrieveDepthFrame(INuiSensor* sensor, HANDLE depthStream, std::int64_t* timestamp, const ImageFrameCallback& rawFrameOp = {}); 58 | static InfraredFrameData RetrieveInfraredFrame(INuiSensor* sensor, HANDLE irStream, std::int64_t* timestamp, const ImageFrameCallback& rawFrameOp = {}); 59 | static void ExtractDepth(DepthFrameData& depthFrame); 60 | 61 | #if HAS_BACKGROUND_REMOVAL 62 | DWORD m_trackedSkeleton; 63 | #endif 64 | ReleasePtr m_cameraSettings; 65 | ReleasePtr m_coordinateMapper; 66 | ReleasePtr m_kinectSensor; 67 | HandlePtr m_elevationUpdateEvent; 68 | HandlePtr m_exitElevationThreadEvent; 69 | std::atomic_bool m_kinectHighRes; 70 | std::atomic_bool m_kinectNearMode; 71 | std::atomic m_kinectElevation; 72 | std::thread m_elevationThread; 73 | bool m_hasColorSettings; 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /include/obs-kinect-core/Helper.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_HELPER 21 | #define OBS_KINECT_PLUGIN_HELPER 22 | 23 | #ifdef _WIN32 24 | #define OBSKINECT_EXPORT __declspec(dllexport) 25 | #define OBSKINECT_IMPORT __declspec(dllimport) 26 | #else 27 | #define OBSKINECT_EXPORT __attribute__((visibility ("default"))) 28 | #define OBSKINECT_IMPORT __attribute__((visibility ("default"))) 29 | #endif 30 | 31 | #ifdef OBS_KINECT_CORE_EXPORT 32 | #define OBSKINECT_API OBSKINECT_EXPORT 33 | #else 34 | #define OBSKINECT_API OBSKINECT_IMPORT 35 | #endif 36 | 37 | #define OBSKINECT_VERSION_MAJOR 0 38 | #define OBSKINECT_VERSION_MINOR 3 39 | #define OBSKINECT_VERSION ((OBSKINECT_VERSION_MAJOR << 8) | OBSKINECT_VERSION_MINOR) 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #ifndef logprefix 47 | #define logprefix "[obs-kinect] " 48 | #endif 49 | 50 | #define blog(log_level, format, ...) blog(log_level, logprefix format, ##__VA_ARGS__) 51 | 52 | #define debuglog(format, ...) blog(LOG_DEBUG, format, ##__VA_ARGS__) 53 | #define errorlog(format, ...) blog(LOG_ERROR, format, ##__VA_ARGS__) 54 | #define infolog(format, ...) blog(LOG_INFO, format, ##__VA_ARGS__) 55 | #define warnlog(format, ...) blog(LOG_WARNING, format, ##__VA_ARGS__) 56 | 57 | struct DummyDeleter 58 | { 59 | void operator()(void*) const 60 | { 61 | } 62 | }; 63 | 64 | template using ObserverPtr = std::unique_ptr; 65 | 66 | struct ObsBFreeDeleter 67 | { 68 | void operator()(void* ptr) const 69 | { 70 | bfree(ptr); 71 | } 72 | }; 73 | 74 | template using ObsMemoryPtr = std::unique_ptr; 75 | 76 | struct ObsGraphics 77 | { 78 | ObsGraphics() { obs_enter_graphics(); } 79 | ~ObsGraphics() { obs_leave_graphics(); } 80 | }; 81 | 82 | struct ObsLibDeleter 83 | { 84 | void operator()(void* lib) const 85 | { 86 | os_dlclose(lib); 87 | } 88 | }; 89 | 90 | using ObsLibPtr = std::unique_ptr; 91 | 92 | struct ObsImageFileDeleter 93 | { 94 | void operator()(gs_image_file_t* imageFile) const 95 | { 96 | ObsGraphics gfx; 97 | gs_image_file_free(imageFile); 98 | 99 | delete imageFile; 100 | } 101 | }; 102 | 103 | using ObsImageFilePtr = std::unique_ptr; 104 | 105 | struct ObsTextureDeleter 106 | { 107 | void operator()(gs_texture_t* texture) const 108 | { 109 | ObsGraphics gfx; 110 | gs_texture_destroy(texture); 111 | } 112 | }; 113 | 114 | using ObsTexturePtr = std::unique_ptr; 115 | 116 | using TranslateSig = const char*(*)(const char*); 117 | 118 | OBSKINECT_API void SetTranslateFunction(TranslateSig translateFunc); 119 | OBSKINECT_API const char* Translate(const char* key); 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/GreenScreenFilterShader.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_GREENSCREENFILTERSHADER 21 | #define OBS_KINECT_PLUGIN_GREENSCREENFILTERSHADER 22 | 23 | #include 24 | #include 25 | 26 | class GreenScreenFilterShader 27 | { 28 | public: 29 | struct BodyFilterParams; 30 | struct DepthFilterParams; 31 | struct BodyOrDepthFilterParams; 32 | struct BodyWithinDepthFilterParams; 33 | 34 | GreenScreenFilterShader(); 35 | ~GreenScreenFilterShader(); 36 | 37 | gs_texture_t* Filter(std::uint32_t width, std::uint32_t height, const BodyFilterParams& params); 38 | gs_texture_t* Filter(std::uint32_t width, std::uint32_t height, const BodyOrDepthFilterParams& params); 39 | gs_texture_t* Filter(std::uint32_t width, std::uint32_t height, const BodyWithinDepthFilterParams& params); 40 | gs_texture_t* Filter(std::uint32_t width, std::uint32_t height, const DepthFilterParams& params); 41 | 42 | struct BodyFilterParams 43 | { 44 | gs_texture_t* bodyIndexTexture; 45 | gs_texture_t* colorToDepthTexture; 46 | }; 47 | 48 | struct DepthFilterParams 49 | { 50 | gs_texture_t* colorToDepthTexture; 51 | gs_texture_t* depthTexture; 52 | float progressiveDepth; 53 | float maxDepth; 54 | float minDepth; 55 | }; 56 | 57 | struct BodyOrDepthFilterParams 58 | { 59 | gs_texture_t* bodyIndexTexture; 60 | gs_texture_t* colorToDepthTexture; 61 | gs_texture_t* depthTexture; 62 | float progressiveDepth; 63 | float maxDepth; 64 | float minDepth; 65 | }; 66 | 67 | struct BodyWithinDepthFilterParams 68 | { 69 | gs_texture_t* bodyIndexTexture; 70 | gs_texture_t* colorToDepthTexture; 71 | gs_texture_t* depthTexture; 72 | float progressiveDepth; 73 | float maxDepth; 74 | float minDepth; 75 | }; 76 | 77 | private: 78 | bool Begin(std::uint32_t width, std::uint32_t height); 79 | gs_texture* Process(std::uint32_t width, std::uint32_t height, gs_technique_t* technique); 80 | template void SetBodyParams(const Params& params); 81 | template void SetDepthParams(const Params& params); 82 | 83 | gs_effect_t* m_effect; 84 | gs_eparam_t* m_params_BodyIndexImage; 85 | gs_eparam_t* m_params_DepthImage; 86 | gs_eparam_t* m_params_DepthMappingImage; 87 | gs_eparam_t* m_params_InvDepthImageSize; 88 | gs_eparam_t* m_params_InvDepthProgressive; 89 | gs_eparam_t* m_params_MaxDepth; 90 | gs_eparam_t* m_params_MinDepth; 91 | gs_technique_t* m_tech_BodyOnlyWithDepthCorrection; 92 | gs_technique_t* m_tech_BodyOnlyWithoutDepthCorrection; 93 | gs_technique_t* m_tech_BodyOrDepthWithDepthCorrection; 94 | gs_technique_t* m_tech_BodyOrDepthWithoutDepthCorrection; 95 | gs_technique_t* m_tech_BodyWithinDepthWithDepthCorrection; 96 | gs_technique_t* m_tech_BodyWithinDepthWithoutDepthCorrection; 97 | gs_technique_t* m_tech_DepthOnlyWithDepthCorrection; 98 | gs_technique_t* m_tech_DepthOnlyWithoutDepthCorrection; 99 | gs_texrender_t* m_workTexture; 100 | }; 101 | 102 | #include 103 | 104 | #endif 105 | -------------------------------------------------------------------------------- /src/obs-kinect-freenect/FreenectPlugin.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include "FreenectPlugin.hpp" 19 | #include "FreenectDevice.hpp" 20 | #include 21 | #include 22 | #include 23 | 24 | void ErrorCallback(freenect_context* /*device*/, freenect_loglevel level, const char* message) 25 | { 26 | switch (level) 27 | { 28 | case FREENECT_LOG_FATAL: errorlog("freenect fatal error: %s", message); break; 29 | case FREENECT_LOG_ERROR: errorlog("freenect error: %s", message); break; 30 | case FREENECT_LOG_WARNING: warnlog("freenect warning: %s", message); break; 31 | case FREENECT_LOG_NOTICE: infolog("freenect notice: %s", message); break; 32 | case FREENECT_LOG_INFO: infolog("freenect info: %s", message); break; 33 | case FREENECT_LOG_DEBUG: debuglog("freenect debug log: %s", message); break; 34 | case FREENECT_LOG_SPEW: debuglog("freenect spew log: %s", message); break; 35 | case FREENECT_LOG_FLOOD: debuglog("freenect flood log: %s", message); break; 36 | } 37 | } 38 | 39 | KinectFreenectPlugin::KinectFreenectPlugin() : 40 | m_context(nullptr), 41 | m_contextThreadRunning(true) 42 | { 43 | if (freenect_init(&m_context, nullptr) != 0) 44 | throw std::runtime_error("failed to initialize freenect context"); 45 | 46 | #ifdef DEBUG 47 | freenect_loglevel logLevel = FREENECT_LOG_DEBUG; 48 | #else 49 | freenect_loglevel logLevel = FREENECT_LOG_INFO; 50 | #endif 51 | 52 | freenect_set_log_level(m_context, logLevel); 53 | freenect_set_log_callback(m_context, &ErrorCallback); 54 | 55 | // we're not supporting audio for now 56 | freenect_select_subdevices(m_context, static_cast(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA)); 57 | 58 | m_contextThread = std::thread([this]() 59 | { 60 | os_set_thread_name("KinectPluginFreenectEvents"); 61 | 62 | while (m_contextThreadRunning) 63 | { 64 | timeval timeout = { 0, 100 * 1000 }; 65 | int res = freenect_process_events_timeout(m_context, &timeout); 66 | if (res < 0) 67 | { 68 | if (res == LIBUSB_ERROR_INTERRUPTED) 69 | continue; //< Ignore interruption signals 70 | 71 | errorlog("freenect event processing errored (libusb error code: %d)", res); 72 | } 73 | } 74 | }); 75 | } 76 | 77 | KinectFreenectPlugin::~KinectFreenectPlugin() 78 | { 79 | m_contextThreadRunning = false; 80 | m_contextThread.join(); 81 | 82 | if (freenect_shutdown(m_context) < 0) 83 | warnlog("freenect shutdown failed"); 84 | } 85 | 86 | std::string KinectFreenectPlugin::GetUniqueName() const 87 | { 88 | return "KinectV1-Freenect"; 89 | } 90 | 91 | std::vector> KinectFreenectPlugin::Refresh() const 92 | { 93 | std::vector> devices; 94 | 95 | freenect_device_attributes* attributes; 96 | int deviceCount = freenect_list_device_attributes(m_context, &attributes); 97 | for (int i = 0; i < deviceCount; ++i) 98 | { 99 | try 100 | { 101 | freenect_device* device; 102 | if (freenect_open_device_by_camera_serial(m_context, &device, attributes->camera_serial) == 0) 103 | devices.emplace_back(std::make_unique(device, attributes->camera_serial)); 104 | else 105 | warnlog("failed to open Kinect #%d", i); 106 | } 107 | catch (const std::exception& e) 108 | { 109 | warnlog("failed to open Kinect #%d: %s", i, e.what()); 110 | } 111 | 112 | attributes = attributes->next; 113 | } 114 | 115 | return devices; 116 | } 117 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/GaussianBlurShader.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | GaussianBlurShader::GaussianBlurShader(gs_color_format colorFormat) 24 | { 25 | ObsMemoryPtr effectFilename(obs_module_file("gaussian_blur.effect")); 26 | 27 | ObsGraphics gfx; 28 | 29 | char* errStr = nullptr; 30 | m_effect = gs_effect_create_from_file(effectFilename.get(), &errStr); 31 | ObsMemoryPtr errStrOwner(errStr); 32 | 33 | if (m_effect) 34 | { 35 | m_blurEffect_Filter = gs_effect_get_param_by_name(m_effect, "Filter"); 36 | m_blurEffect_Image = gs_effect_get_param_by_name(m_effect, "Image"); 37 | m_blurEffect_InvImageSize = gs_effect_get_param_by_name(m_effect, "InvImageSize"); 38 | m_blurEffect_DrawTech = gs_effect_get_technique(m_effect, "Draw"); 39 | 40 | m_workTextureA = gs_texrender_create(colorFormat, GS_ZS_NONE); 41 | m_workTextureB = gs_texrender_create(colorFormat, GS_ZS_NONE); 42 | } 43 | else 44 | { 45 | std::string err("failed to create effect: "); 46 | err.append((errStr) ? errStr : "shader error"); 47 | 48 | throw std::runtime_error(err); 49 | } 50 | } 51 | 52 | GaussianBlurShader::~GaussianBlurShader() 53 | { 54 | ObsGraphics gfx; 55 | 56 | gs_effect_destroy(m_effect); 57 | gs_texrender_destroy(m_workTextureA); 58 | gs_texrender_destroy(m_workTextureB); 59 | } 60 | 61 | gs_texture_t* GaussianBlurShader::Blur(gs_texture_t* source, std::size_t count) 62 | { 63 | std::uint32_t width = gs_texture_get_width(source); 64 | std::uint32_t height = gs_texture_get_height(source); 65 | 66 | vec2 filter; 67 | vec2 invTextureSize = { 1.f / width, 1.f / height }; 68 | 69 | for (std::size_t blurIndex = 0; blurIndex < count; ++blurIndex) 70 | { 71 | gs_texrender_reset(m_workTextureA); 72 | if (!gs_texrender_begin(m_workTextureA, width, height)) 73 | return nullptr; 74 | 75 | gs_ortho(0.0f, float(width), 0.0f, float(height), -100.0f, 100.0f); 76 | 77 | filter.x = 1.f; 78 | filter.y = 0.f; 79 | 80 | gs_effect_set_vec2(m_blurEffect_Filter, &filter); 81 | gs_effect_set_vec2(m_blurEffect_InvImageSize, &invTextureSize); 82 | gs_effect_set_texture(m_blurEffect_Image, (blurIndex == 0) ? source : gs_texrender_get_texture(m_workTextureB)); 83 | 84 | gs_technique_begin(m_blurEffect_DrawTech); 85 | gs_technique_begin_pass(m_blurEffect_DrawTech, 0); 86 | gs_draw_sprite(nullptr, 0, width, height); 87 | gs_technique_end_pass(m_blurEffect_DrawTech); 88 | gs_technique_end(m_blurEffect_DrawTech); 89 | 90 | gs_texrender_end(m_workTextureA); 91 | 92 | gs_texrender_reset(m_workTextureB); 93 | if (!gs_texrender_begin(m_workTextureB, width, height)) 94 | return nullptr; 95 | 96 | gs_ortho(0.0f, float(width), 0.0f, float(height), -100.0f, 100.0f); 97 | 98 | filter.x = 0.f; 99 | filter.y = 1.f; 100 | 101 | gs_effect_set_vec2(m_blurEffect_Filter, &filter); 102 | gs_effect_set_vec2(m_blurEffect_InvImageSize, &invTextureSize); 103 | gs_effect_set_texture(m_blurEffect_Image, gs_texrender_get_texture(m_workTextureA)); 104 | 105 | gs_technique_begin(m_blurEffect_DrawTech); 106 | gs_technique_begin_pass(m_blurEffect_DrawTech, 0); 107 | gs_draw_sprite(nullptr, 0, width, height); 108 | gs_technique_end_pass(m_blurEffect_DrawTech); 109 | gs_technique_end(m_blurEffect_DrawTech); 110 | 111 | gs_texrender_end(m_workTextureB); 112 | } 113 | 114 | return gs_texrender_get_texture(m_workTextureB); 115 | } 116 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/locale/ko-KR.ini: -------------------------------------------------------------------------------- 1 | ObsKinect.KinectSource="키넥트" 2 | 3 | ObsKinect.NoDevice="기기 감지되지 않음" 4 | ObsKinect.Device="키넥트 기기" 5 | ObsKinect.RefreshDevices="키넥트 기기 재검색" 6 | 7 | ObsKinect.Source="키넥트 기기 영상 소스" 8 | ObsKinect.Source_Color="색상 영상" 9 | ObsKinect.Source_Depth="깊이 영상" 10 | ObsKinect.Source_Infrared="적외선 영상" 11 | 12 | ObsKinect.DepthDynamic="동적인 깊이값 (물체에 따라 계산)" 13 | ObsKinect.DepthAverage="평균 거리 (거리 평균값 계산)" 14 | ObsKinect.DepthStandardDeviation="표준 거리값 편차" 15 | 16 | ObsKinect.InfraredDynamic="동적인 적외선 깊이값 (물체에 따라 계산)" 17 | ObsKinect.InfraredAverage="평균 적외선 거리 (거리 평균값 계산)" 18 | ObsKinect.InfraredStandardDeviation="표준 적외선 값 편차" 19 | 20 | ObsKinect.InvisibleShutdown="작동하지 않을 시 전원 차단" 21 | 22 | ; green screen settings 가상 그린 스크린 관련값 23 | ObsKinect.GreenScreen="가상 그린스크린" 24 | ObsKinect.GreenScreenEnabled="가상 그린 스크린 작동여부" 25 | ObsKinect.GreenScreenFadeDist="물체가 흐려지는 거리" 26 | ObsKinect.GreenScreenMaxDist="최대 허용 거리" 27 | ObsKinect.GreenScreenMinDist="최소 허용 거리" 28 | ObsKinect.GreenScreenBlurPassCount="흐릿한 효과 적용 강도" 29 | ObsKinect.GreenScreenType="필터 종류" 30 | ObsKinect.GreenScreenType_Body="인지된 신체" 31 | ObsKinect.GreenScreenType_BodyOrDepth="인지된 신체 혹은 깊이값" 32 | ObsKinect.GreenScreenType_BodyWithinDepth="깊이값 내부 인지된 신체" 33 | ObsKinect.GreenScreenType_Dedicated="KinectSDK 배경 제거 방법" 34 | ObsKinect.GreenScreenType_Depth="깊이" 35 | ObsKinect.GreenScreenGpuDepthMapping="GPU를 사용하여 컬러-깊이 거리 계산" 36 | ObsKinect.GreenScreenGpuDepthMappingDesc="GPU가 해야할 작업을 CPU로 옮깁니다. 문제가 발생할때만 체크를 해제하세요" 37 | ObsKinect.GreenScreenMaxDirtyDepth="Max number of depth-lagging frames allowed" 38 | ObsKinect.GreenScreenMaxDirtyDepthDesc="플리커링 현상을 감소시키나, 빨리 움직이는 경우 쉐도잉 현상을 발생시킬 수 있습니다" 39 | ObsKinect.GreenScreenDistUnit="mm" 40 | ObsKinect.GreenScreenVisibilityMask="Visibility mask" ; missing translation 41 | 42 | ; green screen effects 43 | ObsKinect.BlurBackground.Reversed="뒤집힘" 44 | ObsKinect.BlurBackground.Strength="강도" 45 | ObsKinect.GreenScreenEffect="효과" 46 | ObsKinect.GreenScreenEffect_BlurBackground="배경 흐림" 47 | ObsKinect.GreenScreenEffect_RemoveBackground="배경 제거" 48 | ObsKinect.GreenScreenEffect_ReplaceBackground="배경 교체" 49 | ObsKinect.ReplaceBackground.Path="파일 위치" 50 | 51 | ; color settings 52 | ObsKinect.AnalogGain="아날로그식 색감" 53 | ObsKinect.AutoExposure="자동 채광" 54 | ObsKinect.AutoWhiteBalance="자동 화이트 밸런스" 55 | ObsKinect.BacklightCompensation="백라이트 보정" 56 | ObsKinect.BacklightCompensation_AverageBrightness="평균 밝기" 57 | ObsKinect.BacklightCompensation_CenterOnly="Center only" 58 | ObsKinect.BacklightCompensation_CenterPriority="Center priority" 59 | ObsKinect.BacklightCompensation_LowLightsPriority="Low lights priority" 60 | ObsKinect.Brightness="밝기" 61 | ObsKinect.Contrast="대조" 62 | ObsKinect.DigitalGain="디지털 색감" 63 | ObsKinect.DumpCameraSettings="Dump camera settings" 64 | ObsKinect.ExposureCompensation="노출 보정" 65 | ObsKinect.ExposureControl_FullyAuto="완전 자동" 66 | ObsKinect.ExposureControl_SemiAuto="부분 자동" 67 | ObsKinect.ExposureControl_Manual="수동" 68 | ObsKinect.ExposureIntegrationTime="노출 완성 시간" 69 | ObsKinect.ExposureMode="노출 모드" 70 | ObsKinect.ExposureTime="노출 시간" 71 | ObsKinect.FrameInterval="프레임 인터벌" 72 | ObsKinect.Gain="색감" 73 | ObsKinect.Gain_Blue="파랑" 74 | ObsKinect.Gain_Green="녹색" 75 | ObsKinect.Gain_Red="빨강" 76 | ObsKinect.Gamma="감마" 77 | ObsKinect.Hue="색조" 78 | ObsKinect.PowerlineFrequency="전원선 주파수" 79 | ObsKinect.PowerlineFrequency_Disabled="꺼짐" 80 | ObsKinect.PowerlineFrequency_50Hz="50Hz" 81 | ObsKinect.PowerlineFrequency_60Hz="60Hz" 82 | ObsKinect.Saturation="채도" 83 | ObsKinect.Sharpness="선명도" 84 | ObsKinect.WhiteBalance="화이트 밸런스" 85 | ObsKinect.WhiteBalanceMode="화이트 밸런스 옵션" 86 | ObsKinect.WhiteBalanceMode_Auto="자동" 87 | ObsKinect.WhiteBalanceMode_Manual="수동" 88 | ObsKinect.WhiteBalanceMode_Unknown="불명" ; I don't know what this setting does 89 | 90 | ; obs-kinect-sdk10 backend 91 | ObsKinectV1.CameraElevation="카메라 높이" 92 | ObsKinectV1.HighRes="색상 고품질 모드 유무" 93 | ObsKinectV1.HighResDesc="640x480 대신 1280x960의 화질을 사용하나 프레임이 낮아집니다. (30Hz->15Hz)" 94 | ObsKinectV1.NearMode="근거리 깊이 모드 활성화" 95 | ObsKinectV1.NearModeDesc="80-400cm 모드 대신 40-200cm의 모드를 사용합니다 (360 콘솔기기 버젼의 키넥트는 사용불가능)" 96 | 97 | ; obs-kinect-sdk20 backend 98 | ObsKinectV2.NexusLedIntensity="Nexus led 작동유무" 99 | ObsKinectV2.PrivacyLedIntensity="프라이버시 led 작동유무" 100 | ObsKinectV2.ServicePriority="키넥트 서비스 우선도" 101 | ObsKinectV2.ServicePriority_High="높음" 102 | ObsKinectV2.ServicePriority_AboveNormal="보통 이상" 103 | ObsKinectV2.ServicePriority_Normal="보통" 104 | 105 | ; obs-kinect-azuresdk backend 106 | ObsKinectAzure.ColorResolution="색상 해상도" 107 | ObsKinectAzure.ColorResolution_1280x720="720p (16:9 - 1280×720)" 108 | ObsKinectAzure.ColorResolution_1920x1080="1080p (16:9 - 1920×1080)" 109 | ObsKinectAzure.ColorResolution_2560x1440="1440p (16:9 - 2560×1440)" 110 | ObsKinectAzure.ColorResolution_2048x1536="1536p (4:3 - 2048×1536)" 111 | ObsKinectAzure.ColorResolution_3840x2160="4K (16:9 - 3840×2160)" 112 | ObsKinectAzure.ColorResolution_4096x3072="3072 (4:3 - 4096×3072)" 113 | ObsKinectAzure.DepthMode="깊이 모드" 114 | ObsKinectAzure.DepthMode_NFOV_Unbinned="NFOV unbinned" 115 | ObsKinectAzure.DepthMode_NFOV_2x2Binned="NFOV 2x2 binned (SW)" 116 | ObsKinectAzure.DepthMode_WFOV_Unbinned="WFOV unbinned" 117 | ObsKinectAzure.DepthMode_WFOV_2x2Binned="WFOV 2x2 binned" 118 | ObsKinectAzure.DepthMode_Passive="패시브 적외선 센서" 119 | -------------------------------------------------------------------------------- /include/obs-kinect-core/KinectDevice.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTDEVICE 21 | #define OBS_KINECT_PLUGIN_KINECTDEVICE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | class KinectDeviceAccess; 38 | 39 | class OBSKINECT_API KinectDevice 40 | { 41 | friend KinectDeviceAccess; 42 | 43 | public: 44 | KinectDevice(); 45 | KinectDevice(const KinectDevice&) = delete; 46 | KinectDevice(KinectDevice&&) = delete; 47 | virtual ~KinectDevice(); 48 | 49 | KinectDeviceAccess AcquireAccess(SourceFlags enabledSources); 50 | 51 | virtual obs_properties_t* CreateProperties() const; 52 | 53 | bool GetBoolParameterValue(const std::string& parameterName) const; 54 | double GetDoubleParameterValue(const std::string& parameterName) const; 55 | long long GetIntParameterValue(const std::string& parameterName) const; 56 | KinectFrameConstPtr GetLastFrame(); 57 | 58 | SourceFlags GetSupportedSources() const; 59 | const std::string& GetUniqueName() const; 60 | 61 | void SetDefaultValues(obs_data_t* settings) const; 62 | 63 | void StartCapture(); 64 | void StopCapture(); 65 | 66 | KinectDevice& operator=(const KinectDevice&) = delete; 67 | KinectDevice& operator=(KinectDevice&&) = delete; 68 | 69 | static constexpr std::uint64_t InvalidFrameIndex = std::numeric_limits::max(); 70 | 71 | protected: 72 | std::optional GetSourceFlagsUpdate(); 73 | 74 | bool IsRunning() const; 75 | void RegisterBoolParameter(std::string parameterName, bool defaultValue, std::function combinator); 76 | void RegisterDoubleParameter(std::string parameterName, double defaultValue, double epsilon, std::function combinator); 77 | void RegisterIntParameter(std::string parameterName, long long defaultValue, std::function combinator); 78 | void SetSupportedSources(SourceFlags enabledSources); 79 | void SetUniqueName(std::string uniqueName); 80 | void TriggerSourceFlagsUpdate(); 81 | void UpdateFrame(KinectFramePtr kinectFrame); 82 | 83 | virtual void HandleBoolParameterUpdate(const std::string& parameterName, bool value); 84 | virtual void HandleDoubleParameterUpdate(const std::string& parameterName, double value); 85 | virtual void HandleIntParameterUpdate(const std::string& parameterName, long long value); 86 | virtual void ThreadFunc(std::condition_variable& cv, std::mutex& m, std::exception_ptr& exceptionPtr) = 0; 87 | 88 | private: 89 | using ParameterValue = std::variant; 90 | 91 | struct AccessData 92 | { 93 | SourceFlags enabledSources; 94 | std::unordered_map parameters; 95 | }; 96 | 97 | template 98 | struct DataParameter 99 | { 100 | T defaultValue; 101 | T value; 102 | std::function combinator; 103 | }; 104 | 105 | struct DoubleParameter : DataParameter 106 | { 107 | double epsilon; 108 | }; 109 | 110 | using BoolParameter = DataParameter; 111 | using IntegerParameter = DataParameter; 112 | 113 | using ParameterData = std::variant; 114 | 115 | void RefreshParameters(); 116 | void ReleaseAccess(AccessData* access); 117 | void UpdateDeviceParameters(AccessData* access, obs_data_t* settings); 118 | void UpdateEnabledSources(); 119 | void UpdateParameter(const std::string& parameterName); 120 | 121 | void SetEnabledSources(SourceFlags sourceFlags); 122 | 123 | SourceFlags m_deviceSources; 124 | SourceFlags m_supportedSources; 125 | KinectFramePtr m_lastFrame; 126 | std::atomic_bool m_running; 127 | std::mutex m_deviceSourceLock; 128 | std::mutex m_lastFrameLock; 129 | std::string m_uniqueName; 130 | std::thread m_thread; 131 | std::unordered_map m_parameters; 132 | std::vector> m_accesses; 133 | std::uint64_t m_frameIndex; 134 | bool m_deviceSourceUpdated; 135 | }; 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/locale/en-US.ini: -------------------------------------------------------------------------------- 1 | ObsKinect.KinectSource="Kinect" 2 | 3 | ObsKinect.NoDevice="No device" 4 | ObsKinect.Device="Kinect device" 5 | ObsKinect.RefreshDevices="Refresh devices" 6 | 7 | ObsKinect.Source="Kinect stream" 8 | ObsKinect.Source_Color="Color" 9 | ObsKinect.Source_Depth="Depth" 10 | ObsKinect.Source_Infrared="Infrared" 11 | 12 | ObsKinect.DepthDynamic="Dynamic depth values (based on content)" 13 | ObsKinect.DepthAverage="Average distance (normalized)" 14 | ObsKinect.DepthStandardDeviation="Standard distance deviation" 15 | 16 | ObsKinect.InfraredDynamic="Dynamic infrared values (based on content)" 17 | ObsKinect.InfraredAverage="Average IR value (normalized)" 18 | ObsKinect.InfraredStandardDeviation="Standard IR value deviation" 19 | 20 | ObsKinect.InvisibleShutdown="Shutdown when not visible" 21 | 22 | ; green screen settings 23 | ObsKinect.GreenScreen="Faux greenscreen" 24 | ObsKinect.GreenScreenEnabled="Enable faux greenscreen" 25 | ObsKinect.GreenScreenFadeDist="Fade distance" 26 | ObsKinect.GreenScreenMaxDist="Maximum allowed distance" 27 | ObsKinect.GreenScreenMinDist="Minimum allowed distance" 28 | ObsKinect.GreenScreenBlurPassCount="Blur passes" 29 | ObsKinect.GreenScreenType="Filter type" 30 | ObsKinect.GreenScreenType_Body="Body" 31 | ObsKinect.GreenScreenType_BodyOrDepth="Body or depth" 32 | ObsKinect.GreenScreenType_BodyWithinDepth="Body within depth" 33 | ObsKinect.GreenScreenType_Dedicated="KinectSDK background removal" 34 | ObsKinect.GreenScreenType_Depth="Depth" 35 | ObsKinect.GreenScreenGpuDepthMapping="Use GPU to fetch color-to-depth values" 36 | ObsKinect.GreenScreenGpuDepthMappingDesc="Move some GPU work to the CPU, uncheck only if experiencing troubles" 37 | ObsKinect.GreenScreenMaxDirtyDepth="Max number of depth-lagging frames allowed" 38 | ObsKinect.GreenScreenMaxDirtyDepthDesc="Lowers flickering but adds depth shadowing when moving quickly" 39 | ObsKinect.GreenScreenDistUnit="mm" 40 | ObsKinect.GreenScreenVisibilityMask="Visibility mask" 41 | 42 | ; green screen effects 43 | ObsKinect.BlurBackground.Reversed="Reversed" 44 | ObsKinect.BlurBackground.Strength="Strength" 45 | ObsKinect.GreenScreenEffect="Effect" 46 | ObsKinect.GreenScreenEffect_BlurBackground="Blur background" 47 | ObsKinect.GreenScreenEffect_RemoveBackground="Remove background" 48 | ObsKinect.GreenScreenEffect_ReplaceBackground="Replace background" 49 | ObsKinect.ReplaceBackground.Path="File path" 50 | 51 | ; color settings 52 | ObsKinect.AnalogGain="Analog gain" 53 | ObsKinect.AutoExposure="Automatic exposure" 54 | ObsKinect.AutoWhiteBalance="Automatic white balance" 55 | ObsKinect.BacklightCompensation="Backlight compensation" 56 | ObsKinect.BacklightCompensation_AverageBrightness="Average brightness" 57 | ObsKinect.BacklightCompensation_CenterOnly="Center only" 58 | ObsKinect.BacklightCompensation_CenterPriority="Center priority" 59 | ObsKinect.BacklightCompensation_LowLightsPriority="Low lights priority" 60 | ObsKinect.Brightness="Brightness" 61 | ObsKinect.Contrast="Contrast" 62 | ObsKinect.DigitalGain="Digital gain" 63 | ObsKinect.DumpCameraSettings="Dump camera settings" 64 | ObsKinect.ExposureCompensation="Exposure compensation" 65 | ObsKinect.ExposureControl_FullyAuto="Fully automatic" 66 | ObsKinect.ExposureControl_SemiAuto="Semi automatic" 67 | ObsKinect.ExposureControl_Manual="Manual" 68 | ObsKinect.ExposureIntegrationTime="Exposure integration time" 69 | ObsKinect.ExposureMode="Exposure mode" 70 | ObsKinect.ExposureTime="Exposure time" 71 | ObsKinect.FrameInterval="Frame interval" 72 | ObsKinect.Gain="Gain" 73 | ObsKinect.Gain_Blue="Blue gain" 74 | ObsKinect.Gain_Green="Green gain" 75 | ObsKinect.Gain_Red="Red gain" 76 | ObsKinect.Gamma="Gamma" 77 | ObsKinect.Hue="Hue" 78 | ObsKinect.PowerlineFrequency="Powerline frequency" 79 | ObsKinect.PowerlineFrequency_Disabled="Disabled" 80 | ObsKinect.PowerlineFrequency_50Hz="50Hz" 81 | ObsKinect.PowerlineFrequency_60Hz="60Hz" 82 | ObsKinect.Saturation="Saturation" 83 | ObsKinect.Sharpness="Sharpness" 84 | ObsKinect.WhiteBalance="White balance" 85 | ObsKinect.WhiteBalanceMode="White balance mode" 86 | ObsKinect.WhiteBalanceMode_Auto="Automatic" 87 | ObsKinect.WhiteBalanceMode_Manual="Manual" 88 | ObsKinect.WhiteBalanceMode_Unknown="Unknown" ; I don't know what this setting does 89 | 90 | ; obs-kinect-sdk10 backend 91 | ObsKinectV1.CameraElevation="Camera elevation" 92 | ObsKinectV1.HighRes="Enable color high-res mode" 93 | ObsKinectV1.HighResDesc="Output color at 1280x960 instead of 640x480 but at a lower framerate (15Hz instead of 30Hz)" 94 | ObsKinectV1.NearMode="Enable depth near mode" 95 | ObsKinectV1.NearModeDesc="Brings the depth range to 40-200cm instead of 80-400cm (doesn't work on Kinect for 360 version)" 96 | 97 | ; obs-kinect-sdk20 backend 98 | ObsKinectV2.NexusLedIntensity="Nexus led intensity" 99 | ObsKinectV2.PrivacyLedIntensity="Privacy led intensity" 100 | ObsKinectV2.ServicePriority="Kinect service priority" 101 | ObsKinectV2.ServicePriority_High="High" 102 | ObsKinectV2.ServicePriority_AboveNormal="Above normal" 103 | ObsKinectV2.ServicePriority_Normal="Normal" 104 | 105 | ; obs-kinect-azuresdk backend 106 | ObsKinectAzure.ColorResolution="Color resolution" 107 | ObsKinectAzure.ColorResolution_1280x720="720p (16:9 - 1280×720)" 108 | ObsKinectAzure.ColorResolution_1920x1080="1080p (16:9 - 1920×1080)" 109 | ObsKinectAzure.ColorResolution_2560x1440="1440p (16:9 - 2560×1440)" 110 | ObsKinectAzure.ColorResolution_2048x1536="1536p (4:3 - 2048×1536)" 111 | ObsKinectAzure.ColorResolution_3840x2160="4K (16:9 - 3840×2160)" 112 | ObsKinectAzure.ColorResolution_4096x3072="3072 (4:3 - 4096×3072)" 113 | ObsKinectAzure.DepthMode="Depth mode" 114 | ObsKinectAzure.DepthMode_NFOV_Unbinned="NFOV unbinned" 115 | ObsKinectAzure.DepthMode_NFOV_2x2Binned="NFOV 2x2 binned (SW)" 116 | ObsKinectAzure.DepthMode_WFOV_Unbinned="WFOV unbinned" 117 | ObsKinectAzure.DepthMode_WFOV_2x2Binned="WFOV 2x2 binned" 118 | ObsKinectAzure.DepthMode_Passive="Passive IR" 119 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/locale/de-DE.ini: -------------------------------------------------------------------------------- 1 | ObsKinect.KinectSource="Kinect" 2 | 3 | ObsKinect.NoDevice="Kein Gerät" 4 | ObsKinect.Device="Kinect-Gerät" 5 | ObsKinect.RefreshDevices="Aktualisiere Geräteliste" 6 | 7 | ObsKinect.Source="Kinect Stream" 8 | ObsKinect.Source_Color="Farbe" 9 | ObsKinect.Source_Depth="Tiefe/Entfernung" 10 | ObsKinect.Source_Infrared="Infrarot" 11 | 12 | ObsKinect.DepthDynamic="Dynamische Tiefenwerte (inhaltsbasiert)" 13 | ObsKinect.DepthAverage="Durchschnittstiefe (normalisiert)" 14 | ObsKinect.DepthStandardDeviation="Standardabweichung Tiefe" 15 | 16 | ObsKinect.InfraredDynamic="Dynamische Infrarotwerte (inhaltsbasiert)" 17 | ObsKinect.InfraredAverage="Durchschn. Infrarotwert (normalisiert)" 18 | ObsKinect.InfraredStandardDeviation="Standardabweichung Infrarotwert" 19 | 20 | ObsKinect.InvisibleShutdown="Ausschalten, wenn unsichtbar" 21 | 22 | ; green screen settings 23 | ObsKinect.GreenScreen="Greenscreen-Imitation" 24 | ObsKinect.GreenScreenEnabled="Greenscreen-Imitation aktivieren" 25 | ObsKinect.GreenScreenFadeDist="Übergangsabstand" 26 | ObsKinect.GreenScreenMaxDist="Maximalabstand" 27 | ObsKinect.GreenScreenMinDist="Minimalabstand" 28 | ObsKinect.GreenScreenBlurPassCount="Weichzeichner-Durchgänge" 29 | ObsKinect.GreenScreenType="Filterart" 30 | ObsKinect.GreenScreenType_Body="Körpererkennung" 31 | ObsKinect.GreenScreenType_BodyOrDepth="Körper oder Tiefe" 32 | ObsKinect.GreenScreenType_BodyWithinDepth="Körper in Tiefe" 33 | ObsKinect.GreenScreenType_Dedicated="KinectSDK Hintergrundentfernung" 34 | ObsKinect.GreenScreenType_Depth="Tiefenbasiert" 35 | ObsKinect.GreenScreenGpuDepthMapping="GPU für Farbe-zu-Tiefe-Berechnung verwenden" 36 | ObsKinect.GreenScreenGpuDepthMappingDesc="Nur bei Problemen deaktivieren" 37 | ObsKinect.GreenScreenMaxDirtyDepth="Max. Anzahl an Bildern, um die die Tiefeninformation dem Farbbild hinterher sein darf" 38 | ObsKinect.GreenScreenMaxDirtyDepthDesc="Reduziert Flackern zu Lasten der Bewegungssynchronisation" 39 | ObsKinect.GreenScreenDistUnit="mm" 40 | ObsKinect.GreenScreenVisibilityMask="Sichtbarkeitsmaske" 41 | 42 | ; green screen effects 43 | ObsKinect.BlurBackground.Reversed="Invertiert" 44 | ObsKinect.BlurBackground.Strength="Stärke" 45 | ObsKinect.GreenScreenEffect="Effekt" 46 | ObsKinect.GreenScreenEffect_BlurBackground="Hintergrund weichzeichnen" 47 | ObsKinect.GreenScreenEffect_RemoveBackground="Hintergrund entfernen" 48 | ObsKinect.GreenScreenEffect_ReplaceBackground="Hintergrund ersetzen" 49 | ObsKinect.ReplaceBackground.Path="Dateipfad" 50 | 51 | ; color settings 52 | ObsKinect.AnalogGain="Analoge Verstärkung" 53 | ObsKinect.AutoExposure="Autom. Belichtung aktivieren" 54 | ObsKinect.AutoWhiteBalance="Automatischer Weißabgleich" 55 | ObsKinect.BacklightCompensation="Gegenlichtausgleich" 56 | ObsKinect.BacklightCompensation_AverageBrightness="Durchschnittliche Helligkeit" 57 | ObsKinect.BacklightCompensation_CenterOnly="Bildmitte" 58 | ObsKinect.BacklightCompensation_CenterPriority="Vorrangig Bildmitte" 59 | ObsKinect.BacklightCompensation_LowLightsPriority="Vorrangig schwaches Licht" 60 | ObsKinect.Brightness="Helligkeit" 61 | ObsKinect.Contrast="Kontrast" 62 | ObsKinect.DigitalGain="Digitale Verstärkung" 63 | ObsKinect.DumpCameraSettings="Kameraeinstellungen in Log schreiben" 64 | ObsKinect.ExposureCompensation="Belichtungsausgleich" 65 | ObsKinect.ExposureControl_FullyAuto="Automatisch" 66 | ObsKinect.ExposureControl_SemiAuto="Halbautomatisch" 67 | ObsKinect.ExposureControl_Manual="Manuell" 68 | ObsKinect.ExposureIntegrationTime="Belichtungsintegrationszeit" 69 | ObsKinect.ExposureMode="Belichtung" 70 | ObsKinect.ExposureTime="Belichtungszeit" 71 | ObsKinect.FrameInterval="Bild-Intervall" 72 | ObsKinect.Gain="Verstärkung" 73 | ObsKinect.Gain_Blue="Verstärkung blau" 74 | ObsKinect.Gain_Green="Verstärkung grün" 75 | ObsKinect.Gain_Red="Verstärkung rot" 76 | ObsKinect.Gamma="Gamma" ; 77 | ObsKinect.Hue="Farbton" ; 78 | ObsKinect.PowerlineFrequency="Flimmerreduzierung (Netzfrequenz)" 79 | ObsKinect.PowerlineFrequency_Disabled="Deaktiviert" 80 | ObsKinect.PowerlineFrequency_50Hz="50 Hz" 81 | ObsKinect.PowerlineFrequency_60Hz="60 Hz" 82 | ObsKinect.Saturation="Sättigung" 83 | ObsKinect.Sharpness="Schärfe" 84 | ObsKinect.WhiteBalance="Weißabgleich" 85 | ObsKinect.WhiteBalanceMode="Weißabgleich" 86 | ObsKinect.WhiteBalanceMode_Auto="Automatisch" 87 | ObsKinect.WhiteBalanceMode_Manual="Manuell" 88 | ObsKinect.WhiteBalanceMode_Unknown="Unbekannt" 89 | 90 | ; obs-kinect-sdk10 backend 91 | ObsKinectV1.CameraElevation="Kamerawinkel" 92 | ObsKinectV1.HighRes="Aktiviere Farb High-Res Modus" 93 | ObsKinectV1.HighResDesc="Ausgabe in Farbe mit 1280x960 anstatt mit 640x480 aber mit tieferer Bildrate (15Hz anstatt 30Hz)" 94 | ObsKinectV1.NearMode="Aktiviere Depth Near-Modus" 95 | ObsKinectV1.NearModeDesc="Reduziert den Tiefenfokus auf 40-200 cm anstatt 80-400 cm (funktioniert nicht für Kinect 360 Version)" 96 | 97 | ; obs-kinect-sdk20 backend 98 | ObsKinectV2.NexusLedIntensity="Xbox LED Helligkeit" 99 | ObsKinectV2.PrivacyLedIntensity="Status LED Helligkeit" 100 | ObsKinectV2.ServicePriority="Kinect Dienst-Priorität" 101 | ObsKinectV2.ServicePriority_High="Hoch" 102 | ObsKinectV2.ServicePriority_AboveNormal="Höher als normal" 103 | ObsKinectV2.ServicePriority_Normal="Normal" 104 | 105 | ; obs-kinect-azuresdk backend 106 | ObsKinectAzure.ColorResolution="Color resolution" 107 | ObsKinectAzure.ColorResolution_1280x720="720p (16:9 - 1280×720)" 108 | ObsKinectAzure.ColorResolution_1920x1080="1080p (16:9 - 1920×1080)" 109 | ObsKinectAzure.ColorResolution_2560x1440="1440p (16:9 - 2560×1440)" 110 | ObsKinectAzure.ColorResolution_2048x1536="1536p (4:3 - 2048×1536)" 111 | ObsKinectAzure.ColorResolution_3840x2160="4K (16:9 - 3840×2160)" 112 | ObsKinectAzure.ColorResolution_4096x3072="3072 (4:3 - 4096×3072)" 113 | ObsKinectAzure.DepthMode="Depth mode" 114 | ObsKinectAzure.DepthMode_NFOV_Unbinned="NFOV unbinned" 115 | ObsKinectAzure.DepthMode_NFOV_2x2Binned="NFOV 2x2 binned (SW)" 116 | ObsKinectAzure.DepthMode_WFOV_Unbinned="WFOV unbinned" 117 | ObsKinectAzure.DepthMode_WFOV_2x2Binned="WFOV 2x2 binned" 118 | ObsKinectAzure.DepthMode_Passive="Passive IR" 119 | -------------------------------------------------------------------------------- /src/obs-kinect/Shaders/GreenScreenFilterShader.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | GreenScreenFilterShader::GreenScreenFilterShader() 24 | { 25 | ObsMemoryPtr effectFilename(obs_module_file("greenscreen_filter.effect")); 26 | 27 | ObsGraphics gfx; 28 | 29 | char* errStr = nullptr; 30 | m_effect = gs_effect_create_from_file(effectFilename.get(), &errStr); 31 | ObsMemoryPtr errStrOwner(errStr); 32 | 33 | if (m_effect) 34 | { 35 | m_params_BodyIndexImage = gs_effect_get_param_by_name(m_effect, "BodyIndexImage"); 36 | m_params_DepthImage = gs_effect_get_param_by_name(m_effect, "DepthImage"); 37 | m_params_DepthMappingImage = gs_effect_get_param_by_name(m_effect, "DepthMappingImage"); 38 | m_params_InvDepthImageSize = gs_effect_get_param_by_name(m_effect, "InvDepthImageSize"); 39 | m_params_InvDepthProgressive = gs_effect_get_param_by_name(m_effect, "InvDepthProgressive"); 40 | m_params_MaxDepth = gs_effect_get_param_by_name(m_effect, "MaxDepth"); 41 | m_params_MinDepth = gs_effect_get_param_by_name(m_effect, "MinDepth"); 42 | 43 | m_tech_BodyOnlyWithDepthCorrection = gs_effect_get_technique(m_effect, "BodyOnlyWithDepthCorrection"); 44 | m_tech_BodyOnlyWithoutDepthCorrection = gs_effect_get_technique(m_effect, "BodyOnlyWithoutDepthCorrection"); 45 | 46 | m_tech_BodyOrDepthWithDepthCorrection = gs_effect_get_technique(m_effect, "BodyOrDepthWithDepthCorrection"); 47 | m_tech_BodyOrDepthWithoutDepthCorrection = gs_effect_get_technique(m_effect, "BodyOrDepthWithoutDepthCorrection"); 48 | 49 | m_tech_BodyWithinDepthWithDepthCorrection = gs_effect_get_technique(m_effect, "BodyWithinDepthWithDepthCorrection"); 50 | m_tech_BodyWithinDepthWithoutDepthCorrection = gs_effect_get_technique(m_effect, "BodyWithinDepthWithoutDepthCorrection"); 51 | 52 | m_tech_DepthOnlyWithDepthCorrection = gs_effect_get_technique(m_effect, "DepthOnlyWithDepthCorrection"); 53 | m_tech_DepthOnlyWithoutDepthCorrection = gs_effect_get_technique(m_effect, "DepthOnlyWithoutDepthCorrection"); 54 | 55 | m_workTexture = gs_texrender_create(GS_R8, GS_ZS_NONE); 56 | } 57 | else 58 | { 59 | std::string err("failed to create effect: "); 60 | err.append((errStr) ? errStr : "shader error"); 61 | 62 | throw std::runtime_error(err); 63 | } 64 | } 65 | 66 | GreenScreenFilterShader::~GreenScreenFilterShader() 67 | { 68 | ObsGraphics gfx; 69 | 70 | gs_effect_destroy(m_effect); 71 | gs_texrender_destroy(m_workTexture); 72 | } 73 | 74 | gs_texture_t* GreenScreenFilterShader::Filter(std::uint32_t width, std::uint32_t height, const BodyFilterParams& params) 75 | { 76 | if (!Begin(width, height)) 77 | return nullptr; 78 | 79 | SetBodyParams(params); 80 | 81 | gs_technique_t* technique = (params.colorToDepthTexture) ? m_tech_BodyOnlyWithDepthCorrection : m_tech_BodyOnlyWithoutDepthCorrection; 82 | 83 | return Process(width, height, technique); 84 | } 85 | 86 | gs_texture_t* GreenScreenFilterShader::Filter(std::uint32_t width, std::uint32_t height, const BodyOrDepthFilterParams& params) 87 | { 88 | if (!Begin(width, height)) 89 | return nullptr; 90 | 91 | SetBodyParams(params); 92 | SetDepthParams(params); 93 | 94 | gs_technique_t* technique = (params.colorToDepthTexture) ? m_tech_BodyOrDepthWithDepthCorrection : m_tech_BodyOrDepthWithoutDepthCorrection; 95 | 96 | return Process(width, height, technique); 97 | } 98 | 99 | gs_texture_t* GreenScreenFilterShader::Filter(std::uint32_t width, std::uint32_t height, const BodyWithinDepthFilterParams& params) 100 | { 101 | if (!Begin(width, height)) 102 | return nullptr; 103 | 104 | SetBodyParams(params); 105 | SetDepthParams(params); 106 | 107 | gs_technique_t* technique = (params.colorToDepthTexture) ? m_tech_BodyWithinDepthWithDepthCorrection : m_tech_BodyWithinDepthWithoutDepthCorrection; 108 | 109 | return Process(width, height, technique); 110 | } 111 | 112 | gs_texture_t* GreenScreenFilterShader::Filter(std::uint32_t width, std::uint32_t height, const DepthFilterParams& params) 113 | { 114 | if (!Begin(width, height)) 115 | return nullptr; 116 | 117 | SetDepthParams(params); 118 | 119 | gs_technique_t* technique = (params.colorToDepthTexture) ? m_tech_DepthOnlyWithDepthCorrection : m_tech_DepthOnlyWithoutDepthCorrection; 120 | 121 | return Process(width, height, technique); 122 | } 123 | 124 | bool GreenScreenFilterShader::Begin(std::uint32_t width, std::uint32_t height) 125 | { 126 | gs_texrender_reset(m_workTexture); 127 | if (!gs_texrender_begin(m_workTexture, width, height)) 128 | return false; 129 | 130 | vec4 black = { 0.f, 0.f, 0.f, 1.f }; 131 | gs_clear(GS_CLEAR_COLOR, &black, 0.f, 0); 132 | gs_ortho(0.0f, float(width), 0.0f, float(height), -100.0f, 100.0f); 133 | 134 | return true; 135 | } 136 | 137 | gs_texture* GreenScreenFilterShader::Process(std::uint32_t width, std::uint32_t height, gs_technique_t* technique) 138 | { 139 | gs_technique_begin(technique); 140 | gs_technique_begin_pass(technique, 0); 141 | gs_draw_sprite(nullptr, 0, width, height); 142 | gs_technique_end_pass(technique); 143 | gs_technique_end(technique); 144 | 145 | gs_texrender_end(m_workTexture); 146 | 147 | return gs_texrender_get_texture(m_workTexture); 148 | } 149 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/locale/cs-CZ.ini: -------------------------------------------------------------------------------- 1 | ObsKinect.KinectSource="Kinect" 2 | 3 | ObsKinect.NoDevice="Žádné Kinect zařízení" 4 | ObsKinect.Device="Kamera Kinect" 5 | ObsKinect.RefreshDevices="Obnovit seznam zařízení" 6 | 7 | ObsKinect.Source="Zdroj streamu z Kinectu" 8 | ObsKinect.Source_Color="Barevný" 9 | ObsKinect.Source_Depth="Hloubkový" 10 | ObsKinect.Source_Infrared="Infračervený" 11 | 12 | ObsKinect.DepthDynamic="Automatické hodnoty hloubky (založené na obsahu)" 13 | ObsKinect.DepthAverage="Průměrná vzdálenost (normalizovaná)" 14 | ObsKinect.DepthStandardDeviation="Směrodatná odchylka vzdálenosti" 15 | 16 | ObsKinect.InfraredDynamic="Automatické infračervené hodnoty (založený na obsahu)" 17 | ObsKinect.InfraredAverage="Průměrná IR hodnota (normalizovaná)" 18 | ObsKinect.InfraredStandardDeviation="Směrodatná IR odchylka hodnoty" 19 | 20 | ObsKinect.InvisibleShutdown="Deaktivovat když není viditelný" 21 | 22 | ; green screen settings 23 | ObsKinect.GreenScreen="Virtuální Greenscreen" 24 | ObsKinect.GreenScreenEnabled="Aktivovat virtuální Greenscreen" 25 | ObsKinect.GreenScreenFadeDist="Rozsah efektu prolnutí" 26 | ObsKinect.GreenScreenMaxDist="Maximální viditelná vzdálenost" 27 | ObsKinect.GreenScreenMinDist="Minimální viditelná vzdálenost" 28 | ObsKinect.GreenScreenBlurPassCount="Počet průchodů rozostření" 29 | ObsKinect.GreenScreenType="Typ filtru" 30 | ObsKinect.GreenScreenType_Body="Lidské tělo" 31 | ObsKinect.GreenScreenType_BodyOrDepth="Lidské tělo nebo hloubka" 32 | ObsKinect.GreenScreenType_BodyWithinDepth="Lidské tělo v hloubce" 33 | ObsKinect.GreenScreenType_Dedicated="Odebrání pozadí pomocí KinectSDK" 34 | ObsKinect.GreenScreenType_Depth="Hloubka" 35 | ObsKinect.GreenScreenGpuDepthMapping="Akcelerace získání hodnoty barva-hloubka pomocí GPU" 36 | ObsKinect.GreenScreenGpuDepthMappingDesc="Při problémech zrušte zaškrtnutí pro přesun výpočtů na CPU" 37 | ObsKinect.GreenScreenMaxDirtyDepth="Maximální povolený počet zpožděných hloubkových snímků" 38 | ObsKinect.GreenScreenMaxDirtyDepthDesc="Sníží problikávání, ale přidá stíny při rychlém pohybu" 39 | ObsKinect.GreenScreenDistUnit="mm" 40 | ObsKinect.GreenScreenVisibilityMask="Visibility mask" ; missing translation 41 | 42 | ; green screen effects 43 | ObsKinect.BlurBackground.Reversed="Obrácený" 44 | ObsKinect.BlurBackground.Strength="Silný" 45 | ObsKinect.GreenScreenEffect="Efekt" 46 | ObsKinect.GreenScreenEffect_BlurBackground="Rozmazání pozadí" 47 | ObsKinect.GreenScreenEffect_RemoveBackground="Odstranění pozadí" 48 | ObsKinect.GreenScreenEffect_ReplaceBackground="Nahrazení pozadí" 49 | ObsKinect.ReplaceBackground.Path="Cesta k souboru" 50 | 51 | ; color settings 52 | ObsKinect.AnalogGain="Analogový zisk" 53 | ObsKinect.AutoExposure="Automatická expozice" 54 | ObsKinect.AutoWhiteBalance="Automatické vyvážení bílé" 55 | ObsKinect.BacklightCompensation="Kompenzace světla proti kameře" 56 | ObsKinect.BacklightCompensation_AverageBrightness="Průměrování jasu" 57 | ObsKinect.BacklightCompensation_CenterOnly="Jen střed" 58 | ObsKinect.BacklightCompensation_CenterPriority="Upřednostnit střed" 59 | ObsKinect.BacklightCompensation_LowLightsPriority="Upřednostnit slabé osvětlení" 60 | ObsKinect.Brightness="Jas" 61 | ObsKinect.Contrast="Kontrast" 62 | ObsKinect.DigitalGain="Digitalní zisk" 63 | ObsKinect.DumpCameraSettings="Výpis nastavení kamery" 64 | ObsKinect.ExposureCompensation="Kompenzace expozice" 65 | ObsKinect.ExposureControl_FullyAuto="Plně automatické" 66 | ObsKinect.ExposureControl_SemiAuto="Polo automatické" 67 | ObsKinect.ExposureControl_Manual="Manuální" 68 | ObsKinect.ExposureIntegrationTime="Doba integrace expozice" 69 | ObsKinect.ExposureMode="Režim expozice" 70 | ObsKinect.ExposureTime="Doba expozice" 71 | ObsKinect.FrameInterval="Snímkový interval" 72 | ObsKinect.Gain="Zisk" 73 | ObsKinect.Gain_Blue="Zisk modré barvy" 74 | ObsKinect.Gain_Green="Zisk zelené barvy" 75 | ObsKinect.Gain_Red="Zisk červené barvy" 76 | ObsKinect.Gamma="Gamma (Strmost)" 77 | ObsKinect.Hue="Hue (Odstín)" 78 | ObsKinect.PowerlineFrequency="Frekvence sítě napájení" 79 | ObsKinect.PowerlineFrequency_Disabled="Neaktivní" 80 | ObsKinect.PowerlineFrequency_50Hz="50Hz" 81 | ObsKinect.PowerlineFrequency_60Hz="60Hz" 82 | ObsKinect.Saturation="Saturace" 83 | ObsKinect.Sharpness="Ostrost" 84 | ObsKinect.WhiteBalance="Vvyvážení bílé" 85 | ObsKinect.WhiteBalanceMode="Režim vyvážení bílé" 86 | ObsKinect.WhiteBalanceMode_Auto="Automatický" 87 | ObsKinect.WhiteBalanceMode_Manual="Manuální" 88 | ObsKinect.WhiteBalanceMode_Unknown="Neznámý" ; I don't know what this setting does 89 | 90 | ; obs-kinect-sdk10 backend 91 | ObsKinectV1.CameraElevation="Výška umístění kamery" 92 | ObsKinectV1.HighRes="Povolit režim vysokého rozlišení berevné kamery" 93 | ObsKinectV1.HighResDesc="Výstupní režim 1280x960 namísto standardního 640x480 ale při nižším FPS (15Hz namísto 30Hz)" 94 | ObsKinectV1.NearMode="Povolit blízký režim (hloubky)" 95 | ObsKinectV1.NearModeDesc="Zkrátí rozsah hloubky o polovinu 40-200cm namísto původních 80-400cm (nefunguje na Kinect 360 verzi)" 96 | 97 | ; obs-kinect-sdk20 backend 98 | ObsKinectV2.NexusLedIntensity="Intenzita LED Nexus pole" 99 | ObsKinectV2.PrivacyLedIntensity="Soukromá LED intenzita" 100 | ObsKinectV2.ServicePriority="Priorita zpracování Kinect služby" 101 | ObsKinectV2.ServicePriority_High="Vysoká" 102 | ObsKinectV2.ServicePriority_AboveNormal="Vyšší" 103 | ObsKinectV2.ServicePriority_Normal="Normální" 104 | 105 | ; obs-kinect-azuresdk backend 106 | ObsKinectAzure.ColorResolution="Rozlišení barevné kamery" 107 | ObsKinectAzure.ColorResolution_1280x720="720p (16:9 - 1280×720)" 108 | ObsKinectAzure.ColorResolution_1920x1080="1080p (16:9 - 1920×1080)" 109 | ObsKinectAzure.ColorResolution_2560x1440="1440p (16:9 - 2560×1440)" 110 | ObsKinectAzure.ColorResolution_2048x1536="1536p (4:3 - 2048×1536)" 111 | ObsKinectAzure.ColorResolution_3840x2160="4K (16:9 - 3840×2160)" 112 | ObsKinectAzure.ColorResolution_4096x3072="3072 (4:3 - 4096×3072)" 113 | ObsKinectAzure.DepthMode="Hloubkový režim" 114 | ObsKinectAzure.DepthMode_NFOV_Unbinned="NFOV bez členění" 115 | ObsKinectAzure.DepthMode_NFOV_2x2Binned="NFOV s rozčleněním 2x2 (SW)" 116 | ObsKinectAzure.DepthMode_WFOV_Unbinned="WFOV bez členění" 117 | ObsKinectAzure.DepthMode_WFOV_2x2Binned="WFOV s rozčleněním 2x2" 118 | ObsKinectAzure.DepthMode_Passive="Pasivní IR" 119 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/locale/fr-FR.ini: -------------------------------------------------------------------------------- 1 | ObsKinect.KinectSource="Kinect" 2 | 3 | ObsKinect.NoDevice="Pas de caméra Kinect" 4 | ObsKinect.Device="Caméras Kinect" 5 | ObsKinect.RefreshDevices="Rafraichir les caméras disponible" 6 | 7 | ObsKinect.Source="Flux Kinect" 8 | ObsKinect.Source_Color="Couleur" 9 | ObsKinect.Source_Depth="Profondeur" 10 | ObsKinect.Source_Infrared="Infrarouge" 11 | 12 | ObsKinect.DepthDynamic="Valeurs de profondeur automatiques (basées sur le contenu)" 13 | ObsKinect.DepthAverage="Distance moyenne" 14 | ObsKinect.DepthStandardDeviation="Écart-type de la distance" 15 | 16 | ObsKinect.InfraredDynamic="Valeurs infrarouge automatiques (basées sur le contenu)" 17 | ObsKinect.InfraredAverage="Valeur infrarouge moyenne" 18 | ObsKinect.InfraredStandardDeviation="Écart-type des valeurs infrarouges" 19 | 20 | ObsKinect.InvisibleShutdown="Désactiver quand invisible" 21 | 22 | ; green screen settings 23 | ObsKinect.GreenScreen="Fond vert virtuel" 24 | ObsKinect.GreenScreenEnabled="Activer le fond vert virtuel" 25 | ObsKinect.GreenScreenFadeDist="Distance de fondu" 26 | ObsKinect.GreenScreenMaxDist="Distance maximale autorisée" 27 | ObsKinect.GreenScreenMinDist="Distance minimale autorisée" 28 | ObsKinect.GreenScreenBlurPassCount="Passes de floutage" 29 | ObsKinect.GreenScreenType="Type de filtrage" 30 | ObsKinect.GreenScreenType_Body="Corps" 31 | ObsKinect.GreenScreenType_BodyOrDepth="Corps ou profondeur" 32 | ObsKinect.GreenScreenType_BodyWithinDepth="Corps dans les limites de la profondeur" 33 | ObsKinect.GreenScreenType_Dedicated="Suppression d'arrière-plan du SDK Kinect" 34 | ObsKinect.GreenScreenType_Depth="Profondeur" 35 | ObsKinect.GreenScreenGpuDepthMapping="Utiliser la carte graphique pour récupérer la valeur de profondeur par pixel" 36 | ObsKinect.GreenScreenGpuDepthMappingDesc="Troque une partie de la charge de la carte graphique vers le processeur, décochez uniquement en cas de problème" 37 | ObsKinect.GreenScreenMaxDirtyDepth="Nombre maximum de retard de profondeur autorisé" 38 | ObsKinect.GreenScreenMaxDirtyDepthDesc="Diminue le scintillement mais ajoute une ombre en cas de mouvement rapide" 39 | ObsKinect.GreenScreenDistUnit="mm" 40 | ObsKinect.GreenScreenVisibilityMask="Masque de visibilité" 41 | 42 | ; green screen effects 43 | ObsKinect.BlurBackground.Reversed="Inversé" 44 | ObsKinect.BlurBackground.Strength="Force" 45 | ObsKinect.GreenScreenEffect="Effet" 46 | ObsKinect.GreenScreenEffect_BlurBackground="Flouter le fond" 47 | ObsKinect.GreenScreenEffect_RemoveBackground="Supprimer le fond" 48 | ObsKinect.GreenScreenEffect_ReplaceBackground="Remplacer le fond" 49 | ObsKinect.ReplaceBackground.Path="Chemin" 50 | 51 | ; color settings 52 | ObsKinect.AnalogGain="Gain analogique" 53 | ObsKinect.AutoExposure="Exposition automatique" 54 | ObsKinect.AutoWhiteBalance="Balance des blancs automatique" 55 | ObsKinect.BacklightCompensation="Compensation de contre-jour" 56 | ObsKinect.BacklightCompensation_AverageBrightness="Luminosité moyenne" 57 | ObsKinect.BacklightCompensation_CenterOnly="Centre uniquement" 58 | ObsKinect.BacklightCompensation_CenterPriority="Priorité au centre" 59 | ObsKinect.BacklightCompensation_LowLightsPriority="Priorité aux faibles lumières" 60 | ObsKinect.Brightness="Luminosité" 61 | ObsKinect.Contrast="Contraste" 62 | ObsKinect.DigitalGain="Gain numérique" 63 | ObsKinect.DumpCameraSettings="Logger les paramètres de la caméra" 64 | ObsKinect.ExposureCompensation="Compensation de l'exposition" 65 | ObsKinect.ExposureControl_FullyAuto="Automatique" 66 | ObsKinect.ExposureControl_SemiAuto="Semi-automatique" 67 | ObsKinect.ExposureControl_Manual="Manuel" 68 | ObsKinect.ExposureIntegrationTime="Temps d'intégration de l'exposition" 69 | ObsKinect.ExposureMode="Mode d'exposition" 70 | ObsKinect.ExposureTime="Temps d'exposition" 71 | ObsKinect.FrameInterval="Intervalle d'image" 72 | ObsKinect.Gain="Gain" 73 | ObsKinect.Gain_Blue="Gain (bleu)" 74 | ObsKinect.Gain_Green="Gain (vert)" 75 | ObsKinect.Gain_Red="Gain (rouge)" 76 | ObsKinect.Gamma="Gamma" 77 | ObsKinect.Hue="Teinte" 78 | ObsKinect.PowerlineFrequency="Fréquence du courant" 79 | ObsKinect.PowerlineFrequency_Disabled="Désactivé" 80 | ObsKinect.PowerlineFrequency_50Hz="50Hz" 81 | ObsKinect.PowerlineFrequency_60Hz="60Hz" 82 | ObsKinect.Saturation="Saturation" 83 | ObsKinect.Sharpness="Netteté" 84 | ObsKinect.WhiteBalance="Balance des blancs" 85 | ObsKinect.WhiteBalanceMode="Mode de balance des blancs" 86 | ObsKinect.WhiteBalanceMode_Auto="Automatique" 87 | ObsKinect.WhiteBalanceMode_Manual="Manual" 88 | ObsKinect.WhiteBalanceMode_Unknown="Inconnu" ; I don't know what this setting does 89 | 90 | ; obs-kinect-sdk10 backend 91 | ObsKinectV1.CameraElevation="Élévation de la caméra" 92 | ObsKinectV1.HighRes="Couleur haute-résolution" 93 | ObsKinectV1.HighResDesc="Sort la couleur en 1280x960 au lieu de 640x480 mais à une fréquence plus basse (15Hz au lieu de 30Hz)" 94 | ObsKinectV1.NearMode="Mode de proximité" 95 | ObsKinectV1.NearModeDesc="Amène le champ de profondeur à 40-200cm au lieu de 80-400cm (ne fonctionne pas avec la version Kinect de la Xbox 360)" 96 | 97 | ; obs-kinect-sdk20 backend 98 | ObsKinectV2.NexusLedIntensity="Intensité du logo" 99 | ObsKinectV2.PrivacyLedIntensity="Intensité du voyant d'activation" 100 | ObsKinectV2.ServicePriority="Priorité du service Kinect" 101 | ObsKinectV2.ServicePriority_High="Haute" 102 | ObsKinectV2.ServicePriority_AboveNormal="Au-dessus de la normale" 103 | ObsKinectV2.ServicePriority_Normal="Normale" 104 | 105 | ; obs-kinect-azuresdk backend 106 | ObsKinectAzure.ColorResolution="Résolution des couleurs" 107 | ObsKinectAzure.ColorResolution_1280x720="720p (16:9 - 1280×720)" 108 | ObsKinectAzure.ColorResolution_1920x1080="1080p (16:9 - 1920×1080)" 109 | ObsKinectAzure.ColorResolution_2560x1440="1440p (16:9 - 2560×1440)" 110 | ObsKinectAzure.ColorResolution_2048x1536="1536p (4:3 - 2048×1536)" 111 | ObsKinectAzure.ColorResolution_3840x2160="4K (16:9 - 3840×2160)" 112 | ObsKinectAzure.ColorResolution_4096x3072="3072 (4:3 - 4096×3072)" 113 | ObsKinectAzure.DepthMode="Mode de profondeur" 114 | ObsKinectAzure.DepthMode_NFOV_Unbinned="NFOV sans compartimentation" 115 | ObsKinectAzure.DepthMode_NFOV_2x2Binned="NFOV 2x2 avec compartimentation (SW)" 116 | ObsKinectAzure.DepthMode_WFOV_Unbinned="WFOV 2x2 avec compartimentation" 117 | ObsKinectAzure.DepthMode_WFOV_2x2Binned="WFOV sans compartimentation" 118 | ObsKinectAzure.DepthMode_Passive="Infrarouge passif" 119 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/locale/pl-PL.ini: -------------------------------------------------------------------------------- 1 | ObsKinect.KinectSource="Kinect" 2 | 3 | ObsKinect.NoDevice="Brak urządzenia" 4 | ObsKinect.Device="Urządzenie Kinect" 5 | ObsKinect.RefreshDevices="Odśwież urządzenia" 6 | 7 | ObsKinect.Source="Strumień Kinect" 8 | ObsKinect.Source_Color="Kolor" 9 | ObsKinect.Source_Depth="Głębia" 10 | ObsKinect.Source_Infrared="Podczerwień" 11 | 12 | ObsKinect.DepthDynamic="Wartości dynamiki głebi (na podstawie zawartości)" 13 | ObsKinect.DepthAverage="Średni dystans (normalizowany)" 14 | ObsKinect.DepthStandardDeviation="Odchył standardowego dystansu" 15 | 16 | ObsKinect.InfraredDynamic="Wartości dynamiki podczerwieni (na podstawie zawartości)" 17 | ObsKinect.InfraredAverage="Średnia wartość podczerwieni (normalizowana)" 18 | ObsKinect.InfraredStandardDeviation="Odchył standardowej wartości podczerwieni" 19 | 20 | ObsKinect.InvisibleShutdown="Wyłącz, gdy niewidoczne" 21 | 22 | ; green screen settings 23 | ObsKinect.GreenScreen="Efekt sztucznego greenscreena" 24 | ObsKinect.GreenScreenEnabled="Włącz efekt sztucznego greenscreena" 25 | ObsKinect.GreenScreenFadeDist="Dystans przejścia" 26 | ObsKinect.GreenScreenMaxDist="Maksymalny dozwolony dystans" 27 | ObsKinect.GreenScreenMinDist="Minimalny dozwolony dystans" 28 | ObsKinect.GreenScreenBlurPassCount="Przejścia rozmycia" 29 | ObsKinect.GreenScreenType="Typ filtra" 30 | ObsKinect.GreenScreenType_Body="Ciało" 31 | ObsKinect.GreenScreenType_BodyOrDepth="Ciało lub głębia" 32 | ObsKinect.GreenScreenType_BodyWithinDepth="Ciało wewnątrz głebi" 33 | ObsKinect.GreenScreenType_Dedicated="Usunięcie tła KinectSDK" 34 | ObsKinect.GreenScreenType_Depth="Głębia" 35 | ObsKinect.GreenScreenGpuDepthMapping="Użyj GPU, by sprowadzić wartości koloru do głębi" 36 | ObsKinect.GreenScreenGpuDepthMappingDesc="Przenieś trochę pracy GPU na CPU, odznacz tylko jeśli doświadczasz problemów" 37 | ObsKinect.GreenScreenMaxDirtyDepth="Maskymalna liczba dozwolonych klatek z opóźnioną głębią (depth-lag)" 38 | ObsKinect.GreenScreenMaxDirtyDepthDesc="Obniża migotanie, ale dodaje cieniowanie głębi podczas szybkiego ruchu" 39 | ObsKinect.GreenScreenDistUnit="mm" 40 | ObsKinect.GreenScreenVisibilityMask="Visibility mask" ; missing translation 41 | 42 | ; green screen effects 43 | ObsKinect.BlurBackground.Reversed="Odwrócone" 44 | ObsKinect.BlurBackground.Strength="Nasilenie" 45 | ObsKinect.GreenScreenEffect="Efekt" 46 | ObsKinect.GreenScreenEffect_BlurBackground="Rozmycie tła" 47 | ObsKinect.GreenScreenEffect_RemoveBackground="Usunięcie tła" 48 | ObsKinect.GreenScreenEffect_ReplaceBackground="Zamiana tła" 49 | ObsKinect.ReplaceBackground.Path="Ścieżka do pliku" 50 | 51 | ; color settings 52 | ObsKinect.AnalogGain="Wzmocnienie analogowe" 53 | ObsKinect.AutoExposure="Włącz automatyczną ekspozycję" 54 | ObsKinect.AutoWhiteBalance="Automatyczny balans bieli" 55 | ObsKinect.BacklightCompensation="Kompensacja oświetlenia tła" 56 | ObsKinect.BacklightCompensation_AverageBrightness="Średnia jasność" 57 | ObsKinect.BacklightCompensation_CenterOnly="Tylko środek" 58 | ObsKinect.BacklightCompensation_CenterPriority="Priorytetyzacja środka" 59 | ObsKinect.BacklightCompensation_LowLightsPriority="Priorytetyzacja słabego światła" 60 | ObsKinect.Brightness="Jasność" 61 | ObsKinect.Contrast="Kontrast" 62 | ObsKinect.DigitalGain="Cyfrowe wzmocnienie" 63 | ObsKinect.DumpCameraSettings="Zrzuć ustawienia kamery" 64 | ObsKinect.ExposureCompensation="Kompensacja ekspozycji" 65 | ObsKinect.ExposureControl_FullyAuto="W pełni automatyczna" 66 | ObsKinect.ExposureControl_SemiAuto="Półautomatyczna" 67 | ObsKinect.ExposureControl_Manual="Ręczna" 68 | ObsKinect.ExposureIntegrationTime="Czas integracji ekspozycji" 69 | ObsKinect.ExposureMode="Tryb ekspozycji" 70 | ObsKinect.ExposureTime="Czas ekspozycji" 71 | ObsKinect.FrameInterval="Interwał klatek" 72 | ObsKinect.Gain="Wzmocnienie" 73 | ObsKinect.Gain_Blue="Wzmocnienie niebieskiego" 74 | ObsKinect.Gain_Green="Wzmocnienie zieleni" 75 | ObsKinect.Gain_Red="Wzmocnienie czerwieni" 76 | ObsKinect.Gamma="Gamma" 77 | ObsKinect.Hue="Odcień" 78 | ObsKinect.PowerlineFrequency="Częstotliwość sieci elektrycznej" 79 | ObsKinect.PowerlineFrequency_Disabled="Wyłączone" 80 | ObsKinect.PowerlineFrequency_50Hz="50Hz" 81 | ObsKinect.PowerlineFrequency_60Hz="60Hz" 82 | ObsKinect.Saturation="Nasycenie" 83 | ObsKinect.Sharpness="Ostrość" 84 | ObsKinect.WhiteBalance="Balans bieli" 85 | ObsKinect.WhiteBalanceMode="Tryb balansu bieli" 86 | ObsKinect.WhiteBalanceMode_Auto="Automatyczny" 87 | ObsKinect.WhiteBalanceMode_Manual="Ręczny" 88 | ObsKinect.WhiteBalanceMode_Unknown="Nieznany" ; I don't know what this setting does 89 | 90 | ; obs-kinect-sdk10 backend 91 | ObsKinectV1.CameraElevation="Podniesienie kamery" 92 | ObsKinectV1.HighRes="Włącz tryb koloru w wysokiej rozdzielczości" 93 | ObsKinectV1.HighResDesc="Wyjście koloru ma 1280x960 pikseli zamiast 640x480, ale niższy klatkaż (15Hz zamiast 30Hz)" 94 | ObsKinectV1.NearMode="Włącz tryb bliski głębi" 95 | ObsKinectV1.NearModeDesc="Zbliża zasięg głębi do 40-200cm zamiast 80-400cm (nie działa z użyciem Kinecta dla 360)" 96 | 97 | ; obs-kinect-sdk20 backend 98 | ObsKinectV2.NexusLedIntensity="Intensywność LED" 99 | ObsKinectV2.PrivacyLedIntensity="Intensywność diody aktywacji" 100 | ObsKinectV2.ServicePriority="Priorytet usługi Kinect" 101 | ObsKinectV2.ServicePriority_High="Wysoki" 102 | ObsKinectV2.ServicePriority_AboveNormal="Powyżej normalnego" 103 | ObsKinectV2.ServicePriority_Normal="Normalny" 104 | 105 | ; obs-kinect-azuresdk backend 106 | ObsKinectAzure.ColorResolution="Rozdzielczość koloru" 107 | ObsKinectAzure.ColorResolution_1280x720="720p (16:9 - 1280×720)" 108 | ObsKinectAzure.ColorResolution_1920x1080="1080p (16:9 - 1920×1080)" 109 | ObsKinectAzure.ColorResolution_2560x1440="1440p (16:9 - 2560×1440)" 110 | ObsKinectAzure.ColorResolution_2048x1536="1536p (4:3 - 2048×1536)" 111 | ObsKinectAzure.ColorResolution_3840x2160="4K (16:9 - 3840×2160)" 112 | ObsKinectAzure.ColorResolution_4096x3072="3072 (4:3 - 4096×3072)" 113 | ObsKinectAzure.DepthMode="Tryb głębi" 114 | ObsKinectAzure.DepthMode_NFOV_Unbinned="NFOV unbinned" 115 | ObsKinectAzure.DepthMode_NFOV_2x2Binned="NFOV 2x2 binned (SW)" 116 | ObsKinectAzure.DepthMode_WFOV_Unbinned="WFOV unbinned" 117 | ObsKinectAzure.DepthMode_WFOV_2x2Binned="WFOV 2x2 binned" 118 | ObsKinectAzure.DepthMode_Passive="Pasywny czujnik podczerwieni" 119 | -------------------------------------------------------------------------------- /src/obs-kinect/KinectSource.hpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Copyright (C) 2021 by Jérôme Leclercq 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | ******************************************************************************/ 17 | 18 | #pragma once 19 | 20 | #ifndef OBS_KINECT_PLUGIN_KINECTSOURCE 21 | #define OBS_KINECT_PLUGIN_KINECTSOURCE 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | class KinectDevice; 43 | class KinectDeviceRegistry; 44 | 45 | class KinectSource 46 | { 47 | friend KinectDeviceRegistry; 48 | 49 | public: 50 | enum class GreenScreenFilterType; 51 | enum class SourceType; 52 | struct DepthToColorSettings; 53 | struct GreenScreenSettings; 54 | struct InfraredToColorSettings; 55 | 56 | KinectSource(std::shared_ptr registry, const obs_source_t* source); 57 | ~KinectSource(); 58 | 59 | std::uint32_t GetHeight() const; 60 | std::uint32_t GetWidth() const; 61 | 62 | void OnVisibilityUpdate(bool isVisible); 63 | 64 | void Render(); 65 | 66 | void SetSourceType(SourceType sourceType); 67 | 68 | void ShouldStopOnHide(bool shouldStop); 69 | 70 | void Update(float seconds); 71 | void UpdateDevice(std::string deviceName); 72 | void UpdateDeviceParameters(obs_data_t* settings); 73 | void UpdateDepthToColor(DepthToColorSettings depthToColor); 74 | void UpdateGreenScreen(GreenScreenSettings greenScreen); 75 | void UpdateInfraredToColor(InfraredToColorSettings infraredToColor); 76 | void UpdateVisibilityMaskFile(const std::string_view& filePath); 77 | 78 | enum class GreenScreenFilterType 79 | { 80 | Body = 0, //< Requires Source_Body (| Source_ColorToDepthMapping if color source is used) 81 | BodyOrDepth = 2, //< Requires Source_Body | Source_Depth (| Source_ColorToDepthMapping if color source is used) 82 | BodyWithinDepth = 3, //< Requires Source_Body | Source_Depth (| Source_ColorToDepthMapping if color source is used) 83 | Dedicated = 4, //< Requires Source_BackgroundRemoval 84 | Depth = 1 //< Requires Source_Depth (| Source_ColorToDepthMapping if color source is used) 85 | }; 86 | 87 | enum class SourceType 88 | { 89 | Color = 0, //< Requires Source_Color 90 | Depth = 1, //< Requires Source_Depth 91 | Infrared = 2 //< Requires Source_Infrared 92 | }; 93 | 94 | struct DepthToColorSettings 95 | { 96 | bool dynamic = false; 97 | float averageValue = 0.015f; 98 | float standardDeviation = 3.f; 99 | }; 100 | 101 | struct GreenScreenSettings 102 | { 103 | GreenscreenEffectConfigs effectConfig; 104 | GreenScreenFilterType filterType = GreenScreenFilterType::Depth; 105 | bool enabled = true; 106 | bool gpuDepthMapping = true; 107 | std::size_t blurPassCount = 3; 108 | std::uint16_t depthMax = 1200; 109 | std::uint16_t depthMin = 1; 110 | std::uint16_t fadeDist = 100; 111 | std::uint8_t maxDirtyDepth = 0; 112 | }; 113 | 114 | struct InfraredToColorSettings 115 | { 116 | bool dynamic = false; 117 | float averageValue = 0.08f; 118 | float standardDeviation = 3.f; 119 | }; 120 | 121 | static bool DoesRequireBodyFrame(GreenScreenFilterType greenscreenType); 122 | static bool DoesRequireDepthFrame(GreenScreenFilterType greenscreenType); 123 | 124 | private: 125 | struct DynamicValues 126 | { 127 | double average; 128 | double standardDeviation; 129 | }; 130 | 131 | void ClearDeviceAccess(); 132 | SourceFlags ComputeEnabledSourceFlags() const; 133 | SourceFlags ComputeEnabledSourceFlags(const KinectDevice& device) const; 134 | std::optional OpenAccess(KinectDevice& device); 135 | void RefreshDeviceAccess(); 136 | 137 | static DynamicValues ComputeDynamicValues(const std::uint16_t* values, std::size_t valueCount); 138 | 139 | std::optional m_deviceAccess; 140 | std::shared_ptr m_registry; 141 | std::vector m_bodyMappingMemory; 142 | std::vector m_bodyMappingDirtyCounter; 143 | std::vector m_depthMappingMemory; 144 | std::vector m_depthMappingDirtyCounter; 145 | ConvertDepthIRToColorShader m_depthIRConvertEffect; 146 | GaussianBlurShader m_filterBlur; 147 | GreenScreenFilterShader m_greenScreenFilterEffect; 148 | GreenscreenEffects m_greenscreenEffect; 149 | DepthToColorSettings m_depthToColorSettings; 150 | GreenScreenSettings m_greenScreenSettings; 151 | InfraredToColorSettings m_infraredToColorSettings; 152 | TextureLerpShader m_textureLerpEffect; 153 | ObserverPtr m_finalTexture; 154 | ObsTexturePtr m_backgroundRemovalTexture; 155 | ObsTexturePtr m_bodyIndexTexture; 156 | ObsTexturePtr m_colorTexture; 157 | ObsTexturePtr m_depthMappingTexture; 158 | ObsTexturePtr m_depthTexture; 159 | ObsTexturePtr m_infraredTexture; 160 | SourceType m_sourceType; 161 | ObsImageFilePtr m_visibilityMaskImage; 162 | VisibilityMaskShader m_visibilityMaskEffect; 163 | const obs_source_t* m_source; 164 | std::string m_deviceName; 165 | std::string m_visibilityMaskPath; 166 | std::uint32_t m_height; 167 | std::uint32_t m_width; 168 | std::uint64_t m_lastFrameIndex; 169 | std::uint64_t m_lastTextureTick; 170 | bool m_isVisible; 171 | bool m_stopOnHide; 172 | }; 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /.github/workflows/windows-build.yml: -------------------------------------------------------------------------------- 1 | name: Windows-Build 2 | 3 | on: 4 | pull_request: 5 | push: 6 | paths-ignore: 7 | - '.github/workflows/linux-build.yml' 8 | - '.gitignore' 9 | - 'LICENSE' 10 | - 'README.md' 11 | 12 | jobs: 13 | build: 14 | strategy: 15 | matrix: 16 | os: [windows-latest] 17 | arch: [x64] 18 | mode: [debug, releasedbg] 19 | 20 | runs-on: ${{ matrix.os }} 21 | if: "!contains(github.event.head_commit.message, 'ci skip')" 22 | 23 | env: 24 | QT_VERSION: '5.15.2' 25 | OBS_VERSION: '26.0.0' 26 | CMAKE_GENERATOR: 'Visual Studio 17 2022' 27 | 28 | steps: 29 | - name: Get current date as package key 30 | id: pkg_key 31 | run: echo "::set-output name=key::$(date +'%W')" 32 | 33 | - name: Checkout repository 34 | uses: actions/checkout@v5 35 | 36 | - name: Checkout Kinect SDKs 37 | uses: actions/checkout@v5 38 | continue-on-error: true 39 | with: 40 | repository: SirLynix/kinect-sdks 41 | token: ${{ secrets.KINECT_SDKS_PAT }} 42 | path: ${{ github.workspace }}/kinect-sdks 43 | 44 | - name: Add msbuild to PATH 45 | uses: microsoft/setup-msbuild@v2.0.0 46 | 47 | - name: Enable longpath in git for Windows 48 | run: git config --system core.longpaths true 49 | 50 | # Install Qt 51 | - name: Install Qt 52 | uses: jurplel/install-qt-action@v4 53 | with: 54 | version: ${{ env.QT_VERSION }} 55 | 56 | # Select OBS runtime 57 | - name: Choose OBS Debug or Release build 58 | uses: haya14busa/action-cond@v1 59 | id: cmake_target 60 | with: 61 | cond: ${{ matrix.mode == 'debug' }} 62 | if_true: "Debug" 63 | if_false: "RelWithDebInfo" 64 | 65 | # Cache OBS Studio 66 | - name: Retrieve OBS Studio cache 67 | uses: actions/cache@v5 68 | id: obs-cache 69 | with: 70 | path: ${{ github.workspace }}/obs-studio 71 | key: Windows-OBS-Studio-${{ steps.cmake_target.outputs.value }}-${{ env.OBS_VERSION }} 72 | 73 | # Build obs-studio 74 | - name: Clone OBS 75 | if: steps.obs-cache.outputs.cache-hit != 'true' 76 | uses: actions/checkout@v5 77 | with: 78 | repository: obsproject/obs-studio 79 | path: ${{ github.workspace }}/obs-studio 80 | submodules: 'recursive' 81 | fetch-depth: 0 # for tags 82 | 83 | # Checkout OBS to the wanted version 84 | - name: Checkout OBS-Studio release (${{ env.OBS_VERSION }}) 85 | if: steps.obs-cache.outputs.cache-hit != 'true' 86 | working-directory: ${{ github.workspace }}/obs-studio 87 | run: | 88 | git checkout ${{ env.OBS_VERSION }} 89 | git submodule update 90 | 91 | # Install OBS dependencies 92 | - name: Install OBS dependencies 93 | if: steps.obs-cache.outputs.cache-hit != 'true' 94 | working-directory: ${{ github.workspace }} 95 | run: | 96 | curl https://obsproject.com/downloads/dependencies2019.zip --output dependencies2019.zip 97 | mkdir obsdeps 98 | tar -xv -C obsdeps -f dependencies2019.zip 99 | 100 | # Configure and build obs 101 | - name: Build OBS-Studio 102 | if: steps.obs-cache.outputs.cache-hit != 'true' 103 | working-directory: ${{ github.workspace }}/obs-studio 104 | run: | 105 | mkdir ./build64 106 | cd ./build64 107 | cmake -G "${{ env.CMAKE_GENERATOR }}" -A x64 -DDepsPath=${{ github.workspace }}\obsdeps\win64 -DQTDIR=${{ env.Qt5_DIR }} -DDISABLE_PLUGINS=YES -DENABLE_SCRIPTING=NO .. 108 | msbuild /m /p:Configuration=${{ steps.cmake_target.outputs.value }} ./libobs/libobs.vcxproj 109 | 110 | # Force xmake to a specific folder (for cache) 111 | - name: Set xmake env 112 | run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append 113 | 114 | # Install xmake 115 | - name: Setup xmake 116 | uses: xmake-io/github-action-setup-xmake@v1 117 | with: 118 | xmake-version: branch@dev # avoids a bug in xmake 2.9.1 119 | 120 | # Prepare environment 121 | - name: Configure build 122 | run: 123 | echo "LibObs = { Include = [[${{ github.workspace }}\obs-studio\libobs]], Lib64 = [[${{ github.workspace }}\obs-studio\build64\libobs]] } ObsPlugins={}" > config.lua 124 | 125 | # Update xmake repository (in order to have the file that will be cached) 126 | - name: Update xmake repository 127 | run: xmake repo --update 128 | 129 | # Fetch xmake dephash 130 | - name: Retrieve dependencies hash 131 | id: dep_hash 132 | run: echo "::set-output name=hash::$(xmake l utils.ci.packageskey)" 133 | 134 | # Cache xmake dependencies 135 | - name: Retrieve cached xmake dependencies 136 | uses: actions/cache@v5 137 | with: 138 | path: ${{ env.XMAKE_GLOBALDIR }}\.xmake\packages 139 | key: MSVC-${{ matrix.arch }}-${{ matrix.mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.pkg_key.outputs.key }} 140 | 141 | # Setup compilation mode and install project dependencies 142 | - name: Configure xmake and install dependencies 143 | run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --ccache=n --yes --verbose 144 | env: 145 | KINECTSDKAZUREBT_DIR: ${{ github.workspace }}/kinect-sdks/k4abt 146 | KINECTSDK10_DIR: ${{ github.workspace }}/kinect-sdks/sdk1 147 | KINECT_TOOLKIT_DIR: ${{ github.workspace }}/kinect-sdks/sdk1-toolkit 148 | KINECTSDK20_DIR: ${{ github.workspace }}/kinect-sdks/sdk2 149 | 150 | # Build the plugin 151 | - name: Build obs-kinect 152 | run: xmake --verbose 153 | env: 154 | KINECTSDKAZUREBT_DIR: ${{ github.workspace }}/kinect-sdks/k4abt 155 | KINECTSDK10_DIR: ${{ github.workspace }}/kinect-sdks/sdk1 156 | KINECT_TOOLKIT_DIR: ${{ github.workspace }}/kinect-sdks/sdk1-toolkit 157 | KINECTSDK20_DIR: ${{ github.workspace }}/kinect-sdks/sdk2 158 | 159 | # Install the result files 160 | - name: Install obs-kinect 161 | run: xmake package -vo package 162 | env: 163 | KINECTSDKAZUREBT_DIR: ${{ github.workspace }}/kinect-sdks/k4abt 164 | KINECTSDK10_DIR: ${{ github.workspace }}/kinect-sdks/sdk1 165 | KINECT_TOOLKIT_DIR: ${{ github.workspace }}/kinect-sdks/sdk1-toolkit 166 | KINECTSDK20_DIR: ${{ github.workspace }}/kinect-sdks/sdk2 167 | 168 | # Upload artifacts 169 | - uses: actions/upload-artifact@v6 170 | with: 171 | name: ${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.mode }} 172 | path: package 173 | -------------------------------------------------------------------------------- /data/obs-plugins/obs-kinect/greenscreen_filter.effect: -------------------------------------------------------------------------------- 1 | uniform float4x4 ViewProj; 2 | uniform texture2d BodyIndexImage; 3 | uniform texture2d DepthImage; 4 | uniform texture2d DepthMappingImage; 5 | uniform float2 InvDepthImageSize; 6 | uniform float InvDepthProgressive; 7 | uniform float MaxDepth; 8 | uniform float MinDepth; 9 | 10 | sampler_state textureSampler { 11 | Filter = Linear; 12 | AddressU = Clamp; 13 | AddressV = Clamp; 14 | }; 15 | 16 | sampler_state depthSampler { 17 | Filter = Point; 18 | AddressU = Clamp; 19 | AddressV = Clamp; 20 | }; 21 | 22 | struct VertData { 23 | float4 pos : POSITION; 24 | float2 uv : TEXCOORD0; 25 | }; 26 | 27 | VertData VSDefault(VertData vert_in) 28 | { 29 | VertData vert_out; 30 | vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); 31 | vert_out.uv = vert_in.uv; 32 | 33 | return vert_out; 34 | } 35 | 36 | float ComputeBodyValue(float bodyIndex) 37 | { 38 | bool check = (bodyIndex < 0.1); 39 | return (check) ? 1.0 : 0.0; 40 | } 41 | 42 | float ComputeBodyValueMapped(float bodyIndex, float2 texCoords) 43 | { 44 | bool check = (texCoords.x > 0.0 && texCoords.y > 0.0 && texCoords.x < 1.0 && texCoords.y < 1.0) && 45 | (bodyIndex < 0.1); 46 | 47 | return (check) ? 1.0 : 0.0; 48 | } 49 | 50 | float ComputeDepthValue(float depth) 51 | { 52 | bool check = (depth > MinDepth && depth < MaxDepth); 53 | return (check) ? saturate((MaxDepth - depth) * InvDepthProgressive) : 0.0; 54 | } 55 | 56 | float ComputeDepthValueMapped(float depth, float2 texCoords) 57 | { 58 | bool check = (texCoords.x > 0.0 && texCoords.y > 0.0 && texCoords.x < 1.0 && texCoords.y < 1.0) && 59 | (depth > MinDepth && depth < MaxDepth); 60 | 61 | return (check) ? saturate((MaxDepth - depth) * InvDepthProgressive) : 0.0; 62 | } 63 | 64 | float4 PSBodyOnlyWithDepthCorrection(VertData vert_in) : TARGET 65 | { 66 | float2 texCoords = DepthMappingImage.Sample(textureSampler, vert_in.uv).xy * InvDepthImageSize; 67 | float bodyIndex = BodyIndexImage.Sample(depthSampler, texCoords).r; 68 | 69 | float value = ComputeBodyValueMapped(bodyIndex, texCoords); 70 | 71 | return float4(value, value, value, value); 72 | } 73 | 74 | float4 PSBodyOnlyWithoutDepthCorrection(VertData vert_in) : TARGET 75 | { 76 | float bodyIndex = BodyIndexImage.Sample(depthSampler, vert_in.uv).r; 77 | 78 | float value = ComputeBodyValue(bodyIndex); 79 | 80 | return float4(value, value, value, value); 81 | } 82 | 83 | float4 PSBodyOrDepthWithDepthCorrection(VertData vert_in) : TARGET 84 | { 85 | float2 texCoords = DepthMappingImage.Sample(textureSampler, vert_in.uv).xy * InvDepthImageSize; 86 | float bodyIndex = BodyIndexImage.Sample(depthSampler, texCoords).r; 87 | float depth = DepthImage.Sample(depthSampler, texCoords).r; 88 | 89 | float bodyValue = ComputeBodyValueMapped(bodyIndex, texCoords); 90 | float depthValue = ComputeDepthValueMapped(depth, texCoords); 91 | float value = max(bodyValue, depthValue); 92 | 93 | return float4(value, value, value, value); 94 | } 95 | 96 | float4 PSBodyOrDepthWithoutDepthCorrection(VertData vert_in) : TARGET 97 | { 98 | float bodyIndex = BodyIndexImage.Sample(depthSampler, vert_in.uv).r; 99 | float depth = DepthImage.Sample(depthSampler, vert_in.uv).r; 100 | 101 | float bodyValue = ComputeBodyValue(bodyIndex); 102 | float depthValue = ComputeDepthValue(depth); 103 | float value = max(bodyValue, depthValue); 104 | 105 | return float4(value, value, value, value); 106 | } 107 | 108 | float4 PSBodyWithinDepthWithDepthCorrection(VertData vert_in) : TARGET 109 | { 110 | float2 texCoords = DepthMappingImage.Sample(textureSampler, vert_in.uv).xy * InvDepthImageSize; 111 | float bodyIndex = BodyIndexImage.Sample(depthSampler, texCoords).r; 112 | float depth = DepthImage.Sample(depthSampler, texCoords).r; 113 | 114 | float bodyValue = ComputeBodyValueMapped(bodyIndex, texCoords); 115 | float depthValue = ComputeDepthValueMapped(depth, texCoords); 116 | float value = min(bodyValue, depthValue); 117 | 118 | return float4(value, value, value, value); 119 | } 120 | 121 | float4 PSBodyWithinDepthWithoutDepthCorrection(VertData vert_in) : TARGET 122 | { 123 | float bodyIndex = BodyIndexImage.Sample(depthSampler, vert_in.uv).r; 124 | float depth = DepthImage.Sample(depthSampler, vert_in.uv).r; 125 | 126 | float bodyValue = ComputeBodyValue(bodyIndex); 127 | float depthValue = ComputeDepthValue(depth); 128 | float value = min(bodyValue, depthValue); 129 | 130 | return float4(value, value, value, value); 131 | } 132 | 133 | float4 PSDepthOnlyWithDepthCorrection(VertData vert_in) : TARGET 134 | { 135 | float2 texCoords = DepthMappingImage.Sample(textureSampler, vert_in.uv).xy * InvDepthImageSize; 136 | float depth = DepthImage.Sample(depthSampler, texCoords).r; 137 | 138 | float value = ComputeDepthValueMapped(depth, texCoords); 139 | 140 | return float4(value, value, value, value); 141 | } 142 | 143 | float4 PSDepthOnlyWithoutDepthCorrection(VertData vert_in) : TARGET 144 | { 145 | float depth = DepthImage.Sample(depthSampler, vert_in.uv).r; 146 | 147 | float value = ComputeDepthValue(depth); 148 | 149 | return float4(value, value, value, value); 150 | } 151 | 152 | technique BodyOnlyWithDepthCorrection 153 | { 154 | pass 155 | { 156 | vertex_shader = VSDefault(vert_in); 157 | pixel_shader = PSBodyOnlyWithDepthCorrection(vert_in); 158 | } 159 | } 160 | 161 | technique BodyOnlyWithoutDepthCorrection 162 | { 163 | pass 164 | { 165 | vertex_shader = VSDefault(vert_in); 166 | pixel_shader = PSBodyOnlyWithoutDepthCorrection(vert_in); 167 | } 168 | } 169 | 170 | technique BodyOrDepthWithDepthCorrection 171 | { 172 | pass 173 | { 174 | vertex_shader = VSDefault(vert_in); 175 | pixel_shader = PSBodyOrDepthWithDepthCorrection(vert_in); 176 | } 177 | } 178 | 179 | technique BodyOrDepthWithoutDepthCorrection 180 | { 181 | pass 182 | { 183 | vertex_shader = VSDefault(vert_in); 184 | pixel_shader = PSBodyOrDepthWithoutDepthCorrection(vert_in); 185 | } 186 | } 187 | 188 | technique BodyWithinDepthWithDepthCorrection 189 | { 190 | pass 191 | { 192 | vertex_shader = VSDefault(vert_in); 193 | pixel_shader = PSBodyWithinDepthWithDepthCorrection(vert_in); 194 | } 195 | } 196 | 197 | technique BodyWithinDepthWithoutDepthCorrection 198 | { 199 | pass 200 | { 201 | vertex_shader = VSDefault(vert_in); 202 | pixel_shader = PSBodyWithinDepthWithoutDepthCorrection(vert_in); 203 | } 204 | } 205 | 206 | technique DepthOnlyWithDepthCorrection 207 | { 208 | pass 209 | { 210 | vertex_shader = VSDefault(vert_in); 211 | pixel_shader = PSDepthOnlyWithDepthCorrection(vert_in); 212 | } 213 | } 214 | 215 | technique DepthOnlyWithoutDepthCorrection 216 | { 217 | pass 218 | { 219 | vertex_shader = VSDefault(vert_in); 220 | pixel_shader = PSDepthOnlyWithoutDepthCorrection(vert_in); 221 | } 222 | } --------------------------------------------------------------------------------