cancel
Showing results for 
Search instead for 
Did you mean: 

How can I save the image from camra to usb memory directly without LCD?

Jhan.669
Associate II

Hi

I am working on an stm32f4x9i evaluation board.

I want to save camera images in USB memory without LCD.

Of course, I had worked the example shows how to display the camera image on the LCD and save it in memory.

However, the final goal is to save camera images directly to memory without the LCD.

I tried several things with DMA2D, but it failed to file writing.

static void PicturePrepare(void)

{

 static DMA2D_HandleTypeDef hdma2d_eval;

 uint32_t address1 = CONVERTED_FRAME_BUFFER;

 uint32_t address2 = CAMERA_FRAME_BUFFER;

 uint32_t index = 0;

 /* Configure the DMA2D Mode, Color Mode and output offset */

 hdma2d_eval.Init.Mode     = DMA2D_M2M_PFC;

 hdma2d_eval.Init.ColorMode  = DMA2D_RGB888;

 hdma2d_eval.Init.OutputOffset = 0;

 /* Foreground Configuration */

 hdma2d_eval.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;

 hdma2d_eval.LayerCfg[1].InputAlpha = 0xFF;

 hdma2d_eval.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565;

 hdma2d_eval.LayerCfg[1].InputOffset = 0;

 hdma2d_eval.Instance = DMA2D;

 /* Go to the end of the bitmap file address */

 address2 += ((BSP_LCD_GetXSize() * (BSP_LCD_GetYSize() - 1)) * 4);

 /* Convert picture to RGB888 pixel format */

 for(index = 0; index < (BSP_LCD_GetYSize()); index++)

 {

  /* DMA2D Initialization */

  if(HAL_DMA2D_Init(&hdma2d_eval) == HAL_OK)

  {

   if(HAL_DMA2D_ConfigLayer(&hdma2d_eval, 1) == HAL_OK)

   {

    if (HAL_DMA2D_Start(&hdma2d_eval, address2, address1, (BSP_LCD_GetXSize()), 1) == HAL_OK)

    {

     /* Polling For DMA transfer */

     HAL_DMA2D_PollForTransfer(&hdma2d_eval, 10);

    }

   }

  }

  /* Increment the source and destination buffers */

  address1 += ((BSP_LCD_GetXSize())*3);

  address2 -= BSP_LCD_GetXSize()*4;

 }

Do you have any ideas , how can I store camera images in memory without LCD?

4 REPLIES 4

Do you need the raw data converted, or not?

The DMA2D should be able to operate on memory independently of the LTDC

Without the LCD you'll have to provide the X/Y sizes still.

Raw data should be in the CAMERA_FRAME_BUFFER, processed in the CONVERTED_FRAME_BUFFER

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Jhan.669
Associate II

Thank you reply.

My camera sensor has a ISP. The raw data is output RGB565 format.

I think that I should convert format from RGB565 to RGB888.

so, I have setting the below code.

hdma2d_eval.Init.ColorMode  = DMA2D_RGB888;

 hdma2d_eval.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565;

And BSP_LCD_GetXSize() and BSP_LCD_GetZSize() function's return a value each x, y size.

For example BSP_LCD_GetXSize() is 480, BSP_LCD_GetYSize() is 272..

Ok,

And do you have the USB Host MSC driver working, with FatFs, and can you save files using that, outside of the image capture?

Can you write the frame buffers to a file in the same way? Have you inspected that data?

Do you need to write files in a more standard form? Like BMP, or compress to JPG or GIF?

Break the problem into smaller pieces, getting each to work properly independently before integrating them.

The frame buffer is just a collection of video lines, if you don't bring up the display the memory acts just the same, the LTDC just funnels the data into a stream and too the LCD.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Jhan.669
Associate II

I have one another question.

I know that one-shot mode in the camera causes a frame event following the line event.

Line event is BSP_CAMERA_LineEventCallback . Frame event is BSP_CAMERA_FrameEventCallback.

if the external memory is not set by FMC, the frame event occurs normally after the line event.

However, when set in FMC, only line events occur, even in one-shot mode. No frame event occurs.

The FMC setup is a stage of initializing SDRAM, and I don't know why this is affected by camera line events.