Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What about an alpha channel? #6

Closed
troypesola opened this issue Apr 25, 2021 · 8 comments
Closed

What about an alpha channel? #6

troypesola opened this issue Apr 25, 2021 · 8 comments

Comments

@troypesola
Copy link

Did you test out adding transparency with an alpha channel instead of setting the color?

There is an Alpha YUV format. So it seems like it wouldn't be too hard to add a parameter for transparency, convert to an AYUV, apply the mask, then convert back to the proper output format.

Thoughts? I can fork and give it a shot, but wanted to see if you had tried going direct to transparent already.

@royshil
Copy link
Collaborator

royshil commented Apr 26, 2021

my major hurdle so far is allocating new memory for the obs_source_frame *frame output.

a lot of the problem (and resources) is colorspace conversion, if I can allocate new memory and put the RGBA in there, and set the frame->format = VIDEO_FORMAT_RGBA, then this feature is trivial.

but so far i couldn't get the mem allocation down. i need to do some more research

but you're welcome to try it..

@troypesola
Copy link
Author

I'll take a look when I have some time. I just wanted to check if you had looked at it. Good to know that the color space conversion is the challenge.

Feel free to close this one out.

@brunodoamaral
Copy link

Hi @royshil. First thanks for building this plugin, it works really well!

As @troypesola suggested, I'm too trying to create an alpha output directly from obs-backgroundremoval plugin. Using it together with Chroma Key creates a "color border" effect when I try to make smooth edges.

I already have a working development setup and made some modifications to filter_render in order to create a BGRA image.

I'm new to obs plugin development (actually only a few hours) and tried a few combinations of video formats on video_scaler_create in a hope to output a BGRA frame, but so far I have no success.

If you have time, can you point the modifications necessary to make it work from a obs-plugin perspective? By this time I'm not concerned about memory issues, as you point out in a previous comment. But I'll take it in consideration if I submit a PR.

Best regards!
Bruno

@royshil
Copy link
Collaborator

royshil commented Jun 18, 2021

@brunodoamaral I think the new built in scalers can do this very easily. The mem allocation is trivial.
I can make an effort to implement this in the next couple days...
It's also needed for the "feather" feature that I just rolled out in the last version.

@brunodoamaral
Copy link

@royshil thanks for your fast response.

I added a new feature for mask offset (it uses morphological operation to dilate or erode the mask). Combined with the feather feature, it create a nice fade affect.
But it didn't work well with Chroma Key. That's why I'm looking for some "native" alpha implementation.
I'll spend a few more time on it and came back if I found a solution. Anyway, I'll keep an eye on the progress from your side by subscribing to changes on github.

@tmilker
Copy link

tmilker commented Aug 17, 2021

@troypesola @brunodoamaral You can get a transparent background out of this plugin by placing video source in it's own scene, adding the plugin as a filter, then placing that scene in your scene and filtering that with the ChromaKey filter.

@mhcerri
Copy link

mhcerri commented Oct 21, 2021

Hi, @royshil ! First of all, thank you for the wonderful plugin!

Do you still have plans of implementing the alpha channel? That would be an awesome feature because it would allow smoother contours with transparent backgrounds. Currently when using a chroma key filter that's not possible because the contour would get tinted with the color used for the chroma key.

@royshil
Copy link
Collaborator

royshil commented Nov 2, 2021

@mhcerri I'm working on the alpha channel right now as well as a 27.1.3 (latest) OBS version

royshil pushed a commit that referenced this issue Mar 7, 2023
* Add obs-plugintemplate files (#1)

* Add obs-plugintemplate files

* Rename

* Update CMakeLists.txt

* Update main.yml

* files

* Update CMakeLists.txt

* Fix

* Update .Brewfile

* Update main.yml

* Update main.yml

* check-cmake.sh

* Update main.yml

* Update main.yml

* Build my opencv (#2)

* BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* check-cmake

* Update main.yml

* Update buildspec.json

* Update CMakeLists.txt

* Build my onnxruntime (#3)

* fix

* Update BuildMyOnnxruntime.cmake

* Enable arm64

* 0.5.2

* Update BuildMyOnnxruntime.cmake

* Update .Brewfile

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* fix

* Fix

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* a

* Create .gitmodules

* Create onnxruntime

* Update onnxruntime

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* fix

* Update BuildMyOnnxruntime.cmake

* ARCHITECTURE

* Apply

* Update BuildMyOnnxruntime.cmake

* fix

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* aaa

* Enable Windows build (#4)

* Enable Windows build

* Update main.yml

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Fix linkage

* Remove /WX

* Update ObsPluginHelpers.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update CMakeLists.txt

* Fix

* Update CMakeLists.txt

* a

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Disable DML

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update background-filter.cpp

* Update BuildMyOnnxruntime.cmake

* Disable DML

* Fix segfault (#6)

* Update Model.h

* 0.5.6

* Ccache macos (#8)

* Ccache

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Revert "Update BuildMyOnnxruntime.cmake"

This reverts commit 44d9caa.

* Revert "Update BuildMyOnnxruntime.cmake"

This reverts commit 9294106.

* Direct ml (#7)

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update CMakeLists.txt

* Update CMakeLists.txt

* Update CMakeLists.txt

* dml

* 0.5.7

* Update CMakeLists.txt

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* a

* Update main.yml

* Update BuildMyOnnxruntime.cmake

* Update main.yml

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Fix

* Update BuildMyOnnxruntime.cmake

* Update main.yml

* Linux build (#9)

* linux

* 0.5.8

* Update BuildMyOnnxruntime.cmake

* Update setup_ccache (#10)

* bump version (#11)

* Use ninja on windows (#12)

* Update main.yml

* Update main.yml

* Use Ninja

* Update BuildMyOnnxruntime.cmake

* Update main.yml

* ccache

* Update BuildMyOpenCV.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update BuildMyOnnxruntime.cmake

* Update main.yml

* Update main.yml

* Update CMakeLists.txt

* Update BuildMyOnnxruntime.cmake

* Long path

* Update main.yml

* Update BuildMyOnnxruntime.cmake

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOnnxruntime.cmake

* Windows opencv ccache (#13)

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update BuildMyOpenCV.cmake

* Update main.yml

* Update BuildMyOpenCV.cmake

* bump 0.5.10 (#14)

* Cleanup (#15)

* Cleanup

* bump version

* Fix ep (#16)

* Update BuildMyOnnxruntime.cmake

* Update BuildMyOpenCV.cmake

* Update main.yml (#18)

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* Update main.yml

* 0.5.12

* Fix

* Update package-macos.zsh

* Update package-linux.zsh

* Update CMakeLists.txt

* ci

* Fix

* Update background-filter.cpp

* Fix

* clang-format

* cmake-format

* Update BuildMyOpenCV.cmake

* Update BuildMyOnnxruntime.cmake

* Fix errors

* Use -isystem

* Use list in set_target_properties

* INTERFACE_INCLUDE_DIRECTORIES must be on IMPORTED TARGET

* Update ObsPluginHelpers.cmake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants