[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] consistent heartbeats



I have a question that I'm hoping is appropriate for this group. I'm starting to do some research with computer vision and I'm trying to write my first realtime application. I want to have an application that will always do a full screen grab (ImageGrab() FYI) once every time interval, say 1 or 2 seconds and make that data available to any agents that want it (with potentially many more grabs for smaller sections of the screen in between). I want as near as I can get to zero standard deviation since I want my agents to be able to rely on having current data when they think they should (I am hoping to make them robust enough not to care eventually BTW).

Some of the pygame.time functions look promising, but I'm not sure if any of them do what I want, and I haven't played with events in pygame yet (nor have I ever used threads which I think I'll need). Plus, I know that with system calls suddenly a lot of a programmer's control is gone, and so I'm not sure how much I can fight that. Can I even cancel a system call my program's made?

What concerns me most is that somehow the system (I'm currently on win32) will have a big queue of system calls and I have to wait for my scrape. Or am I worrying about nothing? I'd be happy enough with 1s intervals with 50ms s.d.

Anyone care to shed light on what I'm trying to do? I'm not even sure where to start writing this code. I figure only game programmers ever try to make machines really do interesting things.

Miles