Focusing consistency method and system, computing device and medium

By identifying the excessive number of squares in the calibrated image and adjusting the focal length by using the mountain climbing method, the problems of unstable focus and low accuracy in the existing focus technology are solved, and a higher quality focus effect is achieved.

CN119629473APending Publication Date: 2025-03-14BEIJING ZHAOWEI XINYUAN COMM TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411748231.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-02
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

The existing focus technology has problems of oscillation and poor stability in practical applications, and it is difficult to ensure the quality of focus accuracy.

Method used

By acquiring the calibration images of the calibration plates collected by the camera, identifying each square and obtaining their excessive number, the motor drives the camera to adjust the focal length to the target focal length using the mountain climbing method and the excessive number at different focal lengths.

Benefits of technology

It realizes that the camera focuses based on the target focal length when shooting, improves the quality of focus accuracy and reduces the vibration during the focus process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119629473A_ABST
    Figure CN119629473A_ABST
Patent Text Reader

Abstract

The invention relates to a focusing consistency method and system, computing equipment and a medium. The method comprises the following steps: acquiring a calibration image of a calibration board acquired by a camera; wherein the calibration plate is internally provided with a plurality of grids which are distributed at intervals; identifying the calibration image to obtain each grid; obtaining a transition number corresponding to each grid; wherein the excessive number is the number of excessive pixels; determining the excessive number of the calibration images based on the excessive number corresponding to each grid; and based on a hill climbing method and the excessive number of the calibration images under different focal lengths, controlling a motor to drive a camera to adjust the focal length to a target focal length. The method can ensure the quality of focusing precision.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In optical inspection, focusing technology is a very critical part, which directly affects the accuracy of the inspection results. Focusing technology mainly adjusts the distance between the lens and the object to be measured so that the object to be measured can be clearly imaged on the photosensitive element of the camera. In the existing technology, manual focus or automatic focus is usually used to achieve focus. Among them, manual focus requires the operator to adjust the focus position based on experience and feeling. And automatic focus automatically completes the focusing process through a computer program. However, there are still some problems with the existing focusing technology in practical applications. Whether it is manual focus or automatic focus, they are adjusted based on the current focus state. Due to the uncertainty of the calculated data, this may cause oscillation in the focusing process, affecting the stability of the focus, and it is difficult to ensure the quality of the focus accuracy. In this way, it is difficult to ensure the quality of the focus accuracy by focusing based on the current focus state.

[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0004] In order to overcome the problem that it is difficult to ensure the quality of focusing accuracy when focusing based on the current focusing state in the traditional method, the present invention provides a focusing consistency method, system, computing device and medium.

[0005] In a first aspect, in order to solve the above technical problem, the present invention provides a focus consistency method, comprising:

[0006] Acquire a calibration image of a calibration plate captured by a camera; wherein the calibration plate is provided with a plurality of spaced-apart squares;

[0007] Identify the calibration image to obtain each square;

[0008] Obtaining the number of transitions corresponding to each of the squares; wherein the number of transitions is the number of transition pixels;

[0009] Determine the transition amount of the calibration image based on the transition amount corresponding to each of the squares;

[0010] Based on the hill climbing method and the transition amount of the calibration images at different focal lengths, the motor is controlled to drive the camera to adjust the focal length to the target focal length.

[0011] In a second aspect, in order to solve the above technical problem, the present invention provides a focus consistency system, comprising:

[0012] A first acquisition module is used to acquire a calibration image of a calibration plate captured by a camera; wherein the calibration plate is provided with a plurality of spaced-apart squares;

[0013] A recognition module, used to recognize the calibration image and obtain each square;

[0014] A second acquisition module is used to acquire the number of transitions corresponding to each of the squares; wherein the number of transitions is the number of transition pixels;

[0015] A determination module, configured to determine the number of transitions of the calibration image based on the number of transitions corresponding to each of the squares;

[0016] The control module is used to control the motor to drive the camera to adjust the focal length to the target focal length based on the hill climbing method and the transition amount of the calibration image at different focal lengths.

[0017] In a third aspect, in order to solve the above-mentioned technical problem, the present invention provides a computing device, including a memory, a processor, and a program stored in the memory and running on the processor, and when the processor executes the program, the steps of a focus consistency method as described above are implemented.

[0018] In a fourth aspect, in order to solve the above-mentioned technical problem, the present invention provides a computer-readable storage medium, in which instructions are stored. When the instructions are executed on a terminal device, the terminal device executes the steps of a focus consistency method as described above.

[0019] The beneficial effects of the present invention are:

[0020] By identifying the calibration image captured by the camera, each square in the calibration image is identified. The number of transitions in the calibration image is analyzed based on the number of transitions corresponding to each square, thereby reflecting the focus of the camera. Based on the hill climbing method and the focus of the camera at different focal lengths, the motor is controlled to drive the camera to adjust the camera's focal length to the target focal length. In this way, the best target focal length of the camera is determined by the focus of the camera at different focal lengths, so that the camera can focus based on the target focal length when shooting, ensuring the quality of the focus accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flow chart of a focus consistency method provided by the present invention;

[0022] Figure 2 A schematic diagram of a calibration plate provided by the present invention;

[0023] Figure 3 A schematic diagram of a single grid provided by the present invention;

[0024] Figure 4 A schematic diagram of another calibration plate provided by the present invention;

[0025] Figure 5 A flow chart of another focus consistency method provided by the present invention;

[0026] Figure 6 A line graph of a clarity value provided by the present invention;

[0027] Figure 7 A structural schematic diagram of a focus consistency system provided by the present invention. DETAILED DESCRIPTION

[0028] The principles and features of the present invention are described below. The examples given are only used to explain the present invention and are not used to limit the scope of the present invention.

[0029] A focus consistency method, system, computing device, and medium according to an embodiment of the present invention are described below in conjunction with the accompanying drawings.

[0030] The optical detection system includes a camera, a motor, and an electronic device, etc. Among them, the camera is used to shoot the object to be measured to obtain an image, and send the image to the electronic device for processing. The electronic device controls the motor to drive the camera based on the image processing to adjust the distance between the camera and the object to be measured, thereby adjusting the focal length of the camera. Therefore, a focus consistency method in this embodiment is applied to the aforementioned electronic device. It can be understood that the electronic device is a computer or a server, etc. An optical detection system using a focus consistency method provided in this embodiment can be applied to high-precision measurement fields, such as precision manufacturing and automation equipment.

[0031] like Figure 1 As shown, a focus consistency method provided by an embodiment of the present disclosure includes:

[0032] Step S101, obtaining a calibration image of a calibration plate captured by a camera; wherein a plurality of spaced-apart squares are arranged in the calibration plate.

[0033] For ease of understanding, combined Figure 2 As shown, the grids arranged on the calibration plate are distributed at intervals of 6×6, that is, there are 6 grids in both the horizontal and vertical directions. In this embodiment, the intervals between the grids are background areas.

[0034] Step S102, identifying the calibration image to obtain each square.

[0035] In some embodiments, the canny operator is used to perform edge detection, and the Hough transform is used to identify the straight lines formed by the edges, so as to obtain each square.

[0036] Step S103, obtaining the number of transitions corresponding to each square, wherein the number of transitions is the number of transition pixels; transition pixels represent pixels located at the boundary between the square and the background area, also known as transition pixels.

[0037] Step S104, determining the transition quantity of the calibration image based on the transition quantity corresponding to each square.

[0038] It is understandable that the more obvious the boundary between the grid and the background area is, the fewer the excess pixels corresponding to the grid are. Therefore, the current focus condition of the camera can be reflected by calibrating the number of excess pixels corresponding to the image.

[0039] Step S105 , based on the hill climbing method and the number of transitions of the calibration images at different focal lengths, controlling the motor to drive the camera to adjust the focal length to the target focal length.

[0040] A focus consistency method provided by an embodiment of the present disclosure is adopted to identify the calibration image captured by the camera, and identify each square in the calibration image. The transition number of the calibration image is determined based on the transition number corresponding to each square, thereby reflecting the focus condition of the camera. Based on the hill climbing method and the focus condition of the camera at different focal lengths, the motor is controlled to drive the camera to adjust the focal length of the camera to the target focal length. In this way, the optimal target focal length of the camera is determined by the focus condition of the camera at different focal lengths, so that the camera can focus based on the target focal length when shooting, thereby ensuring the quality of the focus accuracy.

[0041] Preferably, obtaining the number of transitions corresponding to each square includes: obtaining the midpoint of each side of each square; connecting the midpoints of two vertical sides of the same square to obtain a first initial line segment, and connecting the midpoints of two horizontal sides of the same square to obtain a second initial line segment; extending the first initial line segment to a corresponding preset position to obtain a first target line segment, and extending the second initial line segment to a corresponding preset position to obtain a second target line segment; wherein the preset position is the middle position between two adjacent squares; and taking the sum of the number of transitions on the first target line segment and the second target line segment corresponding to the same square as the number of transitions corresponding to each square.

[0042] The first target line segment is the middle boundary of the square in the horizontal direction, which is convenient for characterizing the pixel situation of the square in the horizontal direction; the second target line segment is the middle boundary of the square in the vertical direction, which is convenient for characterizing the pixel situation of the square in the vertical direction. Therefore, it is convenient to quickly determine the number of transitions of the square in the horizontal direction based on the pixel situation of the square in the horizontal direction, and it is convenient to quickly determine the number of transitions of the square in the vertical direction based on the pixel situation of the square in the vertical direction. Then, by taking the sum of the number of transitions on the first target line segment and the second target line segment corresponding to the same square as the number of transitions corresponding to the square, the amount of calculation can be reduced and the efficiency of obtaining the number of transitions corresponding to each square can be improved.

[0043] For ease of understanding, combined Figure 3 As shown, Figure 3 include Figure 3 a and Figure 3 b. Among them, Figure 3 a shows a square and the first initial line segment and the second initial line segment corresponding to the square. Figure 3 b shows a square and the first target line segment and the second target line segment corresponding to the square. In this embodiment, the interval between the square and the adjacent square is a preset length a. The first initial line segment extends along the left and right sides until it extends to 1 / 2 of the preset length a, that is, the two sides of the first initial line segment extend to the position of half the interval between the left and right adjacent squares, and the extended first initial line segment is used as the first target line segment. Similarly, the second initial line segment extends along the upper and lower sides until it extends to 1 / 2 of the preset length a, that is, the two sides of the second initial line segment extend to the position of half the interval between the upper and lower adjacent squares, and the extended second initial line segment is used as the second target line segment.

[0044] Preferably, the midpoint of each side of each square is obtained, including: using Hough transform to extract four edge lines of each square, and using the four edge lines as the four sides of the square; using the intersection of the four sides of the same square as the corner point; using the midpoint between the two corner points of each side in the same square as the midpoint of each side of each square.

[0045] In this way, the four sides of each square can be identified more accurately through Hough transform, so as to facilitate the determination of the corner points of each square and the midpoint of each side.

[0046] Preferably, the sum of the numbers of transitions on the first target line segment and the second target line segment corresponding to the same square is taken as the number of transitions corresponding to each square, including: respectively determining the pixel value of each pixel point on each first target line segment and each second target line segment; based on each pixel value, calculating the pixel difference between each pair of adjacent pixel points on each first target line segment and each second target line segment; determining each pixel point corresponding to the pixel difference that meets a preset threshold condition as a transition pixel; based on each transition pixel, taking the sum of the numbers of transitions on the first target line segment and the second target line segment corresponding to the same square as the number of transitions corresponding to each square.

[0047] There are over-pixels between the square and the background area, and there are obvious differences in the pixel difference between the square and the over-pixel, the pixel difference between the over-pixels, and the pixel difference between the over-pixel and the background area. Therefore, by calculating the pixel difference between each adjacent pixel point on the first target line segment and each second target line segment, and then determining each pixel point corresponding to the pixel difference that meets the preset threshold condition as an over-pixel, the number of over-pixels on each first target line segment and the second target line segment can be determined more accurately, so as to determine the over-pixel number corresponding to each square more accurately.

[0048] It is understandable that the greater the absolute value of the pixel difference, the more likely the corresponding pixel is an excessive pixel. Therefore, the preset threshold condition may be that the absolute value of the pixel difference is greater than a preset value, which is usually close to 0. In some embodiments, the preset value is any value such as 1 or 5.

[0049] In some embodiments, in combination Figure 4 As shown, Figure 4 A schematic diagram of another calibration plate is provided. Figure 4Take the second target line segment in the upper left square as an example. In this embodiment, the coordinates of the upper endpoint of the second target line segment are (64, 36), the coordinates of the lower endpoint are (64, 76), and the coordinates of the intersection of the second target line segment and the two horizontal sides of the square are (64, 46,) and (64, 66) respectively. It can be seen that the pixel difference between each two adjacent pixels between the upper endpoint and the lower endpoint of the second target line segment is [-1.0,0.0,0.0,0.0,1.0,-6.0,-2.0,8.0,14.0,16.0,23.0,36.0,18.0,2.0,-1.0,-1.0,-4.0,-3.0,1.0,2.0,0.0,-5.0,4.0,4.0,1.0,7.0,-6.0,-20.0,-30.0,-24.0,-22.0,-13.0,-3.0,0.0,4.0,-1.0,0.0,2.0,-2.0,1.0]. These pixel differences are processed by mean filtering and the filtered pixel differences are obtained as [-0.12, 0.5, -0.5, 0.25, -0.25, -2.75, -1.38, 3.75, 13.75, 18.5, 25.75, 32.75, 21.0, 1.88, -5.0, -3.25, -1.38, -0.62, 0.75, -1.38, 0.88, -1.25, 3.5, 2.25, 3.75, 3.12, -5.12, -22.38, -27.75, -24.5, -22.5, -12.25, -4.5, 2.5, 1.88, 0.62, -1.25, 0.62, 0.0, -0.12]. The pixels whose absolute values ​​of pixel differences are greater than the preset threshold are assigned a value of 255, and the pixels whose absolute values ​​of pixel differences are less than or equal to the preset threshold are assigned a value of 0, and the assigned data is [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 255.0, 255.0, 255.0, 255.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 255.0, 255.0, 255.0, 255.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0. It can be seen that in this embodiment, there are 8 transition pixels on the second target line segment corresponding to the upper left grid.

[0050] In some embodiments, Gaussian filtering is performed on the pixels on each first target line segment and each second target line segment to filter out noise pixels, wherein the noise pixels are pixels with abnormal pixel values.

[0051] Preferably, determining the transition number of the calibration image based on the transition number corresponding to each square includes: calculating the average transition number corresponding to each square based on the transition number corresponding to each square; and using the average transition number as the transition number of the calibration image.

[0052] Since there are squares in the calibration image, the number of transitions corresponding to each square is different. Therefore, the average value of the number of transitions corresponding to each square is calculated to facilitate the calculation of the number of transitions in the calibration image.

[0053] Preferably, a focus consistency method further includes: determining a corresponding clarity value based on the number of transitions in the calibration image. It is understandable that the number of transitions in the calibration image is inversely proportional to the clarity value, that is, the more transitions in the calibration image, the smaller the corresponding clarity value; the fewer transitions in the calibration image, the larger the corresponding clarity value.

[0054] Preferably, based on the hill climbing method and the number of transitions of the calibration images at different focal lengths, the motor is controlled to drive the camera to adjust the focal length to the target focal length, including: obtaining the number of transitions of the calibration images at three different focal lengths, and determining the moving direction based on the number of transitions of each calibration image and the corresponding focal length; controlling the motor to drive the camera to adjust the focal length along the moving direction; obtaining the number of transitions of the calibration image at the adjusted focal length; determining whether the number of transitions of the calibration image at the adjusted focal length is less than the transition of the calibration image before the adjustment; if so, returning to execute the step of controlling the motor to drive the camera to adjust the focal length along the moving direction, if not, taking the focal length before the current adjustment as the target focal length.

[0055] The camera shoots at different focal lengths, and the number of transitions in the obtained calibration image is different. Therefore, the change in the number of transitions in the calibration image is convenient for determining the direction of the motor's movement. Then determine whether the number of transitions in the calibration image at the focal length after the move is less than the number of transitions in the calibration image before the adjustment. If so, it means that the focal length after the move is closer to the target focal length, and it needs to be adjusted again to find the target focal length. If not, it means that the number of transitions in the calibration image before this adjustment is less, that is, the focal length before this adjustment is the target focal length.

[0056] Combination Figure 5 As shown, Figure 5 Another focus consistency method is provided, including:

[0057] Step S201, obtaining a calibration image of a calibration plate captured by a camera; wherein a plurality of spaced-apart squares are arranged in the calibration plate.

[0058] Step S202: recognize the calibration image to obtain each square.

[0059] Step S203, obtaining the number of transitions corresponding to each square, wherein the number of transitions is the number of transition pixels. Transition pixels represent pixels located at the boundary between the square and the background area, also known as transition pixels.

[0060] Step S204, determining the transition quantity of the calibration image based on the transition quantity corresponding to each square.

[0061] Step S205, obtaining the transition numbers of the calibration images at three different focal lengths, and determining the moving direction based on the transition numbers of each calibration image and the corresponding focal length;

[0062] Step S206, controlling the motor to drive the camera to adjust the focal length along the moving direction.

[0063] Step S207, obtaining the transition quantity of the calibration image at the adjusted focal length.

[0064] Step S208, determining whether the transition amount of the calibration image under the adjusted focal length is less than the transition amount of the calibration image before the adjustment; if so, returning to step S206, if not, executing step S209.

[0065] Step S209, taking the focal length before the current adjustment as the target focal length.

[0066] In some embodiments, by determining the number of transitions of calibration images at different focal lengths (i.e., different focal planes), and then based on the number of transitions of each calibration image, using a clarity evaluation algorithm or a clarity evaluation function to evaluate the clarity of each calibration image, the clarity value corresponding to the calibration image at different focal lengths is determined. The clarity value represents the relative clarity between calibration images at different focal lengths. In this embodiment, the clarity values ​​corresponding to different focal lengths are displayed in the form of a line graph. This facilitates intuitive determination of the target focal length. For example, Figure 6 As shown, Figure 6 A line graph of clarity values. Figure 6 Included Figure 6 a. Figure 6 b. Figure 6 c and Figure 6 d four pictures. Figure 6 a is the line chart of the clarity value corresponding to the Brenner_data method, Figure 6 b is the line graph of the clarity value corresponding to the EOG_data method, Figure 6 c is the line chart of the clarity value corresponding to the Robert_data method, Figure 6 d is the line graph of the clarity value corresponding to the Sobel_data method. The horizontal axis of each line graph of clarity value is the i-th measurement, and the vertical axis is the clarity value; i is 1, 2, 3, 4, 5, and the corresponding focal length is different for each measurement.

[0067] Specifically, the moving direction is determined based on the transition amount of each calibration image and the corresponding focal length, including: arranging the focal lengths in order, and taking the second focal length as the basic focal length. Comparing the transition amount of the calibration image under the basic focal length and the other two focal lengths, and determining the focal length corresponding to the transition amount less than the calibration image under the basic focal length as the moving focal length. The direction in which the camera moves from the basic focal length to the moving focal length is taken as the moving direction. In this way, by taking the direction in which the transition amount of the calibration image decreases as the moving direction, the motor is controlled to drive the camera in the direction in which the transition amount of the calibration image decreases to adjust the focal length.

[0068] For ease of understanding, an embodiment of obtaining the target focal length is shown as follows: a focal length is selected as the initial focal length, and the step length of the motor is set to 2um. Wherein, the step length of the motor is the increment of the focal length adjustment when the motor drives the camera to adjust the focal length. The calibration image collected by the camera at the initial focal length is obtained, and the number of transitions corresponding to the initial focal length is determined based on the average value of the number of transitions of each square in the calibration image. The motor is controlled to drive the camera so that the focal length increases by one step length to obtain the first focal length; and the calibration image collected by the camera at the first focal length is obtained, and the number of transitions corresponding to the first focal length is determined based on the average value of the number of transitions of each square in the calibration image (that is, the number of transitions of the calibration image corresponding to the first focal length). Then the motor is controlled to drive the camera so that the focal length decreases by two steps to obtain the second focal length; and the calibration image collected by the camera at the second focal length is obtained, and the number of transitions corresponding to the second focal length is determined based on the average value of the number of transitions of each square in the calibration image. The minimum value of the three transitions is determined, and the direction in which the camera moves from the base focal length to the focal length corresponding to the minimum value of the transition is used as the moving direction. In this way, the motor is controlled to drive the camera to move one step in the moving direction, and after each movement, the transition number of the calibration image after the current movement is compared with that before the movement. If the transition number of the calibration image after the current movement is less, it is still necessary to continue moving. If the transition number of the calibration image before the current movement is more, it means that the focal length corresponding to the current movement before the current movement is the target focal length.

[0069] Preferably, a focus consistency method also includes: for each square, determining the number of targets based on the number of transitions corresponding to the squares; searching in a preset data table based on the number of targets corresponding to each square, respectively, to find out the display color corresponding to the target number; wherein the preset data table stores the correspondence between the target number and the display color; determining the color corresponding to each square based on each display color; determining a pseudo-color map corresponding to the calibration image based on the color corresponding to each square; wherein the pseudo-color map includes each square and the color corresponding to each square.

[0070] In this way, the display color of the square is determined by searching, and the pseudo color image corresponding to the calibration image is determined accordingly, so that the transition quantity corresponding to each square in the calibration image can be intuitively displayed.

[0071] In some embodiments, the preset data table is as follows:

[0072] Preset Data Table

[0073]

[0074]

[0075] In this way, when the staff is focusing, they can use the pseudo-color image to know in real time the amount of transition of the calibrated image at different focal lengths (i.e., different focal planes), which is convenient for the staff to focus.

[0076] In some embodiments, for each square, determining the target number based on the number of transitions corresponding to the square includes: for each square, using the number of transitions corresponding to the square as the target number. In this way, using the number of transitions corresponding to the square as the target number enables the pseudo-color image to reflect the overall number of transitions of the calibration image.

[0077] In other embodiments, for each square, the target number is determined based on the number of transitions corresponding to the square, including: for each square, the number of transitions on the first target line segment corresponding to the square is used as the target number. In this way, the number of transitions on the first target line segment of the square is used as the target number, so that the pseudo-color image can reflect the number of transitions in the horizontal direction of the calibration image.

[0078] In other embodiments, for each square, the target number is determined based on the number of transitions corresponding to the square, including: for each square, the number of transitions on the second target line segment corresponding to the square is used as the target number. In this way, the number of transitions on the second target line segment of the square is used as the target number, so that the pseudo-color image can reflect the number of transitions in the vertical direction of the calibration image.

[0079] In some other embodiments, for each square, the target number is determined based on the number of transitions corresponding to the square, including: for each square, taking the average of the number of transitions on the first target line segment and the second target line segment corresponding to the square as the target number. In this way, taking the average as the target number enables the pseudo-color image to reflect the overall number of transitions of the calibration image.

[0080] Preferably, a focus consistency method further includes: obtaining a calibration image captured by the camera at a target focal length as a target calibration image; determining a pseudo-color image corresponding to the target calibration image as a target pseudo-color image. The calibration images captured by the camera are obtained at intervals of a preset duration, and the pseudo-color image corresponding to the calibration images obtained at the intervals of the preset duration is determined as a test pseudo-color image; the test color image is compared with the target calibration image to determine the current focus status of the camera.

[0081] After the camera has been working for a long time, it is easy to have focus errors. In this way, by obtaining the inspection pseudo-color image at intervals of a preset time, and by comparing the inspection pseudo-color image with the target calibration image, it is easy to determine whether the current focus of the camera has errors.

[0082] Combination Figure 7 As shown, an embodiment of the present disclosure provides a focus consistency system, including: a first acquisition module, an identification module, a second acquisition module, a determination module and a control module. The first acquisition module is used to acquire a calibration image of a calibration plate captured by a camera. A plurality of spaced-apart squares are provided in the calibration plate. The identification module is used to identify the calibration image and obtain each square. The second acquisition module is used to acquire the number of transitions corresponding to each square. The number of transitions is the number of transition pixels. The determination module is used to determine the number of transitions of the calibration image based on the number of transitions corresponding to each square. The control module is used to control the motor to drive the camera to adjust the focal length to the target focal length based on the hill climbing method and the number of transitions of the calibration images at different focal lengths.

[0083] A focus consistency system provided by an embodiment of the present disclosure is used to identify the calibration image captured by the camera, and each square in the calibration image is identified. The number of transitions corresponding to each square is used to analyze the number of transitions in the calibration image, thereby reflecting the focus of the camera. Based on the hill climbing method and the focus of the camera at different focal lengths, the motor is controlled to drive the camera to adjust the focal length of the camera to the target focal length. In this way, the optimal target focal length of the camera is determined by the focus of the camera at different focal lengths, so that the camera can focus based on the target focal length when shooting, thereby ensuring the quality of the focus accuracy.

[0084] Preferably, the second acquisition module is specifically used to obtain the midpoint of each side of each square; connect the midpoints of the two vertical sides of the same square to obtain a first initial line segment, and connect the midpoints of the two horizontal sides of the same square to obtain a second initial line segment; extend the first initial line segment to the corresponding preset position to obtain a first target line segment, and extend the second initial line segment to the corresponding preset position to obtain a second target line segment; wherein the preset position is the middle position between two adjacent squares; and take the sum of the transition numbers on the first target line segment and the second target line segment corresponding to the same square as the transition number corresponding to each square.

[0085] Preferably, the second acquisition module is specifically used to use Hough transform to extract the four edge straight lines of each square, and use the four edge straight lines as the four sides of the square; use the intersection of the four sides of the same square as the corner point; and use the midpoint between the two corner points of each side in the same square as the midpoint of each side of each square.

[0086] Preferably, the second acquisition module is specifically used to respectively determine the pixel value of each pixel point on each first target line segment and each second target line segment; based on each pixel value, calculate the pixel difference between each adjacent pixel point on each first target line segment and each second target line segment; determine each pixel point corresponding to the pixel difference that meets the preset threshold condition as an excessive pixel; based on each excessive pixel, take the sum of the excessive numbers on the first target line segment and the second target line segment corresponding to the same square as the excessive number corresponding to each square.

[0087] Preferably, the determination module is specifically used to calculate the average value of the number of transitions corresponding to each square based on the number of transitions corresponding to each square; and use the average value as the number of transitions of the calibration image.

[0088] Preferably, the control module is specifically used to obtain the transition numbers of the calibration images at three different focal lengths, and determine the moving direction based on the transition numbers of each calibration image and the corresponding focal length; control the motor to drive the camera to adjust the focal length along the moving direction; obtain the transition number of the calibration image at the adjusted focal length; determine whether the transition number of the calibration image at the adjusted focal length is greater than the transition number of the calibration image before the adjustment; if so, return to execute the step of controlling the motor to drive the camera to adjust the focal length along the moving direction, if not, use the focal length before the current adjustment as the target focal length.

[0089] Preferably, a focus consistency system further includes: a pseudo-color map module. The pseudo-color map module is used to determine the number of targets for each square based on the number of transitions corresponding to the squares, search in a preset data table based on the target data corresponding to each square, and find out the display color corresponding to the target number; wherein the preset data table stores the correspondence between the target number and the display color; determine the color corresponding to each square based on each display color; determine the pseudo-color map corresponding to the calibration image based on the color corresponding to each square; wherein the pseudo-color map includes each square and the color corresponding to each square.

[0090] A computing device according to an embodiment of the present invention includes a memory, a processor, and a program stored in the memory and running on the processor. When the processor executes the program, some or all steps of the above-mentioned focus consistency method are implemented.

[0091] Among them, the computing device can be a computer, and correspondingly, its program is computer software. The above-mentioned parameters and steps in a computing device of the present invention can refer to the parameters and steps in an embodiment of a focus consistency method mentioned above, and will not be repeated here.

[0092] In an embodiment of the present invention, a computer-readable storage medium is provided, in which instructions are stored. When the instructions are executed, the steps of the above-mentioned focus consistency method are executed.

[0093] The computer-readable storage medium may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.

[0094] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method of the embodiment of the present disclosure. The aforementioned computer-readable storage medium may be a non-transitory computer-readable storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes, or a transient computer-readable storage medium.

[0095] Those skilled in the art know that the present invention can be implemented as a system, method or computer program product. Therefore, the present disclosure can be specifically implemented in the following forms, namely: it can be complete hardware, it can be complete software (including firmware, resident software, microcode, etc.), or it can be a combination of hardware and software, generally referred to as "circuit", "module" or "system" herein. In addition, in some embodiments, the present invention can also be implemented in the form of a computer program product in one or more computer-readable media, and the computer-readable medium contains computer-readable program code. Computer-readable storage media can be, for example, but not limited to - electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above.

[0096] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0097] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.

Claims

1. A focus consistency method, characterized in that: include: Acquire a calibration image of a calibration plate captured by a camera; wherein the calibration plate is provided with a plurality of spaced-apart squares; Identify the calibration image to obtain each square; Obtaining the number of transitions corresponding to each of the squares; wherein the number of transitions is the number of transition pixels; Determine the transition amount of the calibration image based on the transition amount corresponding to each of the squares; Based on the hill climbing method and the transition amount of the calibration images at different focal lengths, the motor is controlled to drive the camera to adjust the focal length to the target focal length.

2. The method according to claim 1, characterized in that The obtaining of the number of transitions corresponding to each of the squares includes: Obtain the midpoint of each side of each of the squares; Connect the midpoints of two vertical sides of the same square to obtain a first initial line segment, and connect the midpoints of two horizontal sides of the same square to obtain a second initial line segment; Extending the first initial line segment to a corresponding preset position to obtain a first target line segment, and extending the second initial line segment to a corresponding preset position to obtain a second target line segment; wherein the preset position is a middle position between two adjacent squares; The sum of the transition numbers on the first target line segment and the second target line segment corresponding to the same square is taken as the transition number corresponding to each square.

3. The method according to claim 2, characterized in that The obtaining of the midpoint of each side of each of the squares comprises: The four edge lines of each square are extracted by using Hough transform, and the four edge lines are used as the four sides of the square; The intersection of the four sides of the same square is regarded as the corner point; The midpoint between the two corner points of each side of the same square is taken as the midpoint of each side of each of the squares.

4. The method according to claim 2, characterized in that: The method of taking the sum of the transition numbers on the first target line segment and the second target line segment corresponding to the same square as the transition number corresponding to each square comprises: respectively determining the pixel value of each pixel point on each of the first target line segments and each of the second target line segments; Based on each of the pixel values, calculating a pixel difference between each of the two adjacent pixel points on each of the first target line segments and each of the second target line segments; Determine each pixel point corresponding to the pixel difference that meets the preset threshold condition as a transition pixel; Based on each transition pixel, the sum of the transition numbers on the first target line segment and the second target line segment corresponding to the same square is taken as the transition number corresponding to each square.

5. The method according to claim 1, characterized in that The step of determining the transition amount of the calibration image based on the transition amount corresponding to each of the squares includes: Based on the number of excesses corresponding to each of the squares, calculating an average value of the number of excesses corresponding to each of the squares; The average value is taken as the excess amount of the calibration image.

6. The method according to claim 1, characterized in that The method of controlling the motor to drive the camera to adjust the focal length to the target focal length based on the hill climbing method and the number of transitions of the calibration images at different focal lengths includes: Obtaining transition amounts of calibration images at three different focal lengths, and determining a moving direction based on the transition amounts of each calibration image and the corresponding focal length; Controlling the motor to drive the camera to adjust the focal length along the moving direction; Get the excess amount of the calibration image at the adjusted focal length; Determine whether the number of transitions of the calibration image at the adjusted focal length is less than the number of transitions of the calibration image before the adjustment; If yes, the step of returning to the step of controlling the motor to drive the camera to adjust the focal length along the moving direction is executed; if no, the focal length before the current adjustment is used as the target focal length.

7. The method according to any one of claims 1 to 6, characterized in that: Also includes: For each of the squares, determining a target quantity based on the excess quantity corresponding to the square; Searching in a preset data table based on the target quantity corresponding to each of the squares, respectively, to find out the display color corresponding to the target quantity; wherein the preset data table stores the corresponding relationship between the target quantity and the display color; Determine the color corresponding to each of the squares based on each of the display colors; The pseudo-color image corresponding to the calibration image is determined based on the colors corresponding to the squares; wherein the pseudo-color image includes the squares and the colors corresponding to each square.

8. A focus consistency system, characterized in that: include: A first acquisition module is used to acquire a calibration image of a calibration plate captured by a camera; wherein the calibration plate is provided with a plurality of spaced-apart squares; A recognition module, used to recognize the calibration image and obtain each square; A second acquisition module is used to acquire the number of transitions corresponding to each of the squares; wherein the number of transitions is the number of transition pixels; A determination module, configured to determine the number of transitions of the calibration image based on the number of transitions corresponding to each of the squares; The control module is used to control the motor to drive the camera to adjust the focal length to the target focal length based on the hill climbing method and the transition amount of the calibration image at different focal lengths.

9. A computing device comprising a memory, a processor, and a program stored in the memory and running on the processor, characterized in that: When the processor executes the program, the steps of a focus consistency method as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device executes the steps of a focus consistency method as described in any one of claims 1 to 7.