STM32F407 two-dimensional code recognition (using internal RAM + no FIFO camera OV7670

STM32F407 two-dimensional code recognition (use internal RAM + no FIFO camera OV7670
Key points:
1. Camera configuration, the camera without FIFO needs to pay attention to clock configuration and window configuration, otherwise the image cannot be output
2. DCMI configuration: DCMI needs to be configured as DMA transfer mode and use Line and field interrupts are used to collect image data (it is also possible to use frame interrupts, but it is necessary to ensure that the data will not be wrong, and the address of the data buffer cannot be mistaken). 3.
RAM configuration: Since the F407 contains 128KB of SRAM and 64KB of high-speed RAM (CCM), the buffer used to capture images is set to internal SRAM, and the buffer used to identify is set to CCM, so that it can be recognized while capturing, otherwise it will not work normally Recognition, the reason is that the QR code recognition process requires a lot of memory and computing power, and it must be given a separate RAM to run, and the clock of SRAMIN is derived from the main frequency (168MH frequency division, generally 168/2), Only SRAMCCM on the chip is running at the system frequency of 168MH (about 2-3 times faster than SDRAM), so high-speed RAM can be used to perform recognition, and the same method can be used for other image recognition. 4. Image array size
setting Determination: In theory, the internal high-speed CCM can be used to recognize 240x240 images, but because the CPU has to execute other key programs, 240x240 may not be realized. Secondly, the original image array is best to collect YUV data, and then extract the Y data from the original data as For the input of two-dimensional code recognition, the overall memory consumption is (SRAMIN(img_w img_h 2)+SRAMCCM(img_w*img_h)), which can just meet the allocation method of F407 internal RAM.
5. Image acquisition problem: In the previous attempt, the DCMI+DMA dual buffer of F407 was used to acquire image data, and the image with a window opening of 120x160 in QVGA format could be successfully acquired, but the larger image could not be acquired, and the reason was analyzed It is because the internal SRAM of the F4 cannot copy the data in the buffer in time (I use a clock configuration of 15 frames/s), so the collection of larger data formats cannot be completed in this way, and then the DCMI line interrupt method can be used Successfully collect QCIF images and perform QR code recognition. The recognition efficiency for numbers or letters is about 10 times/S, which can basically meet the demand. The more information the QR code recognizes, the slower it is.

Guess you like

Origin blog.csdn.net/weixin_40672861/article/details/105539926