Visual detection system, calibration method, device, and readable storage medium
By designing calibration board and processor analysis methods, multi-faceted calibration of linear array cameras is realized, solving the problems of incomplete detection objects and installation errors of linear array cameras, improving the accuracy and efficiency of the detection system, and reducing calibration costs.
Patent Information
- Application Number
- CN202211281537.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-19
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2042-10-19
AI Technical Summary
In the existing machine vision detection system, the detection objects of the linear array camera cannot obtain a complete image at once, and the installation errors of multiple linear array cameras make imaging consistency difficult to ensure, and the existing calibration methods are limited in accuracy and poor in applicability.
A calibration plate is designed, including a positioning area and multiple calibration areas, and the calibration images are collected through the camera device, and the processor analyzes the calibration information to realize the calibration of information such as focus, alignment, centering, deformation, viewing angle and color difference, and to build an independent coordinate system to reduce detection errors.
It improves the accuracy and efficiency of visual inspection, reduces calibration time and cost, and can obtain multiple calibration functions at one time, simplifies adjustment difficulty and meets high-precision requirements.
Smart Images

Figure CN115684012B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of visual detection technologies, and particularly relates to a visual detection system, a calibration method, a device and a readable storage medium. Background Art
[0002] In a machine vision detection system, line cameras are favored due to their high resolution, complete color models, controllable scanning frame rates, etc. Considering both detection accuracy and width, the detection object of the line camera usually moves at a constant speed when performing detection tasks. However, since a line camera can only scan one line of the object to be measured at a time and cannot obtain a complete image of the object to be measured at once, the quality of the collected image is affected. Moreover, when multiple line cameras are jointly detecting, due to installation errors of the cameras, it is difficult to ensure the collinearity of the scanning angle of the scanning line of one line camera and the scanning line of the adjacent line camera under specific working conditions. Therefore, in order to ensure the imaging consistency of the detection system, it is necessary to calibrate the cameras.
[0003] In related technologies, the camera attitude adjustment is realized by aligning the camera scanning line with the light rays of the linear light source. Its adjustment accuracy is limited to a certain extent, and it is difficult to realize functions such as camera centering and focusing, and its applicability is poor. Summary of the Invention
[0004] In view of this, the present application provides a visual detection system, a calibration method, a device and a readable storage medium, which can accurately and quickly realize the calibration of the visual detection system in multiple aspects by optimizing the calibration plate design.
[0005] According to one aspect of the present application, a visual detection system is provided, including:
[0006] An imaging device;
[0007] A calibration plate, located within the field of view of the imaging device. The calibration plate is provided with a positioning area and a calibration area. Both the positioning area and the calibration area have color differences from the background color of the calibration plate. The calibration area includes: a first calibration area, a second calibration area, a third calibration area, and a fourth calibration area. Among them, the first calibration area is used to determine the focusing information, alignment information and color difference information of the calibration image, the second calibration area is used to determine the centering information of the calibration image, the third calibration area determines the deformation information of the calibration image, and the fourth calibration area determines the viewing angle information, pixel equivalent information and color difference information of the calibration image;
[0008] A processor, electrically connected to the imaging device. The processor is used to process the calibration image collected by the imaging device to determine the calibration information of the imaging device. The calibration image shows the calibration plate.
[0009] According to another aspect of the present application, a calibration method is provided, including:
[0010] Obtain a calibration image collected by an imaging device, where the calibration image shows a calibration plate;
[0011] Determine a first region of interest in the calibration image, where the first region of interest includes two borders adjacent to the positioning region;
[0012] Construct a calibration coordinate system of the calibration image according to the first region of interest;
[0013] Process the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device;
[0014] Wherein, the calibration information includes at least one of the following: focusing information, chromatic aberration information, alignment information, centering information, viewing angle information, deformation information, and pixel equivalent information.
[0015] According to another aspect of the present application, there is provided a calibration device, including:
[0016] An acquisition module, configured to acquire a calibration image collected by an imaging device of a vision detection system, where the calibration image shows a calibration plate;
[0017] A positioning module, configured to determine a first region of interest in the calibration image, where the first region of interest includes two borders adjacent to the positioning region; and construct a calibration coordinate system of the calibration image according to the first region of interest;
[0018] A calibration module, configured to process the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device;
[0019] Wherein, the calibration information includes at least one of the following: focusing information, chromatic aberration information, alignment information, centering information, viewing angle information, deformation information, and pixel equivalent information.
[0020] According to another aspect of the present application, there is provided a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the above calibration method are implemented.
[0021] With the above technical solution, the vision detection system includes a camera device, a calibration plate, and a processor. When the system is calibrated, the camera device captures a calibration image of the calibration plate that can be acquired. The processor processes the calibration image and analyzes the calibration information of the camera device to facilitate the calibration adjustment of the spatial position of the camera device. Moreover, a positioning area is designed on the calibration plate, and an independent coordinate system is constructed using the positioning area to reduce the detection error caused by the rotation of the calibration plate. At the same time, there are multiple calibration areas on the calibration plate, and different calibration areas are used to achieve different calibration functions to measure whether the device itself of the current camera device is damaged or whether the installation position meets the standards, etc. Thus, while ensuring the vision detection accuracy and efficiency of the system, all the work of whether the images captured by the system meet the standards is achieved through one calibration plate, effectively reducing the time required for calibration. And since the results of multiple calibration functions can be obtained at one time, when performing calibration adjustment, the results of multiple calibration functions can be comprehensively considered for one-time adjustment control, reducing the adjustment difficulty, meeting the requirements of higher detection accuracy, and further helping to reduce the vision calibration cost.
[0022] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the description. And in order to make the above and other purposes, features, and advantages of the present application more obvious and understandable, the following specifically gives the specific implementation manners of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] The drawings described herein are used to provide a further understanding of the present application and form a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:
[0024] Figure 1 shows a schematic structural diagram of the vision detection system provided by an embodiment of the present application;
[0025] Figure 2 shows a schematic structural diagram of the calibration plate provided by an embodiment of the present application;
[0026] Figure 3 shows a schematic flowchart of the calibration method provided by an embodiment of the present application;
[0027] Figure 4 shows one of the schematic diagrams of the calibration method scene provided by an embodiment of the present application;
[0028] Figure 5 shows another schematic diagram of the calibration method scene provided by an embodiment of the present application;
[0029] Figure 6 shows a third schematic diagram of the calibration method scene provided by an embodiment of the present application;
[0030] Figure 7 Figure 4 shows a schematic diagram of the scenario of the calibration method provided by an embodiment of the present application;
[0031] Figure 8 Figure 5 shows a schematic diagram of the scenario of the calibration method provided by an embodiment of the present application;
[0032] Figure 9 Figure 6 shows a schematic structural diagram of the calibration device provided by an embodiment of the present application.
[0033] Reference numerals:
[0034] 110 Camera device, 120 Calibration plate, 130 Processor, 121 Positioning area, 1221 Second calibration area, 1222 Second calibration area, 1223 Third calibration area, 1224 Fourth calibration area, 201 First region of interest, 202 Second region of interest, 203 Third region of interest, 204 Fourth region of interest, 205 Fifth region of interest, 206 Sixth region of interest, 207 Seventh region of interest, 208 Eighth region of interest. Detailed implementation manners
[0035] The present application will be described in detail below with reference to the drawings and in combination with embodiments. It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other.
[0036] The embodiments of the present application will be described in detail below. The examples of the embodiments are shown in the drawings, where the same or similar reference numerals denote the same or similar elements or elements with the same or similar functions from beginning to end. The embodiments described below with reference to the drawings are exemplary and are only used to explain the present application, and cannot be construed as a limitation to the present application.
[0037] Those skilled in the art of the present technology can understand that, unless specifically stated otherwise, the singular forms "a", "an", "the" and "said" used herein may also include the plural forms. It should be further understood that the term "including" used in the specification of the present application means the presence of the described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their groups. It should be understood that when we say that an element is "connected" or "joined" to another element, it can be directly connected or joined to other elements, or there may also be intermediate elements. In addition, the "connection" or "joining" used herein may include wireless connection or wireless coupling. The phrase "and / or" used herein includes all or any unit and all combinations of one or more related listed items.
[0038] Now, exemplary embodiments according to the present application will be described in more detail with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many different forms and should not be construed as being limited only to the embodiments set forth herein. It should be understood that these embodiments are provided so that the disclosure of the present application is thorough and complete, and the concepts of these exemplary embodiments are fully conveyed to those of ordinary skill in the art.
[0039] In this embodiment, a vision detection system is provided, as Figure 1 and Figure 2 shown, the system includes: a camera device 110, a calibration plate 120, and a processor 130.
[0040] Specifically, the camera device 110 is used to capture images. The calibration plate 120 is located within the field of view of the camera device. The calibration plate 120 is used to inspect whether problems such as the installation position and device defects of the camera device 110 meet the standards, so that the images captured by the camera device 100 can be clearer, thereby improving the vision detection accuracy. The processor 130 is electrically connected to the camera device 110. The processor 130 is used to process the calibration images captured by the camera device 110 and determine the calibration information of the camera device 110. The calibration images show the calibration plate 120. The calibration plate 120 is provided with a positioning area 121 and a plurality of calibration areas. Both the positioning area 121 and the calibration areas have color differences from the plate background color of the calibration plate, so that the processor 130 can quickly locate and calibrate through the image parts corresponding to the positioning area 121 and the calibration areas. Among them, the plurality of calibration areas include: a first calibration area 1221, a second calibration area 1222, a third calibration area 1223, and a fourth calibration area 1224. The calibration information includes at least one of the following: focusing information, alignment information, centering information, viewing angle information, deformation information, pixel equivalent information, and color difference information. The first calibration area 1221 is used to verify whether the images captured by the camera device 110 are in focus and whether the left-right or up-down focus of the images is aligned; the second calibration area 1222 is used to verify whether the center of the field of view of the camera device 110 and the actual center of the calibration plate are on the same vertical line; the third calibration area 1223 is used to verify whether the images captured by the camera device 110 are deformed; the fourth calibration area 124 is used to determine whether there is local color difference in the images captured by the camera device 110, whether the pixel equivalent of the images captured by the camera device 110 meets the standards, and whether the viewing angle of the camera device 110 is perpendicular, that is, whether the camera device 110 is perpendicular to the moving direction of the camera device 110.
[0041] In this embodiment, when the system is calibrated, the imaging device 110 captures a calibration image of the calibration plate 120 that can be acquired. The processor 130 first fits two straight lines corresponding to the positioning area 121 through the region of interest of the positioning area 121 in the calibration image, and constructs a calibration coordinate system for this calibration with the intersection point of the two straight lines and one of the straight lines. By comparing the calibration coordinate system constructed from the calibration image with the standard coordinate system of the calibration plate 120, the swing position offset of the calibration plate 120 corresponding to the calibration image relative to the calibration position can be determined. Thus, when analyzing the calibration information of the imaging device 110 through the calibration image, the region of interest for analyzing the calibration information can be moved according to the offset amount to accurately obtain the region of interest, so that a reliable detection object can be obtained for subsequent detection of the calibration information, thereby reducing the detection error caused by the swing position offset of the calibration plate 120 or the imaging device 100, and facilitating the calibration position adjustment or maintenance of the imaging device 100 or the calibration plate 120. At the same time, multiple calibration areas are designed on the calibration plate 120, and different calibration areas are used to achieve different calibration functions. Thus, while ensuring the accuracy and efficiency of the system's visual detection, all the work of determining whether the images captured by the system meet the standards can be achieved through one calibration plate 120, effectively reducing the time required for calibration. Moreover, since the results of multiple calibration functions can be obtained at one time, when performing calibration adjustment, the results of multiple calibration functions can be comprehensively considered for one-time adjustment control, reducing the adjustment difficulty, and further helping to reduce the visual calibration cost.
[0042] It is worth mentioning that the imaging device can be one or more line array CCD cameras, infrared cameras, etc.
[0043] It can be understood that it is only necessary that the positioning area 121 and the calibration area are different from the plate background color of the calibration plate 120, that is, the color of the non-calibration area of the calibration plate 120. The present application does not make specific limitations on the color of the calibration area and the plate background color. For example, as Figure 2 shown, the positioning area 121 and the calibration area are designed to be black, and the plate background color is designed to be white to facilitate quick identification of pixel grayscale. Further, the positioning area 121 and the calibration area can also be sunken, convex or flush with the non-calibration area of the calibration plate 120 to form a visual difference.
[0044] In an actual application scenario, such as Figure 2As shown, the positioning area 121 is configured as a rectangular frame structure. Thus, the outer frames of the positioning area 121 are all straight lines, and adjacent frames are perpendicular to each other. The distance between the outer frame line of the positioning area 121 and the edge of the corresponding calibration plate 120 is less than the first preset distance. That is, the positioning area 121 is arranged close to the edge of the calibration plate 120. Among them, the first preset distance can be reasonably set according to the resolution of the imaging device and the size of the calibration plate 120. For example, the first preset distance can be set to 0.1 cm, 1 cm, 3 cm, 8 cm or 20 cm.
[0045] In this embodiment, since there is a color difference between the positioning area 121 and the plate background color, the color difference between the positioning area 121 and the plate background color can be used to quickly identify the differences between the pixel values of the pixel points in the calibration image. Furthermore, the contour of the positioning area 121 in the calibration image can be determined. Then, the calibration coordinate system is constructed using this contour to facilitate the selection of the region of interest for calibration through the calibration coordinate system. This avoids the deviation in the selection of the region of interest caused by the non-standard placement of the calibration plate 120, not only improving the accuracy of subsequent calibration information detection, but also increasing the tolerance rate of the calibration plate 120 placement, which helps to reduce the operation difficulty of the visual calibration system.
[0046] In the actual application scenario, as Figure 2 shown, the first calibration area 1221 includes four rectangular frame structures, and the four rectangular frame structures of the first calibration area 1221 are correspondingly distributed at the four corners of the positioning area 121. Further, the distances between the center points of the four rectangular frame structures and their corresponding calibration plate edges are the same.
[0047] In this embodiment, not only can the image gradient and transition pixels be determined through the part corresponding to the first calibration area 1221 in the calibration image to judge whether the imaging device 110 is focused or whether the calibration image is in focus up and down or left and right, but also the average gray value can be calculated using the area enclosed by the part corresponding to the first calibration area 1221 in the calibration image to judge whether there is a color difference at the four corners of the calibration image.
[0048] In the actual application scenario, as Figure 2 shown, the second calibration area 1222 includes at least two alignment lines of the same length, and the at least two alignment lines are cross - set to form a aiming - heart structure, enabling the processor 130 to more quickly identify the calibration center point coordinates.
[0049] In this embodiment, after the calibration image is acquired, the coordinates of the center points presented by the at least two alignment lines in the calibration image are compared with the calibration coordinate range corresponding to the actual second calibration area 1222 in the calibration plate 120. If the coordinates of the center points presented in the calibration image are within the calibration coordinate range, it can be determined that the imaging device 110 is centered. In Figure 2In [the device], the two directrices are constructed into a "+" structure, and the intersection point of the two directrices is located at the midpoint of the two directrices. Of course, the two directrices can also be constructed into a "×" structure.
[0050] In an actual application scenario, such as Figure 2 shown, the third calibration region 1223 is constructed into a circular structure.
[0051] In this embodiment, when there is no deformation (compression or stretching) in the calibration image, the roundness of the region corresponding to the third calibration region in the calibration image should be close to 1. When the calibration image is compressed or stretched, the roundness of the region corresponding to the third calibration region in the calibration image will be much less than 1. Thus, it is possible to determine whether the calibration image has deformation (compression or stretching) by the roundness of the circle presented in the calibration image.
[0052] Among them, roundness refers to the degree to which a circle approaches a theoretical circle. When the difference between the maximum radius and the minimum radius of the circle is 0, the roundness is 1, and at this time the circle is a theoretical circle. Roundness calculation formula:
[0053]
[0054] Among them, C is the roundness, F is the area of the circular region, max is the maximum value from the center of the circular region to all edge contour points, and 0 ≤ roundness ≤ 1.
[0055] In an actual application scenario, such as Figure 2 shown, the fourth calibration region 1224 is constructed into a rectangular frame structure. The distance between the center point of the fourth calibration region 1224 and the center point of the calibration plate 120 is less than the second preset distance, that is, the fourth calibration region 1224 is arranged as close as possible to the center of the calibration plate 120. And the length of the rectangular frame structure representing the fourth calibration region 1224 is designed to be greater than the preset length to ensure that the area of the region enclosed by the rectangular frame structure is relatively large, capable of accommodating more pixels, so as to facilitate the calculation of the average gray value and pixel equivalent. Among them, the preset length is used to limit the length of the fourth calibration region 1224, and can be reasonably set according to the size of the calibration plate.
[0056] In this embodiment, since the fourth calibration region 1224 is also configured as a rectangular frame structure and is located at the center point of the calibration plate 120, the average gray value can be calculated through the region enclosed by the fourth calibration region 1224 to determine whether there is a color difference in the middle region of the calibration image. Moreover, the borders of the rectangular frame structure are all straight lines, and adjacent borders are perpendicular to each other. The angle between the straight lines in the calibration image can be used to determine whether the imaging device 110 is perpendicular to its moving direction. Further, since the length of the rectangular frame structure meets the condition of the preset length, the pixel equivalent of the calibration image can be calculated based on the pixel distance between two opposite borders in the calibration image and the actual distance between the two opposite borders on the calibration plate 120, and then it can be determined whether the working distance of the imaging device 110 meets the standard.
[0057] It is worth mentioning that the above rectangular frame structure can be a rectangular structure or a square structure, and the embodiments of the present application do not make specific limitations.
[0058] Further, as a refinement and extension of the specific implementation manner of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, the vision detection system further includes: a moving device.
[0059] Specifically, the moving device is connected to the imaging device and electrically connected to the processor. The moving device is used to control the imaging device to translate or rotate.
[0060] In this embodiment, after the processor obtains the calibration information, if there is information in the calibration information that does not meet the detection requirements, the processor can control the moving device according to the calibration information that does not meet the detection requirements, so that the moving device drives the imaging device to translate or rotate, so that the adjusted imaging device can meet the detection requirements.
[0061] Further, as a specific implementation of the above vision detection system, a calibration method is provided in this embodiment, as Figure 3 shown, the calibration method includes:
[0062] Step 310, obtain a calibration image collected by the imaging device.
[0063] Among them, the calibration image shows a calibration plate, that is, the imaging device takes a picture of the calibration plate to obtain the calibration image.
[0064] Specifically, corresponding to the calibration plate, the calibration image also shows the positioning region, the first calibration region, the second calibration region, the third calibration region, and the fourth calibration region of the calibration plate.
[0065] It can be understood that if the color of the calibration plate is color, the calibration image is first grayscale processed to facilitate the processor to quickly locate the calibration region and detect the gray value of the pixel points in the calibration image. Refer to Figures 4 to 8, in the case of no error, the gray value of the calibration area is 255 for white and 0 for black, and the gray value of the non-calibration area is 0 for white and 255 for black.
[0066] Step 320, determine the first region of interest in the calibration image.
[0067] Among them, the first region of interest includes two borders adjacent to the positioning area.
[0068] Step 330, construct a calibration coordinate system for the calibration image according to the first region of interest.
[0069] In this embodiment, since the positioning area is constructed as a rectangular frame structure and two adjacent borders of the rectangular frame structure are perpendicular, thus, the coordinate origin can be located according to the first region of interest including two borders adjacent to the positioning area, and then the calibration coordinate system of the calibration image can be constructed. This enables the position of the calibration image to be corresponded to the actual position of the calibration plate during offline testing, so that the subsequently selected ROI (region of interest) can change with the change of the position of the calibration plate, thereby reducing the detection error caused by the rotation of the calibration plate.
[0070] For example, as Figure 4 shown, perform edge extraction on the first region of interest 201, and then fit a straight line, and establish a calibration coordinate system with the intersection point of the two straight lines and one of the straight lines.
[0071] Step 340, process the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device.
[0072] Among them, the calibration information includes at least one of the following: focusing information, pixel equivalent information, alignment information, centering information, viewing angle information, deformation information, and color difference information. The focusing information includes whether the imaging device is focused. The alignment information includes whether the opposite sides of the calibration image are in focus. The centering information includes whether the center of the field of view of the imaging device and the actual center of the calibration plate are on the same vertical line. The deformation information includes whether the calibration image is deformed (such as stretching or compression). The pixel equivalent information includes whether the pixel equivalent of the calibration image meets the standard. The viewing angle information includes whether the imaging device is perpendicular to the moving direction. The color difference information includes whether the average gray values at different positions of the calibration image are the same.
[0073] It should be noted that the focusing information, alignment information, and color difference information can be determined through the region of interest including the first calibration area in the calibration image, the centering information can be determined through the region of interest including the second calibration area in the calibration image, the deformation information can be determined through the region of interest including the third calibration area in the calibration image, and the viewing angle information, pixel equivalent information, and color difference information can be determined through the region of interest including the fourth calibration area in the calibration image.
[0074] In this embodiment, since multiple calibration regions are designed on the calibration plate, when the system is calibrated, the imaging device can capture the calibration image of the calibration plate through shooting, and the processor processes the calibration image according to the calibration coordinate system to analyze the calibration information of different aspects of the imaging device. Thus, while ensuring the accuracy and efficiency of the system's visual detection, all the work of determining whether the captured images of the system meet the standards can be completed through the calibration image obtained by one-time shooting, effectively reducing the time required for calibration. Moreover, since the results of multiple calibration functions can be obtained at one time, when performing calibration adjustment, the results of multiple calibration functions can be comprehensively considered for one-time adjustment control, reducing the adjustment difficulty, meeting the requirements of higher detection accuracy, and further helping to reduce the visual calibration cost.
[0075] Further, the positioning region of the calibration plate is configured as a rectangular frame structure, and the calibration information includes alignment information. As a refinement and extension of the specific implementation manner of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, step 340, that is, processing the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device, specifically includes the following two methods:
[0076] Method 1: Obtain at least three second regions of interest in the calibration image according to the calibration coordinate system; calculate the sum of the squares of the gradients of all pixels in each second region of interest; if the difference between the sum of the squares of the gradients of any two second regions of interest among at least three second regions of interest is less than the first preset difference, it is determined that the imaging device is not tilted in the X-axis and Y-axis directions relative to the calibration image; if the difference between the sum of the squares of the gradients of any two second regions of interest among at least three second regions of interest is greater than or equal to the first preset difference, it is determined that the imaging device is tilted in the X-axis and / or Y-axis directions relative to the calibration image.
[0077] Among them, as Figure 5 shown, the second region of interest 202 includes a rectangular frame structure in the first calibration region.
[0078] Specifically, the second region of interest is selected on the calibration coordinate system of the calibration image according to the coordinate of the required region of the calibration plate.
[0079] In this embodiment, the sum of the squares of the gradients of the second region of interest is used as the calibration condition. Since the four rectangular frame structures of the first calibration region are located in different orientations of the calibration plate, three of them can be used to represent the opposite sides of the calibration plate. Then, it is possible to determine whether there is uneven focusing at different positions of the calibration image by comparing whether there is a difference in the sum of the squares of the gradients of any two of the three second regions of interest. If the difference between the sums of the squares of the gradients of any two second regions of interest is less than the first preset difference, it indicates that the calibration image is in focus vertically or horizontally, that is, the imaging device is not tilted in the X-axis and Y-axis directions relative to the calibration image. Conversely, as long as the difference between the sums of the squares of the gradients of two second regions of interest is greater than or equal to the first preset difference, it indicates that there is uneven focusing at different positions of the calibration image, and it is determined that the calibration image is not in focus vertically or horizontally.
[0080] Method 2: Obtain four third regions of interest in the calibration image according to the calibration coordinate system; perform straight line fitting processing on each third region of interest to identify the first straight line in each third region of interest; select multiple calibration points on the first straight line according to a preset distance; determine the gradient values of the edge pixels corresponding to each calibration point, where the edge pixels are located in the normal direction of the calibration point; count the number of edge pixels corresponding to each calibration point whose gradient values are greater than the gradient threshold; if the difference between the number of transition pixels of any two of the four third regions of interest is less than or equal to the first preset number, determine that the imaging device is not tilted in the X-axis and Y-axis directions relative to the calibration image; if the difference between the number of transition pixels of any two of the four third regions of interest is greater than the first preset number, determine that the imaging device is tilted in the X-axis and / or Y-axis directions relative to the calibration image; where the number of transition pixels is the mode, average value or weighted average value of the number of edge pixels of multiple calibration points.
[0081] Among them, as Figure 6 shown, the third region of interest 203 includes a partial border of a rectangular frame structure in the first calibration region of the calibration plate.
[0082] It can be understood that the straight line fitting processing includes multiple steps such as edge extraction, edge filling, and fitting, and existing straight line fitting techniques can be used, which are not specifically limited in the embodiments of the present application.
[0083] In this embodiment, since there is a color difference between the positioning area of the calibration plate and the plate background color, the number of transition pixels can reflect the color transition between the positioning area and the non-calibration area of the calibration plate, so as to facilitate the analysis of the clarity of the calibration image. Based on this, taking part of the border of the rectangular frame structure in the first calibration area as a reference, the corresponding gradient value is calculated using the first straight line corresponding to part of the border of the rectangular frame structure in the third region of interest. Then, according to the gradient value, the number of transition pixels in each third region of interest is determined, that is, the mode, average value or weighted average of the number of edge pixels with a gradient value greater than the gradient threshold in the third region of interest. The width of the transition band of the edge line is represented by the number of transition pixels. By comparing whether there are differences in the number of transition pixels between any two of the four third regions of interest, it is judged whether there is uneven focus at different positions of the calibration image. If the difference between the number of transition pixels of any two third regions of interest is less than or equal to the first preset number, it means that the calibration image is in focus up and down or left and right, that is, the camera device does not tilt in the X-axis and Y-axis directions relative to the calibration image. On the contrary, as long as the difference between the number of transition pixels of two third regions of interest is greater than the first preset number, it means that there is uneven focus at different positions of the calibration image, and it is determined that the calibration image is not in focus up and down or left and right.
[0084] Specifically, for example, as Figure 6 shown, select the third region of interest 203 and match the best first straight line. Search for edge points in the normal direction of this first straight line, calculate the gradient difference of adjacent pixels in the normal direction of a calibration point, and take the maximum value in the gradient difference as the gradient value at the position of this calibration point. Further along the extension direction of this first straight line, search for the edges of each normal of other calibration points at a certain step length with the above calibration point as the origin, and determine the gradient values of all calibration points on the first straight line. Count the number of pixel points (number of edge pixels) greater than the gradient threshold corresponding to each normal, and sort them according to size. Calculate the mode (the value that appears more frequently) in this sequence as the number of transition pixels of the first straight line. For example, there are 10 calibration points on the first straight line, and the number of pixels with a gradient exceeding the gradient threshold corresponding to each calibration point is 2, 3, 4, 3, 2, 3, 3, 3, 2, 3 respectively. Calculate the mode as the number of transition pixels this time. Thus, 3 is used as the number of transition pixels of this region of interest. Then, compare the number of transition pixels of the four third regions of interest 203 up, down, left, and right. If the number of transition pixels of the four third regions of interest 203 up, down, left, and right varies greatly, it is considered that the lens is tilted and the focusing condition of the entire calibration plate is inconsistent.
[0085] Furthermore, based on the above principle, the calibration information includes focusing information. In step 340, that is, the calibration image is processed according to the calibration coordinate system to determine the calibration information of the camera device, which specifically includes the following two methods:
[0086] Method 1: Obtain the second region of interest in the calibration image according to the calibration coordinate system; calculate the sum of the squares of the gradients of all pixels in the second region of interest; if the sum of the squares of the gradients of the second region of interest is less than the calibration gradient value, determine that the imaging device is in focus; if the sum of the squares of the gradients of the second region of interest is greater than or equal to the calibration gradient value, determine that the imaging device is out of focus.
[0087] Among them, as Figure 5 shown, the second region of interest 202 includes a rectangular frame structure in the first calibration region.
[0088] In this embodiment, a second region of interest containing a complete rectangular frame structure is selected, and the sum of the squares of the gradients of all pixels in the second region of interest is determined. During the actual focusing process, when the focus is clear, the sum of the squares of the gradients should be the theoretical maximum value (calibration gradient value). Therefore, by comparing this sum of the squares of the gradients with the standard calibration gradient value, it is determined whether the imaging device is in focus.
[0089] Specifically, in the case of determining focus, when adjusting the focus ring in one direction, the focus value will increase from small to large and then decrease again. The software layer will record the maximum value (calibration gradient value) of the sum of the squares of the gradients generated, so as to use it as a standard value for subsequent calibration.
[0090] Specifically, for example, as Figure 5 shown, three second regions of interest 202 containing complete rectangular frame structures are selected. Calculate the sum of the squares of the gradients of all pixels in each second region of interest 202. When calibrating using a calibration plate, if the sum of the squares of the gradients is less than the theoretical maximum value, the focus ring needs to be rotated and recalibrated to test the new sum of the squares of the gradients until the maximum value is reached.
[0091] Specifically, the sum of the squares of the gradients can be calculated using the Sobel operator of the Tenengrad function. The formula is as follows:
[0092] F(a) = ∑ i ∑ j [S(i,j)] 2 ,
[0093]
[0094] G i (i,j) = I(i - 1,j + 1) + 2I(i,j + 1) + I(i + 1,j + 1) - I(i - 1,j - 1) - 2I(i,j - 1) - I(i + 1,j - 1),
[0095] G j(i,j) = I(i - 1,j - 1) + 2I(i - 1,j) + I(i - 1,j + 1) - I(i + 1,j - 1) - 2I(i + 1,j) - I(i + 1,j + 1);
[0096] Where f(a) is the sum of squared gradients, s(i,j) is the gradient value of the pixel at the position with coordinates i and j, and I(i,j) is the pixel value at the coordinate position of i and j.
[0097] Method 2: Obtain the third region of interest of the calibration image according to the calibration coordinate system; perform a straight line fitting process on the third region of interest to identify the first straight line in the third region of interest; select multiple calibration points on the first straight line according to a preset distance; determine the gradient value of the edge pixel corresponding to each calibration point, and the edge pixel is located in the normal direction of the calibration point; accumulate the maximum gradient values corresponding to multiple calibration points to obtain the focus degree of the third region of interest; count the number of edge pixels corresponding to each calibration point whose gradient value is greater than the gradient threshold; if the focus degree of the third region of interest is greater than or equal to the focus degree threshold, and the number of transition pixels in the third region of interest is less than or equal to the second preset number, determine that the camera device is in focus; if the focus degree of the third region of interest is less than the focus degree threshold, and / or the number of transition pixels in the third region of interest is greater than the second preset number, determine that the camera device is out of focus.
[0098] In this embodiment, on the basis of calculating the number of transition pixels of the first straight line, further take the maximum value in the gradient values of the edge pixels corresponding to each calibration point as the maximum gradient value corresponding to the calibration point, and calculate the focus degree of the third region of interest through an addition operation on the maximum gradient values corresponding to the calibration points. Judging whether the camera device is in focus by combining the number of transition pixels and the focus degree greatly improves the accuracy of focus calibration.
[0099] Specifically, for example, as Figure 6 shown, after calculating the number of transition pixels of the third region of interest 203, add the maximum gradient values in each normal direction as the focus degree. When the focus is clear, if the number of transition pixels is greater than or equal to 3, there may be a problem that the lens focus is not clear. If the number of transition pixels is greater than or equal to 3 and the focus value is less than 40, there may be a situation where although the lens is focused, the focus value is low due to a problem with the working distance of the lens, resulting in unclear imaging, and adjustment is required. It should be noted that the first preset number and the second preset number can be reasonably set according to the detection accuracy.
[0100] Furthermore, the calibration information includes centering information. As a refinement and extension of the specific implementation manner of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, step 340, that is, process the calibration image according to the calibration coordinate system to determine the calibration information of the camera device, specifically including:
[0101] Step 411: Obtain the fourth region of interest of the calibration plate in the calibration image according to the calibration coordinate system.
[0102] Among them, as Figure 7 shown, the fourth region of interest 204 includes the second calibration region of the calibration plate. The second calibration region of the calibration plate includes at least two fiducial lines of the same length, and the at least two fiducial lines are arranged in a crossed manner.
[0103] Step 412: Perform threshold segmentation processing on the fourth region of interest to determine the contour information of the second calibration region.
[0104] Step 413: Determine the center coordinates of the second calibration region in the fourth region of interest according to the calibration coordinate system and the contour information.
[0105] Step 414: If the center coordinates are within the calibration coordinate range, determine that the field of view of the imaging device is centered.
[0106] Among them, the calibration coordinate range can be reasonably set according to the center point position and error distance of the second calibration region in the calibration plate.
[0107] Step 415: If the center coordinates exceed the calibration coordinate range, determine that the field of view of the imaging device is not centered.
[0108] In this embodiment, the contour information presented by the second calibration region in the calibration image is identified through threshold segmentation. Filling the contour can identify the image corresponding to the second calibration region. The calibration coordinate system is found by searching for the intersection points of the lines generated after the contour filling to determine the center coordinates. Comparing the center coordinates with the standard calibration coordinate range, if the center coordinates are within the calibration coordinate range, it is confirmed that the imaging device is centered; otherwise, it is confirmed that the imaging device is not centered, thereby realizing the centering calibration of the imaging device.
[0109] Further, the third calibration region of the calibration plate is configured as a circular structure, and the calibration information includes deformation information. As a refinement and extension of the specific implementation manner of the above embodiment, in order to completely illustrate the specific implementation process of this embodiment, step 340, that is, process the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device, specifically including:
[0110] Step 421: Obtain the fifth region of interest of the calibration image according to the calibration coordinate system.
[0111] Among them, as Figure 4 shown, the fifth region of interest 205 includes the third calibration region of the calibration plate.
[0112] Step 422: Perform threshold segmentation processing on the fifth region of interest to determine the contour information of the third calibration region.
[0113] Step 423: Detect the roundness of the third calibration region in the fifth region of interest according to the contour information.
[0114] Among them, roundness refers to the degree to which a circle approaches a theoretical circle. When the difference between the maximum radius and the minimum radius of a circle is 0, the roundness is 1, and at this time the circle is a theoretical circle. The roundness calculation formula:
[0115]
[0116] Among them, C is the roundness, F is the area of the circular region, max is the maximum value from the center of the circular region to all edge contour points, and 0 ≤ roundness ≤ 1.
[0117] Step 424: If the roundness is less than the calibrated roundness, determine that the calibrated image is deformed.
[0118] Among them, the preset roundness can be reasonably set according to the calibration requirements. The range of the preset roundness can be 0 to 1. For example, in a scenario with high precision requirements, the preset roundness can be set to 1 or close to 1, such as 0.95. In a scenario with low precision requirements, the preset roundness can be set to a value greater than 0 and less than 1, such as 0.8.
[0119] Step 425: If the roundness is greater than or equal to the calibrated roundness, determine that the calibrated image is not deformed.
[0120] In this embodiment, the contour information of the third calibration region is obtained through threshold segmentation, and the contour is filled to identify the third calibration region in the corresponding calibrated image. Since the third calibration region of the calibration plate is constructed as a circular structure, in the case where there is no deformation (compression or stretching) in the calibrated image, the roundness of the third calibration region in the calibrated image should be close to 1. In the case where the calibrated image is compressed or stretched, the roundness of the third calibration region in the calibrated image should be less than 1. Therefore, by detecting the roundness of the third calibration region in the calibrated image and the size relationship between the detected roundness and the calibrated roundness, it is possible to determine whether the calibrated image has compression or stretching, thus realizing the shooting deformation calibration of the imaging device.
[0121] Furthermore, the fourth calibration region of the calibration plate is constructed as a rectangular frame structure, and the calibration information includes viewing angle information. As a refinement and extension of the specific implementation manner of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, step 340, that is, processing the calibrated image according to the calibration coordinate system to determine the calibration information of the imaging device, specifically includes:
[0122] Step 431: Obtain the sixth region of interest in the calibrated image according to the calibration coordinate system.
[0123] Among them, as Figure 8As shown, the sixth region of interest 206 includes two adjacent side frames of the fourth calibration region of the calibration plate.
[0124] Step 432: Perform a straight line fitting process on the sixth region of interest to determine two second straight lines in the sixth region of interest.
[0125] Step 433: Detect the angle between the two second straight lines.
[0126] Step 434: If the angle is within the calibration angle range, determine that the viewing angle of the imaging device is perpendicular to the moving direction of the imaging device.
[0127] Among them, the preset angle range can be reasonably set according to the right angle and the angle error.
[0128] Step 435: If the angle exceeds the calibration angle range, determine that the viewing angle of the imaging device is not perpendicular to the moving direction of the imaging device.
[0129] In this embodiment, the fourth calibration region of the calibration plate is configured as a rectangular frame structure, so that the four side frames of the fourth calibration region are all straight lines, and the adjacent side frames are perpendicular to each other. Thus, when performing viewing angle calibration, first obtain the sixth region of interest including two adjacent side frames. Perform a straight line fitting process on the two adjacent side frames in the sixth region of interest to eliminate the errors introduced during the image acquisition process. Determine the angle between the two adjacent side frames after the straight line fitting process through an identification algorithm. If the angle is within the calibration angle range, it is determined that the viewing angle of the imaging device is perpendicular to the moving direction of the imaging device, otherwise it is not perpendicular, thereby realizing the viewing angle calibration of the imaging device.
[0130] Specifically, for example, as Figure 8 shown, obtain two sixth regions of interest 206. The sixth region of interest 206 includes one side frame of the rectangular frame structure. Fit straight lines to the two sixth regions of interest 206 respectively, and calculate the included angle between the two side frames. Determine whether the imaging device is perpendicular to the moving direction by confirming whether the included angle is 90 degrees.
[0131] Furthermore, the fourth calibration region of the calibration plate is configured as a rectangular frame structure; the calibration information includes pixel equivalent information. As a refinement and extension of the specific implementation manner of the above embodiment, in order to completely illustrate the specific implementation process of this embodiment, step 340, that is, process the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device, specifically including:
[0132] Step 441: Obtain the seventh region of interest of the calibration image according to the calibration coordinate system.
[0133] Among them, as Figure 4 shown, the seventh region of interest 207 includes two opposite side frames of the fourth calibration region of the calibration plate.
[0134] Step 442: Perform a straight line fitting process on the seventh region of interest to determine two third straight lines in the seventh region of interest.
[0135] Step 443: Determine the pixel distance between the two third straight lines.
[0136] Step 444: Calculate the pixel equivalent of the calibration image based on the pixel distance and the actual distance between the two opposite borders of the fourth calibration region.
[0137] Specifically, the pixel equivalent refers to the actual physical size represented by a pixel point in the image. Pixel equivalent = actual distance / pixel distance. For example, the actual coordinates of two coordinate points opposite to each other on the two borders of the fourth calibration region on the calibration plate are P1(0, 10) and P2(0, 20), and the pixel coordinates of the two coordinate points opposite to each other on the calibration image are P3(0, 10) and P4(0, 110). Then the pixel equivalent = 10 / 100 = 0.1 (mm / pix).
[0138] Step 445: If the pixel equivalent is within the calibration pixel equivalent range, determine that the pixel equivalent is normal.
[0139] Step 446: If the pixel equivalent exceeds the calibration pixel equivalent range, determine that the pixel equivalent is abnormal.
[0140] In this embodiment, the corresponding image region (the seventh region of interest) is selected on the calibration coordinate system according to the input region of interest parameters. Edge extraction and straight line fitting are respectively performed on the seventh region of interest to determine the pixel distance between the two third straight lines in the seventh region of interest. Given the actual distance between the two borders of the fourth calibration region on the calibration plate, the pixel equivalent can be calculated based on the pixel distance and the actual distance. Then, the pixel equivalent is compared with the calibration pixel equivalent range. If there is a large deviation, the working distance of the imaging device needs to be adjusted. If the pixel equivalent meets the calibration pixel equivalent range, it indicates that the imaging device can meet the user's requirements for the pixel equivalent.
[0141] Furthermore, the first calibration region of the calibration plate includes four rectangular frame structures. The fourth calibration region of the calibration plate is configured as a rectangular frame structure, and the distance between the center point of the fourth calibration region and the center point of the calibration plate is less than the second preset distance; the calibration information includes color difference information. As a refinement and extension of the specific implementation manner of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, step 340, that is, processing the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device, specifically includes:
[0142] Step 451: Obtain five eighth regions of interest of the calibration image according to the calibration coordinate system.
[0143] Among them, as Figure 7 shown, the eighth region of interest 208 includes the region enclosed by the rectangular frame structure of the first calibration region or the region enclosed by the rectangular frame structure of the fourth calibration region.
[0144] Step 452, identify the gray values of all pixel points in each eighth region of interest.
[0145] Step 453, calculate the average gray value of each eighth region of interest according to the gray values.
[0146] Step 454, if the difference between the average gray values of any two of the five eighth regions of interest is less than the second preset difference, determine that there is no color difference in the calibration image.
[0147] Step 455, if the difference between the average gray values of any two of the five eighth regions of interest is greater than or equal to the second preset difference, determine that there is a color difference in the calibration image.
[0148] In this embodiment, the corresponding eighth region of interest in the calibration image is obtained. The gray values of all pixel points in the eighth region of interest are identified to determine the gray levels at different positions in the calibration image. Finally, the average gray value is calculated according to the gray values of all pixel points. If the difference between the average gray values of any two eighth regions of interest is less than the second preset difference, it indicates that the gray levels in different regions of the calibration image are relatively uniform, that is, there is no color difference in the calibration image. On the contrary, if there is a difference between the average gray values of any two eighth regions of interest that is greater than or equal to the second preset difference, that is, there is a color difference between two different positions in the calibration image. Thus, the calibration of color difference information is achieved through the average gray values of different regions, facilitating the user to evaluate the imaging device based on the color difference information.
[0149] Specifically, the formula for calculating the average gray value is as follows:
[0150]
[0151] In the formula, R is the eighth region of interest, p is the coordinate position of the pixel point, g(p) is the gray value of the pixel point at the current position, and N is the area of the region, that is, the number of pixels in the eighth region of interest.
[0152] Further, after determining the calibration information, the imaging device can be controlled to translate, rotate, or directly repaired according to the calibration information, so that the images captured by the imaging device can meet the standards.
[0153] Further, as Figure 9 shown, as a specific implementation of the above calibration method, an embodiment of the present application provides a calibration device, which includes: an acquisition module 501, a positioning module 502, and a calibration module 503.
[0154] Among them, an acquisition module 501 is configured to acquire a calibration image collected by a camera device of a vision detection system, where the calibration image shows a calibration plate; a positioning module 502 is configured to determine a first region of interest in the calibration image, where the first region of interest includes two borders adjacent to a positioning region; and construct a calibration coordinate system of the calibration image according to the first region of interest; a calibration module 503 is configured to process the calibration image according to the calibration coordinate system to determine calibration information of the camera device; where the calibration information includes at least one of the following: focusing information, pixel equivalent information, alignment information, centering information, viewing angle information, deformation information, and chromatic aberration information.
[0155] In this embodiment, when the system is calibrated, the camera device captures a calibration image of the calibration plate that can be captured, and the processor processes the calibration image to analyze the calibration information of the camera device, so as to calibrate and adjust the spatial position of the camera device. At the same time, multiple calibration regions are designed on the calibration plate, and different calibration regions are used to implement different calibration functions. Thus, while ensuring the visual detection accuracy and efficiency of the system, all the work of whether the images captured by the system meet the standards is achieved through one calibration plate, effectively reducing the time required for calibration. Moreover, since the results of multiple calibration functions can be obtained at one time, when performing calibration adjustment, the results of multiple calibration functions can be comprehensively used for one-time adjustment control, reducing the adjustment difficulty, and further helping to reduce the visual calibration cost.
[0156] Further, the first calibration region of the calibration plate includes four rectangular frame structures, and the four rectangular frame structures of the first calibration region are correspondingly distributed at the four corners of the positioning region, and the calibration information includes alignment information; the acquisition module 501 is further configured to acquire at least three second regions of interest in the calibration image according to the calibration coordinate system, where the second region of interest includes one rectangular frame structure in the first calibration region; the calibration module 503 is specifically configured to calculate the sum of the squares of the gradients of all pixels in each second region of interest; if the difference between the sum of the squares of the gradients of any two second regions of interest among the at least three second regions of interest is less than a first preset difference, it is determined that the camera device is not tilted in the X-axis and Y-axis directions relative to the calibration image; if the difference between the sum of the squares of the gradients of any two second regions of interest among the at least three second regions of interest is greater than or equal to the first preset difference, it is determined that the camera device is tilted in the X-axis and / or Y-axis directions relative to the calibration image.
[0157] Further, the calibration information includes focusing information; the calibration module 503 is specifically configured to determine that the camera device is in focus if the sum of the squares of the gradients of any second region of interest is less than a calibration gradient value; and determine that the camera device is out of focus if the sum of the squares of the gradients of any second region of interest is greater than or equal to the calibration gradient value.
[0158] Further, the first calibration area of the calibration plate includes four rectangular frame structures, and the four rectangular frame structures of the first calibration area are correspondingly distributed at the four corners of the positioning area; the calibration information includes alignment information. Then, the calibration image is processed according to the calibration coordinate system to determine the calibration information of the imaging device, including: an acquisition module 501, further configured to acquire four third regions of interest in the calibration image according to the calibration coordinate system, where the third region of interest includes partial borders of a rectangular frame structure in the first calibration area of the calibration plate; a calibration module 503, specifically configured to perform a straight line fitting process on each third region of interest, identify the straight lines in each third region of interest; select multiple calibration points on the straight line according to a preset distance; determine the gradient value of the edge pixels corresponding to each calibration point, where the edge pixels are located in the normal direction of the calibration point; count the number of edge pixels corresponding to each calibration point whose gradient value is greater than the gradient threshold; if the difference between the number of transition pixels of any two of the four third regions of interest is less than or equal to the first preset number, it is determined that the imaging device is not tilted in the X-axis and Y-axis directions relative to the calibration image; if the difference between the maximum edge pixels of any two of the four third regions of interest is greater than the first preset number, it is determined that the imaging device is tilted in the X-axis and / or Y-axis directions relative to the calibration image; where the number of transition pixels is the mode, average value, or weighted average value of the number of edge pixels of multiple calibration points.
[0159] Further, the calibration information includes focusing information; the calibration module 503 is specifically configured to accumulate the maximum gradient values corresponding to multiple calibration points to obtain the focusing degree of the third region of interest; if the focusing degree of any third region of interest is greater than or equal to the focusing degree threshold, and the number of transition pixels of any third region of interest is less than or equal to the second preset number, it is determined that the imaging device is in focus; if the focusing degree of any third region of interest is less than the focusing degree threshold, and / or the number of transition pixels of any third region of interest is greater than the second preset number, it is determined that the imaging device is out of focus.
[0160] Further, the second calibration area of the calibration plate includes at least two alignment lines of the same length, and the at least two alignment lines are arranged in a cross manner; the calibration information includes centering information; the acquisition module 501 is further configured to acquire a fourth region of interest of the calibration plate in the calibration image according to the calibration coordinate system, where the fourth region of interest includes the second calibration area of the calibration plate; the calibration module 503 is specifically configured to perform a threshold segmentation process on the fourth region of interest to determine the contour information of the second calibration area; according to the calibration coordinate system and the contour information, determine the center coordinates of the second calibration area in the fourth region of interest; if the center coordinates are within the calibration coordinate range, it is determined that the field of view of the imaging device is centered; if the center coordinates exceed the calibration coordinate range, it is determined that the field of view of the imaging device is not centered.
[0161] Further, the third calibration area of the calibration plate is configured as a circular structure, and the calibration information includes deformation information; the acquisition module 501 is further configured to acquire a fifth region of interest of the calibration image according to the calibration coordinate system, and the fifth region of interest includes the third calibration area of the calibration plate; the calibration module 503 is specifically configured to perform threshold segmentation processing on the fifth region of interest to determine the contour information of the third calibration area; detect the roundness of the third calibration area in the fifth region of interest according to the contour information; if the roundness is less than the calibration roundness, determine that the calibration image is deformed; if the roundness is greater than or equal to the calibration roundness, determine that the calibration image is not deformed.
[0162] Further, the fourth calibration area of the calibration plate is configured as a rectangular frame structure, and the calibration information includes viewing angle information; the acquisition module 501 is further configured to acquire a sixth region of interest in the calibration image according to the calibration coordinate system, and the sixth region of interest includes two adjacent borders of the fourth calibration area of the calibration plate; the calibration module 503 is specifically configured to perform straight line fitting processing on the sixth region of interest to determine two second straight lines in the sixth region of interest; detect the angle between the two second straight lines; if the angle is within the calibration angle range, determine that the viewing angle of the imaging device is perpendicular to the moving direction of the imaging device; if the angle exceeds the calibration angle range, determine that the viewing angle of the imaging device is not perpendicular to the moving direction of the imaging device.
[0163] Further, the fourth calibration area of the calibration plate is configured as a rectangular frame structure; the calibration information includes pixel equivalent information; the acquisition module 501 is further configured to acquire a seventh region of interest of the calibration image according to the calibration coordinate system, and the sixth region of interest includes two opposite borders of the fourth calibration area of the calibration plate; the calibration module 503 is specifically configured to perform straight line fitting processing on the seventh region of interest to determine two third straight lines in the seventh region of interest; determine the pixel distance between the two third straight lines; calculate the pixel equivalent of the calibration image according to the pixel distance and the actual distance between two opposite borders of the fourth calibration area; if the pixel equivalent is within the calibration pixel equivalent range, determine that the pixel equivalent is normal; if the pixel equivalent exceeds the calibration pixel equivalent range, determine that the pixel equivalent is abnormal.
[0164] Further, the first calibration area of the calibration plate includes four rectangular frame structures, the fourth calibration area of the calibration plate is configured as a rectangular frame structure, and the distance between the center point of the fourth calibration area and the center point of the calibration plate is less than a second preset distance. The calibration information includes color difference information. The acquisition module 501 is further configured to obtain five eighth regions of interest of the calibration image according to the calibration coordinate system. The eighth regions of interest include the region enclosed by the rectangular frame structure of the first calibration area or the region enclosed by the rectangular frame structure of the fourth calibration area. The calibration module 503 is specifically configured to identify the gray values of all pixel points in each eighth region of interest, calculate the average gray value of each eighth region of interest according to the gray values, determine that there is no color difference in the calibration image if the difference between the average gray values of any two of the five eighth regions of interest is less than a second preset difference, and determine that there is a color difference in the calibration image if the difference between the average gray values of any two of the five eighth regions of interest is greater than or equal to the second preset difference.
[0165] For specific limitations on the calibration device, reference may be made to the limitations on the calibration method in the foregoing text, which will not be elaborated herein. Each module in the above calibration device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor of the computer device in the form of hardware or independent of it, or 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 the above modules.
[0166] Based on the above method as Figure 3 shown, correspondingly, an embodiment of the present application further provides a readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the above calibration method as Figure 3 shown is implemented.
[0167] Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in various implementation scenarios of the present application.
[0168] Based on the above method as Figure 3 shown, and Figure 9 the virtual device embodiment shown, to achieve the above object, an embodiment of the present application further provides a computer device, which can specifically be a personal computer, a server, a network device, etc. The computer device includes a storage medium and a processor. The storage medium is used to store a computer program. The processor is used to execute the computer program to implement the above calibration method as Figure 3 shown.
[0169] Optionally, the computer device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a Bluetooth interface, a WI-FI interface), etc.
[0170] Those skilled in the art will appreciate that the computer device structure provided in this embodiment does not limit the computer device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0171] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages and saves the hardware and software resources of the computer device, and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the storage medium, and communication with other hardware and software in the physical device.
[0172] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware to obtain a calibration image captured by a camera device, the calibration image showing a calibration board; the calibration image is processed to determine the calibration information of the camera device. The embodiment of the present application can realize different multiple calibration functions in a single calibration process, so that while ensuring the accuracy and efficiency of the system's visual detection, all work of whether the system's captured images meet the standards can be realized through a calibration board, effectively reducing the time required for calibration, and because the results of multiple calibration functions can be obtained at one time, when performing calibration adjustments, the results of multiple calibration functions can be integrated to perform a one-time adjustment control, reducing the difficulty of adjustment, and being able to meet higher detection accuracy requirements, thereby helping to reduce the cost of visual calibration.
[0173] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0174] The above serial numbers of this application are only for description and do not represent the advantages or disadvantages of the implementation scenarios. The above disclosure is only several specific implementation scenarios of this application. However, this application is not limited thereto, and any changes that can be conceived by those skilled in the art should fall within the protection scope of this application.
Claims
1. A calibration method for a visual detection system, characterized in that, The visual detection system includes a camera device and a calibration plate. The calibration plate is provided with a positioning area and a calibration area. The calibration area includes: a first calibration area, a second calibration area, a third calibration area, and a fourth calibration area. The method includes: Obtain a calibration image collected by the camera device, and the calibration plate is shown in the calibration image; Determine a first region of interest in the calibration image, and the first region of interest includes two adjacent borders of the positioning area; Construct a calibration coordinate system of the calibration image according to the first region of interest; Process the calibration image according to the calibration coordinate system to determine the calibration information of the camera device; Wherein, the calibration information includes at least one of the following: focusing information, chromatic aberration information, alignment information, centering information, viewing angle information, deformation information, and pixel equivalent information; The first calibration area of the calibration plate includes four rectangular frame structures, and the four rectangular frame structures of the first calibration area are correspondingly distributed at the four corners of the positioning area; if the calibration information includes alignment information, then processing the calibration image according to the calibration coordinate system to determine the calibration information of the camera device includes: obtaining at least three second regions of interest in the calibration image according to the calibration coordinate system, and the second region of interest includes a rectangular frame structure in the first calibration area; calculating the sum of the squares of the gradients of all pixels in each second region of interest; if the difference between the sum of the squares of the gradients of any two second regions of interest among the at least three second regions of interest is less than a first preset difference, it is determined that the camera device is not tilted in the X-axis and Y-axis directions relative to the calibration image; if the difference between the sum of the squares of the gradients of any two second regions of interest among the at least three second regions of interest is greater than or equal to the first preset difference, it is determined that the camera device is tilted in the X-axis and / or Y-axis directions relative to the calibration image; or, obtaining four third regions of interest in the calibration image according to the calibration coordinate system, and the third region of interest includes a partial border of a rectangular frame structure in the first calibration area; performing a straight line fitting process on each third region of interest to identify the first straight line in each third region of interest; selecting a plurality of calibration points on the first straight line according to a preset distance; determining the gradient value of the edge pixel corresponding to each calibration point, and the edge pixel is located in the normal direction of the calibration point; counting the number of edge pixels corresponding to each calibration point whose gradient value is greater than a gradient threshold; if the difference between the number of transition pixels of any two third regions of interest among the four third regions of interest is less than or equal to a first preset number, it is determined that the camera device is not tilted in the X-axis and Y-axis directions relative to the calibration image; if the difference between the number of transition pixels of any two third regions of interest among the four third regions of interest is greater than the first preset number, it is determined that the camera device is tilted in the X-axis and / or Y-axis directions relative to the calibration image; wherein, the number of transition pixels is the mode, average value or weighted average value of the number of edge pixels of the plurality of calibration points; And / or, The first calibration area of the calibration plate includes four rectangular frame structures, and the four rectangular frame structures of the first calibration area are correspondingly distributed at the four corners of the positioning area; when the calibration information includes focusing information, processing the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device includes: obtaining a second region of interest in the calibration image according to the calibration coordinate system, where the second region of interest includes one rectangular frame structure in the first calibration area; if the sum of squared gradients of any second region of interest is less than the calibration gradient value, determining that the imaging device is in focus; if the sum of squared gradients of any second region of interest is greater than or equal to the calibration gradient value, determining that the imaging device is out of focus; or, obtaining a third region of interest in the calibration image according to the calibration coordinate system, where the third region of interest includes a partial border of one rectangular frame structure in the first calibration area; accumulating the maximum gradient values corresponding to multiple calibration points to obtain the focus degree of the third region of interest; if the focus degree of any third region of interest is greater than or equal to the focus degree threshold, and the number of transition pixels in any third region of interest is less than or equal to a second preset number, determining that the imaging device is in focus; if the focus degree of any third region of interest is less than the focus degree threshold, and / or the number of transition pixels in any third region of interest is greater than the second preset number, determining that the imaging device is out of focus.
2. The calibration method according to claim 1, wherein The second calibration area of the calibration plate includes at least two alignment lines of the same length, and at least two of the alignment lines are arranged in a cross manner; when the calibration information includes centering information, processing the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device includes: Obtaining a fourth region of interest of the calibration image according to the calibration coordinate system, where the fourth region of interest includes the second calibration area of the calibration plate; Performing threshold segmentation processing on the fourth region of interest to determine the contour information of the second calibration area; Determining the center coordinates of the second calibration area in the fourth region of interest according to the calibration coordinate system and the contour information; If the center coordinates are within the calibration coordinate range, determining that the field of view of the imaging device is centered; If the center coordinates exceed the calibration coordinate range, determining that the field of view of the imaging device is not centered.
3. The calibration method according to claim 1, wherein The third calibration area of the calibration plate is constructed as a circular structure, and when the calibration information includes deformation information, processing the calibration image according to the calibration coordinate system to determine the calibration information of the imaging device includes: Obtaining a fifth region of interest of the calibration image according to the calibration coordinate system, where the fifth region of interest includes the third calibration area of the calibration plate; Performing threshold segmentation processing on the fifth region of interest to determine the contour information of the third calibration area; Detecting the roundness of the third calibration area in the fifth region of interest according to the contour information; If the roundness is less than the calibration roundness, determining that the calibration image is deformed; If the roundness is greater than or equal to the calibrated roundness, it is determined that the calibrated image is not deformed.
4. The calibration method according to claim 1, wherein The fourth calibration area of the calibration plate is configured as a rectangular frame structure; the calibration information includes viewing angle information, then processing the calibrated image according to the calibration coordinate system to determine the calibration information of the imaging device includes: Obtaining a sixth region of interest of the calibrated image according to the calibration coordinate system, where the sixth region of interest includes two adjacent frames of the fourth calibration area of the calibration plate; Performing a straight line fitting process on the sixth region of interest to determine two second straight lines in the sixth region of interest; Detecting the angle between the two second straight lines; If the angle is within the calibration angle range, it is determined that the viewing angle of the imaging device is perpendicular to the moving direction of the imaging device; If the angle exceeds the calibration angle range, it is determined that the viewing angle of the imaging device is not perpendicular to the moving direction of the imaging device.
5. The calibration method according to claim 1, wherein The fourth calibration area of the calibration plate is configured as a rectangular frame structure; the calibration information includes pixel equivalent information, then processing the calibrated image according to the calibration coordinate system to determine the calibration information of the imaging device includes: Obtaining a seventh region of interest of the calibrated image according to the calibration coordinate system, where the seventh region of interest includes two opposite frames of the fourth calibration area of the calibration plate; Performing a straight line fitting process on the seventh region of interest to determine two third straight lines in the seventh region of interest; Determining the pixel distance between the two third straight lines; Calculating the pixel equivalent of the calibrated image according to the pixel distance and the actual distance between the two opposite frames of the fourth calibration area; If the pixel equivalent is within the calibrated pixel equivalent range, it is determined that the pixel equivalent is normal; If the pixel equivalent exceeds the calibrated pixel equivalent range, it is determined that the pixel equivalent is abnormal.
6. The calibration method according to claim 1, wherein The first calibration area of the calibration plate includes four rectangular frame structures, the fourth calibration area of the calibration plate is configured as a rectangular frame structure, and the distance between the center point of the fourth calibration area and the center point of the calibration plate is less than a second preset distance; the calibration information includes color difference information, then processing the calibrated image according to the calibration coordinate system to determine the calibration information of the imaging device includes: Obtaining five eighth regions of interest of the calibrated image according to the calibration coordinate system, where the eighth regions of interest include the regions enclosed by the rectangular frame structures of the first calibration area or the regions enclosed by the rectangular frame structures of the fourth calibration area; Identifying the gray values of all pixel points in each eighth region of interest; Calculating the average gray value of each eighth region of interest according to the gray values; If the difference between the average gray values of any two of the five eighth regions of interest is less than a second preset difference, it is determined that there is no color difference in the calibrated image; If the difference between the average gray values of any two of the five eighth regions of interest is greater than or equal to the second preset difference, it is determined that there is a color difference in the calibrated image.
7. A calibration device for a visual detection system, characterized in that The visual detection system includes a camera device and a calibration plate. The calibration plate is provided with a positioning area and a calibration area. The calibration area includes: a first calibration area, a second calibration area, a third calibration area, and a fourth calibration area. The device includes: An acquisition module, configured to acquire a calibration image collected by the camera device of the visual detection system, where the calibration image shows the calibration plate; A positioning module, configured to determine a first region of interest in the calibration image, where the first region of interest includes two adjacent borders of the positioning area; and, A calibration coordinate system of the calibration image is constructed according to the first region of interest; a calibration module, configured to process the calibration image according to the calibration coordinate system to determine calibration information of the camera device; Wherein, the calibration information includes at least one of the following: focusing information, chromatic aberration information, alignment information, centering information, viewing angle information, deformation information, and pixel equivalent information; The first calibration area of the calibration plate includes four rectangular frame structures, and the four rectangular frame structures of the first calibration area are correspondingly distributed at the four corners of the positioning area; the calibration information includes alignment information: The acquisition module is further configured to acquire at least three second regions of interest in the calibration image according to the calibration coordinate system, where the second region of interest includes a rectangular frame structure in the first calibration area; The calibration module is specifically configured to calculate the sum of the squared gradients of all pixels in each second region of interest; and, if the difference between the sum of the squared gradients of any two of the at least three second regions of interest is less than a first preset difference, it is determined that the camera device is not tilted in the X-axis and Y-axis directions relative to the calibration image; and, if the difference between the sum of the squared gradients of any two of the at least three second regions of interest is greater than or equal to the first preset difference, it is determined that the camera device is tilted in the X-axis and / or Y-axis directions relative to the calibration image; Or, The acquisition module is further configured to acquire four third regions of interest in the calibration image according to the calibration coordinate system, where the third region of interest includes a partial border of a rectangular frame structure in the first calibration area; The calibration module is specifically configured to perform linear fitting processing on each third region of interest to identify the first straight line in each third region of interest; and, select a plurality of calibration points on the first straight line at a preset distance; and, determine the gradient value of the edge pixel corresponding to each calibration point, where the edge pixel is in the normal direction of the calibration point; and, count the number of edge pixels corresponding to each calibration point whose gradient value is greater than the gradient threshold; and, if the difference between the number of transition pixels of any two of the four third regions of interest is less than or equal to the first preset number, determine that the imaging device is not tilted in the X-axis and Y-axis directions relative to the calibration image; and, if the difference between the number of transition pixels of any two of the four third regions of interest is greater than the first preset number, determine that the imaging device is tilted in the X-axis and / or Y-axis directions relative to the calibration image; where the number of transition pixels is the mode, average value or weighted average value of the number of edge pixels of the plurality of calibration points. and / or, The first calibration area of the calibration plate includes four rectangular frame structures, and the four rectangular frame structures of the first calibration area are correspondingly distributed at the four corners of the positioning area; the calibration information includes focusing information: The acquisition module is further configured to acquire a second region of interest in the calibration image according to the calibration coordinate system, and the second region of interest includes one rectangular frame structure in the first calibration area. The calibration module is specifically configured to determine that the imaging device is in focus if the sum of the squares of the gradients of any second region of interest is less than the calibration gradient value; and determine that the imaging device is not in focus if the sum of the squares of the gradients of any second region of interest is greater than or equal to the calibration gradient value. Or, The acquisition module is further configured to acquire a third region of interest in the calibration image according to the calibration coordinate system, and the third region of interest includes a partial border of one rectangular frame structure in the first calibration area. The calibration module is specifically configured to accumulate the maximum gradient values corresponding to a plurality of calibration points to obtain the focusing degree of the third region of interest; if the focusing degree of any third region of interest is greater than or equal to the focusing degree threshold, and the number of transition pixels of the any third region of interest is less than or equal to the second preset number, determine that the imaging device is in focus; if the focusing degree of any third region of interest is less than the focusing degree threshold, and / or the number of transition pixels in the any third region of interest is greater than the second preset number, determine that the imaging device is not in focus.
8. The calibration device according to claim 7, wherein The second calibration area of the calibration plate includes at least two alignment lines of the same length, and at least two of the alignment lines are cross-set; the calibration information includes centering information; The acquisition module is further configured to acquire a fourth region of interest of the calibration image according to the calibration coordinate system, and the fourth region of interest includes the second calibration area of the calibration plate. The calibration module is specifically configured to perform threshold segmentation processing on the fourth region of interest to determine the contour information of the second calibration area; and, Determine the central coordinates of the second calibration region in the four regions of interest according to the calibration coordinate system and the contour information; and, If the central coordinates are within the calibration coordinate range, determine that the field of view of the imaging device is centered; And, If the central coordinates exceed the calibration coordinate range, determine that the field of view of the imaging device is not centered.
9. The calibration device according to claim 7, wherein The third calibration region of the calibration plate is configured as a circular structure, and the calibration information includes deformation information; The acquisition module is further configured to acquire a fifth region of interest of the calibration image according to the calibration coordinate system, and the fifth region of interest includes the third calibration region of the calibration plate; The calibration module is specifically configured to perform threshold segmentation processing on the fifth region of interest to determine the contour information of the third calibration region; and, Detect the roundness of the third calibration region in the fifth region of interest according to the contour information; And, If the roundness is less than the calibration roundness, determine that the calibration image is deformed; And, If the roundness is greater than or equal to the calibration roundness, determine that the calibration image is not deformed.
10. The calibration device according to claim 7, wherein The fourth calibration region of the calibration plate is configured as a rectangular frame structure; the calibration information includes viewing angle information; The acquisition module is further configured to acquire a sixth region of interest of the calibration image according to the calibration coordinate system, and the sixth region of interest includes two adjacent sides of the fourth calibration region of the calibration plate; The calibration module is specifically configured to perform a straight line fitting process on the sixth region of interest to determine two second straight lines in the sixth region of interest; and, Detect the angle between the two second straight lines; and, If the angle is within the calibration angle range, determine that the viewing angle of the imaging device is perpendicular to the moving direction of the imaging device; and, If the angle exceeds the calibration angle range, determine that the viewing angle of the imaging device is not perpendicular to the moving direction of the imaging device.
11. The calibration device according to claim 7, characterized in that, The fourth calibration region of the calibration plate is configured as a rectangular frame structure; the calibration information includes pixel equivalent information; The acquisition module is further configured to acquire a seventh region of interest of the calibration image according to the calibration coordinate system, and the seventh region of interest includes two opposite sides of the fourth calibration region of the calibration plate; The calibration module is specifically configured to perform a straight line fitting process on the seventh region of interest to determine two third straight lines in the seventh region of interest; and, Determine the pixel distance between the two third straight lines; and, Calculate the pixel equivalent of the calibration image according to the pixel distance and the actual distance between two opposite sides of the fourth calibration region; And, If the pixel equivalent is within the calibration pixel equivalent range, determine that the pixel equivalent is normal; And, If the pixel equivalent exceeds the calibration pixel equivalent range, determine that the pixel equivalent is abnormal.
12. The calibration device according to claim 7, wherein, The first calibration region of the calibration plate includes four rectangular frame structures, the fourth calibration region of the calibration plate is configured as a rectangular frame structure, and the distance between the center point of the fourth calibration region and the center point of the calibration plate is less than a second preset distance; the calibration information includes color difference information; The obtaining module is further configured to obtain five eighth regions of interest of the calibration image according to the calibration coordinate system, where the eighth regions of interest include the regions enclosed by the rectangular frame structures of the first calibration region or the regions enclosed by the rectangular frame structures of the fourth calibration region; The calibration module is specifically configured to identify the gray values of all the pixel points in each eighth region of interest; And, calculate the average gray value of each eighth region of interest according to the gray values; and, if the difference between the average gray values of any two of the five eighth regions of interest is less than a second preset difference, determine that there is no color difference in the calibration image; and, if the difference between the average gray values of any two of the five eighth regions of interest is greater than or equal to the second preset difference, determine that there is a color difference in the calibration image.
13. A readable storage medium, on which a program or instructions are stored, characterized in that, When the program or instruction is executed by a processor, the steps of the calibration method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Multi-view image calibration device and method
CN111127561A
Camera correction jig and method for correcting camera
JP2021067514A