[HeRos] Improve the camera capture

Yesterday, I’ve found a new source in internet which provides the registers to set in order to get bigger screen. I’m not able to capture 800×600 or 1600×1200.

http://sourceforge.net/p/nuttx/git/ci/a72d404bf6ca85b27f74d93ee901ff35db57703f/tree/nuttx/drivers/video/ov2640.c
The quality is good :

First medium capture

Captured with the ov2640

When I got this picture, I immediately try the full size 1600×1200. I receive something but I lost the beginning of the frame (\ff\d8). However, I still can find the end of the trame in the output hex files.
The difficulty was that the picture was too pig to stay in the two buffers and the dma overwritten the first buffer when it finished to fill the second.
It was time to use the interrupt callback. There are two callbacks :

  • DMA callback : every time a buffer is filled (first or second) this function is called
  • Frame end callback : when a frame is totally captured

At every DMA callback, an another thread is in charge to send the buffer 1 or 2 through the serial port. When the Frame End callback is called, I send the last buffer.

The result is not perfect :

Image in HD

Biggest size with the ov2640

PS : I can send through the serial port which goes to the wifi. But I suspect that the android app are not able to print all the jpeg received. The same picture stay at the screen. I have tested yesterday that every capture is different.

Eric Masseran

LinkedIn 

3 comments to [HeRos] Improve the camera capture

  • Samuel Tardieu

    Are you certain that in highest quality the first buffer can be transmitted through the serial port before it gets reused? The image quality is quite good though!

    • Morikko

      I have no idea but if I dont’send it immediately what can I do ?

      If I save it in a second buffer in memory, I will use a lot of memory ?
      Is it possible that the DMA is faster and rewrites the buffer before the buffer is totally sent ?

  • Alexis Polti

    ” Is it possible that the DMA is faster and rewrites the buffer before the buffer is totally sent ?”: that should be easy to test 🙂
    Anyway, is it really worth trying to send pictures at the maximum resolution ?