Dec-10-2018, 11:05 AM
Hello,
I would like to create a very simple animation (a moving dot) guided by data recorded in real time.i achieved the script to collect data (the code below) but i don't know how to keep these data in order to animate my dot point in a GUI frame.The real time data is marker.x.
Ideally, i would like to have a script which collect real time data and output the real time data i could use in an other GUI script.
Thanks!
I would like to create a very simple animation (a moving dot) guided by data recorded in real time.i achieved the script to collect data (the code below) but i don't know how to keep these data in order to animate my dot point in a GUI frame.The real time data is marker.x.
Ideally, i would like to have a script which collect real time data and output the real time data i could use in an other GUI script.
Thanks!
import asyncio import qtm import xml.etree.ElementTree as ET def labelMarker(xml_Str): print(xml_Str) async def setup(): """ Main function """ connection = await qtm.connect("127.0.0.1",version="1.16") if connection is None: return """ Marker Label identification""" xml_string=await connection.get_parameters(parameters=["3d"]) root = ET.fromstring(xml_string) label=[]# list creation dico_marker={} # dictionnary creation for sub1 in root: for name in sub1.iter('Name'): label.append(name.text) def streamData(packet): """ Callback function that is called everytime a data packet arrives from QTM """ #print("Framenumber: {}".format(packet.framenumber)) header, markers = packet.get_3d_markers() i=0 ''' Data are stored in a dictionnary''' for marker in markers: dico_marker[label[i%len(label)],'X',i]=marker.x i=i+1 #print(dico_marker.keys()) await connection.stream_frames(components=["3d"], on_packet=streamData) def main(): asyncio.ensure_future(setup()) # creation of future object that will eventually give a result some time in the future loop=asyncio.get_event_loop() # creation of event loop which schedule my coroutine loop.run_forever() # run the event loop until stop()is called if __name__ == "__main__": main()