Processing frames from an IP camera

Unlike USB cameras, frames coming from an IP camera are buffered and processed one after the other. Since usually the frame rate of the video stream is higher than the speed frames are processed, the video buffer gets filled up and overflows.

If this is not taken into account when developing a CrowdSight SDK based application, the result is that a very slow video rendering (analyzed frames are usually rendered on a GUI window) can be experienced and a skip-forward effect happens when the video buffer overflows.

To overcome this effect the CrowdSight SDK based application needs handle the frame processing in a separate thread. While the processing thread is busy in the frame analysis, frames grabbed in the main thread need to be discarded (or simply rendered).

The following pseudo code could help understanding the mechanism:

// Main thread
while( true )
{ frame = grab_frame_from_IP_camera(); if( crowdsight_processing_mutex.try_lock() ) { feed_frame_to_crowdsight( frame ); crowdsight_processing_mutex.unlock(); } else { discard( frame ); } } // Processing thread while( true ) { if( frame_to_process_available() ) { crowdsight_processing_mutex.lock(); frame = get_frame_to_process(); crowdsight_instance.process( frame ); crowdsight_processing_mutex.unlock(); } }
Have more questions? Submit a request


Please sign in to leave a comment.
Powered by Zendesk