-
Notifications
You must be signed in to change notification settings - Fork 79
Activate overlay to hide parts of the screen
The following example will use pattern matching to make sure certain elements of the screen are hidden if a particular pattern can be found. We will use hiding the production tab in Starcraft 2 whenever an a certain unit is built - regardless of how many - as an example.
The following scene / source setup will be used to achieve this behaviour:
- A single example scene (1)
- A color source used to block certain parts of the screen, to indicate that the macro successfully matched the pattern (2)
- A game/display capture source to capture the gameplay (3)
Toggling the visibility of the color source will either show or hide the production tab, by overlaying a grey box over top off it.
Next we need a pattern to match - for this example we will use the "Marine" icon.
This image was created by simply taking a screenshot of the video source and cutting it down to the needed size.
You can also automatically create a screenshot of the given source by clicking the "Browse" button (3) of the file selection in the image below.
If you already have selected the area you want to perform the check on the screenshot will be resized automatically.
Once the pattern is ready we can create our macros to automate the showing and hiding of the color source overlay. We start by creating a macro to show the color source if the pattern is found:
First we create a video condition and select "Display Capture" as the video source to analyze (1), "matches pattern" as the type of check we want to perform (2), and which pattern file we want to use (3).
Next we add an action of type "Scene item visibility" to show the color source if the above condition is met. (4)
While this might already work as expected we can tweak the settings of video condition for better results and performance:
First we reduce the interval at which this conditions is checked to roughly only once a second (1) and we reduce the area that needs to be checked to only cover the area where we expect the pattern to occur (2).
An additional improvement that could be made to avoid false positives would be to improve the pattern.
By replacing the area at which the number is being displayed to represent the number of units of that type being produced with an transparent rectangle we can effectively ignore this part of the pattern.
To achieve this we create a new pattern:
... and select it in the video condition (1).
Then we check the "Use alpha channel as mask for pattern" option. Note that the pattern file should be exported with transparency, so the file format should support transparency, like png.
Next we have to tweak the "Threshold" value to be used.
This is best done by clicking the "Show match" option and playing back some example footage.
If the pattern can be found it will be highlighted in a red box.
As a last step we create the inverse of the "Show overlay" macro to automatically hide the overlay if the pattern cannot be found:
Instead of once again performing the same pattern matching we can reuse the results of the checks of the "Show overlay" macro by using a condition of type "Macro" of type "State". (1)
This will safe CPU resources and will also avoid conflicts if you change some parameters on one macro but not the other.
Now we just need to add the action to hide the overlay (2) and everything should be set up.
Make sure that the scene switcher is running and enjoy your automatic overlay toggling! :)
- Show webcam only when speaking
- Twitch Category Changer
- Show text source with latest Twitch follower
- Detect elements on screen and hide them automatically
- Motion detection
- Start other programs when starting OBS
- Crossfading audio during scene changes
- Switch scenes randomly
- Re-shuffle VLC source
- Automatically switch scene if a game capture's target window no longer exists
- Audio based scene switching in podcast setting
- Switching scenes based on portrait or landscape mode resolution of a window capture source
- Set up a hotkey to start and stop recording with a fade from and to black
- Automatically cycle through a list of scenes
- Toggle visibility of scene items on a timer
- Advance through a list of scenes by hotkey
- Performing actions only when transitioning from A to B
- Media playlist with commercial interruptions
- Split recording of stream into chunks
- Switching scenes for Aitum Vertical plugin
- Using MIDI devices
- Change capture window of Window Capture source
- Show URLs in clipboard in browser source
- General tab overview
- Starting and stopping the plugin
- Macros explained
- Creating a macro
- Pausing macros
- Macro duration modifiers
- Exporting and importing individual macros
- Audio condition
- Cursor condition
- Date condition
- Hotkey condition
- Media condition
- Process condition
- Scene item transform condition
- Slide Show condition
- Video condition
- Audio action
- Http action
- Hotkey action
- Random action
- Scene item visibility
- Sequence action
- Action Queue example
- Variables
- Websockets
- Scripting
- Scene groups
- Troubleshooting
- Saving and loading settings