Choosing an area on screen for chromakey ?

SadMango

New Member
Hey,

So I think a picture would speak for 1000 words, here it is:

Chroma Key setup.jpg


I want to do this, just locate the Chroma key filter in the red square, so I can change the green screen setting without picking up "greenish" part in my room.
I've tryed to use the masks filter but it didn't worked for me..

If you have a solution for this, thanks guys !
 

SadMango

New Member
I want OBS to only pick up green pixels in the red area showed in my picture, so even if I go a bit overboard with the chroma key Similarity/smoothness setting to get less noise on the incrustation on my green screen, the rest of my room will not began to be picked up by OBS as beeing part of the green space.
 

SadMango

New Member
I have tryed that, you can't use the same vidéo source more than one time, every time I create a new video souce using the same elgato camlink 4K input, they sync together, so they share filters.
 

SadMango

New Member
Ok nice I kinda follow what you've said, but changed some things with how the chroma key is apply to what cam/scene, and it worked !
It's kinda tricky to change background on the fly as it can "pop out" between the 2 scenes, but that is already far better than before.
Thank you very much !
I'm still thinking that there should be a way to apply a mask filter on the chromakey filter, should be too long to code ether.
 

Suslik V

Active Member
You need to cover the window by green cloth. Then you can try next steps.

You need 2 alpha masks: BlackHole and BiggerThanHole casual mask files.
Chroma Key setup - step 01 - Prepare Alpha Mask BlackHole.png Chroma Key setup - step 01 - Prepare Alpha Mask (BiggerThanHole).png
above source is Group 2
with the Filters:
  • Image Mask/Blend - BlackHole.png
below layer is Group (this group can be and should be cropped with ALT+Mouse)
with the Filters:
  • Image Mask/Blend - BiggerThanHole.png
  • Chroma Key
Both Groups has same source - the actual Camera footage (no filters).
Sources arrangement (above/under not so important and depends only on mask and filtering quality)

Before (only Chroma Key over the Group):

OBS Studio window area filtering.jpg


After (different masks for both groups, and Chroma Key only for group with the BiggerThanHole casual mask):

OBS Studio window area filtering result.jpg
 

SadMango

New Member
Ooooh that works exacly like I was thinking it would ! thank you very much
There should be an easy way tho, but this works !
 

OBS_User_2021

New Member
Hey Everyone, this is exactly what i need too (Chroma KEy only covering a certain Area). Unfortunately I cant follow all the steps i have to take to get there :( I created both pictures (black and white). So now I have to create 2 groups without the cam first and insert both pictures ? In The screenshots i cant see the webcam.. where do i put the cam ? Sorry for not understanding... Will someone please be so nice and explain the steps just a little bit more clearer ? Thanks so much in advance
 

koala

Active Member
In Suslik V's post, the webcam covers the whole screen (it's what you see as the empty chair, desk, door and window). In the sources window, it is the source that is listed as "Chroma Key setup.j"). It is present 2 times, because you need to apply the two different filter sets.
 

OBS_User_2021

New Member
In Suslik V's post, the webcam covers the whole screen (it's what you see as the empty chair, desk, door and window). In the sources window, it is the source that is listed as "Chroma Key setup.j"). It is present 2 times, because you need to apply the two different filter sets.

Thanks for the reply. But if "Chroma Key setup.j" is the webcam in both groups, how do i change the Image/Mask Blend ? When i apply the filter it also syncs with the other group as its the same webcam. On which source do i have to apply the filters ? I cant apply a filter to the whole group i guess.. there is no filter option on the group.
 

koala

Active Member
As Suslik V wrote, you apply the filters to the groups, not directly to the sources. That's what the groups are for in this example: to enable you to apply separate filters. If you find no filter option on a group, look again. There is.
 

Suslik V

Active Member
Scene added as Source also can work here instead of the Group. Then filters should apply to the Scene sources. But thus you will need two additional scenes that has only a reference to the webcam source. And the third scene needed where this two will be added. Long time ago some artifacts (filtering of the semi-transparent areas if no background layer was set in OBS) were present on some combinations of the filters per scene, so you need to check it by yourself, is it OK or not as for today.
 

OBS_User_2021

New Member
Thanks, but how do i add different filters to the same source (webcam) ? If i change the filter on the webcam source it will change it to all scenes with the webcam as a source. I'm afraid this is to compliacted for me :( Usually I'm pretty good at doing things like this but this is overkill for me :( Is there a Step by Step manual anywhere for this ? Like Step 1: do this Step 2: then this and so on ? Thanks everyone
 

koala

Active Member
Again: if you use OBS Studio, you can put one or multiple sources into a group. Then, in OBS Studio, you can apply filters to groups. Right-click on the Group->Filters. It's the same place in the context menu where it is for a source.
This way you don't attach any filter to a source directly, so the filters are not inherited by any additional instance of a source. If you are not able to find the function to attach a filter to a group, you cannot implement Suslik V's post.
 

OBS_User_2021

New Member
But "Suslik" mentioned in his last post instead of using Groups, i can use Scenes !? " Scene added as Source also can work here instead of the Group. Then filters should apply to the Scene sources"

I dont want to switch to OBS Studio because i have everything else setup on streamlabs obs.
 

koala

Active Member
Since this is the support forum for the free OBS Studio, and Streamlabs OBS is a commercial product owned by Logitech, that should be able to provide support on their own, I can only recommend you seek for that support over there.
 

OBS_User_2021

New Member
OMG i did it :) :) Thanks for your patience everyone !! I created 3 Scenes and had to apply the filters to the scene and add the Scenes as Source to my main scene.... Thanks again <3
 
Necro-ing this thread because I could have used this advice myself today.

I really appreciate @Suslik V 's answer, but the wording left a little to be desired, as well as some steps having been left out. I'm assuming English is not their first language, so please allow me to elaborate on the steps to make them easier to follow

First, we'll set things up in OBS Studio to make things a little easier on us down the road:
- Create a new scene named something like "Camera Only", and add your camera to it with no filters or anything else in the scene
Camera Only Scene.png

- Create another scene, the one in which you will be using the camera and "selective" chroma key (e.g. "Chatting")
- Add two groups, "Group 1" and "Group 2", respectively
- Add the SCENE that has your camera by itself to this new scene, twice
- Drag the "Camera Only" scene into each of the two groups
- Add a source (image, video, game capture, etc) to the scene that you want to show in the "selective" chroma-key area, to the very bottom of the source list
Ingredients Scene.png


Alright, now to make the two image masks:
- Switch over to the "Camera Only" scene and right click on the preview area, then click "Screenshot (Source)"
Source Screenshot.png

- A message will appear at the bottom left of OBS Studio saying that the screenshot was saved to "C:\user\blahblahblah" , which will be the location set for recordings in your OBS Studio settings (Settings > Output > Recording > Recording Path)
- Open your favorite image editing software (GIMP, Photoshop, etc), I use GIMP in my example, and a couple of my instructions are GIMP-specific since I don't know how to do it in other software
- Drag the screenshot you just saved from OBS Studio into the image editor
- Select the area of the screenshot in which you want the "selective" chroma key to be shown
- You can use whatever tool you like. For polygonal areas with straight sides, I prefer the "Path" tool, then "Selection from Path", but you can use the rectangular select, ellipse, lasso, etc.
Selecting Area.jpg

- With the paint bucket tool, fill this selected area with BLACK
- Invert the selection so that everything BUT the black section is selected (In GIMP this is Ctrl+i)
- Fill the rest of the image with WHITE
05 Black Hole Example.png

- Export this as something like "BlackHole" or "ImageMask1" or whatever will help you know that this is the one with the BLACK chroma-key area
- You can export it as either jpg or png, it doesn't matter
- Now with the white area still selected, switch your bucket tool to BLACK and fill in this selection
- I know the entire image will be black, we'll fix that in a moment
- Invert the selection again, and BEFORE we fill the selection with white, we need to make it slightly bigger so that when we apply the masks and chroma-key within OBS Studio, there won't be a 1px border around the area
- In GIMP, click "Select > Grow" and increase the size of the selection by 2-5 pixels (no more than 5 pixels) then click "OK"
06 Grow Selection.png

- NOW fill this new selection in with WHITE
- Export this new image as something like "WhiteHole" or "ImageMask2", similarly to the first
07 White Hole Example.png


Now why do we need both of these masks? We'll find out when we apply them
Now comes the fun but confusing part--applying the masks and the chroma-key:
- In OBS Studio, return to our scene that has the two groups and the source that we want to show through the chroma key
- Right click on the first group, highest in the list, and click "Filters"
- in the bottom left click the Plus sign to add a new filter and select "Image Mask/Blend", you can leave the name as the default
- On the right, leave "Type" alone and click "Browse" next to "Path"
- Locate the "White Hole" file and double-click it to add it to the mask
10 First Mask Applied.png

- By default, applying a mask tells OBS Studio that anything in the white area needs to shine through to the output, and anything in black gets hidden. Thus, with this first mask, we're telling OBS Studio that only the area where we want to put our green screen is going to the output for this first group.
- Click the Plus sign again and add a "Chroma Key" filter, leaving the name alone again
- You'll likely have to fiddle with the sliders within the chroma key settings to make the required color transparent, but that's outside the scope of these instructions
- NOTE: In my example image, my chroma-key area is *blue*, even though "Key Color Type" is set to "Green". The options are "Green", "Blue", "Magenta", and "Custom". Select whichever applies to your situation!
11 Chroma Key Filter.png

- Close the filter window for the first group
- Right click on the second group and click "Filters"
- Add another "Image Mask/Blend" filter, this time selecting the "Black Hole" image
- Now with the black and white areas switched, this mask is telling OBS Studio that everything BUT the chroma-key area needs to be sent to the output. Separating the masks like this, and then only applying the chroma-key filter to the first group, is what allows us to select a particular area to chroma-key, rather than the entire scene.

And Voila, that should be it! Chroma-key should now be applied only to a particular area of the view from your camera.
13 Final Product.png
 
Last edited:
Top