Speedup image acquisition with OpenCV

When I try to acquire image from my web-cam using my Raspberry Pi and OpenCV I notice a big delay.
This lag is caused by a buffer that internally the OpenCV store the grabbed frame.
Usually this is a good thing but due to low hardware of Raspberry Pi this buffer cause a lot of delay.

The only way to reduce this delay and speed-up image grab is modify source code of OpenCV and remove this buffer.

To remove this buffer I had to modify the file /opencv/modules/highgui/src/cap_libv4l.c changing the following line from: 


#define MAX_V4L_BUFFERS 10
#define DEFAULT_V4L_BUFFERS 4

to:

#define MAX_V4L_BUFFERS 1
#define DEFAULT_V4L_BUFFERS 1



To made effective this modification I had to recompile all openCV libraries.

Commenti