cancel
Showing results for 
Search instead for 
Did you mean: 

DCMI Crop feature

lglad
Associate

Hi all, I recently started learning about st-controllers and I am stuck in this, any help would be greatly appreciated.
I am working with stmf746, I wanted to crop the captured image with DCMI crop feature, I am configuring crop window size and offset with HAL_DCMI_ConfigCrop() and enabling crop with HAL_DCMI_EnableCrop(); If I want crop to size MxN from size 90x60, I am calling these function before camera capture after BSP_CAMERA_INIT();  HAL_DCMI_ConfigCROP(&dcmi, X0, Y0, M-1, N-1); HAL_DCMI_EnableCROP(&dcmi);

But I can see that the cropped image is not getting displayed properly, I can see the image is cropped, but there was there more than one image in a frame (4 to 5 images in a frame), I have correctly configured the code to display cropped image to MxN, can someone please explain me why this is happening, is there something I am missing? or anything wrong? 

3 REPLIES 3
KDJEM.1
ST Employee

Hello @lglad and welcome to the Community 🙂,

Which camera module are you using?

Are you using Embedded (or internal) synchronization mode ?

Please note, when using the embedded synchronization mode, the DCMI does not support the compressed data (JPEG) and the crop feature. (AN5020 Application note Introduction to digital camera interface (DCMI) for STM32 MCUs)

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @KDJEM.1, Thank you for your response!
I am using hardware synchronization mode and I am using OV5640
I am able to fix this I found out that I need to send the cropped window size and not the captured image size in HAL_DCMI_Start_DMA(), now I am able to crop and display the captured image.

Can you please confirm if I am understanding right? Are we capturing the image with the resolution the camera is configured and then cropping it, then sending it to DMA, I can see that there is some extra camera capture time (around 20ms) added after I crop the image by enabling crop. Is it the cropping that is adding the extra ms here?
If so, can you please help me understand how the cropping is adding the addtional time here?

Thank you.

KDJEM.1
ST Employee

Hello @researchscholar_1090 and welcome to the community 🙂,

With the crop feature, the camera interface can select a rectangular window from the received image. The start (upper left corner) coordinates and size (horizontal dimension in number of pixel clocks and vertical dimension in number of lines) are specified using two 32-bit registers (DCMI_CWSTRT and DCMI_CWSIZE). The size of the window is specified in number of pixel clocks (horizontal dimension) and in number of lines (vertical dimension).

These registers specify the coordinates of the starting point of the capture window as a line number (in the frame, starting from 0) and a number of pixel clocks (on the line, starting from 0), and the size of the window as a line number and a number of pixel clocks. 

So, if the crop feature is enabled, only the data inside the window specified by the crop register will be captured. If the size of the crop window exceeds the picture size, then only the picture size is captured.

Thank you.

Kaouthar

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.