Video Texture + Socket = Logic slow down

Hi,

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 !

Do you have any clue of the problem ?

thanks for your help

Blend File : http://www.pasteall.org/blend/177

no one knows ? :’(

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)


still the same :’(

Ignore this. I read your question again. Didn’t understand it the first time. Understand it now but don’t know the answer.

Clark

maybe I forgot to do something with the socket ? I don’t get it :’(

salut francois,

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.

pat

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 :wink: )

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.