cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX and DCMI together

eng23
Senior

Hi,

I'm adding camera to my custom board with TouchGFX using DCMI.

I have doubts on how to put video camera in framebuffer used by TouchGFX..

I've created 2 framebufferes in LTDC and the first is used by Touch. I don't know if I use the second framebuffer to camera and show the second in LCD or I use the same framebuffer for both. How I leave TouchGFX using framebuffer...

Thanks.

11 REPLIES 11
Martin KJELDSEN
Chief III

Hi @eng23​,

What is the resolution of the camera? What you could do is receive an interrupt every time there's a new frame ready in the camera, read that data into a piece of memory which is configured for a DynamicBitmap. You can then invalidate() this bitmap to show the new camera frame. Notice that you can only show camera frames at the same speed that the application is running.

/Martin

eng23
Senior

Hi @Martin KJELDSEN​ ,

Welcome back to work!

My cameras have the resolution of 1280x960, the other has 648x488. But my LCD is 480x272, so an adaptation is necessary.

I was thinking doing something like this using DMA:

frame = (uint8_t *)LTDC_Layer1->CFBAR;
 
HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS, (uint32_t)frame, 0x0000FF00);

But it conflicts with TouchGFX framebuffer.

I understand your suggest, I will try this and let you know.

Thanks!

Martin KJELDSEN
Chief III

Hi @eng23​,

Yes, that will conflict. If you're doing a continuous mode, maybe you should just do the following to test:;

  1. In your view, create a dynamic bitmap that points to the memory area you want to fill with camera data through DMA.
  2. in each tick of your view ( handleTickEvent() ) invalidate your dynamic bitmap to display the updated data.
  3. Transform the data in your camera buffer in some way so that it matches the dimensions you want such that it matches the dimensions of the dynamic bitmap.

Are you looking to have a full screen application showing the camera frames?

/Martin

eng23
Senior

Hi @Martin KJELDSEN​ ,

Thanks for reply.

I could create a dynamic bitmap and I'm showing properly in LCD. I set an area in external SRAM and this is used in this bitmap.

After I pointed the DCMI_DMA to this area in snapshot mode and the screen shows different images in each update (but abstract images), so this process is working (by TGFX).

My problem now is that this images are comming from camera, but I don't know if the pattern is wrong (PAL, NTSC..), synchronization, resolution... so my effort is in this, but the TouchGFX feature to show video (or snaps) is ok (I hope)!

Yes I'm looking to have a full screen showing camera frames.

Thanks.

Martin KJELDSEN
Chief III

How does it look? Also consider the bitdepth of the frames generated by the camera. It must match the setting of LTDC/TouchGFX.

/Martin

eng23
Senior

Hi,

At this moment I have this:

0690X0000098OWdQAM.jpg

This image should show colors bar (a function from video decoder) and we can see a few pixels like it should be.

I'm checking DCMI settings and synchronization. If I move camera position this screen has little changes, but with this beautiful pixels!

Thanks

Martin KJELDSEN
Chief III

How are you doing on this? Did your checks turn up anything? How many bars did you expect there to be? There may be an offset issue - That's typically indicated by the slanted lines. Maybe your dynamic bitmap is one pixel too wide.

/Martin

Hi Martin,

Well about the bars the problem was the synchronization in HSYNC, because I was expecting that DCMI peripheral should do this, but it doesn't.

My camera format is YCbCr, so I needed to implement in code this sync and then convert, in code too, to RGB888 format.

The problem about this is the frame rate, which I could reach only 10 FPS (because the conversion YCbCr > RGB888 done in code).

In TGFX side, I add a Dynamic Bitmap and every VSYNC interrupt I do the conversion and invalidate the image.

Another think is that the camera has more resolution than my TFT, so currently I show only a part of full image, because I think if I downscale I need more processing and could reduce even more the FPS.

Regards

Further processing the image would probably slow down things considerably, i agree. So, actually, some ST chips support in-hardware-YCbCr decoding directly into the DynamicBitmap memory area.

/Martin