cancel
Showing results for 
Search instead for 
Did you mean: 

SM32N6570-DK Camera Snapshot Mode

Cococarbine
Associate II

Hello,

I am working with this guide:
How to integrate TouchGFX and camera middleware on an STM32N6570-DK 

And was wondering if there was an easy way to capture snapshots instead of running the camera continuously.  I tried setting the mode to CMW_MODE_SNAPSHOT with no luck.

I was able to get snapshot mode to work in the DCMIPP_SnapshotDecimationMode example, but it seems that example interacts with the ISP a little differently from the link above.

The end goal is to store snapshots in different locations on PSRAM (multiple cameras muxed to the MCU's CSI port)

1 ACCEPTED SOLUTION

Accepted Solutions
Cococarbine
Associate II

Ok after some debugging of cmw_camera.c I found out that the pipe in HAL_DCMIPP_CSI_PIPE_Start() was not ready yet.  I modified the code to stop the pipe (below), and all seems to be working well.

if (received_State == MSG_CAMERA_ON)
{
	frames = CMW_GetNbMainFrames();

	int err = CMW_CAMERA_Start(DCMIPP_PIPE1, (uint8_t *) u8DCMIPP_ImageArray, CMW_MODE_SNAPSHOT);
	if (err != CMW_ERROR_NONE)
	{
		Error_Handler();
	}
	tx_thread_sleep(50);
	CMW_CAMERA_Stop(DCMIPP_PIPE1);
}

 

View solution in original post

4 REPLIES 4
Saket_Om
ST Employee

Hello @Cococarbine 


@Cococarbine wrote:

Hello,

I am working with this guide:
How to integrate TouchGFX and camera middleware on an STM32N6570-DK 

And was wondering if there was an easy way to capture snapshots instead of running the camera continuously.  I tried setting the mode to CMW_MODE_SNAPSHOT with no luck.


What "issues", exactly, do you encounter?

 


@Cococarbine wrote:

Hello,
I was able to get snapshot mode to work in the DCMIPP_SnapshotDecimationMode example, but it seems that example interacts with the ISP a little differently from the link above.


Did you try to copy the configuration of the example on your setup?

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.
Saket_Om

Hi Saket,

Thank you for reaching out.  I modified the camera thread from the link above to attempt to capture snapshots instead of starting / stopping a continuous pipe.  The first MSG_CAMERA_ON (triggered from button press) does appear to capture a new frame successfully; however, subsequent button presses CMW_CAMERA_Start() returns with -4 CMW_ERROR_PERIPH_FAILURE. 

VOID  Camera_thread_entry(ULONG initial_input)
{
	DCMIPP_DecimationConfTypeDef pDecConfig = {0};
	uint32_t pitch_value ;
	ULONG received_State;
	pitch_value = (800 * 4) / 2;
	pDecConfig.HRatio  = DCMIPP_HDEC_1_OUT_2;
	pDecConfig.VRatio  = DCMIPP_VDEC_1_OUT_2;
	HAL_DCMIPP_PIPE_SetDecimationConfig(hDcmipp, DCMIPP_PIPE1, &pDecConfig);
	HAL_DCMIPP_PIPE_EnableDecimation(hDcmipp, DCMIPP_PIPE1);
	HAL_DCMIPP_PIPE_SetPitch(hDcmipp, DCMIPP_PIPE1, pitch_value);

	//Update LTDC Display window
	HAL_LTDC_SetWindowSize(&hltdc, 800/2 , 480/2, LTDC_LAYER_2);

	//Initially disable the layer 2
	__HAL_LTDC_LAYER_DISABLE(&hltdc, LTDC_LAYER_2);
	HAL_LTDC_ReloadLayer(&hltdc, LTDC_RELOAD_VERTICAL_BLANKING, LTDC_LAYER_2);
	SCB_CleanDCache ();

	//Start continuous pipe
	if (CMW_CAMERA_Start(DCMIPP_PIPE1, (uint8_t *) u8DCMIPP_ImageArray, CMW_MODE_CONTINUOUS) != CMW_ERROR_NONE)
	{
		Error_Handler();
	}

	//30 Frames for ISP to adjust exposure upon startup
	volatile uint32_t frames = CMW_GetNbMainFrames();
	while(frames < 30)
	{
		frames = CMW_GetNbMainFrames();
		CMW_CAMERA_Run();	//ISP Process
	}
	CMW_SetNbMainFrames(0);
	frames = CMW_GetNbMainFrames();

	//Stop continuous pipe
	CMW_CAMERA_Stop(DCMIPP_PIPE1);

	//Reload Layer 2
	 __HAL_LTDC_LAYER_ENABLE(&hltdc, 1);
	HAL_LTDC_ReloadLayer(&hltdc, LTDC_RELOAD_VERTICAL_BLANKING, 1);


	/* Application main loop */
	 while(1)
	{
		 UINT status = tx_queue_receive(&Camera_Queue_ptr,&received_State,10);
 		 if (status == TX_SUCCESS)
		 {
			 if (received_State == MSG_CAMERA_ON)
			 {
				 frames = CMW_GetNbMainFrames();

				 int err = CMW_CAMERA_Start(DCMIPP_PIPE1, (uint8_t *) u8DCMIPP_ImageArray, CMW_MODE_SNAPSHOT);
				 if (err != CMW_ERROR_NONE)
				 {
				     Error_Handler();
				 }
				 CMW_CAMERA_Run();	//ISP Process
	         }
		 }
	}
}



I will start diving into the camera driver tomorrow to see why.  I will also attempt to use the example from DCMIPP_SnapshotDecimationMode in place of cmw, but wanted to see if I could get snapshot working with the above cmw camera middleware from the GPM / MGD Application Teams first (maybe not necessary?).

db16122
Associate II

NUCLEO-N657X0-Q Nucleo board with STEVAL-55G1MBI1 - STMicroelectronics Community

If you want to know reason for the CMW_ERROR_PERIPH_FAILURE information, you may need set debug point at cmw_camera.c and check which error you met

Cococarbine
Associate II

Ok after some debugging of cmw_camera.c I found out that the pipe in HAL_DCMIPP_CSI_PIPE_Start() was not ready yet.  I modified the code to stop the pipe (below), and all seems to be working well.

if (received_State == MSG_CAMERA_ON)
{
	frames = CMW_GetNbMainFrames();

	int err = CMW_CAMERA_Start(DCMIPP_PIPE1, (uint8_t *) u8DCMIPP_ImageArray, CMW_MODE_SNAPSHOT);
	if (err != CMW_ERROR_NONE)
	{
		Error_Handler();
	}
	tx_thread_sleep(50);
	CMW_CAMERA_Stop(DCMIPP_PIPE1);
}