[beagleboard] Video capture on the BeagleBoard XM

I have logged the time it takes for each image to be captured, and while
most images take ~33ms, for some images it could take triple that, which
obviously messes things up. The BeagleBoard seems to just pause or lock
every few seconds.

Does anyone know why this might be happening?

Maybe some background process running with higher priority which
preempts your capturing thread?

Nothing that I can see. How would I check that?

Just to give you some more information, I’m hoping to capture from two cameras simultaneously,

a Point Grey usb camera, using the libdc1394 capture functions (1280x960)
an infrared analog camera, using an analog to usb video grabber, using the v4l2 capture functions (640x480)

Both of these are able to capture no problem, but I’m not sure if I can get 15fps.

I tried capturing and saving from the infrared camera only, and put the saving in a separate thread. So as the images are captured, they are queued up for saving. From the logging it appears that the capturing is at a constant frame rate, but when I look at the video after joining up the images, the first few seconds look fine, but then there’s sudden jumps and the video appears to cycle over the same number of frames over and over. If I instead save the images as they are captured (all in one thread), there’s no cycling but there are still jumps. So tracking seems to be out of the question.

The strange thing is that if I use ffmpeg to capture on the command line, the resulting video looks fine, smooth, 15fps, perfect. So the BeagleBoard is capable of capturing at 15fps.

Hi Elizabeth,

Just to give you some more information, I'm hoping to capture from two
cameras simultaneously,

a Point Grey usb camera, using the libdc1394 capture functions (1280x960)

Just out of curiosity - how are you going to connect FireWire (1394)
camera to BeagleBoard? :wink:

Nothing that I can see. How would I check that?

I would start with "top" running in parallel with your program to
search for something very obvious.

It is impossible to make any reasonable suggestions without really
seeing your code and spending time on debugging. So the following is
just my guesses.

How is capturing loop organized? Are you using select() based approach
or something else?

To find out if the problem related to your implementation of storage,
for example, you can start with changing the performance of the
storage. You can try to use either much slower or much faster SD card
or even better nfs-mount remote file system and store your images over
there.

Since you are using separate thread for storage, you have classical
producer/consumer scenario. How it is implemented? Typical mistake in
such cases is race conditions caused by bugs in synchronization. Maybe
your producer (capturing) thread overwriting the data structure used
by storage thread in unexpected moments? I would suggest to equip your
code with bunch of printf()s to trace the execution flow (however,
printf()s might change execution timing and the bug might not appear).

Since you mentioned that ffmpeg can capture without problems, my gut
feeling tells me that there is a bug in your capturing, storing or
interaction between them. But this is just a guess.

Good luck with debugging,
Andrey.