1
1
import obspython as obs
2
2
from mouse import get_position # python -m pip install mouse
3
3
4
- __version__ = "0.2.1 "
4
+ __version__ = "0.3.0-alpha "
5
5
REFRESH_RATE = 15
6
6
FLAG = True
7
7
@@ -16,8 +16,13 @@ class CursorAsSource:
16
16
def __init__ (self , source_name = None ):
17
17
self .source_name = source_name
18
18
self .lock = True
19
+ self .update_xy = False
20
+ self .update_gs = False # green screen
21
+ self .update_cr = False
19
22
20
23
def update_cursor (self ):
24
+ """ in script settings check update cursor"""
25
+
21
26
source = obs .obs_get_source_by_name (self .source_name )
22
27
settings = obs .obs_data_create ()
23
28
if source is not None :
@@ -43,14 +48,58 @@ def update_cursor(self):
43
48
obs .obs_scene_release (scene )
44
49
obs .obs_source_release (source )
45
50
51
+ def update_green (self ):
52
+ """
53
+ create new scene with name:__spotlight__
54
+ add color source , add opacity(color correction) to that source
55
+ add green circle
56
+ add that scene as source to ur current scene
57
+ apply chromakey filter to that source
58
+ in script settings check update green
59
+ """
60
+ source = obs .obs_get_source_by_name (self .source_name )
61
+ settings = obs .obs_data_create ()
62
+ if source is not None :
63
+ scene_width = obs .obs_source_get_width (source )
64
+ scene_height = obs .obs_source_get_height (source )
65
+ # get all scenes
66
+ scenes = obs .obs_frontend_get_scenes ()
67
+ for sc in scenes :
68
+ # select the one with chromakey cursor(green)
69
+ name = obs .obs_source_get_name (sc )
70
+ if name == "__spotlight__" :
71
+ # assign it
72
+ _item = sc
73
+ else :
74
+ obs .obs_source_release (sc )
75
+
76
+ scene = obs .obs_scene_from_source (_item )
77
+ scene_item = obs .obs_scene_find_source (scene , self .source_name )
78
+ if scene_item :
79
+ scale = obs .vec2 ()
80
+ obs .obs_sceneitem_get_scale (scene_item , scale )
81
+ scene_width , scene_height = apply_scale (
82
+ scale .x , scale .y , scene_width , scene_height
83
+ )
84
+ next_pos = obs .vec2 ()
85
+ next_pos .x , next_pos .y = get_position ()
86
+ next_pos .x -= scene_width / 2
87
+ next_pos .y -= scene_height / 2
88
+ # set position to center of source where cursor is
89
+ obs .obs_sceneitem_set_pos (scene_item , next_pos )
90
+
91
+ obs .obs_data_release (settings )
92
+ obs .obs_scene_release (scene )
93
+ obs .obs_source_release (source )
94
+
46
95
def update_crop (self ):
47
96
"""
48
97
Create 2 display captures.
49
98
Create crop filter with this name: cropXY.
50
99
Check relative.
51
100
Set Width and Height to relatively small numbers e.g : 64x64 .
52
101
Image mask blend + color correction might be an option too.
53
- Run script,select this source as cursor source , check Update crop, click start.
102
+ Run script,select this source as cursor source , check Update crop and updated cursor , click start.
54
103
"""
55
104
source = obs .obs_get_source_by_name (self .source_name )
56
105
crop = obs .obs_source_get_filter_by_name (source , "cropXY" )
@@ -76,7 +125,9 @@ def ticker(self):
76
125
if self .update_xy :
77
126
self .update_crop ()
78
127
self .update_cursor ()
79
- else :
128
+ if self .update_gs :
129
+ self .update_green ()
130
+ if self .update_cr :
80
131
self .update_cursor ()
81
132
82
133
if not self .lock :
@@ -112,6 +163,8 @@ def script_defaults(settings):
112
163
def script_update (settings ):
113
164
global REFRESH_RATE
114
165
py_cursor .update_xy = obs .obs_data_get_bool (settings , "bool_yn" )
166
+ py_cursor .update_xy = obs .obs_data_get_bool (settings , "bool_yn_cursor" )
167
+ py_cursor .update_gs = obs .obs_data_get_bool (settings , "bool_yn_green" )
115
168
py_cursor .source_name = obs .obs_data_get_string (settings , "source" )
116
169
REFRESH_RATE = obs .obs_data_get_int (settings , "refresh_rate" )
117
170
@@ -138,4 +191,6 @@ def script_properties(): # ui
138
191
obs .obs_properties_add_button (props , "button" , "Stop" , stop_pressed )
139
192
obs .obs_properties_add_button (props , "button2" , "Start" , start_pressed )
140
193
obs .obs_properties_add_bool (props , "bool_yn" , "Update crop" )
194
+ obs .obs_properties_add_bool (props , "bool_yn_green" , "Update green circle" )
195
+ obs .obs_properties_add_bool (props , "bool_yn_cursor" , "Update cursro " )
141
196
return props
0 commit comments