Two-degree-of-freedom holder control system and method based on STM32 and OpenMV

By using high-precision stepper motors and the PID algorithm of the STM32 microcontroller in the PTZ control system, combined with OpenMV's Retinex algorithm and RGB to grayscale technology, the problems of low accuracy and inaccurate target recognition of the PTZ control system are solved , achieving higher stability and recognition accuracy.

CN118585000APending Publication Date: 2024-09-03杨佳
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410783154.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

The existing low-cost pan/tilt control system based on STM32 microcontrollers has problems such as low accuracy, slow response speed, easy overshoot in rotation, and obvious jitter. In addition, target recognition is not accurate enough and is greatly affected by ambient light.

Method used

A high-precision stepper motor is used as the driving device, combined with the PID algorithm on the STM32 microcontroller to improve the accuracy and stability of the gimbal, and the Retinex algorithm and RGB to grayscale technology are used in OpenMV to enhance image processing and improve the response of target recognition. Speed ​​and accuracy.

Benefits of technology

It effectively improves the accuracy and stability of the gimbal, enhances the response speed and accuracy of target recognition, and reduces the impact on ambient light.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585000A
    Figure CN118585000A
Patent Text Reader

Abstract

The invention relates to a two-degree-of-freedom cradle head control system and method based on STM32 and OpenMV, a high-precision stepping motor is used as a driving device of the cradle head control system, and a PID algorithm is used on an STM32 microcontroller to improve the precision and stability of a cradle head; a Retinex algorithm is adopted in the OpenMV, an image is enhanced by converting RGB into gray, and the data complexity is reduced; therefore, the response speed and recognition accuracy of target recognition during target tracking are improved, and the problem that target recognition is greatly influenced by ambient light is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of pan / tilt control, and in particular relates to a two-degree-of-freedom pan / tilt control system and method based on STM32 and OpenMV. Background Art

[0002] The PTZ control system is an automated device specifically used for remote operation and monitoring of equipment viewing angles. It is widely used in various scenarios, including security monitoring, drone aerial photography, robotics technology and other fields to achieve equipment orientation, positioning and other functions.

[0003] At present, most of the high-speed and stable PTZ control systems have the problems of high cost and large size. Low-cost PTZ control systems based on STM32 microcontrollers usually use servos such as MG90S servos and HS-645MG servos as PTZ drive devices, which have the problems of low accuracy, slow response speed, easy overshoot and obvious jitter. In addition to the problems of the PTZ drive device, the target recognition device of such existing systems also has the problems of inaccurate recognition and being greatly affected by ambient light. Summary of the invention

[0004] In view of the above-mentioned prior art problems, the object of the present invention is to provide a two-degree-of-freedom pan-tilt control system and method based on STM32 and OpenMV. The present invention uses a high-precision and high-precision stepper motor as a driving device of the pan-tilt control system, and uses a PID algorithm on the STM32 microcontroller to improve the accuracy and stability of the pan-tilt; in OpenMV, we use the Retinex algorithm and RGB to grayscale to enhance the image and reduce data complexity, so as to improve the reaction speed of target recognition and enhance the accuracy of recognition, effectively solving the problem that target recognition is greatly affected by ambient light.

[0005] On the one hand, the present invention provides a two-degree-of-freedom pan-tilt control system based on STM32 and OpenMV, the pan-tilt control system comprising: a pan-tilt, OpenMV, and an STM32 microcontroller, the STM32 microcontroller and the OpenMV communicating via serial ports, the pan-tilt being connected to a high-precision stepper motor, the STM32 microcontroller being electrically connected to the high-precision stepper motor; the minimum rotation angle of the high-precision stepper motor being less than or equal to 0.56 degrees.

[0006] The OpenMV includes: a camera module for collecting images, and an image data processing module for performing image processing on the collected images; the image data processing module includes an image preprocessing module for performing image preprocessing using a Retinex algorithm and RGB to grayscale conversion, and an image processing signal generation module for grayscale image data processing; The TX-RX (transmitter-receiver) interface of the STM32 microcontroller is connected to the RX-TX (receiver-transmitter) interface of OpenMV, and the output of the STM32 microcontroller is connected to control the movement of the high-precision stepper motor.

[0007] Furthermore, in the pan / tilt control system of the present invention, the Retinex algorithm calculation steps are: S1: Input the collected original image and the radius range of the filter of the original image, the radius range is 3 pixels * 3 pixels; S2: Calculate the result of Gaussian filtering of the original image according to formula A and formula B to obtain L(x,y); The formula A is: I(x,y)=R(x,y)*L(x,y), The formula B is: L(x,y)=I(x,y)*G(x,y); S3: Calculate according to formula C to obtain Log[R(x,y)]; quantize Log(R(x,y)) to a pixel value in the range of 0-255 according to formula D, and then output the resulting image; The formula C is: Log(R(x,y))=Log(I(x,y))- Log(L(x,y)), The formula D is: R(x,y)=(Value - Min) / (Max - Min)*255; Among them, in Formula A, Formula B, Formula C and Formula D, * represents convolution, G(x, y) represents a Gaussian kernel, I(x, y) represents an image signal observed or received by a camera, L(x, y) represents the illumination component of ambient light, and R(x, y) represents the reflection component of the target object carrying image detail information.

[0008] Furthermore, in the pan / tilt control system of the present invention, the working process of converting the RGB image to grayscale is: by performing weighted average calculation on the red, green and blue channels of the color image, a single-channel grayscale image representing brightness information is obtained; The calculation formula of the weighted average method is: Gray = 0.299R + 0.587G + 0.114B, Among them, R is the red channel pixel value, G is the green channel pixel value, and B is the blue channel pixel value.

[0009] Further, in the pan-tilt control system of the present invention, the working process of the image processing signal generating module is: automatically identifying the morphological contour of the moving target in the single-channel grayscale image, and using the rectangular function in the OpenMV function path to obtain the image processing signal, wherein the image processing signal is the slope K and distance L of the calculation rectangle in the rectangular function; The calculation formula of the rectangular function is: Slope K = |y1-y2| / |x1-x2|, Distance L = [(x1-x2) 2 +(y1+y2) 2 ] 1 / 2 ; Wherein, a minimum rectangle that can surround the target is drawn in the picture displayed by the camera module, and the minimum rectangle is the calculation rectangle; Among them, y1 is the value of the vertical coordinate of the pixel at the center point of the camera image, y2 is the value of the vertical coordinate of the center point of the rectangle, x1 is the value of the horizontal coordinate of the pixel at the center point of the camera image, and x2 is the value of the horizontal coordinate of the center point of the rectangle.

[0010] Furthermore, in the pan-tilt control system of the present invention, the slope K and the distance L signals output by the OpenMV are transmitted together to the STM32 microcontroller.

[0011] Furthermore, in the pan-tilt control system of the present invention, a PID algorithm is used in the STM32 microcontroller to generate PWM.

[0012] Furthermore, in the pan-tilt control system of the present invention, the communication mode between the OpenMV and the STM32 microcontroller is selected as one of UART serial communication or I2C communication.

[0013] On the other hand, the present invention provides a two-degree-of-freedom pan-tilt control method based on STM32 and OpenMV, and the pan-tilt control method adopts any of the pan-tilt control systems described above.

[0014] Furthermore, in the pan / tilt control method of the present invention, the pan / tilt control method comprises the following steps: SS1: The OpenMV captures an image through a camera module, performs image preprocessing on the captured image to obtain a grayscale image, and then performs image data processing on the grayscale image to obtain an image processing signal; SS2: The image processing signal is transmitted to the STM32 microcontroller, and after the STM32 microcontroller receives the image processing signal data, the clock is enabled; SS3: The STM32 microcontroller generates a PWM signal according to the received image processing signal, and transmits the PWM signal to the high-precision stepper motor in real time. The high-precision stepper motor performs corresponding movement under the drive of the PWM signal. SS4: When the high-precision stepper motor moves to a specified position or completes a specified action, the OpenMV sends a command to the STM32 microcontroller to control the high-precision stepper motor to stop moving.

[0015] On the other hand, the present invention provides a use of the pan-tilt control system described above, wherein the pan-tilt control system is used in a target tracking system.

[0016] Compared with the prior art, the present invention has the following beneficial technical effects: The invention discloses a two-degree-of-freedom pan / tilt control system, method and application based on STM32 and OpenMV, uses a high-precision and high-accuracy stepper motor as a driving device of the pan / tilt control system, and uses a PID algorithm on an STM32 microcontroller to improve the accuracy and stability of the pan / tilt; in OpenMV, a Retinex algorithm and RGB to grayscale conversion are used to enhance the image and reduce data complexity; thereby improving the reaction speed and recognition accuracy of target recognition during target tracking, and effectively solving the problem that target recognition is greatly affected by ambient light. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a schematic diagram of the pan / tilt control system of the present invention. DETAILED DESCRIPTION

[0018] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, the specific implementation methods of the present invention are now described in detail with reference to the accompanying drawings. The described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. If the specific conditions are not specified in the specific implementation methods, they shall be carried out according to the conventional conditions or the conditions recommended by the manufacturer.

[0019] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims. The terms used in the present disclosure are only for the purpose of describing specific embodiments and are not intended to limit the present disclosure.

[0020] The present invention is further described in detail below in conjunction with specific embodiments. Example 1

[0021] like Figure 1 As shown, a two-degree-of-freedom pan-tilt control system based on STM32 and OpenMV of the present invention, the pan-tilt control system includes: a pan-tilt, OpenMV, and an STM32 microcontroller, the STM32 microcontroller and the OpenMV communicate via serial ports, the pan-tilt is connected to a high-precision stepper motor, and the STM32 microcontroller is electrically connected to the high-precision stepper motor; the minimum rotation angle of the high-precision stepper motor is 0.56 degrees, and tan (0.56°) is 0.001; the high-precision stepper motor of this embodiment 1 is a 42 stepper motor.

[0022] OpenMV includes: a camera module for collecting images, and an image data processing module for processing the collected images; the image data processing module includes an image preprocessing module for preprocessing images using a Retinex algorithm and converting RGB to grayscale, and an image processing signal generation module for processing grayscale image data; The TX-RX (transmitter-receiver) interface of the STM32 microcontroller is connected to the RX-TX (receiver-transmitter) interface of the OpenMV, and the output of the STM32 microcontroller is connected to control the movement of the high-precision stepper motor.

[0023] The calculation steps of the Retinex algorithm are: S1: Input the collected original image and the radius range of the filter of the original image, the radius range is 3 pixels * 3 pixels; S2: Calculate the result of Gaussian filtering of the original image according to formula A and formula B to obtain L(x,y); The formula A is: I(x,y)=R(x,y)*L(x,y), The formula B is: L(x,y)=I(x,y)*G(x,y); S3: Calculate according to formula C to obtain Log[R(x,y)]; quantize Log(R(x,y)) to a pixel value in the range of 0-255 according to formula D, and then output the resulting image; The formula C is: Log(R(x,y))=Log(I(x,y))- Log(L(x,y)), The formula D is: R(x,y)=(Value - Min) / (Max - Min)*255; Among them, in Formula A, Formula B, Formula C and Formula D, * represents convolution, G(x, y) represents a Gaussian kernel, I(x, y) represents an image signal observed or received by a camera, L(x, y) represents the illumination component of ambient light, and R(x, y) represents the reflection component of the target object carrying image detail information.

[0024] The working process of converting RGB image to grayscale is as follows: by performing weighted average calculation on the red, green and blue channels of the color image, a single-channel grayscale image representing brightness information is obtained; The calculation formula of the weighted average method is: Gray = 0.299R + 0.587G + 0.114B, Among them, R is the red channel pixel value, G is the green channel pixel value, and B is the blue channel pixel value.

[0025] The working process of the image processing signal generation module is: automatically identify the shape contour of the moving target in the single-channel grayscale image, and use the rectangular function in the OpenMV function path to obtain the image processing signal. The image processing signal is the slope K and distance L of the calculated rectangle in the rectangular function; The calculation formula of the rectangular function is: Slope K = |y1-y2| / |x1-x2|, Distance L = [(x1-x2) 2 +(y1+y2) 2 ] 1 / 2 ; Wherein, a minimum rectangle that can surround the target is drawn in the picture displayed by the camera module, and the minimum rectangle is the calculation rectangle; Among them, y1 is the value of the vertical coordinate of the pixel at the center point of the camera image, y2 is the value of the vertical coordinate of the center point of the rectangle, x1 is the value of the horizontal coordinate of the pixel at the center point of the camera image, and x2 is the value of the horizontal coordinate of the center point of the rectangle.

[0026] The slope K and distance L signals output by OpenMV are transmitted to the STM32 microcontroller together. The PID algorithm is used in the STM32 microcontroller to generate PWM. The communication method between OpenMV and STM32 microcontroller is selected as UART serial communication. Example 2

[0027] The present invention provides a two-degree-of-freedom pan-tilt control method based on STM32 and OpenMV, wherein the pan-tilt control method adopts the pan-tilt control system of embodiment 1, such as Figure 1 shown.

[0028] The PTZ control method comprises the following steps: SS1: OpenMV collects images through the camera module, performs image preprocessing on the collected images to obtain grayscale images, and then performs image data processing on the grayscale images to obtain image processing signals; SS2: The image processing signal is transmitted to the STM32 microcontroller. After the STM32 microcontroller receives the image processing signal data, the clock is enabled. SS3: The STM32 microcontroller generates a PWM signal based on the received image processing signal and transmits it to the high-precision stepper motor in real time. The high-precision stepper motor performs corresponding movements under the drive of the PWM signal. SS4: When the high-precision stepper motor moves to the specified position or completes the specified action, OpenMV sends a command to the STM32 microcontroller to control the high-precision stepper motor to stop moving. Example 3

[0029] The purpose of the pan-tilt control system of an embodiment 1 of the present invention is to use the pan-tilt control system in a target tracking system.

[0030] The present invention is described by the above specific embodiments, and those skilled in the art should understand that various changes and equivalent substitutions can be made to the present invention without departing from the scope of the present invention. The parts not described in detail in the present specification are well-known technologies to those skilled in the art. In addition, various modifications can be made to the present invention for specific situations or specific circumstances without departing from the scope of the present use. Therefore, the present invention is not limited to the specific embodiments disclosed, but should include all implementation methods falling within the scope of the claims of the present invention.

Claims

1. A two-degree-of-freedom pan-tilt control system based on STM32 and OpenMV, characterized in that: The pan-tilt control system includes: a pan-tilt, OpenMV, and an STM32 microcontroller, wherein the STM32 microcontroller and the OpenMV communicate via serial ports, the pan-tilt is connected to a high-precision stepper motor, and the STM32 microcontroller is electrically connected to the high-precision stepper motor; the minimum rotation angle of the high-precision stepper motor is less than or equal to 0.56 degrees; The OpenMV includes: a camera module for collecting images, and an image data processing module for performing image processing on the collected images; the image data processing module includes an image preprocessing module for performing image preprocessing using a Retinex algorithm and RGB to grayscale conversion, and an image processing signal generation module for grayscale image data processing; The TX-RX interface end of the STM32 microcontroller is connected to the RX-TX interface end of the OpenMV, and the output end of the STM32 microcontroller is connected to and controls the movement of the high-precision stepper motor.

2. The PTZ control system according to claim 1, characterized in that: The calculation steps of the Retinex algorithm are: S1: Input the collected original image and the radius range of the filter of the original image, the radius range is 3 pixels * 3 pixels; S2: Calculate the result of Gaussian filtering of the original image according to formula A and formula B to obtain L(x,y); The formula A is: I(x,y)=R(x,y)*L(x,y), The formula B is: L(x,y)=I(x,y)*G(x,y); S3: Calculate according to formula C to obtain Log[R(x,y)]; quantize Log(R(x,y)) to a pixel value in the range of 0-255 according to formula D, and then output the resulting image; The formula C is: Log(R(x,y))=Log(I(x,y))- Log(L(x,y)), The formula D is: R(x,y)=(Value - Min) / (Max - Min)*255; Among them, in Formula A, Formula B, Formula C and Formula D, * represents convolution, G(x, y) represents a Gaussian kernel, I(x, y) represents an image signal observed or received by a camera, L(x, y) represents the illumination component of ambient light, and R(x, y) represents the reflection component of the target object carrying image detail information.

3. The PTZ control system according to claim 2, characterized in that: The working process of converting the RGB image to grayscale is as follows: a single-channel grayscale image representing brightness information is obtained by performing weighted average calculation on the red, green and blue channels of the color image; The calculation formula of the weighted average method is: Gray = 0.299R + 0.587G + 0.114B, Among them, R is the red channel pixel value, G is the green channel pixel value, and B is the blue channel pixel value.

4. The PTZ control system according to claim 3, characterized in that: The working process of the image processing signal generation module is: automatically identifying the morphological contour of the moving target in the single-channel grayscale image, and using the rectangular function in the OpenMV function library to obtain the image processing signal, wherein the image processing signal is the slope K and the distance L between the center point of the camera screen and the center point of the rectangle calculated in the rectangular function; The calculation formula of the rectangular function is: Slope K = |y1-y2| / |x1-x2|, Distance L = [(x1-x2) 2 +(y1+y2) 2 ] 1 / 2 ; Wherein, a minimum rectangle that can surround the target is drawn in the picture displayed by the camera module, and the minimum rectangle is the calculation rectangle; Among them, y1 is the value of the vertical coordinate of the pixel at the center point of the camera image, y2 is the value of the vertical coordinate of the center point of the rectangle, x1 is the value of the horizontal coordinate of the pixel at the center point of the camera image, and x2 is the value of the horizontal coordinate of the center point of the rectangle.

5. The PTZ control system according to claim 4, characterized in that: The slope K and the distance L signals output by the OpenMV are transmitted together to the STM32 microcontroller.

6. The PTZ control system according to claim 5, characterized in that: The STM32 microcontroller uses a PID algorithm to generate PWM.

7. The PTZ control system according to claim 6, characterized in that: The communication mode between the OpenMV and the STM32 microcontroller is selected as one of UART serial communication or I2C communication.

8. A two-degree-of-freedom pan-tilt control method based on STM32 and OpenMV, characterized in that: The pan-tilt control method adopts the pan-tilt control system described in any one of claims 1 to 7.

9. The PTZ control method according to claim 8, characterized in that: The pan / tilt control method comprises the following steps: SS1: The OpenMV captures an image through a camera module, performs image preprocessing on the captured image to obtain a grayscale image, and then performs image data processing on the grayscale image to obtain an image processing signal; SS2: The image processing signal is transmitted to the STM32 microcontroller, and after the STM32 microcontroller receives the image processing signal data, the clock is enabled; SS3: The STM32 microcontroller generates a PWM signal according to the received image processing signal, and transmits the PWM signal to the high-precision stepper motor in real time. The high-precision stepper motor performs corresponding movement under the drive of the PWM signal. SS4: When the high-precision stepper motor moves to a specified position or completes a specified action, the OpenMV sends a command to the STM32 microcontroller to control the high-precision stepper motor to stop moving.

10. A use of a PTZ control system according to any one of claims 1 to 7, characterized in that: The purpose is that the pan / tilt control system is used in a target tracking system.

Citation Information

Cited By

  • Image quality distortion detection and identification system and method and automatic tracking pusher

    CN119380032A