Camera preset position automatic deviation correction method, device and computer equipment
By calculating the feature point matching and homography matrix of the reference image of the preset position of the camera and the image to be detected, the offset is automatically calculated and corrected, and the problems of camera preset position accuracy error and manual deviation correction are solved, automatic deviation correction is achieved, and the efficiency and accuracy of the monitoring system are improved.
Patent Information
- Application Number
- CN202111418908.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-26
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2041-11-26
AI Technical Summary
The load rotational inertia carried by the camera gimbal leads to a large torque of the drive motor, and the spacing of the mechanical gears and the accuracy of the structural parts cause errors in the preset accuracy. Calling the preset position for a long time will accumulate errors, causing preset position offsets. The current preset position correction mainly relies on manual operations, which consumes time and effort and wastes human resources.
By obtaining the reference image of the preset position and the image to be detected, a coordinate system is established, a feature point is found and matched, a homophobic matrix is calculated, and the vertex coordinates of the overlapping part of the image to be detected in the reference image in the reference image is calculated, and the offset is calculated and the preset position is corrected.
Automatic deviation correction of camera preset position is realized, effectively ensuring that the camera returns to the set preset position, reducing the need for manual operation, and improving the efficiency and accuracy of the monitoring system.
Smart Images

Figure CN114078161B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automatic control of power systems, and in particular to a method, device, computer equipment, storage medium and computer program product for automatic correction of camera preset positions. Background Art
[0002] The load inertia of the camera pan / tilt is large, which determines that the pan / tilt drive motor torque must be large. The spacing of the mechanical gears of the drive motor and the accuracy of the structural parts cause errors in the preset position accuracy. In addition, long-term use of the preset position will cause the error to accumulate, causing the preset position to deviate from the original position. The deviation of the camera preset position affects the normal monitoring of the monitoring system. At present, the preset position correction is mainly completed by manual operation, which is time-consuming and labor-intensive, wasting a lot of human resources. Summary of the invention
[0003] Based on this, it is necessary to provide a method, device, computer equipment, computer-readable storage medium and computer program product that can realize automatic correction of camera preset positions in order to solve the above-mentioned technical problems.
[0004] In a first aspect, the present application provides a method for automatically correcting camera preset positions. The method comprises:
[0005] Get the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0,0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image;
[0006] Find the feature points of the reference image and the image to be detected, and match the feature points to obtain a matching pair;
[0007] Compute the homography matrix from the matching pairs;
[0008] Obtaining vertex coordinates of the overlapping portion of the image to be detected in the reference image according to the homography matrix;
[0009] The offset of the image to be detected compared with the reference image in the x and y directions is calculated according to the vertex coordinates, and the preset position correction is performed according to the offset.
[0010] In one embodiment, the method further comprises:
[0011] When the offset of each vertex of the image to be detected in the x-direction is equal, and / or the offset of each vertex of the image to be detected in the y-direction is equal, the camera automatically performs preset position correction according to the offset; otherwise, the preset position correction is performed by manually controlling the rotation of the camera; wherein the offset of each vertex is the offset of the vertex in the image to be detected compared to the corresponding vertex in the reference image.
[0012] In one embodiment, the method further comprises:
[0013] When the vertex coordinates of the overlapping part are (x 1 ,0),(x 0 ,0),(x 0 ,y 1 ), (x 1 ,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 -y 0 ;
[0014] When the vertex coordinates of the overlapping part are (0,y 1 ), (x 1 ,y 1 ), (x 1 ,y 0 ), (0,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 -x 0 , the offset in the y direction is Δy=y 1 ;
[0015] When the vertex coordinates of the overlapping part are (x 1 ,y 1 ), (x 0 ,y 1 ), (x 0 ,y 0 ), (x 1 ,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 ;
[0016] When the vertex coordinates of the overlapping part are (0,0), (x 1 ,0),(x 1 ,y 1 ), (0,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 0 -x 1 , the offset in the y direction is Δy=y0 -y 1 .
[0017] In one embodiment, the method further comprises:
[0018] After performing the preset position correction, re-capture the image and determine whether the image is offset. If it is offset, re-execute the preset position correction process, otherwise, complete the correction.
[0019] In one embodiment, the method further comprises:
[0020] Detect the clarity, brightness and color deviation of the image to be detected;
[0021] When at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, the correction is stopped; otherwise, the feature points of the reference image and the image to be detected are found.
[0022] In one embodiment, detecting the clarity, brightness and color deviation of the image to be detected includes:
[0023] The image to be detected is converted into a grayscale image and the blur amount is calculated. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0024] Calculate the mean and variance of the grayscale image of the image to be detected, and use the mean and variance to calculate the offset mean; obtain the brightness coefficient according to the offset mean, and when the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0025] The RGB space of the image to be detected is converted to the Lab space; the mean and variance of the image to be detected on the a and b components are calculated. When the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0026] In a second aspect, the present application also provides a camera preset position automatic deviation correction device. The device comprises:
[0027] The image acquisition module is used to obtain the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0,0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image;
[0028] A feature matching module is used to find feature points of the reference image and the image to be detected, and to match the feature points to obtain a matching pair;
[0029] A homography matrix acquisition module is used to calculate the homography matrix according to the matching pairs;
[0030] An overlapping part acquisition module is used to obtain the vertex coordinates of the overlapping part of the image to be detected in the reference image according to the homography matrix;
[0031] The correction module is used to calculate the offset of the image to be detected compared with the reference image in the x and y directions according to the vertex coordinates, and perform preset position correction according to the offset.
[0032] In a third aspect, the present application further provides a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned camera preset position automatic deviation correction method are implemented.
[0033] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above-mentioned method for automatically correcting the camera preset position when the computer program is executed by a processor.
[0034] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned camera preset position automatic deviation correction method are implemented.
[0035] The above-mentioned method, device, computer equipment, storage medium and computer program product for automatic correction of camera preset positions obtain the vertex coordinates of the overlapping part of the image to be detected at the preset position in the reference image, calculate the offset of the image to be detected in the x and y directions compared with the reference image according to the vertex coordinates, and perform preset position correction according to the offset, thereby realizing automatic correction of the preset position and effectively ensuring that the camera is restored to the set preset position. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flowchart of a method for automatically correcting camera pre-positioning in one embodiment;
[0037] Figure 2 is a schematic diagram of a process of image quality detection in one embodiment;
[0038] Figure 3 A schematic diagram of a flow chart of a method for automatically correcting camera pre-positioning in another embodiment;
[0039] Figure 4 It is a structural block diagram of a camera preset position automatic deviation correction device in one embodiment;
[0040] Figure 5 It is a structural block diagram of a camera preset position automatic deviation correction device in another embodiment;
[0041] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0042] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0043] In one embodiment, Figure 1 As shown, a method for automatically correcting the preset position of a camera is provided. This embodiment uses the method applied to a terminal as an example for explanation. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps:
[0044] Step 102: Obtain the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0, 0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image.
[0045] Specifically, the system is started, the camera is scanned to obtain camera-related information, or camera-related information is manually input to obtain a list of target cameras, and the reference images and images to be detected of all preset positions of each camera are batch acquired.
[0046] Step 104 , searching for feature points of the reference image and the image to be detected, and performing feature point matching to obtain a matching pair.
[0047] Optionally, use the SIFT algorithm to find the feature points of the two images, and use BruteForceMatcher to match the feature points to obtain matching pairs.
[0048] Step 106, calculating the homography matrix according to the matching pairs.
[0049] Specifically, the pixel coordinates corresponding to the matching pair are found and the homography matrix is calculated. The homography matrix constrains the 2D homogeneous coordinates of the same 3D space point in two pixel planes.
[0050] Step 108 , obtaining vertex coordinates of the overlapping portion of the image to be detected in the reference image according to the homography matrix.
[0051] Specifically, based on the homography matrix, the positions of the four vertices of the image to be detected in the reference image are calculated. Some positions may have exceeded the field of view of the reference image. Therefore, it is only necessary to obtain the vertices of the image to be detected in the reference image and the intersection with the boundary of the reference image. The enclosed polygon is the overlapping part, and the vertex coordinates of the overlapping part are obtained.
[0052] Step 110 , calculating the offset of the image to be detected compared with the reference image in the x and y directions according to the vertex coordinates, and performing pre-position correction according to the offset.
[0053] In one embodiment, the correction method further includes:
[0054] When the offset of each vertex of the image to be detected in the x-direction is equal, and / or the offset of each vertex of the image to be detected in the y-direction is equal, the camera automatically performs preset position correction according to the offset; otherwise, the preset position correction is performed by manually controlling the rotation of the camera; wherein the offset of each vertex is the offset of the vertex in the image to be detected compared to the corresponding vertex in the reference image.
[0055] Specifically, when the offset of each vertex of the image to be detected in the x direction is equal, and / or the offset of each vertex of the image to be detected in the y direction is equal, that is, the camera only moves up, down, left, and right, the deviation between the current image to be detected and the preset reference image is calculated, and the PTZ parameters that need to be corrected are sent to the target camera according to the calculation result of the offset, and the camera automatically performs preset position correction. When the image to be detected is offset in other directions, that is, the camera is skewed, or there is no overlapping area between the image to be detected and the reference image, the camera rotation is manually controlled according to the actual offset to correct the deviation. The system will synchronize the current manually corrected PTZ correction amount to each set preset position, eliminating the tedious steps of repeatedly correcting the camera preset position. In the process of manually adjusting the camera, the system also has an auxiliary image comparison tool to facilitate manual and precise adjustment of the preset position.
[0056] In one embodiment, the camera preset position automatic deviation correction method further includes:
[0057] When the vertex coordinates of the overlapping part are (x 1 ,0),(x 0 ,0),(x 0 ,y 1 ), (x 1 ,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 -y 0 ;
[0058] When the vertex coordinates of the overlapping part are (0,y 1 ), (x 1 ,y 1 ), (x 1 ,y 0 ), (0,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 -x 0 , the offset in the y direction is Δy=y 1 ;
[0059] When the vertex coordinates of the overlapping part are (x 1 ,y 1 ), (x 0 ,y 1 ), (x 0 ,y 0 ), (x 1 ,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 ;
[0060] When the vertex coordinates of the overlapping part are (0,0), (x 1 ,0),(x 1 ,y 1 ), (0,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 0 -x 1 , the offset in the y direction is Δy=y 0 -y 1 .
[0061] In one embodiment, the correction method further includes:
[0062] After performing the preset position correction, re-capture the image and determine whether the image is offset. If it is offset, re-execute the preset position correction process, otherwise, complete the correction.
[0063] In the above-mentioned camera preset position automatic correction method, by obtaining the vertex coordinates of the overlapping part of the image to be detected at the preset position in the reference image, the offset of the image to be detected in the x and y directions compared with the reference image is calculated according to the vertex coordinates, and the preset position correction is performed according to the offset, thereby realizing automatic correction of the preset position and effectively ensuring that the camera is restored to the set preset position.
[0064] The above embodiment describes the process of automatic correction of camera preset position. Now, an embodiment is used to describe the process of image quality detection of the image to be detected in the correction method. Figure 2 As shown, in one embodiment, the correction method further includes:
[0065] Step 202: Detect the clarity, brightness and color deviation of the image to be detected.
[0066] Step 204: when at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, stop correcting the deviation; otherwise, find the feature points of the reference image and the image to be detected.
[0067] Regarding step 202 in the above embodiment, in another embodiment, it further specifically includes:
[0068] The image to be detected is converted into a grayscale image and the blur amount is calculated. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0069] Specifically, first set the image blur threshold, then convert the image to be detected into a grayscale image using the cvtColor() function, and then use the Laplacian() operator to calculate the blur amount in the image to be detected, and compare the returned blur amount with the blur threshold. When the blur amount is higher than the threshold, it is determined that the clarity of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0070] Calculate the mean and variance of the grayscale image of the image to be detected, and use the mean and variance to calculate the offset mean; obtain the brightness coefficient according to the offset mean, and when the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0071] Specifically, the image to be detected is converted into a grayscale image. First, the mean offset of the grayscale image pixels is set to 128, and then the mean and variance of the image to be detected on the grayscale image are calculated, and the offset mean is calculated using the mean and variance. The brightness coefficient k can be further obtained by the offset mean. If the brightness coefficient k>1, the brightness of the image to be detected is normal and meets the requirements; if the brightness coefficient 1>k>0, the image is too bright; if the brightness coefficient k<0, the image is too dark.
[0072] Convert the RGB space of the image to be detected to the Lab space; calculate the mean and variance of the a and b components of the image to be detected. When the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements;
[0073] Specifically, the RGB space of the image to be detected is converted to the CIE Lab space, where L represents the image brightness, a represents the red / green component of the image, and b represents the yellow / blue component of the image; the mean and variance of the image to be detected on the a and b components are calculated, and when the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements. If the image to be detected has color deviation, the mean on the a and b components will deviate far from the origin, and the variance will also be small; a>0, reddish, otherwise greenish; b>0, yellowish, otherwise blueish.
[0074] In the above embodiment, the imaging quality of the camera is evaluated, including analyzing and determining the clarity, brightness and color deviation of the image to be detected, so as to ensure the availability of the current monitoring image.
[0075] In one embodiment, Figure 3 As shown, a method for automatically correcting the camera preset position is also provided, which specifically includes:
[0076] Step 302: Obtain the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0, 0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image.
[0077] Specifically, the system is started, the camera is scanned to obtain camera-related information, or camera-related information is manually input to obtain a list of target cameras, and the reference images and images to be detected of all preset positions of each camera are batch acquired.
[0078] Step 304, converting the image to be detected into a grayscale image and calculating the blur amount. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement.
[0079] Specifically, first set the image blur threshold, then convert the image to be detected into a grayscale image using the cvtColor() function, and then use the Laplacian() operator to calculate the blur amount in the image to be detected, and compare the returned blur amount with the blur threshold. When the blur amount is higher than the threshold, it is determined that the clarity of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0080] Step 306, calculate the mean and variance of the grayscale image of the image to be detected, and use the mean and variance to calculate the offset mean; obtain the brightness coefficient according to the offset mean, and when the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement.
[0081] Specifically, the image to be detected is converted into a grayscale image. First, the mean offset of the grayscale image pixels is set to 128, and then the mean and variance of the image to be detected on the grayscale image are calculated, and the offset mean is calculated using the mean and variance. The brightness coefficient k can be further obtained by the offset mean. If the brightness coefficient k>1, the brightness of the image to be detected is normal and meets the requirements; if the brightness coefficient 1>k>0, the image is too bright; if the brightness coefficient k<0, the image is too dark.
[0082] Step 308, convert the RGB space of the image to be detected to the Lab space; calculate the mean and variance of the image to be detected on the a and b components, and when the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0083] Specifically, the RGB space of the image to be detected is converted to the CIE Lab space, where L represents the image brightness, a represents the red / green component of the image, and b represents the yellow / blue component of the image; the mean and variance of the image to be detected on the a and b components are calculated, and when the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements. If the image to be detected has color deviation, that is, it does not meet the requirements, the mean on the a and b components will deviate far from the origin, and the variance will also be small; a>0, reddish, otherwise greenish; b>0, yellowish, otherwise blueish.
[0084] Step 310: When at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, stop correcting the deviation; otherwise, proceed to the next step.
[0085] Step 312, finding feature points of the reference image and the image to be detected, and performing feature point matching to obtain a matching pair.
[0086] Specifically, the SIFT algorithm is used to find the feature points of the two images, and the BruteForceMatcher is used to match the feature points to obtain a matching pair.
[0087] Step 314, calculating the homography matrix according to the matching pairs.
[0088] Specifically, the pixel coordinates corresponding to the matching pair are found and the homography matrix is calculated. The homography matrix constrains the 2D homogeneous coordinates of the same 3D space point in two pixel planes.
[0089] Step 316: Obtain the vertex coordinates of the overlapping portion of the image to be detected in the reference image according to the homography matrix.
[0090] Specifically, based on the homography matrix, the positions of the four vertices of the image to be detected in the reference image are calculated. Some positions may have exceeded the field of view of the reference image. Therefore, it is only necessary to obtain the vertices of the image to be detected in the reference image and the intersection with the boundary of the reference image. The enclosed polygon is the overlapping part, and the vertex coordinates of the overlapping part are obtained.
[0091] Specifically, when the vertex coordinates of the overlapping part are (x 1 ,0),(x 0 ,0),(x 0 ,y 1 ), (x 1 ,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 1, the offset in the y direction is Δy=y 1 -y 0 ;
[0092] When the vertex coordinates of the overlapping part are (0,y 1 ), (x 1 ,y 1 ), (x 1 ,y 0 ), (0,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 -x 0 , the offset in the y direction is Δy=y 1 ;
[0093] When the vertex coordinates of the overlapping part are (x 1 ,y 1 ), (x 0 ,y 1 ), (x 0 ,y 0 ), (x 1 ,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 ;
[0094] When the vertex coordinates of the overlapping part are (0,0), (x 1 ,0),(x 1 ,y 1 ), (0,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 0 -x 1 , the offset in the y direction is Δy=y 0 -y 1 .
[0095] Step 318, when the offset of each vertex of the image to be detected in the x-direction is equal, and / or the offset of each vertex of the image to be detected in the y-direction is equal, the camera automatically performs preset position correction according to the offset; otherwise, the preset position correction is performed by manually controlling the rotation of the camera; wherein the offset of each vertex is the offset of the vertex in the image to be detected compared to the corresponding vertex in the reference image.
[0096] Specifically, when the offset of each vertex of the image to be detected in the x direction is equal, and / or the offset of each vertex of the image to be detected in the y direction is equal, that is, the camera only moves up, down, left, and right, the deviation between the current camera image to be detected and the preset reference image is calculated, and the PTZ parameters that need to be corrected are sent to the target camera according to the calculated offset, and the camera automatically performs preset position correction. When the image to be detected is offset in other directions, that is, the camera is skewed, or there is no overlapping area between the image to be detected and the reference image, the deviation is corrected by manually controlling the rotation of the camera according to the actual offset. The system will synchronize the current manually corrected PTZ correction amount to each set preset position, eliminating the tedious steps of repeatedly correcting the camera preset position. In the process of manually adjusting the camera, the system also has an auxiliary image comparison tool to facilitate manual and precise adjustment of the preset position.
[0097] Step 320, after performing the preset position correction, re-capture the image and determine whether the image is offset. If it is offset, re-execute steps 312 to 318, otherwise, complete the correction.
[0098] In the above-mentioned method for automatic correction of camera preset positions, the imaging quality of the camera is first evaluated, including analyzing and determining the clarity, brightness and color deviation of the image to be detected, so as to ensure the availability of the current monitoring screen, and then the vertex coordinates of the overlapping part of the image to be detected at the preset position in the reference image are obtained, the offset of the image to be detected in the x and y directions compared with the reference image is calculated according to the vertex coordinates, and the preset position correction is performed according to the offset, thereby realizing automatic correction of the preset position; when the camera is tilted or the offset is too large, the preset position correction is performed by manually controlling the rotation of the camera, effectively ensuring that the camera is restored to the set preset position.
[0099] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0100] Based on the same inventive concept, the embodiment of the present application also provides a camera preset position automatic deviation correction device for implementing the camera preset position automatic deviation correction method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more camera preset position automatic deviation correction device embodiments provided below can refer to the limitations of the camera preset position automatic deviation correction method above, and will not be repeated here.
[0101] In one embodiment, Figure 4 As shown, a camera preset position automatic correction device is provided, comprising: an image acquisition module, a feature matching module, a homography matrix acquisition module, an overlapping part acquisition module and a correction module, wherein:
[0102] The image acquisition module is used to obtain the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0,0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image;
[0103] A feature matching module is used to find feature points of the reference image and the image to be detected, and to match the feature points to obtain a matching pair;
[0104] A homography matrix acquisition module is used to calculate the homography matrix according to the matching pairs;
[0105] An overlapping part acquisition module is used to obtain the vertex coordinates of the overlapping part of the image to be detected in the reference image according to the homography matrix;
[0106] The correction module is used to calculate the offset of the image to be detected compared with the reference image in the x and y directions according to the vertex coordinates, and perform preset position correction according to the offset.
[0107] In one embodiment, the device further comprises an image quality detection module, such as Figure 5 As shown, the image quality detection module is used to detect the clarity, brightness and color deviation of the image to be detected. When at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, the correction is stopped; otherwise, the feature points of the reference image and the image to be detected are found.
[0108] In one embodiment, the image quality detection module further includes a clarity detection unit, a brightness detection unit and a color deviation detection unit. Figure 5 As shown:
[0109] The clarity detection unit is used to convert the image to be detected into a grayscale image and calculate the blur amount. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0110] The brightness detection unit is used to calculate the mean and variance of the grayscale image of the image to be detected, calculate the offset mean using the mean and variance, and obtain the brightness coefficient according to the offset mean. When the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0111] The color deviation detection unit is used to convert the RGB space of the image to be detected into the Lab space, calculate the mean and variance of the a and b components of the image to be detected, and when the mean and variance are not greater than the preset values, determine that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0112] Each module in the above-mentioned camera preset position automatic deviation correction device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0113] In one embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 6 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the offset of the image to be detected. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for automatically correcting the preset position of a camera is implemented.
[0114] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0115] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0116] Get the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0,0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image;
[0117] Find the feature points of the reference image and the image to be detected, and match the feature points to obtain a matching pair;
[0118] Compute the homography matrix from the matching pairs;
[0119] Obtaining vertex coordinates of the overlapping portion of the image to be detected in the reference image according to the homography matrix;
[0120] The offset of the image to be detected compared with the reference image in the x and y directions is calculated according to the vertex coordinates, and the preset position correction is performed according to the offset.
[0121] In one embodiment, when the processor executes the computer program, it also implements:
[0122] When the offset of each vertex of the image to be detected in the x-direction is equal, and / or the offset of each vertex of the image to be detected in the y-direction is equal, the camera automatically performs preset position correction according to the offset; otherwise, the preset position correction is performed by manually controlling the rotation of the camera; wherein the offset of each vertex is the offset of the vertex in the image to be detected compared to the corresponding vertex in the reference image.
[0123] In one embodiment, when the processor executes the computer program, it also implements:
[0124] When the vertex coordinates of the overlapping part are (x 1 ,0),(x 0 ,0),(x 0 ,y 1 ), (x 1 ,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 -y 0 ;
[0125] When the vertex coordinates of the overlapping part are (0,y 1 ), (x 1 ,y 1 ), (x 1 ,y 0 ), (0,y 0 ), determine the offset of the image to be detected in the x direction Δx = x1 -x 0 , the offset in the y direction is Δy=y 1 ;
[0126] When the vertex coordinates of the overlapping part are (x 1 ,y 1 ), (x 0 ,y 1 ), (x 0 ,y 0 ), (x 1 ,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 ;
[0127] When the vertex coordinates of the overlapping part are (0,0), (x 1 ,0),(x 1 ,y 1 ), (0,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 0 -x 1 , the offset in the y direction is Δy=y 0 -y 1 .
[0128] In one embodiment, when the processor executes the computer program, it also implements:
[0129] After performing the preset position correction, re-capture the image and determine whether the image is offset. If it is offset, re-execute the preset position correction process, otherwise, complete the correction.
[0130] In one embodiment, when the processor executes the computer program, it also implements:
[0131] Detect the clarity, brightness and color deviation of the image to be detected;
[0132] When at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, the correction is stopped; otherwise, the feature points of the reference image and the image to be detected are found.
[0133] In one embodiment, when the processor executes the computer program, it also implements:
[0134] The image to be detected is converted into a grayscale image and the blur amount is calculated. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0135] Calculate the mean and variance of the grayscale image of the image to be detected, and use the mean and variance to calculate the offset mean; obtain the brightness coefficient according to the offset mean, and when the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0136] The RGB space of the image to be detected is converted to the Lab space; the mean and variance of the image to be detected on the a and b components are calculated. When the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0137] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0138] Get the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0,0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image;
[0139] Find the feature points of the reference image and the image to be detected, and match the feature points to obtain a matching pair;
[0140] Compute the homography matrix from the matching pairs;
[0141] Obtaining vertex coordinates of the overlapping portion of the image to be detected in the reference image according to the homography matrix;
[0142] The offset of the image to be detected compared with the reference image in the x and y directions is calculated according to the vertex coordinates, and the preset position correction is performed according to the offset.
[0143] In one embodiment, when the processor executes the computer program, it also implements:
[0144] When the offset of each vertex of the image to be detected in the x-direction is equal, and / or the offset of each vertex of the image to be detected in the y-direction is equal, the camera automatically performs preset position correction according to the offset; otherwise, the preset position correction is performed by manually controlling the rotation of the camera; wherein the offset of each vertex is the offset of the vertex in the image to be detected compared to the corresponding vertex in the reference image.
[0145] In one embodiment, when the processor executes the computer program, it also implements:
[0146] When the vertex coordinates of the overlapping part are (x 1 ,0),(x 0 ,0),(x 0 ,y1 ), (x 1 ,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 -y 0 ;
[0147] When the vertex coordinates of the overlapping part are (0,y 1 ), (x 1 ,y 1 ), (x 1 ,y 0 ), (0,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 -x 0 , the offset in the y direction is Δy=y 1 ;
[0148] When the vertex coordinates of the overlapping part are (x 1 ,y 1 ), (x 0 ,y 1 ), (x 0 ,y 0 ), (x 1 ,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 ;
[0149] When the vertex coordinates of the overlapping part are (0,0), (x 1 ,0),(x 1 ,y 1 ), (0,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 0 -x 1 , the offset in the y direction is Δy=y 0 -y 1 .
[0150] In one embodiment, when the processor executes the computer program, it also implements:
[0151] After performing the preset position correction, re-capture the image and determine whether the image is offset. If it is offset, re-execute the preset position correction process, otherwise, complete the correction.
[0152] In one embodiment, when the processor executes the computer program, it also implements:
[0153] Detect the clarity, brightness and color deviation of the image to be detected;
[0154] When at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, the correction is stopped; otherwise, the feature points of the reference image and the image to be detected are found.
[0155] In one embodiment, when the processor executes the computer program, it also implements:
[0156] The image to be detected is converted into a grayscale image and the blur amount is calculated. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0157] Calculate the mean and variance of the grayscale image of the image to be detected, and use the mean and variance to calculate the offset mean; obtain the brightness coefficient according to the offset mean, and when the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0158] The RGB space of the image to be detected is converted to the Lab space; the mean and variance of the image to be detected on the a and b components are calculated. When the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0159] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the following steps:
[0160] Get the preset reference image and the image to be detected, and establish a coordinate system with the plane where the reference image is located as the xy plane. The coordinates of the four vertices of the reference image are (0,0), (x 0 ,0),(x 0 ,y 0 ), (0,y 0 ), the size of the image to be detected is the same as that of the reference image;
[0161] Find the feature points of the reference image and the image to be detected, and match the feature points to obtain a matching pair;
[0162] Compute the homography matrix from the matching pairs;
[0163] Obtaining vertex coordinates of the overlapping portion of the image to be detected in the reference image according to the homography matrix;
[0164] The offset of the image to be detected compared with the reference image in the x and y directions is calculated according to the vertex coordinates, and the preset position correction is performed according to the offset.
[0165] In one embodiment, when the processor executes the computer program, it also implements:
[0166] When the offset of each vertex of the image to be detected in the x-direction is equal, and / or the offset of each vertex of the image to be detected in the y-direction is equal, the camera automatically performs preset position correction according to the offset; otherwise, the preset position correction is performed by manually controlling the rotation of the camera; wherein the offset of each vertex is the offset of the vertex in the image to be detected compared to the corresponding vertex in the reference image.
[0167] In one embodiment, when the processor executes the computer program, it also implements:
[0168] When the vertex coordinates of the overlapping part are (x 1 ,0),(x 0 ,0),(x 0 ,y 1 ), (x 1 ,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 -y 0 ;
[0169] When the vertex coordinates of the overlapping part are (0,y 1 ), (x 1 ,y 1 ), (x 1 ,y 0 ), (0,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 -x 0 , the offset in the y direction is Δy=y 1 ;
[0170] When the vertex coordinates of the overlapping part are (x 1 ,y 1 ), (x 0 ,y 1 ), (x 0 ,y 0 ), (x 1 ,y 0 ), determine the offset of the image to be detected in the x direction Δx = x 1 , the offset in the y direction is Δy=y 1 ;
[0171] When the vertex coordinates of the overlapping part are (0,0), (x 1 ,0),(x 1 ,y 1 ), (0,y 1 ), determine the offset of the image to be detected in the x direction Δx = x 0 -x 1, the offset in the y direction is Δy=y 0 -y 1 .
[0172] In one embodiment, when the processor executes the computer program, it also implements:
[0173] After performing the preset position correction, re-capture the image and determine whether the image is offset. If it is offset, re-execute the preset position correction process, otherwise, complete the correction.
[0174] In one embodiment, when the processor executes the computer program, it also implements:
[0175] Detect the clarity, brightness and color deviation of the image to be detected;
[0176] When at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, the correction is stopped; otherwise, the feature points of the reference image and the image to be detected are found.
[0177] In one embodiment, when the processor executes the computer program, it also implements:
[0178] The image to be detected is converted into a grayscale image and the blur amount is calculated. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0179] Calculate the mean and variance of the grayscale image of the image to be detected, and use the mean and variance to calculate the offset mean; obtain the brightness coefficient according to the offset mean, and when the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement;
[0180] The RGB space of the image to be detected is converted to the Lab space; the mean and variance of the image to be detected on the a and b components are calculated. When the mean and variance are not greater than the preset values, it is determined that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements.
[0181] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0182] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0183] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0184] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for automatically correcting camera preset positions, characterized in that: The method comprises: Obtain a preset reference image and an image to be detected, establish a coordinate system with the plane where the reference image is located as the xy plane, the coordinates of the four vertices of the reference image are (0,0), (x0,0), (x0,y0), (0,y0), and the image to be detected is the same size as the reference image; The image to be detected is converted into a grayscale image and the amount of blur is calculated. When the amount of blur is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirement, otherwise it does not meet the requirement; the mean and variance of the grayscale image of the image to be detected are calculated, and the offset mean is calculated using the mean and variance. The brightness coefficient is obtained according to the offset mean. When the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirement, otherwise it does not meet the requirement; the RGB space of the image to be detected is converted to the Lab space, and the mean and variance of the a and b components of the image to be detected are calculated. When the mean and variance are not greater than a preset value, it is determined that the color deviation of the image to be detected meets the requirement, otherwise it does not meet the requirement; When at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, stop correcting; otherwise, find the feature points of the reference image and the image to be detected, and perform feature point matching to obtain a matching pair; Calculating a homography matrix based on the matching pairs; Obtaining vertex coordinates of an overlapping portion of the image to be detected in the reference image according to the homography matrix; The offsets of the image to be detected compared to the reference image in the x and y directions are calculated according to the vertex coordinates, and the preset position correction is performed according to the offsets.
2. The method according to claim 1, characterized in that The method further comprises: When the offset of each vertex of the image to be detected in the x-direction is equal, and / or the offset of each vertex of the image to be detected in the y-direction is equal, the camera automatically performs preset position correction according to the offset; otherwise, the preset position correction is performed by manually controlling the rotation of the camera; wherein the offset of each vertex is the offset of the vertex in the image to be detected compared to the corresponding vertex in the reference image.
3. The method according to claim 1, characterized in that: The calculating, according to the vertex coordinates, the offset of the image to be detected compared to the reference image in the x and y directions comprises: When the vertex coordinates of the overlapping part are (x1,0), (x0,0), (x0,y1), (x1,y1), determining the offset Δx=x1 of the image to be detected in the x direction and the offset Δy=y1-y0 in the y direction; When the vertex coordinates of the overlapping part are (0, y1), (x1, y1), (x1, y0), (0, y0), determining the offset Δx=x1-x0 of the image to be detected in the x direction and the offset Δy=y1 in the y direction; When the vertex coordinates of the overlapping part are (x1, y1), (x0, y1), (x0, y0), (x1, y0), determining the offset Δx=x1 of the image to be detected in the x direction and the offset Δy=y1 in the y direction; When the vertex coordinates of the overlapping part are (0,0), (x1,0), (x1,y1), (0,y1), the offset Δx=x0-x1 of the image to be detected in the x direction and the offset Δy=y0-y1 in the y direction are determined.
4. The method according to claim 1, characterized in that The method further comprises: After the preset position deflection correction is performed, the image is recaptured and it is determined whether the image is offset. If it is offset, the preset position deflection correction process is re-executed, otherwise, the deflection correction is completed.
5. A camera preset position automatic deviation correction device, characterized in that: The device comprises: An image acquisition module is used to obtain a preset reference image and an image to be detected, and to establish a coordinate system with the plane where the reference image is located as an xy plane, wherein a vertex of the reference image is the origin of the coordinate system, and the coordinates of the four vertices of the reference image are respectively (0,0), (x0,0), (x0,y0), and (0,y0), and the image to be detected has the same size as the reference image; The quality detection module includes a clarity detection unit, a brightness detection unit and a color deviation detection unit; the clarity detection unit is used to convert the image to be detected into a grayscale image and calculate the blur amount. When the blur amount is higher than a threshold, it is determined that the clarity of the image to be detected meets the requirements, otherwise it does not meet the requirements; the brightness detection unit is used to calculate the mean and variance of the grayscale image of the image to be detected, calculate the offset mean using the mean and variance, and obtain the brightness coefficient according to the offset mean. When the brightness coefficient is greater than 1, it is determined that the brightness of the image to be detected meets the requirements, otherwise it does not meet the requirements; the color deviation detection unit is used to convert the RGB space of the image to be detected into the Lab space, calculate the mean and variance of the image to be detected on the a and b components, and when the mean and variance are not greater than a preset value, it is determined that the color deviation of the image to be detected meets the requirements, otherwise it does not meet the requirements; when at least one of the clarity, brightness and color deviation of the image to be detected does not meet the requirements, stop the deviation correction; A feature matching module, used to find feature points of the reference image and the image to be detected, and match the feature points to obtain a matching pair when the clarity, brightness and color deviation of the image to be detected meet the requirements; A homography matrix acquisition module, used for calculating the homography matrix according to the matching pair; An overlapping portion acquisition module, used for obtaining the vertex coordinates of the overlapping portion of the image to be detected in the reference image according to the homography matrix; The correction module is used to calculate the offset of the image to be detected compared with the reference image in the x and y directions according to the vertex coordinates, and perform preset position correction according to the offset.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
8. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Robot holder servo secondary alignment method and device
CN110084842A