A method, system, device and storage medium for automatic camera adjustment

By introducing six degrees of freedom moving mechanisms and feature pattern algorithms in the optical system, the problems of low camera adjustment efficiency and low accuracy in the prior art are solved, and fast and accurate camera deviation adjustment is achieved to meet the automatic optical detection system. need.

CN119012016BActive Publication Date: 2025-02-14SHENZHEN SEICHITECH TECHN CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411481451.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-14
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

The camera adjustment of existing optical systems mainly relies on manual operations, resulting in low adjustment efficiency and low accuracy, and the camera's object distance, perpendicularity, rotation and translation deviations cannot be fully covered.

Method used

By introducing six degrees of freedom moving mechanisms of the X-axis, Y-axis, Z-axis, θ-axis, θX-axis and θY-axis, using the feature patterns in the calibration image as a reference, the feature center point, slope, and transition of the feature image are calculated by the algorithm through an algorithm. Automatically generate accurate adjustment instructions for the number of pixels and angles.

Benefits of technology

It realizes rapid and precise camera deviation adjustment, covering the camera's object distance, perpendicularity, rotation and translation deviations, improving the accuracy and reliability of adjustment, and meeting the needs of automatic optical detection systems and optical De-Mura systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119012016B_ABST
    Figure CN119012016B_ABST
Patent Text Reader

Abstract

The present application discloses a method, system, device and storage medium for automatic camera adjustment, which is used to quickly and accurately adjust the camera deviation, and comprehensively cover the deviation of the object distance, verticality, rotation and translation of the camera. The present application includes: determining the characteristic center point of the first characteristic pattern in the adjustment image, and controlling the camera to move on the Z axis according to the length from the characteristic center point to the edge of the first characteristic pattern; determining the first reference line or the second reference line in the second characteristic pattern in the adjustment image, and controlling the camera to move on the θY axis or the θX axis according to the slope of the first reference line or the second reference line; determining the number of transition pixels of the characteristic pattern in the adjustment image, and controlling the camera to move on the Z axis according to the number of transition pixels; determining the third reference line in the second characteristic pattern in the adjustment image, and controlling the camera to rotate on the θ axis according to the angle of the third reference line; and controlling the camera to move on the X axis and the Y axis according to the center coordinates of the characteristic pattern in the adjustment image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of optical detection technology, and in particular to a method, system, device and storage medium for automatic adjustment of a camera. Background Art

[0002] The automatic optical inspection (AOI) system and optical De-Mura system of display screens play a vital role in the display screen manufacturing process. These systems use high-precision industrial cameras to capture images of the display screen in order to detect possible defects on the display screen, such as bright spots, dark spots, dead spots, etc. The imaging quality of the optical system directly affects the accuracy and stability of the inspection results, and thus affects the quality of the final product. Therefore, how to quickly and accurately adjust the optical system to the expected standard is an important task of machine vision.

[0003] In the prior art, in most adjustment solutions for optical systems, the camera is adjusted mainly by manual adjustment, by opening multiple holes or U-shaped long holes on the camera mounting fixture, and when adjustment is needed, manually loosen the fixing screws and manually adjust their positions before fixing. There are also some solutions that fix the camera on a moving mechanism with three axes of XYθ, and adjust the translation and rotation of the camera by manually controlling the movement of the axes.

[0004] However, this adjustment scheme has few adjustable mechanisms and can only simply adjust the camera plane offset and verticality, but cannot cover the camera deviation. In addition, there is no reference standard for debugging, and it needs to be manually adjusted repeatedly in a visual manner, which results in low debugging efficiency and low adjustment accuracy. Summary of the invention

[0005] The present application provides a method, system, device and storage medium for automatic camera adjustment, which are used to quickly and accurately adjust the camera deviation, comprehensively covering the deviation of the camera's object distance, verticality, rotation and translation.

[0006] In a first aspect, the present application provides a method for automatic adjustment of a camera, wherein the camera is connected to a control mechanism, wherein the control mechanism includes a moving mechanism of an X-axis, a Y-axis, a Z-axis, a θ-axis, a θX-axis, and a θY-axis, wherein the θ-axis is connected to the X-axis and the Y-axis, and the θX-axis and the θY-axis are connected to the θ-axis, and the method includes:

[0007] Controlling the display device to display a calibration image, and using the camera to shoot the display device after each movement of the camera to obtain an adjusted image, wherein the calibration image includes a plurality of characteristic patterns, wherein the characteristic patterns include a first characteristic pattern whose center coincides with the center of the calibration image, and second characteristic patterns distributed around the first characteristic pattern;

[0008] Determine a feature center point of the first feature pattern in the adjusted image, and control the camera to move on the Z axis according to the length from the feature center point to the edge of the first feature pattern;

[0009] In the adjustment image, a first reference line or a second reference line is determined in the second characteristic pattern, and the camera is controlled to move on the θY axis or the θX axis according to the slope of the first reference line or the second reference line, and the first reference line and the second reference line are perpendicular to each other;

[0010] Determine the number of transition pixels of the characteristic pattern in the adjusted image, and control the camera to move on the Z axis according to the number of transition pixels;

[0011] Determine a third reference line in the second characteristic pattern in the adjustment image, and control the camera to rotate on the θ axis according to an angle of the third reference line;

[0012] The camera is controlled to move on the X-axis and the Y-axis according to the central coordinates of the characteristic pattern in the adjustment image.

[0013] Optionally, determining the number of transition pixels of the characteristic pattern in the adjusted image includes:

[0014] intercepting a display area image from the adjustment image, performing iterative mean filtering on the display area image, and calculating a grayscale mean of the display area image;

[0015] Performing a first threshold segmentation on the display area image in combination with a first preset grayscale, and detecting a first size of the characteristic pattern in the display area image;

[0016] performing a second threshold segmentation on the display area image in combination with a second preset grayscale, and detecting a second size of the characteristic pattern in the display area image;

[0017] The number of transition pixels of the characteristic pattern in the adjusted image is determined according to the difference between the first size and the second size.

[0018] Optionally, controlling the camera to move on the Z axis according to the number of transition pixels includes:

[0019] Controlling the camera to move on the Z axis, and calculating the gradient relationship between the number of transition pixels before and after the movement and the Z axis movement distance;

[0020] Calculating the next Z-axis moving distance according to the set target transition pixel number and the gradient relationship;

[0021] Iterate repeatedly until the target transition pixel quantity meets a preset quantity range.

[0022] Optionally, determining a first reference line in the second characteristic pattern in the adjusted image, and controlling the camera to move on the θY axis according to a slope of the first reference line includes:

[0023] determining at least two first transverse reference lines in the second characteristic pattern in the adjusted image;

[0024] calculating the slopes of the first reference lines respectively, and judging whether the first reference lines are parallel according to the slopes of the first reference lines;

[0025] If not, the camera is controlled to move on the θY axis, the gradient relationship is calculated according to the difference between the slopes of the first reference lines before and after the movement and the θY axis movement distance, and the next θY axis movement distance is calculated according to the gradient relationship until the first reference lines are parallel.

[0026] Optionally, determining a second reference line in the second characteristic pattern in the adjusted image, and controlling the camera to move on the θX axis according to a slope of the second reference line includes:

[0027] Determining at least two vertical second reference lines in the second characteristic pattern in the adjusted image;

[0028] calculating the slopes of the second reference lines respectively, and judging whether the second reference lines are parallel to each other according to the slopes of the second reference lines;

[0029] If not, the camera is controlled to move on the θX axis, the gradient relationship is calculated according to the difference between the slopes of the second reference lines before and after the movement and the θX axis movement distance, and the next θX axis movement distance is calculated according to the gradient relationship until the second reference lines are parallel.

[0030] Optionally, the method further includes:

[0031] Determining a target ratio parameter between a resolution of the display device and a resolution of the camera according to an application scenario;

[0032] The step of controlling the camera to move on the X-axis and the Y-axis according to the central coordinates of the characteristic pattern in the adjustment image comprises:

[0033] Controlling the camera to move on the X-axis and the Y-axis, detecting the central coordinates of the characteristic pattern in the adjustment image before and after the movement, and calculating the proportional relationship between the moving distance of the camera on the X-axis and the Y-axis and the pixel deviation according to the central coordinates of the characteristic pattern in the adjustment image before and after the movement;

[0034] The moving distance of the camera on the X-axis and the Y-axis is calculated according to the proportional relationship and the target proportional parameter.

[0035] Optionally, the characteristic pattern is a circular pattern, and after each movement of the camera, the display device is photographed using the camera to obtain an adjusted image, the method further includes:

[0036] All circular features in the adjusted image are detected by using the Hough circle to obtain the feature pattern in the adjusted image.

[0037] A second aspect of the present application provides a system for automatic adjustment of a camera, wherein the camera is connected to a control mechanism, wherein the control mechanism includes a moving mechanism of an X-axis, a Y-axis, a Z-axis, a θ-axis, a θX-axis, and a θY-axis, wherein the θ-axis is connected to the X-axis and the Y-axis, and the θX-axis and the θY-axis are connected to the θ-axis, and the system includes:

[0038] a photographing unit, used for controlling the display device to display a calibration image, and using the camera to photograph the display device after each movement of the camera to obtain an adjusted image, wherein the calibration image includes a plurality of characteristic patterns, wherein the characteristic patterns include a first characteristic pattern whose center coincides with the center of the calibration image, and second characteristic patterns distributed around the first characteristic pattern;

[0039] A first adjustment unit, used for determining a feature center point of the first feature pattern in the adjustment image, and controlling the camera to move on the Z axis according to a length from the feature center point to an edge of the first feature pattern;

[0040] a second adjustment unit, which determines a first reference line or a second reference line in the second characteristic pattern in the adjustment image, and controls the camera to move on the θY axis or the θX axis according to a slope of the first reference line or the second reference line, wherein the first reference line and the second reference line are perpendicular to each other;

[0041] a third adjustment unit, which determines the number of transition pixels of the characteristic pattern in the adjustment image, and controls the camera to move on the Z axis according to the number of transition pixels;

[0042] a fourth adjustment unit, configured to determine a third reference line in the second characteristic pattern in the adjustment image, and control the camera to rotate on the θ axis according to an angle of the third reference line;

[0043] A fifth adjustment unit controls the camera to move on the X-axis and the Y-axis according to the central coordinates of the characteristic pattern in the adjustment image.

[0044] Optionally, the third adjusting unit is specifically used for:

[0045] intercepting a display area image from the adjustment image, performing iterative mean filtering on the display area image, and calculating a grayscale mean of the display area image;

[0046] Performing a first threshold segmentation on the display area image in combination with a first preset grayscale, and detecting a first size of the characteristic pattern in the display area image;

[0047] performing a second threshold segmentation on the display area image in combination with a second preset grayscale, and detecting a second size of the characteristic pattern in the display area image;

[0048] The number of transition pixels of the characteristic pattern in the adjusted image is determined according to the difference between the first size and the second size.

[0049] Optionally, the third adjusting unit is further configured to:

[0050] Controlling the camera to move on the Z axis, and calculating the gradient relationship between the number of transition pixels before and after the movement and the Z axis movement distance;

[0051] Calculating the next Z-axis moving distance according to the set target transition pixel number and the gradient relationship;

[0052] Iterate repeatedly until the target transition pixel quantity meets a preset quantity range.

[0053] Optionally, the second adjusting unit is specifically used for:

[0054] determining at least two first transverse reference lines in the second characteristic pattern in the adjusted image;

[0055] calculating the slopes of the first reference lines respectively, and judging whether the first reference lines are parallel according to the slopes of the first reference lines;

[0056] If not, the camera is controlled to move on the θY axis, the gradient relationship is calculated according to the difference between the slopes of the first reference lines before and after the movement and the θY axis movement distance, and the next θY axis movement distance is calculated according to the gradient relationship until the first reference lines are parallel.

[0057] Optionally, the second adjusting unit is further configured to:

[0058] Determining at least two vertical second reference lines in the second characteristic pattern in the adjusted image;

[0059] calculating the slopes of the second reference lines respectively, and judging whether the second reference lines are parallel to each other according to the slopes of the second reference lines;

[0060] If not, the camera is controlled to move on the θX axis, the gradient relationship is calculated according to the difference between the slopes of the second reference lines before and after the movement and the θX axis movement distance, and the next θX axis movement distance is calculated according to the gradient relationship until the second reference lines are parallel.

[0061] Optionally, the system further includes:

[0062] A ratio determination unit, used to determine a target ratio parameter between a resolution of the display device and a resolution of the camera according to an application scenario;

[0063] The fifth adjusting unit is specifically used for:

[0064] Controlling the camera to move on the X-axis and the Y-axis, detecting the central coordinates of the characteristic pattern in the adjustment image before and after the movement, and calculating the proportional relationship between the moving distance of the camera on the X-axis and the Y-axis and the pixel deviation according to the central coordinates of the characteristic pattern in the adjustment image before and after the movement;

[0065] The moving distance of the camera on the X-axis and the Y-axis is calculated according to the proportional relationship and the target proportional parameter.

[0066] Optionally, the characteristic pattern is a circular pattern, and the system further comprises:

[0067] The detection unit is used to detect all circular features in the adjusted image through a Hough circle to obtain the feature pattern in the adjusted image.

[0068] A third aspect of the present application provides a device, the device comprising:

[0069] Processor, memory, input-output unit, and bus;

[0070] The processor is connected to the memory, the input and output unit, and the bus;

[0071] The memory stores a program, and the processor calls the program to execute the first aspect and any optional method in the first aspect.

[0072] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional method in the first aspect.

[0073] It can be seen from the above technical solutions that this application has the following advantages:

[0074] By introducing the six degrees of freedom mobile mechanism of X-axis, Y-axis, Z-axis, θ-axis, θX-axis and θY-axis, and using the characteristic pattern in the calibration image as a reference, the algorithm calculates the length, slope, number of transition pixels and angle from the characteristic center point of the characteristic image to the edge of the pattern, and automatically generates accurate adjustment instructions. The Z-axis is first roughly adjusted by determining the length from the characteristic center point of the characteristic pattern to the edge of the pattern; the θX and θY axes are adjusted by calculating the slope of the reference line to ensure that the camera is perpendicular to the display device; the Z-axis is fine-tuned by calculating the number of edge pixels of the characteristic pattern; the θ-axis adjusts the rotation deviation by calculating the angle of the reference line to ensure that the camera is parallel to the display screen coordinate system; the X and Y axes adjust the camera translation by the pixel deviation at the center of the characteristic pattern to eliminate the translation deviation.

[0075] Through the above automated adjustment steps, the camera deviation adjustment can be performed quickly and accurately, covering the deviation of the camera's object distance, verticality, rotation and translation. The entire adjustment process does not require visual judgment, which greatly improves the accuracy and reliability of the adjustment, meets the application requirements of automatic optical inspection systems and optical De-Mura systems, ensures the high quality and stability of image acquisition, and ultimately improves the overall performance of the inspection. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0077] Figure 1 A schematic diagram of a flow chart of an embodiment of a method for automatic camera adjustment provided by the present application;

[0078] Figure 2 A schematic flow chart of another embodiment of the method for automatic camera adjustment provided by the present application;

[0079] Figure 3 A schematic diagram of calibrating an image in the camera automatic adjustment method provided in this application;

[0080] Figure 4A schematic diagram of the structure of an embodiment of a system for automatic camera adjustment provided by the present application;

[0081] Figure 5 A schematic diagram of the structure of an embodiment of the device for automatic camera adjustment provided in the present application. DETAILED DESCRIPTION

[0082] The present application provides a method, system, device and storage medium for automatic camera adjustment, which are used to quickly and accurately adjust the camera deviation, comprehensively covering the deviation of the camera's object distance, verticality, rotation and translation.

[0083] It should be noted that the method provided in this application can be applied to a terminal or a server. For example, the terminal can be a smart phone or a computer, a tablet computer, a smart TV, a smart watch, a portable computer terminal, or a fixed terminal such as a desktop computer. For the convenience of explanation, this application uses the system as an example for the execution subject.

[0084] The camera provided in the present application is connected to a control mechanism, and the control mechanism includes a moving mechanism of an X-axis, a Y-axis, a Z-axis, a θ-axis, a θX-axis, and a θY-axis. Among them, the X-axis is the horizontal lateral moving axis of the camera, and the Y-axis is the vertical moving axis of the camera in the horizontal direction. The horizontal direction and the horizontal and vertical directions can be determined according to the actual implementation situation, and it is necessary to ensure that the X-axis is perpendicular to the Y-axis. The θ-axis is the rotation axis of the camera in the horizontal direction. The Z-axis is a moving axis perpendicular to the shooting plane, which mainly controls the object distance of the camera. The θX-axis is the vertical swing angle axis of the camera in the X-direction, and the θY-axis is the vertical swing angle axis of the camera in the Y-direction. These two axes can control the swing of the camera in the vertical direction. The Z-axis is the base axis of the entire control mechanism, and the entire camera and all other moving mechanisms are fixed on the Z-axis for movement. The X-axis and the Y-axis are connected to the Z-axis, the θ-axis is connected to the X-axis and the Y-axis, the θX is connected to the θ-axis, and the θY is connected to the θX-axis. The Z-axis selects a stepper motor and driver with corresponding power according to the actual weight of the entire control mechanism. The motor is equipped with a brake. The remaining axes are also driven by stepper motors and drivers.

[0085] See also Figure 1 , Figure 1 An embodiment of the method for automatic camera adjustment provided by the present application includes:

[0086] 101. Control the display device to display a calibration image, and use the camera to shoot the display device after each movement of the camera to obtain an adjusted image, wherein the calibration image includes a plurality of characteristic patterns, and the characteristic patterns include a first characteristic pattern whose center coincides with the center of the calibration image, and second characteristic patterns distributed around the first characteristic pattern;

[0087] First, you need to make a calibration image that is consistent with the resolution of the display device, and mark a set of characteristic patterns in the calibration image. The characteristic pattern specifically includes a first characteristic pattern whose center coincides with the center of the calibration image, that is, the center point of the first characteristic pattern coincides with the geometric center of the calibration image, which is the core reference point for adjusting the camera position. The characteristic pattern also includes a second characteristic pattern symmetrically distributed around the calibration image, which can be used to detect the inclination, rotation angle and translation state of the camera. It should be noted that the characteristic pattern can be a circle, rectangle or crosshair, etc. The number of the second characteristic patterns can be set according to the needs, and is not limited here.

[0088] In the actual adjustment process, the calibration image needs to be continuously displayed through the display device to ensure that the position and angle of the camera are calibrated by shooting the calibration image after each camera movement. Specifically, after each camera movement, the camera will shoot the display device to obtain an adjustment image for analysis and adjustment. The adjustment image is used to reflect the difference between the current state of the camera and the ideal state, and is used to guide further adjustment of the camera.

[0089] 102. Determine a feature center point of the first feature pattern in the adjusted image, and control the camera to move on the Z axis according to the length from the feature center point to the edge of the first feature pattern;

[0090] In the adjustment image captured by the camera, the contour of the first characteristic pattern is detected by the image processing algorithm, and the characteristic center point of the first characteristic pattern in the adjustment image is determined. The length from the characteristic center point to the edge of the first characteristic pattern directly reflects the change in the focal length of the camera. As the camera moves on the Z axis, that is, when the camera is close to or away from the display device, the length from the characteristic center point of the first characteristic pattern in the adjustment image to the edge of the first characteristic pattern will change accordingly. Therefore, by analyzing the change in the length from the characteristic center point to the edge of the first characteristic pattern, it can be determined whether the distance between the camera and the display device is appropriate.

[0091] Specifically, according to the difference between the determined length from the characteristic center point of the first characteristic pattern in the adjustment image to the edge of the pattern and the preset target length, the distance that the camera needs to move on the Z axis can be calculated, thereby achieving the adjustment of the camera object distance. For example, when the first characteristic pattern is circular, the camera can be controlled to move to a suitable distance on the Z axis by its characteristic center point and radius size in the adjustment image, and when the first characteristic pattern is rectangular, the camera can be controlled to move to a suitable distance on the Z axis by its characteristic center point in the adjustment image to the edge of the rectangle.

[0092] 103. In the adjusted image, a first reference line or a second reference line is determined in the second characteristic pattern, and the camera is controlled to move on the θY axis or the θX axis according to the slope of the first reference line or the second reference line, and the first reference line and the second reference line are perpendicular to each other;

[0093] The tilt of the camera, that is, the deviation of verticality, will cause the captured image to be distorted, affecting the subsequent image processing and analysis. When the camera is tilted in the vertical direction, the captured image may show the effect of stretching or compressing the upper and lower parts. The height of the object in the image will be distorted, resulting in the image not accurately reflecting the shape and proportion of the real object. When the camera is tilted in the horizontal direction, the image content on the left and right sides will be stretched or compressed, and the shape of the object in the image will be tilted or deformed. Since the θX axis and θY axis control the rotation of the camera in the vertical and horizontal directions respectively, the camera rotates around the θX axis to correct the tilt of the camera in the vertical direction. This adjustment can ensure that the captured image is perpendicular to the display device, without distortion in the up and down directions, so that the height ratio of the object in the image returns to normal. The camera rotates around the θY axis to correct the tilt of the camera in the horizontal direction. This adjustment ensures that the horizontal line of the image is parallel to the display device, eliminates the tilt distortion in the left and right directions, and makes the width ratio of the object accurate.

[0094] The second characteristic patterns in the adjustment image are distributed around the calibration image. By analyzing these second characteristic patterns, two mutually perpendicular reference lines can be determined: a first reference line and a second reference line. For example, the first reference line is a horizontal reference line formed by connecting the center points of the characteristic patterns on the left and right sides of the adjustment image, and the second reference line is a vertical reference line formed by connecting the center points of the characteristic patterns on the upper and lower sides of the adjustment image.

[0095] The first reference line and the second reference line can reflect the current tilt of the camera in the horizontal and vertical directions. If the camera is tilted in the horizontal or vertical direction, the geometry of the second characteristic pattern in the adjustment image captured will change. Therefore, by calculating the deviation of the slope, the system can accurately determine the angle of camera deviation and calculate the required rotation adjustment amount accordingly. By adjusting the θX axis and θY axis, the vertical deviation of the camera can be eliminated to ensure that the geometry of the characteristic pattern is consistent with the real object. After the geometric distortion is corrected, subsequent image processing can be performed on an accurate geometric basis, and the adjustment result is more reliable.

[0096] 104. Determine the number of transition pixels of the characteristic pattern in the adjustment image, and control the camera to move on the Z axis according to the number of transition pixels;

[0097] Transition pixels refer to the blurred area of ​​pixels when the edge of an object transitions from one color or grayscale to another color or grayscale. Transition pixels reflect the accuracy of camera focus. Ideally, the edges of feature patterns in the adjusted image should be clear and the number of transition pixels should be as small as possible. However, in actual operation, as the distance between the camera and the target object, that is, the object distance, changes, the adjustment of the focus will affect the number of transition pixels: when the focus deviates, the number of transition pixels increases and the image becomes blurred.

[0098] Therefore, the system needs to use an algorithm to detect the number of transition pixels of the characteristic pattern in the adjustment image, such as edge detection, threshold segmentation or blur detection algorithm. By counting the number of transition pixels, the clarity and focus of the current adjustment image can be reflected. Based on the number of transition pixels detected, the system determines whether the object distance between the camera and the display device is appropriate. If the number of transition pixels is large, it means that the camera has failed to focus, and the Z-axis position needs to be adjusted to change the distance between the camera and the target object. The movement of the Z axis can be forward (closer to the target) or backward (away from the target), and the distance of the Z axis movement depends on the deviation between the current focal length and the ideal focal length.

[0099] Specifically, the system may use only the number of transition pixels in the first characteristic pattern to perform Z-axis adjustment control, or may use the average number of transition pixels in all characteristic patterns to perform Z-axis adjustment control, which is not specifically limited here.

[0100] It should be noted that in step 102, the length from the feature center point of the first feature pattern to the edge of the pattern is used as the main detection target, which is used to adjust the object distance of the camera to ensure that the distance between the camera and the display device reaches the initial ideal state. Step 104 requires that on the premise of eliminating the camera tilt in step 103, the number of transition pixels at the edge of the image is used as the detection target to accurately adjust the camera focal length to ensure the clarity of the image. The tilt of the camera will directly affect the geometric shape and focusing result in the image. If the tilt is not eliminated before the focus adjustment, it will cause inconsistent object distance and geometric distortion of the image, affecting the accuracy of the focus adjustment.

[0101] 105. Determine a third reference line in the second characteristic pattern in the adjusted image, and control the camera to rotate on the θ axis according to an angle of the third reference line;

[0102] Rotational deviation can cause the geometric shape of the object in the image to be distorted, such as a rectangle becoming a parallelogram, which affects subsequent image analysis. By adjusting the rotation of the θ axis, the geometric symmetry of the image can be restored to ensure that the shape in the image is consistent with the actual object.

[0103] The third reference line is a straight line connected by certain key points of the second characteristic pattern in the adjustment image, such as the center point, edge point, etc. The third reference line is used to detect the rotation deviation of the camera, that is, the rotation of the camera around the Z axis, which is specifically controlled by the θ axis. Ideally, the third reference line should be parallel to the X axis or Y axis of the adjustment image. If the camera rotates, the third reference line will show a certain tilt angle. Therefore, by calculating the angle of the third reference line, the system can determine the rotation deviation in the adjustment image and adjust the camera rotation around the θ axis accordingly until the third reference line is aligned with the ideal X axis or Y axis at an angle of 0 degrees.

[0104] By calculating the angle of the third reference line, the system can automatically detect the rotation deviation of the camera and quickly correct it to ensure that the image will not be rotated. After rotation correction, the horizontal and vertical lines of the image can be adjusted to accurately align the coordinate system of the display device.

[0105] 106. Control the camera to move on the X-axis and the Y-axis according to the center coordinates of the characteristic pattern in the adjustment image.

[0106] Ideally, the center point of the feature pattern should coincide with the point at the corresponding position in the adjustment image. For example, the center point of the first feature pattern should coincide with the geometric center of the image. If the center deviates, it means that the camera is offset on the X-axis or Y-axis and the camera position needs to be adjusted.

[0107] The difference between the center coordinates of the characteristic pattern in the image and the ideal coordinates can reflect the translation deviation of the camera on the X-axis and Y-axis. By calculating these deviations, the system can determine the displacement of the camera on the X-axis and Y-axis, and automatically adjust the position of the camera until the deviation is close to zero, aligning the center of the camera's field of view with the geometric center of the image to eliminate the translation deviation.

[0108] It should be noted that the adjustment sequence in this embodiment specifically includes coarse adjustment of the Z axis first, then adjustment of the θX and θY axes, then fine adjustment of the Z axis, and finally adjustment of the θ axis and the X and Y axes. Among them, the coarse adjustment of the Z axis must be performed first. Since the Z axis determines the distance between the camera and the display device, the main purpose is to quickly adjust the camera to a reasonable object distance range. The coarse adjustment of the Z axis enables the obtained adjustment image to have basic clarity. The adjustment of the θX and θY axes must be performed before the fine adjustment of the Z axis. Adjusting the θX and θY axes ensures the geometric alignment of the camera in the horizontal and vertical directions. If the camera angle is not aligned, directly fine-tuning the Z axis will cause the focal length adjustment to fail. Therefore, the angle adjustment should take precedence over the fine adjustment of the Z axis. The remaining adjustment sequences can be exchanged according to actual conditions, for example, adjusting the θ axis first, then fine-tuning the Z axis, and finally adjusting the X and Y axes.

[0109] In this embodiment, by introducing the six degrees of freedom mobile mechanism of X-axis, Y-axis, Z-axis, θ-axis, θX-axis and θY-axis, and using the characteristic pattern in the calibration image as a reference, the length, slope, number of transition pixels and angle, etc. from the characteristic center point of the characteristic image to the edge of the pattern are calculated by the algorithm, and accurate adjustment instructions are automatically generated. Among them, the Z-axis is first roughly adjusted by determining the length from the characteristic center point of the characteristic pattern to the edge of the pattern; the θX and θY axes are adjusted by calculating the slope of the reference line to ensure that the camera is perpendicular to the display device; the Z-axis is fine-tuned by calculating the number of edge pixels of the characteristic pattern; the θ-axis adjusts the rotation deviation by calculating the angle of the reference line to ensure that the camera is parallel to the display screen coordinate system; the X and Y axes adjust the camera translation by the pixel deviation at the center position of the characteristic pattern to eliminate the translation deviation.

[0110] Through the above automated adjustment steps, the camera deviation adjustment can be performed quickly and accurately, covering the deviation of the camera's object distance, verticality, rotation and translation. The entire adjustment process does not require visual judgment, which greatly improves the accuracy and reliability of the adjustment, meets the application requirements of automatic optical inspection systems and optical De-Mura systems, ensures the high quality and stability of image acquisition, and ultimately improves the overall performance of the inspection.

[0111] The following is a detailed description of the camera automatic adjustment method provided by this application. Figure 2 , Figure 2 In another embodiment of the system for automatic camera adjustment provided by the present application, the method includes:

[0112] 201. Control the display device to display a calibration image, and use the camera to shoot the display device after each movement of the camera to obtain an adjusted image, wherein the calibration image includes a plurality of characteristic patterns, and the characteristic patterns include a first characteristic pattern whose center coincides with the center of the calibration image, and second characteristic patterns distributed around the first characteristic pattern;

[0113] In this embodiment, step 201 is similar to step 101 in the aforementioned embodiment and will not be described again here.

[0114] 202. Detect all circular features in the adjusted image through the Hough circle to obtain a feature pattern in the adjusted image;

[0115] See also Figure 3 , Figure 3 : is a schematic diagram of the calibration image in this embodiment. The characteristic pattern in the calibration image is a circle, and the calibration image includes a first characteristic pattern located at the center of the calibration image and a second characteristic pattern at each of the four corners. After the adjustment image is captured, the system needs to use the Hough circle to detect all circular features in the adjustment image and use it as a reference for subsequent camera adjustment.

[0116] The characteristic pattern data in the calibration image are , , , , .

[0117] The characteristic pattern data in the adjusted image obtained by Hough circle detection are: , , , , .

[0118] 203. Determine a target ratio parameter between a resolution of a display device and a resolution of a camera according to an application scenario;

[0119] Before making adjustments, it is also necessary to determine the target ratio parameter MR between the resolution of the display device and the resolution of the camera according to the application scenario. The target ratio parameter MR determines the shooting accuracy of the camera in a specific application scenario, ensuring that the clarity and details of the image can meet the application requirements. Therefore, the system needs to determine the size of the detection object and the accuracy requirements of the detection according to the specific application scenario. If it is a subtle detection, a higher target ratio parameter MR should be selected; if it is a large-scale detection, a lower target ratio parameter MR can be selected. For example, micro-detection scenarios usually require MR to be greater than 3.5, while macro-detection scenarios require MR to be less than 1.

[0120] In addition, the lens aperture and lens focus position need to be fixed before the camera automatically adjusts to ensure that the image quality during the adjustment process is not affected by changes in lens parameters.

[0121] 204. Determine a feature center point of the first feature pattern in the adjusted image, and control the camera to move on the Z axis according to the length from the feature center point to the edge of the first feature pattern;

[0122] Generally, the initial fixed position of the camera is usually near the working object distance, but preliminary adjustments are required to make the image focus relatively clear. Since the characteristic pattern is circular, the camera movement on the Z axis can be directly controlled by the radius length of the characteristic pattern.

[0123] First, take an adjustment image, and according to the first characteristic pattern radius detected in step 202 ; Control the Z axis to move a small distance d in the positive direction and obtain the center feature pattern radius again ;

[0124] Calculate the change in diameter of the characteristic image before and after movement , from which the gradient relationship between the Z-axis movement and the pattern radius can be calculated ;

[0125] According to the MR value set in step 203, the radius of the first characteristic pattern on the image is , from which the movement amount of the next adjustment can be calculated as ; To prevent excessive movement, the calculated movement value is multiplied by the coefficient k (k<1).

[0126] Repeat this adjustment process until the conditions are met. , It is the deviation setting value. When the conditions are met, the next step of adjustment will be entered.

[0127] 205. In the adjusted image, determine a first reference line or a second reference line in the second characteristic pattern, control the camera to move on the θY axis or the θX axis according to the slope of the first reference line or the second reference line, and the first reference line and the second reference line are perpendicular to each other;

[0128] The following is an explanation of the adjustment process of the θY axis:

[0129] A1. determining at least two first transverse reference lines in a second characteristic pattern in an adjusted image;

[0130] A2. Calculate the slopes of the first reference lines respectively, and determine whether the first reference lines are parallel according to the slopes of the first reference lines;

[0131] According to the formula of the slope of a straight line , combined with the characteristic pattern data in the adjusted image detected in step 202, the second characteristic pattern can be obtained, that is, two first horizontal reference lines formed by the centers of the four corner characteristic patterns in pairs, and the straight line slope of the first reference line is , .

[0132] When the camera is perpendicular to the display screen in the X direction, the two straight lines in the X direction should be parallel, so If the first reference lines are not parallel, the θY axis is adjusted. This is because the θY axis controls the vertical swing angle of the camera in the horizontal direction, that is, the camera rotates around the Y axis, thereby adjusting the tilt angle of the camera in the X direction.

[0133] A3. If not, control the camera to move on the θY axis, calculate the gradient relationship according to the difference between the slopes of the first reference lines before and after the movement and the θY axis movement distance, and calculate the next θY axis movement distance according to the gradient relationship until the first reference lines are parallel.

[0134] Calculate the slope difference between the first reference lines ;

[0135] Control θY to move the distance dx and calculate the slope difference before and after the movement , ;

[0136] Calculate the gradient relationship coefficient between the slope difference in the θY direction and the moving distance ;

[0137] Then the slope difference deviation that θY needs to adjust is , the adjustment distance is .

[0138] For the adjustment of the θX axis, similarly, the adjustment of the θX axis needs to first combine the second characteristic pattern to determine the two second vertical reference lines formed by the centers of the four corner characteristic patterns, and then calculate the slope of the second reference line. , When the camera is perpendicular to the display screen in the Y direction, the two straight lines in the Y direction should have . Calculate the difference in slopes of vertical lines , and then calculate the coefficient between the slope difference before and after the movement and the moving distance Finally, the adjustment distance of the θX axis is .

[0139] Steps 206 to 211 are the Z-axis fine adjustment process, which is described in detail below:

[0140] 206. intercepting a display area image from the adjusted image, performing iterative mean filtering on the display area image, and calculating a grayscale mean of the display area image;

[0141] The image of the display area, that is, the specific display area captured by the camera, is intercepted from the adjusted image as the basic image for subsequent processing. First, the image of the display area is iteratively mean filtered to smooth the image. The neighborhood mean of each pixel is calculated through multiple iterations (more than 20 times) to reduce image noise and unnecessary details, effectively reduce random noise in the image and extract background information. After filtering, the grayscale mean Gm of the display area image is calculated for subsequent threshold segmentation.

[0142] 207. Perform a first threshold segmentation on the display area image in combination with the first preset grayscale, and detect a first size of the characteristic pattern in the display area image;

[0143] The calculated grayscale mean Gm is used as the first preset grayscale to perform the first threshold segmentation on the display area image. The first size of the characteristic pattern in the image is detected through the segmented image. In this embodiment, the radii R1 to R5 of the five characteristic patterns in the image can be specifically detected.

[0144] 208. Perform a second threshold segmentation on the display area image in combination with a second preset grayscale, and detect a second size of the characteristic pattern in the display area image;

[0145] The second preset grayscale, for example, grayscale 253, is used to perform a second threshold segmentation on the same display area image to further refine the boundary between the foreground and the background. The second size of the same feature pattern is detected through the image after the second segmentation, that is, the radius R6-R10 of the feature pattern recalculated at a higher grayscale.

[0146] 209. Determine the number of transition pixels of the characteristic pattern in the adjusted image according to the difference between the first size and the second size;

[0147] Since the two segmentations use different grayscale values ​​to detect the edges of the feature pattern, the dynamic grayscale mean Gm is used to extract the rougher contour in the first segmentation, while the fixed high threshold is used in the second segmentation to further refine the edge. At this time, the difference between the first size and the second size directly reflects the degree of image edge blur, which is related to the number of transition pixels. Therefore, the mean of the two groups of radius is calculated separately. , , and determine the number of transition pixels , thereby quantifying the number of transition pixels of blurred edges in the image and evaluating the focus adjustment of the camera accordingly.

[0148] 210. Control the camera to move on the Z axis, and calculate the gradient relationship between the number of transition pixels before and after the movement and the Z axis movement distance;

[0149] After calculating the initial number of transition pixels, the system controls the camera to move along the Z axis and calculates the new number of transition pixels again after the movement. By comparing the number of transition pixels before and after the movement, the system can obtain the impact of the current focal length adjustment on the image clarity. The gradient relationship between the number of transition pixels and the Z axis movement distance is calculated by the ratio of the difference in the number of transition pixels before and after the movement to the camera's Z axis movement distance. This gradient relationship represents the change in the number of transition pixels caused by each unit of Z axis movement distance, and is a key parameter for subsequent calculations of Z axis adjustments.

[0150] Specifically, the Z-axis moving distance is d, and the method of steps 206 to 209 is used to obtain the number of transition pixels before and after the movement. , , at this time, the gradient relationship between the number of transition pixels and the moving distance is .

[0151] 211. Calculate the next Z-axis moving distance according to the set target transition pixel number and gradient relationship;

[0152] The system can now set a target number of transition pixels, and determine the Z-axis distance d that the camera needs to move next time based on the target number of transition pixels and the previously calculated gradient relationship to reduce the current number of transition pixels.

[0153] Z axis moving distance ,in is the number of transition pixels for the target. To prevent excessive movement, the calculated moving distance also needs to be multiplied by a coefficient less than 1.

[0154] 212. Repeat the iteration until the target transition pixel quantity meets the preset quantity range;

[0155] The system gradually reduces the number of transition pixels by continuously repeating the aforementioned steps 206 to 211, and ensures that the focus of the image is adjusted to the optimal state through multiple iterative movements of the Z axis. Each iteration updates the number of transition pixels and the Z axis movement distance, and the number of transition pixels gradually decreases with each adjustment. The system continuously adjusts the Z axis until the number of transition pixels reaches a preset number range.

[0156] It should be noted that the preset number range is to control the clarity of the image and avoid the appearance of moiré caused by overfocusing. By controlling the number of transition pixels within the preset range, the image is kept reasonably clear while avoiding the moiré problem caused by overfocusing. This control helps to maintain the natural presentation of image details and textures, improve the overall quality and usability of the image, and ensure that the image maintains moderate clarity and quality in AOI system and optical De-Mura system applications. For example, the preset number range is set to 3≤ ≤5.

[0157] 213. Determine a third reference line in the second characteristic pattern in the adjusted image, and control the camera to rotate on the θ axis according to an angle of the third reference line;

[0158] The goal of the θ-axis adjustment is to make the display screen and the camera image coordinate system parallel to each other. Therefore, just rotate the camera so that the straight line formed by the coordinates of the center of the upper left corner feature pattern and the center of the upper right corner feature pattern, that is, the angle of the third reference line, is 0 degrees. The formula for calculating the straight line angle based on the coordinates of two points is: , we can calculate the angle that the current camera needs to rotate to .

[0159] 214. Control the camera to move on the X-axis and the Y-axis, detect the central coordinates of the characteristic pattern in the adjustment image before and after the movement, and calculate the proportional relationship between the movement distance of the camera on the X-axis and the Y-axis and the pixel deviation according to the central coordinates of the characteristic pattern in the adjustment image before and after the movement;

[0160] The system controls the camera to move along the X-axis and Y-axis respectively to detect the center coordinates of the characteristic pattern in the adjustment image. Based on the first characteristic pattern, the system calculates the physical movement distance of the camera on the X-axis and Y-axis by comparing the changes in the center coordinates of the characteristic pattern in the image before and after the movement. , The proportional relationship between pixel deviation:

[0161] , .

[0162] 215. Calculate the movement distance of the camera on the X-axis and Y-axis according to the proportional relationship and the target proportional parameters.

[0163] Based on the calculated proportional relationship between the physical moving distance and the pixel deviation and the set target ratio parameter MR, the system can calculate the next moving distance of the camera on the X-axis and Y-axis to align the center of the feature pattern to the target position.

[0164] Specifically, according to the set MR value, the deviation between the current position and the target image is , , the deviation values ​​that the X and Y axes need to move are:

[0165] ;

[0166] .

[0167] In this embodiment, through the adjustment process of multiple dimensions, the automatic adjustment of the camera on the X, Y, Z axis and the θX, θY, θ axis is ensured, so that the system can quickly and accurately adjust the camera position in different application scenarios, thereby achieving high-quality image acquisition. In the AOI system and the optical De-Mura system, the focal length accuracy of the image is crucial. In terms of focal length adjustment, through multiple iterations of mean filtering, threshold segmentation and transition pixel detection, it is ensured that the focal length of the camera can be dynamically adjusted and accurately controlled to obtain appropriate image blur and prevent moiré caused by excessive clarity. This automated adjustment process can continuously and iteratively adjust the position and focal length of the camera according to real-time image feedback to ensure that the image achieves the best balance between clarity and image interference. And by setting the target ratio parameter between the display device resolution and the camera resolution, it can flexibly respond to the needs of different detection scenarios. This flexible adjustment method can adapt to various scene requirements in AOI and optical De-Mura systems, ensuring that the system can provide the best adjustment effect under different resolution conditions.

[0168] The following is a detailed description of the device provided by this application. Figure 4 , Figure 4 Another embodiment of the system for automatic camera adjustment provided by the present application includes:

[0169] The shooting unit 401 is used to control the display device to display the calibration image, and use the camera to shoot the display device after each movement of the camera to obtain an adjusted image, wherein the calibration image includes a plurality of characteristic patterns, and the characteristic patterns include a first characteristic pattern whose center coincides with the center of the calibration image, and second characteristic patterns distributed around the first characteristic pattern;

[0170] A first adjustment unit 402, used to determine a feature center point of the first feature pattern in the adjustment image, and control the camera to move on the Z axis according to the length from the feature center point to the edge of the first feature pattern;

[0171] A second adjustment unit 403 determines a first reference line or a second reference line in a second characteristic pattern in the adjustment image, and controls the camera to move on the θY axis or the θX axis according to a slope of the first reference line or the second reference line, wherein the first reference line and the second reference line are perpendicular to each other;

[0172] The third adjustment unit 404 determines the number of transition pixels of the characteristic pattern in the adjustment image, and controls the camera to move on the Z axis according to the number of transition pixels;

[0173] The fourth adjustment unit 405 determines a third reference line in the second characteristic pattern in the adjustment image, and controls the camera to rotate on the θ axis according to an angle of the third reference line;

[0174] The fifth adjustment unit 406 controls the camera to move on the X-axis and the Y-axis according to the central coordinates of the characteristic pattern in the adjustment image.

[0175] Optionally, the third adjusting unit 404 is specifically configured to:

[0176] A display area image is intercepted from the adjustment image, and an iterative mean filter is performed on the display area image to calculate the grayscale mean of the display area image;

[0177] Performing a first threshold segmentation on the display area image in combination with a first preset grayscale, and detecting a first size of the characteristic pattern in the display area image;

[0178] Performing a second threshold segmentation on the display area image in combination with a second preset grayscale, and detecting a second size of the characteristic pattern in the display area image;

[0179] The number of transition pixels of the characteristic pattern in the adjusted image is determined according to the difference between the first size and the second size.

[0180] Optionally, the third adjusting unit 404 is further configured to:

[0181] Control the camera to move on the Z axis and calculate the gradient relationship between the number of transition pixels before and after the movement and the Z axis movement distance;

[0182] Calculate the next Z-axis moving distance according to the set target transition pixel number and gradient relationship;

[0183] Iterate repeatedly until the target transition pixel number meets the preset number range.

[0184] Optionally, the second adjusting unit 403 is specifically configured to:

[0185] determining at least two transverse first reference lines in the second characteristic pattern in the adjusted image;

[0186] Calculating the slopes of the first reference lines respectively, and judging whether the first reference lines are parallel to each other according to the slopes of the first reference lines;

[0187] If not, the camera is controlled to move on the θY axis, and the gradient relationship is calculated according to the difference between the slopes of the first reference lines before and after the movement and the θY axis movement distance, and the next θY axis movement distance is calculated according to the gradient relationship until the first reference lines are parallel.

[0188] Optionally, the second adjusting unit 403 is further configured to:

[0189] Determining at least two vertical second reference lines in a second characteristic pattern in the adjusted image;

[0190] Calculating the slopes of the second reference lines respectively, and judging whether the second reference lines are parallel to each other according to the slopes of the second reference lines;

[0191] If not, the camera is controlled to move on the θX axis, and the gradient relationship is calculated according to the difference between the slopes of the second reference lines before and after the movement and the θX axis movement distance, and the next θX axis movement distance is calculated according to the gradient relationship until the second reference lines are parallel.

[0192] Optionally, the system further includes:

[0193] A ratio determination unit 407, used to determine a target ratio parameter between the resolution of the display device and the resolution of the camera according to an application scenario;

[0194] The fifth adjustment unit 406 is specifically used for:

[0195] Control the camera to move on the X-axis and the Y-axis, detect the center coordinates of the characteristic pattern in the adjustment image before and after the movement, and calculate the proportional relationship between the movement distance of the camera on the X-axis and the Y-axis and the pixel deviation according to the center coordinates of the characteristic pattern in the adjustment image before and after the movement;

[0196] Calculate the movement distance of the camera on the X and Y axes according to the proportional relationship and the target proportional parameters.

[0197] Optionally, the characteristic pattern is a circular pattern, and the system further comprises:

[0198] The detection unit 408 is configured to detect all circular features in the adjusted image using a Hough circle to obtain a feature pattern in the adjusted image.

[0199] In this embodiment, the functions of each unit are the same as those described above. Figure 1 or Figure 2 The steps in the method embodiment shown correspond to each other and will not be repeated here.

[0200] This application also provides, see Figure 5 , Figure 5 An embodiment of a device for automatic camera adjustment provided by the present application includes:

[0201] Processor 501, memory 502, input and output unit 503, bus 504;

[0202] The processor 501 is connected to the memory 502, the input and output unit 503 and the bus 504;

[0203] The memory 502 stores a program, and the processor 501 calls the program to execute any of the above camera automatic adjustment methods.

[0204] The present application also relates to a computer-readable storage medium on which a program is stored, wherein when the program is run on a computer, the computer executes any of the above-mentioned methods for automatic camera adjustment.

[0205] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0206] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0207] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0208] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0209] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk, etc. Various media that can store program codes.

Claims

1. A method for automatic camera adjustment, characterized in that: The camera is connected to a control mechanism, and the control mechanism includes a moving mechanism of an X-axis, a Y-axis, a Z-axis, a θ-axis, a θX-axis, and a θY-axis, wherein the θ-axis is connected to the X-axis and the Y-axis, the θX-axis and the θY-axis are connected to the θ-axis, the X-axis is a lateral moving axis of the camera in the horizontal direction, the Y-axis is a vertical moving axis of the camera in the horizontal direction, the Z-axis is a moving axis perpendicular to a shooting plane, the θ-axis is a rotation axis of the camera in the horizontal direction, the θX-axis is a vertical swing angle axis of the camera in the X direction, and the θY-axis is a vertical swing angle axis of the camera in the Y direction; The method comprises: Controlling the display device to display a calibration image, and using the camera to shoot the display device after each movement of the camera to obtain an adjusted image, wherein the calibration image includes a plurality of characteristic patterns, wherein the characteristic patterns include a first characteristic pattern whose center coincides with the center of the calibration image, and second characteristic patterns distributed around the first characteristic pattern; Determine a feature center point of the first feature pattern in the adjusted image, and control the camera to move on the Z axis according to the length from the feature center point to the edge of the first feature pattern; Determine a first reference line in the second characteristic pattern in the adjustment image, and control the camera to move on the θY axis according to the slope of the first reference line, or determine a second reference line in the second characteristic pattern in the adjustment image, and control the camera to move on the θX axis according to the slope of the second reference line, the first reference line and the second reference line are perpendicular to each other, the first reference line is formed by connecting the center points of the second characteristic patterns on the left and right sides of the adjustment image, and the second reference line is formed by connecting the center points of the second characteristic patterns on the upper and lower sides of the adjustment image; Determine the number of transition pixels of the characteristic pattern in the adjusted image, and control the camera to move on the Z axis according to the number of transition pixels; Determine a third reference line in the second characteristic pattern in the adjustment image, and control the camera to rotate on the θ axis according to an angle of the third reference line, wherein the third reference line is formed by connecting center points or edge points of the second characteristic pattern; The camera is controlled to move on the X-axis and the Y-axis according to the central coordinates of the characteristic pattern in the adjustment image.

2. The method according to claim 1, characterized in that The determining the number of transition pixels of the characteristic pattern in the adjusted image comprises: intercepting a display area image from the adjustment image, performing iterative mean filtering on the display area image, and calculating a grayscale mean of the display area image; Performing a first threshold segmentation on the display area image in combination with a first preset grayscale, and detecting a first size of the characteristic pattern in the display area image; performing a second threshold segmentation on the display area image in combination with a second preset grayscale, and detecting a second size of the characteristic pattern in the display area image; The number of transition pixels of the characteristic pattern in the adjusted image is determined according to the difference between the first size and the second size.

3. The method according to claim 2, characterized in that Controlling the camera to move on the Z axis according to the number of transition pixels includes: Controlling the camera to move on the Z axis, and calculating the gradient relationship between the number of transition pixels before and after the movement and the Z axis movement distance; Calculating the next Z-axis moving distance according to the set target transition pixel number and the gradient relationship; Iterate repeatedly until the target transition pixel quantity meets a preset quantity range.

4. The method according to claim 1, characterized in that: Determining a first reference line in the second characteristic pattern in the adjustment image, and controlling the camera to move on the θY axis according to the slope of the first reference line, comprising: determining at least two first transverse reference lines in the second characteristic pattern in the adjusted image; calculating the slopes of the first reference lines respectively, and judging whether the first reference lines are parallel according to the slopes of the first reference lines; If not, the camera is controlled to move on the θY axis, the gradient relationship is calculated according to the difference between the slopes of the first reference lines before and after the movement and the θY axis movement distance, and the next θY axis movement distance is calculated according to the gradient relationship until the first reference lines are parallel.

5. The method according to claim 1, characterized in that Determining a second reference line in the second characteristic pattern in the adjustment image, and controlling the camera to move on the θX axis according to the slope of the second reference line, comprising: Determining at least two vertical second reference lines in the second characteristic pattern in the adjusted image; calculating the slopes of the second reference lines respectively, and judging whether the second reference lines are parallel to each other according to the slopes of the second reference lines; If not, the camera is controlled to move on the θX axis, the gradient relationship is calculated according to the difference between the slopes of the second reference lines before and after the movement and the θX axis movement distance, and the next θX axis movement distance is calculated according to the gradient relationship until the second reference lines are parallel.

6. The method according to claim 1, characterized in that The method further comprises: Determining a target ratio parameter between a resolution of the display device and a resolution of the camera according to an application scenario; The step of controlling the camera to move on the X-axis and the Y-axis according to the central coordinates of the characteristic pattern in the adjustment image comprises: Controlling the camera to move on the X-axis and the Y-axis, detecting the central coordinates of the characteristic pattern in the adjustment image before and after the movement, and calculating the proportional relationship between the moving distance of the camera on the X-axis and the Y-axis and the pixel deviation according to the central coordinates of the characteristic pattern in the adjustment image before and after the movement; The moving distance of the camera on the X-axis and the Y-axis is calculated according to the proportional relationship and the target proportional parameter.

7. The method according to any one of claims 1 to 6, characterized in that The characteristic pattern is a circular pattern, and after each movement of the camera, the display device is photographed using the camera to obtain an adjusted image, the method further includes: All circular features in the adjusted image are detected by using the Hough circle to obtain the feature pattern in the adjusted image.

8. A system for automatic camera adjustment, characterized in that: The camera is connected to a control mechanism, and the control mechanism includes a moving mechanism of an X-axis, a Y-axis, a Z-axis, a θ-axis, a θX-axis, and a θY-axis, wherein the θ-axis is connected to the X-axis and the Y-axis, the θX-axis and the θY-axis are connected to the θ-axis, the X-axis is a lateral moving axis of the camera in the horizontal direction, the Y-axis is a vertical moving axis of the camera in the horizontal direction, the Z-axis is a moving axis perpendicular to a shooting plane, the θ-axis is a rotation axis of the camera in the horizontal direction, the θX-axis is a vertical swing angle axis of the camera in the X direction, and the θY-axis is a vertical swing angle axis of the camera in the Y direction; The system comprises: a photographing unit, used for controlling the display device to display a calibration image, and using the camera to photograph the display device after each movement of the camera to obtain an adjusted image, wherein the calibration image includes a plurality of characteristic patterns, wherein the characteristic patterns include a first characteristic pattern whose center coincides with the center of the calibration image, and second characteristic patterns distributed around the first characteristic pattern; A first adjustment unit, used for determining a feature center point of the first feature pattern in the adjustment image, and controlling the camera to move on the Z axis according to a length from the feature center point to an edge of the first feature pattern; a second adjustment unit, which determines a first reference line in the second characteristic pattern in the adjustment image, and controls the camera to move on the θY axis according to the slope of the first reference line, or determines a second reference line in the second characteristic pattern in the adjustment image, and controls the camera to move on the θX axis according to the slope of the second reference line, wherein the first reference line and the second reference line are perpendicular to each other, the first reference line is formed by connecting the center points of the second characteristic patterns on the left and right sides of the adjustment image, and the second reference line is formed by connecting the center points of the second characteristic patterns on the upper and lower sides of the adjustment image; a third adjustment unit, which determines the number of transition pixels of the characteristic pattern in the adjustment image, and controls the camera to move on the Z axis according to the number of transition pixels; a fourth adjustment unit, configured to determine a third reference line in the second characteristic pattern in the adjustment image, and control the camera to rotate on the θ axis according to an angle of the third reference line, wherein the third reference line is formed by connecting center points or edge points of the second characteristic pattern; A fifth adjustment unit controls the camera to move on the X-axis and the Y-axis according to the central coordinates of the characteristic pattern in the adjustment image.

9. A device for automatic camera adjustment, characterized in that: The device comprises: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a program stored thereon, wherein the program, when executed on a computer, performs the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Vehicle-mounted camera calibration method and device and terminal equipment

    CN112912932A

  • Image processing method, electronic equipment and storage medium

    CN117635598A