GVillani82
GVillani82

Reputation: 17429

Issue realtime frame manipulation

I developed a c# application that takes in input the streamRGB (640x480 rate:30fps) generated by Kinect device. After each frame is received I save it on disk as file.wmv. The problem starts when I try to manipulate each frame before save it, cause the stream rate is 30fps and the operation of manipulating lasts about 200ms (so I can acquire just 5fps).

I know this is a common problem. What are the most common solution used in order to solve it?

Upvotes: 1

Views: 87

Answers (1)

Deathspike
Deathspike

Reputation: 8780

This is a common problem that occurs when you need to do something in real-time, but which is actually too slow to be handled in real-time. The first and foremost 'solution' would be to increase performance of the real-time operations so it will be fast enough, however this is often not possible.

The more realistic option is to establish a queue to be processed on another thread. This is a perfect example for a consumer/producer design pattern, as you can will be producing frames and consuming them to be handled as fast as possible. To off-load memory, you can write the frames to the file disk and read them when consuming.

Also note that GDI+, the code behind bitmaps, is single threaded and will lock everything regarding image manipulation to a single thread. This can be migrated using different processes (one for each core) to optimize machine performance.

Upvotes: 1

Related Questions