I don’t know why (probably did something wrong) but in the following blend, the Logic goes really slow.
I’m using Video Texture which grab a webcam and render it on a plan as background of my scene. VideoStart.py is called one time to init the webcam and VideoUpdate.py is called by an “Always” Sensor to update the video texture
Then I imported the Socket for network communication. Connect.py is called one time to init the socket and camcam_matrix.py is called by an “Always” Sensor which gets the data from the server, parse the string, and set the value from the string to an object.
the result is that the object is moving at the right time, but the video shows up really really too late. the serveur is a small application (which I cannot give away) which send matrix through socket.
The problem seems to come from the both Always Sensor. if I run just one of them everything is fine, but both at the same time, the video is dramaticly slow !
Don’t have a webcam, but what happens if you put all the code into VideoUpdate.py?
import string
#recieving data from camcam
if hasattr(GameLogic, 'Sock'):
data = string.split(GameLogic.Sock.recv(1024)," ")
GameLogic.Ground.setPosition([float(-data[3]),float(data[4]),float(data[5])])
GameLogic.Ground.setOrientation([float(data[0]),float(data[1]),float(data[2])])
# refresh video
if hasattr(GameLogic, 'video'):
GameLogic.video.refresh(True)
i tried your example on linux with /dev/video0 and it’s working well (60 fps). also i have a similar project: augmented reality (suzanne instead of my head)! let’s talk, maybe we can help each other.
actually I don’t think it’s coming from the socket since I have the same issue with the ARToolkit port to blender. it more likely the kind of camera I try to use. I’ll make some other test.
What is your project ? (send me an email, we’ll talk )
This might be completely unrelated to your issues but here’s a few things I’ve stumbled upon.
I’ve noticed that if you set a “wrong” framerate for your camera it might still work but have a delay. Using a framerate of 15 I had a 3 second delay on the video and using 30 I had none.
I also noticed that if you have a windowed application and you move the window after setting up the video it will stop playing while you move the window and after that you’ll have a small delay on the video.