ziberg
|
ziberg
Posted 3 Years Ago
|
Group: Forum Members
Last Active: 3 Years Ago
Posts: 1,
Visits: 19
|
I'm trying to capture a screen and paste it onto a BillBoard as Texture, while motion live is recording. I update the BillBoard's texture with a timer(interval = 1000ms). The python code looks like: #--------------------------------------------block1-------------------------------------- g_texture_img_file_name = "mooctexture.png" def refresh_texture_once(g_boardNode, g_material_component, g_mesh_name, g_material_name, g_texture_channel): global g_logger, g_texture_img_file_name g_material_component.LoadImageToTexture(g_mesh_name, g_material_name, g_texture_channel, g_texture_img_file_name) start_prepare_texture_file_thread(g_texture_img_file_name)
class RefreshTextureTimerCallback(RLPy.RPyTimerCallback): def __init__(self): RLPy.RPyTimerCallback.__init__(self) def Timeout(self): global g_material_component, g_mesh_name, g_material_name, g_texture_channel, g_boardNode refresh_texture_once(g_boardNode, g_material_component, g_mesh_name, g_material_name, g_texture_channel)
g_textureTimer = RLPy.RPyTimer() g_textureTimer.SetInterval(1000) #textureTimer.SetSingleShot(True) timer_callback = RefreshTextureTimerCallback() g_textureTimer.RegisterPyTimerCallback(timer_callback)
def prepare_texture_file(file_name): g_selected_screen_index = 0 current_screen = QtWidgets.QApplication.screens()[g_selected_screen_index] rect = current_screen.geometry() im = ImageGrab.grab(bbox=(rect.x(), rect.y(), rect.x()+rect.width(), rect.y()+rect.height()), include_layered_windows=False, all_screens=True) width = im.size[0] height = im.size[1] im = im.resize((int(width * 0.3), int(height * 0.3)), Image.ANTIALIAS) im.save(file_name)
def start_prepare_texture_file_thread(file_name): th = threading.Thread(target=prepare_texture_file, args=(file_name,)) th.start()
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Prop, "BlackBoard") #a BillBoard in iClone with the name "BlackBoard" g_boardNode = avatar g_material_component = avatar.GetMaterialComponent() mesh_list = avatar.GetMeshNames() g_mesh_name = mesh_list[0] material_list = g_material_component.GetMaterialNames(g_mesh_name) g_material_name = material_list[0] g_texture_channel = RLPy.EMaterialTextureChannel_Diffuse g_textureTimer.Start() #----------------------------------------------------------------------------------
The (real) code in block1 works well, capturing the screen and pasting it on the BillBoard every 1 second.
However, when i start the Motion Live (a GREAT work!), click the "Record" button and press SpaceBar, the Motion Live begins, and STOPS when the g_textureTimer executes the Timeout().
It seems that, the timer stops the Motion Live's thread, since they both update the scence in iClone.
The initial purpose is to import a video stream into the scence in iclone while previewing/recording the Motion Live. However, the RIMaterialComponent.LoadVideoToTexture() has no RTSP file format options. When i load the RTSP(rtsp://127.0.0.1:8554/test.mpg) with the following python code:
ret = g_material_component.LoadVideoToTexture(key, g_mesh_name, g_material_name, g_texture_channel, "rtsp://127.0.0.1:8554/test.mpg")
The ret is Sucess, iClone accepts it, but the BillBoard is blank(white).
By the way, the [rtsp://127.0.0.1:8554/test.mpg] is produced by live555MediaServer.exe and can be viewed in VLC. And the original movie file can be loaded as texture: g_material_component.LoadVideoToTexture(key, g_mesh_name, g_material_name, g_texture_channel, "D:/live555/test.mpg")
So my question is: 1) Is it possible to import a RTSP stream as a video texture; 2) or is it possible to update the texture without interrupting Motion Live, and how?
|