FPGA open source project: ball tracking system design (temporary open source)

1. Brief description

This design is based on the realization of color feature recognition. This is not a high-level algorithm. Personal ability is limited and the difficulty of FPGA implementation of the algorithm is not small. Therefore, the simplest method is adopted to realize it, but as an introductory study of FPGA is sufficient. This design was made in April 19th. At that time, my knowledge of FPGA was rather hazy and my ability to develop FPGA was average. Therefore, there were many design problems in this design, and there is no time to modify it. , I hope capable friends can improve it, thank you in advance!

When I started learning FPGA, I completed the FPGA-based image acquisition system according to Deng Kanwen's "Those Things about SDRAM" video tutorial. But there were a lot of bugs. At that time, my ability was too bad and I couldn't solve the problem, so I didn't use it in the subsequent image processing projects. This design is also the same, using the image acquisition routine delivered by the FPGA board. I developed on this basis, adding an image processing module and a two-axis steering gear control module.

2. Algorithm architecture

The image acquisition and display process is generally: FPGA buffers the image data collected by the camera to SDRAM, and then transports it from SDRAM to the LCD driver for output display. As can be seen from the overall block diagram below, image processing is performed when the LCD image stream is output. The image processing module adopts a pipeline processing method to complete RGB2YCbCr (binarization), morphological filtering of expansion and corrosion, and target object coordinate extraction, and finally output image and object coordinates. Then the steering gear drive module drives the two-axis steering gear to achieve real-time tracking.
Insert picture description here

3. A brief introduction to the image algorithm module

1). The following figure is a partial screenshot of the top layer of the image processing module. This realizes image selection and output. Press the button to select one of the four image effects of original image, binarization, corrosion and expansion.
Insert picture description here
2). All image algorithm modules are instantiated on the top layer, and there is also a serial port. This is to facilitate debugging of binary threshold parameters, which can shorten debugging time and improve efficiency. Insert picture description here
3). The following figure is the target object coordinate extraction module. The calculation method is to add up the effective coordinates, and finally divide by the number of effective pixels to get the target object's coordinates. Insert picture description here
4). The parameter adjustment data received by the serial port is finally used in the RGB2Ycbcr module, and the uncommented is the threshold value determined by the final adjustment. When you need to adjust the threshold, comment the upper part and uncomment the lower part. The serial port tuning command is: 01xx0102xx0203xx0304xx04. xx is the value you need to enter, and the 4 xx correspond to the four data of tuning.
Insert picture description here
5). These are the areas where there are doubts about image processing. Other principles like algorithm implementation can be learned from Baidu. The content is too much but not complicated.

4. Servo drive module

1). The steering gear control is to generate PWM, the specific principle is Baidu. The following figure produces a reference time of 0.4us, and then a 20ms servo control cycle, pulse_cnt, is generated on this reference. Insert picture description here
2). Convert the horizontal and vertical coordinates obtained by the image processing module to obtain the control value of the steering gear rotation angle. The coordinate and the center coordinate are subtracted to get the offset of the current object. Dividing by a coefficient here is to adjust the PID ratio. Directly using / is a bit of a violation, it is best to use the divider IP to handle it. Finally get the x_value and y_value values, which are the values ​​that control the rotation angle of the steering gear, and compare with the pulse_cnt obtained above to output PWM.
Insert picture description here

5. Supplement

The original plan was to share step by step. Now the working hours are too tight and there is not much time to organize. In order to meet the requirements of my friends, I will share the original project directly. There are some problems with the code written before, and I hope you can forgive me. The original track ball works backstage Re: small ball track can be obtained.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_40377195/article/details/109171151