2025-05-25 5:51 AM
Dear ST Community,
I have successfully run the Object Detection Application on the STM32N6 Discovery Kit using the reference firmware from the STM32AI ModelZoo.
As part of extending its functionality, I am looking to implement the following two features:
For the RGB-to-JPEG conversion, I have referred to this JPEF Encoder example and integrated this JPEG encoding logic into the object detection firmware. Specifically, I am feeding the nn_in buffer (used as neural network input) to the JPEG encoder. However, during execution, the program gets stuck at this line:
jpeg_encode_processing_end = JPEG_EncodeOutputHandler(&hjpeg);
The jpeg_encode_processing_end flag is not being set to 1, indicating that the encoding process does not complete. I suspect either the JPEG input handling is not progressing, or the DMA isn't properly triggering the required callbacks.
Could you kindly review the approach and suggest the correct way to integrate JPEG encoding into the object detection pipeline?
I have attached my modified main.c file for your reference.
Appreciate your guidance on this.
2025-05-26 7:47 AM
Hello @pikud
Could you try to put as input the image in the JPEG encoder example.
2025-05-27 12:21 AM
Hi @Saket_Om
Following your suggestion, I tried using the static test image from the JPEG encoder example (image_320_240_rgb.h) as the input to the JPEG encoder of object detection firmware. However, upon doing so, the build fails with a linker error due to .rodata exceeding the available memory in the AXISRAM1_S region:
.section `.rodata' will not fit in region `AXISRAM1_S'
region `AXISRAM1_S' overflowed by 660280 bytes
To work around this, I moved large .rodata arrays (such as the test image or other large const buffers) into PSRAM using custom section attributes and appropriate linker script modifications. But by doing that I am unable to Run the program, but can build it.
Can you suggest what else needs to be done here?
2025-05-27 6:30 AM
Hello @pikud
@pikud wrote:
But by doing that I am unable to Run the program, but can build it.
Can you suggest what else needs to be done here?
What is the problem that appear when you run the program?
2025-05-27 7:38 AM - last edited on 2025-05-27 8:01 AM by Peter BENSCH
Hi @Saket_Om
1.) I’ve attached the problem log image below. Could you help identify what this might be related to?
2.) Also, the earlier issue of the program getting stuck at jpeg_encode_processing_end = JPEG_EncodeOutputHandler(&hjpeg) is resolved now
It seems the JPEG encoding was getting stuck because the required interrupt handlers for JPEG and DMA were missing. I added them in stm32n6xx_it.x and it was fixed
3.)Currently, JPEG encoding is running, but I’m seeing corrupted or unexpected byte data in the encoded jpeg output. I've attached the updated main.c file for reference.
My question is: since nn_in is the pointer to the camera's output buffer (used as the NN input), is it safe and valid to pass it directly into the JPEG encoder like this?
JPEG_Encode_DMA(&hjpeg, (uint32_t)nn_in, RGB_IMAGE_SIZE_1, jpgBuffer);
Would appreciate any guidance on whether the nn_in buffer requires any format conversion or cache handling before passing it to the JPEG encoder.