geraspi
Posts: 7
Joined: Tue May 13, 2014 12:32 pm

MMAL - RPI

Thu Jul 10, 2014 7:20 am

Hi,

In Raspberry Pi board if we want to run camera preview we have to give the below command with time. And we can increase the time as per our requirement so preview will run continuously till the time complete.
"raspistill -t 2000"

I am implementing the camera driver support in Android for Raspberry Pi. Now camera preview is running and it is running only few seconds. Please let me know how to increase the time and how to run continuous preview through MMAL code.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7149
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: MMAL - RPI

Thu Jul 10, 2014 8:18 am

Hmm, that sounds suspiciously like my day job! :D
We have a full Android libCamera1 implementation sitting on top of MMAL, so it is totally possible. You'll want to talk to MMAL directly rather than via raspistill as you need to pass frames out to SurfaceFlinger, StageFright and the like.
Obviously I can't give our code out, but I'm happy to give pointers and advice if necessary. We make heavy use of mmal_connections on the GPU, and only pull buffers back to the ARM when needing to deliver them out to the rest of the system.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

RpiName
Posts: 712
Joined: Sat Jul 06, 2013 3:14 am

Re: MMAL - RPI

Thu Jul 10, 2014 10:03 am

geraspi wrote: I am implementing the camera driver support in Android for Raspberry Pi.
Do you know where the Android image for Rpi can be downloaded from?

geraspi
Posts: 7
Joined: Tue May 13, 2014 12:32 pm

Re: MMAL - RPI

Thu Jul 10, 2014 12:22 pm

Hi,

In Raspberry Pi board if we want to run camera preview we have to give the below command with time. And we can increase the time as per our requirement so preview will run continuously till the time complete.
"raspistill -t 2000"

I am implementing the camera driver support in Android for Raspberry Pi. Now camera preview is running and it is running only few seconds. Please let me know how to increase the time and how to run continuous preview through MMAL code.

Please let me know if anyone knows about this.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23393
Joined: Sat Jul 30, 2011 7:41 pm

Re: MMAL - RPI

Thu Jul 10, 2014 12:54 pm

geraspi wrote:Hi,

In Raspberry Pi board if we want to run camera preview we have to give the below command with time. And we can increase the time as per our requirement so preview will run continuously till the time complete.
"raspistill -t 2000"

I am implementing the camera driver support in Android for Raspberry Pi. Now camera preview is running and it is running only few seconds. Please let me know how to increase the time and how to run continuous preview through MMAL code.

Please let me know if anyone knows about this.
Please read post above by 6by9.

Are you using raspistill? If so you really shouldn't. It's simply demo code and not really suitable for straight incorporation in to Android. You'll need to be a little more sophisticated and use mmal directly.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

kaikeraut
Posts: 30
Joined: Tue Apr 29, 2014 8:18 am

Re: MMAL - RPI

Mon Jul 28, 2014 11:56 am

6by9 wrote:Hmm, that sounds suspiciously like my day job! :D
We have a full Android libCamera1 implementation sitting on top of MMAL, so it is totally possible. You'll want to talk to MMAL directly rather than via raspistill as you need to pass frames out to SurfaceFlinger, StageFright and the like.
Obviously I can't give our code out, but I'm happy to give pointers and advice if necessary. We make heavy use of mmal_connections on the GPU, and only pull buffers back to the ARM when needing to deliver them out to the rest of the system.
Hi 6by9,
i am trying to do the same thing, how can i get the preview buffers which will passed through surface flinger.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7149
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: MMAL - RPI

Mon Jul 28, 2014 1:08 pm

kaikeraut wrote:Hi 6by9,
i am trying to do the same thing, how can i get the preview buffers which will passed through surface flinger.
It depends on exactly how Surface Flinger is set up and what it supports, but the simplest option is:
  • In intialise create a MMAL camera component.
  • From startPreview, set output[0] format to be the desired resolution. Encoding wants to be either MMAL_ENCODING_I420 which is almost the same as YV12 (luma padded to a multiple of 32, chroma to 16. Android wants both to a multiple of 16), or MMAL_ENCODING_NV21 which is almost the same as NV21 (Both planes are padded to a multiple of 32, when Android wants no padding).
  • From setPreviewWindow you can ask the window for the minimum number of undequeued buffers. Your buffer pool really wants to be this size plus probably 3 for smooth video.
  • Enable the port.
  • Dequeue all the buffers from the window, and associate them with a MMAL buffer (there's a user_private or similar field in the MMAL_BUFFER_HEADER_T which is convenient for storing the native window buffer). You can then call cancel_buffer on MIN_UNDEQUEUED_BUFFERS, and send the rest to the camera->output[0].
  • On getting a callback, you can call queue_buffer with the associated native buffer, and dequeue_buffer to get back another one for recycling (send it to the output port)
There are various improvements that we've made which I can't really divulge, but that should get you going. Have fun. You never know, given a few months away from the madhouse, I might come and join you on this project (have to be careful not to infringe copyright by recreating the camera HAL that was written for Broadcom) :)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”