Take the 2-minute tour ×

I have opened this new thread after having tried lots of thing. My application (C++ on VS2010) has to grab an image, elaborate the image, send through UDP the result. The problem is the frequency: 200 times/second. So I have a camera that records image in a double buffer at 200Hz, and I have to elaborate the image in less than 5 milliseconds. The application works at 99,999 % of the time but I think that Win7 Pro take out my realtime priority and so in 1 of 100000 cases something goes wrong. Reading msdn forum and so on, I can only use:

  1. SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); To get a realtime priority of the process when it have been launched with administrator's priviledges

Now, I have 5 threads started by me (_beginthreadex) and several thread started inside a compiled DLL of the camera. I think that if I set Time Critical priority to all my 5 thread, none of them has higher priority than others.

So I have two questions:

  • could I work at 200 Hz without Windows's lags?
  • have you any suggestions for my threads' settings?

Thanks!! Bye bye Paolo

share|improve this question
What does 'something goes wrong' means? –  Daniel Mošmondor Jul 6 '12 at 10:21
Well.. image period 5ms, disk latency 10ms = misery. Any swaps and you're stuffed, (on a spinner, anyway). Still, I would expect that you could get close-ish to 5ms overall, with care, extra buffering and accepting a little latency. –  Martin James Jul 6 '12 at 10:32
@Martin James: I'm using a SSD in order to avoid that disk latency. –  user1506386 Jul 6 '12 at 12:42
@Daniel Mosmondor: "something goes wrong" means that the camera overwrites the buffer while I'm elaborating it.. For example: if the camera swaps buffer every 5 millisecs, and my elaboration lasts 6 milliseconds then the camera overwrites a little of my buffer. I could use more than 2 buffers, but I must send a result every 5 milliseconds, so it doen't change the situation.. –  user1506386 Jul 6 '12 at 12:43
What is maximum delay between image and its 'summary' that you send through the UDP? I am asking that because you say that you have to send datagrams every 5ms, but you don't say what is their timing in respect to the incoming picture... –  Daniel Mošmondor Jul 6 '12 at 14:03

1 Answer 1

Oh I would use more than two buffers for this. A pool of 200 image objects seems like a better bet.

How much latency can you afford, overall? It's always the same story with video streaming - you can have consistent, pause-free operation, or low latency, but not both.

How big is the video image buffer queue on the client side?


'I must ever send a UDP datagram every 5 millisec' :((

OK, so you have an image output queue with a UDP send thread on a 5ms loop, yes? The queue must never empty. Sounds indeed like the elaborations are the bottleneck.

Do you have a [number of cores+] pool of threads doing the elaborations?

share|improve this answer
I used a double buffer because I must ever send a UDP datagram every 5 millisec. So, I could use a 200-image buffer, but I have to break the elaboration if I'm overlapping the 5-ms period.. –  user1506386 Jul 6 '12 at 12:41

Your Answer


