def startCountClick(props, prop): global itemSource global xCoord global yCoord global Debug_Mode global jsonItemData global imagePath global imageName global widthCount global heightCount if (obs.obs_frontend_preview_program_mode_active()): sceneSource = obs.obs_frontend_get_current_preview_scene() else: sceneSource = obs.obs_frontend_get_current_scene() sceneWidth = obs.obs_source_get_width(sceneSource) sceneHeight = obs.obs_source_get_height(sceneSource) xWidth = math.ceil(sceneWidth / widthCount) yHeight = math.ceil(sceneHeight / heightCount) blankImage = np.zeros(shape=[yHeight, xWidth, 4], dtype=np.uint8) cv2.rectangle(blankImage, (0, 0), (xWidth, yHeight), (169, 169, 169, 255), 2) if (os.path.isfile(imagePath + imageName)): os.remove(imagePath + imageName) cv2.imwrite(imagePath + imageName, blankImage) if Debug_Mode: print("startCount") print(imagePath + imageName) gridWidth = 0 gridHeight = 0 scene = obs.obs_scene_from_source(sceneSource) itemData = obs.obs_data_create_from_json(jsonItemData) itemSource = obs.obs_load_source(itemData) vec2 = obs.vec2() position = 0 if itemSource != None: item = obs.obs_scene_find_source(scene, "OBSWindowGridItem") while item != None: obs.obs_sceneitem_remove(item) item = obs.obs_scene_find_source(scene, "OBSWindowGridItem") vec2.y = 0 while gridHeight < sceneHeight: gridWidth = 0 vec2.x = 0 while gridWidth < sceneWidth: newItem = obs.obs_scene_add(scene, itemSource) obs.obs_sceneitem_set_pos(newItem, vec2) obs.obs_sceneitem_set_locked(newItem, True) obs.obs_sceneitem_set_order_position(newItem, position) position += 1 vec2.x += xWidth gridWidth += xWidth vec2.y += yHeight gridHeight += yHeight
def script_load(settings): s = S.obs_data_create_from_json(JSON_DATA) a = S.obs_data_get_array(s, ID) h = S.obs_hotkey_register_frontend(ID, ID, on_obs_key_1) S.obs_hotkey_load(h, a) S.obs_data_array_release(a) S.obs_data_release(s)
def hook(obs_htk_id, htk_id, callback): json_data = '{"%s":[{"key":"%s"}]}' % (htk_id, obs_htk_id) s = S.obs_data_create_from_json(json_data) a = S.obs_data_get_array(s, htk_id) h = S.obs_hotkey_register_frontend(htk_id, obs_htk_id, callback) S.obs_hotkey_load(h, a) S.obs_data_array_release(a) S.obs_data_release(s)
def get_properties(self): print("PythonManager get_properties") self.liveSource = True self.props = libobs.obs_properties_create() #need to load from the save file or new python managers will wipe our scripts data = open_json_config_file("PythonScripts.json") obsdata = libobs.obs_data_create_from_json(json.dumps(data)) libobs.obs_source_update(self.source, obsdata) libobs.obs_data_release(obsdata) scriptFiles = libobs.obs_properties_add_editable_list( self.props, "ScriptFiles", "PythonScriptFiles", True, "*.py", "../../data/obs-plugins/obs-python/scripts") libobs.obs_properties_apply_settings(self.props, obsdata) return self.props