Flatness visual detection method and device, electronic equipment and storage medium

By setting up multiple light sources in the monocular camera optical detection system, the images and grayscale images under different light sources of the workpiece are obtained, and the geometric relationship and grayscale value correspondence relationship are used to solve the problem that the monocular camera cannot detect three-dimensional deformation, and the effective detection of the planet of the workpiece is achieved.

CN119991559APending Publication Date: 2025-05-13SHENZHENSHI YUZHAN PRECISION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411914313.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

In the test piece deformation measurement, a monocular camera can only determine the two-dimensional dimensions and contours of the product, and it is impossible to determine whether the product has undergone three-dimensional deformation.

Method used

By setting up a set of light sources and a monocular camera, the image and grayscale map of the workpiece under different light sources are obtained, and the geometric relationship and grayscale value correspondence of the optical detection system are used to determine the true plane size of the workpiece at each pixel point, and planarity detection is performed.

Benefits of technology

The use of a monocular camera to detect the planeness of the workpiece, which can determine whether the workpiece has undergone three-dimensional deformation, and improves the accuracy of the detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119991559A_ABST
    Figure CN119991559A_ABST
Patent Text Reader

Abstract

The invention discloses a flatness visual detection method and device, electronic equipment and a storage medium. The flatness visual detection method and device are used for detecting the flatness of a product through a monocular camera. The method comprises: acquiring images of a workpiece under a first light source and a second light source; obtaining a grey-scale map based on the image; obtaining a first gray value and a second gray value based on the gray-scale map; representing a representation corresponding relation including a first gray value and a second gray value based on a plane calibration size and a plane real size corresponding to a target pixel point location in the image and a relative geometrical relation of an optical detection system, and determining the plane real size of the workpiece at the target pixel point location; and detecting the flatness of the workpiece according to the real plane size. When the workpiece is deformed, different gray values can be obtained when light rays at different angles irradiate the workpiece, the real plane size of the pixel point can be obtained by constructing the corresponding relation of the gray values under illumination at different angles, and flatness detection can be carried out on the workpiece according to the real plane size.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image detection technology, and specifically to a flatness visual detection method, device, electronic device and storage medium. Background Art

[0002] In the related technology, monocular cameras are widely used in the field of specimen deformation measurement. When using a monocular camera, a light source needs to be set. The light source shines on the product, and the product reflects the light to the photoelectric sensor of the monocular camera. Then the monocular camera measures the product size according to the degree of reflection of the product. However, the monocular camera can only determine the two-dimensional size and contour of the product, and cannot determine whether the product has undergone three-dimensional deformation. Summary of the invention

[0003] In view of this, the present application provides a flatness visual inspection method, device, electronic device and storage medium to facilitate the use of a monocular camera to inspect the flatness of a product.

[0004] In a first aspect, an embodiment of the present application provides a flatness visual detection method, which is applied to an optical detection system, wherein the optical detection system comprises: a monocular camera perpendicular to an area to be detected, and a first light source and a second light source located on both sides of the monocular camera and facing the area to be detected; the method comprises: Acquire a first image of the workpiece under the first light source and a second image of the workpiece under the second light source; Acquire a first grayscale image corresponding to the first image, and a second grayscale image corresponding to the second image; Determine a first grayscale value of a target pixel in the first grayscale image, and a second grayscale value of the target pixel in the second grayscale image; Based on the plane calibration size corresponding to the target pixel position, the plane real size, and the relative geometric relationship of the optical detection system, a characterization correspondence relationship including the first grayscale value and the second grayscale value is characterized, and the plane real size of the workpiece corresponding to the target pixel position is confirmed; wherein the plane calibration size is the pixel measurement size of the monocular camera after calibration; Whether the flatness of the workpiece is qualified is determined according to the true plane size of the target pixel point.

[0005] In some possible embodiments, determining the plane real size of the target pixel position according to the plane calibration size corresponding to the target pixel position, the first grayscale value, and the second grayscale value using a geometric relationship in the optical detection system includes: Based on the plane calibration size and the plane real size corresponding to the target pixel point (the plane real size can be regarded as an unknown quantity at this time), and in combination with the relative geometric relationship of the optical detection system, a first fitted undulating area of ​​the workpiece under the first light source and a second fitted undulating area of ​​the workpiece under the second light source are characterized; Based on the first fitting undulating area and the second fitting undulating area, the first grayscale value and the second grayscale value are characterized to obtain the plane real size of the target pixel position.

[0006] In some possible embodiments, characterizing the first grayscale value and the second grayscale value based on the first fitting undulation area and the second fitting undulation area, and acquiring the plane real size of the target pixel position includes: Calculate the plane real size L of the target pixel point; wherein the specific calculation formula includes: in, is the first gray value, is the second gray value, is the conversion factor, is the light intensity of the first light source, is the light intensity of the second light source, is the light emitting angle of the first light source, is the luminous angle of the second light source, Calibrate the dimensions for the plane.

[0007] In some possible embodiments, determining whether the flatness of the workpiece is qualified according to the real plane size of the target pixel point includes: Acquire a fitting deformation inclination angle of the target pixel position according to the plane calibration size and the plane real size of the target pixel position; Determine whether the fitting deformation inclination angle is greater than the luminous angle of the first light source ; If it is greater than the luminous angle of the first light source , it is determined that the flatness of the workpiece is unqualified; If not greater than , it is determined whether the fitting deformation inclination angle is greater than the luminous angle of the second light source ; If it is greater than the luminous angle of the second light source , it is determined that the flatness of the workpiece is unqualified.

[0008] In some possible embodiments, acquiring the fitting deformation inclination angle of the target pixel position according to the plane calibration size and the plane real size of the target pixel position includes: Calculate the fitting deformation inclination angle of the target pixel point ; Among them, the specific calculation formula includes: .

[0009] In some possible embodiments, determining whether the flatness of the workpiece is qualified according to the real plane size of the target pixel point includes: According to the plane calibration size and the plane real size of the target pixel point, obtaining the height size of the target pixel point; According to the height size of the target pixel point, obtaining the pixel height accumulation value of the target area on the workpiece; Determine whether the pixel height accumulation value is greater than a height threshold; If it is greater than the height threshold, it is determined that the flatness of the workpiece is unqualified.

[0010] In a second aspect, an embodiment of the present application provides a flatness visual detection device, which is applied to an optical detection system, wherein the optical detection system comprises: a monocular camera perpendicular to an area to be detected, and a first light source and a second light source located on both sides of the monocular camera and facing the area to be detected; the device comprises: An image acquisition module, used to acquire a first image of the workpiece under the first light source and a second image of the workpiece under the second light source; A grayscale processing module, configured to obtain a first grayscale image corresponding to the first image and a second grayscale image corresponding to the second image; A grayscale value determination module, used to determine a first grayscale value of a target pixel in the first grayscale image, and a second grayscale value of the target pixel in the second grayscale image; A size determination module is used to characterize the corresponding relationship including the first grayscale value and the second grayscale value based on the plane calibration size corresponding to the target pixel point, the plane real size, and the relative geometric relationship of the optical detection system, and confirm the plane real size of the workpiece corresponding to the target pixel point; wherein the plane calibration size is the pixel measurement size of the monocular camera after calibration; The flatness detection module is used to determine whether the flatness of the workpiece is qualified according to the real plane size of the target pixel point.

[0011] In some possible embodiments, the size determination module is specifically used to: Based on the plane calibration size and the plane real size corresponding to the target pixel point (the plane real size can be regarded as an unknown quantity at this time), and in combination with the relative geometric relationship of the optical detection system, a first fitted undulating area of ​​the workpiece under the first light source and a second fitted undulating area of ​​the workpiece under the second light source are characterized; Based on the first fitting undulating area and the second fitting undulating area, the first grayscale value and the second grayscale value are characterized to obtain the plane real size of the target pixel position.

[0012] In some possible embodiments, the size determination module is specifically used to: Calculate the plane real size L of the target pixel point; wherein the specific calculation formula includes: in, is the first gray value, is the second gray value, is the conversion factor, is the light intensity of the first light source, is the light intensity of the second light source, is the light emitting angle of the first light source, is the luminous angle of the second light source, Calibrate the dimensions for the plane.

[0013] In some possible embodiments, the flatness detection module is specifically used to: Acquire a fitting deformation inclination angle of the target pixel position according to the plane calibration size and the plane real size of the target pixel position; Determine whether the fitting deformation inclination angle is greater than the luminous angle of the first light source ; If it is greater than the luminous angle of the first light source , it is determined that the flatness of the workpiece is unqualified; If it is not greater than the luminous angle of the first light source , it is determined whether the fitting deformation inclination angle is greater than the luminous angle of the second light source ; If it is greater than the luminous angle of the second light source , it is determined that the flatness of the workpiece is unqualified.

[0014] In some possible embodiments, the flatness detection module is specifically used to: Calculate the fitting deformation inclination angle of the target pixel point ; Among them, the specific calculation formula includes: .

[0015] In some possible embodiments, the flatness detection module is specifically used to: According to the plane calibration size and the plane real size of the target pixel point, obtaining the height size of the target pixel point; According to the height size of the target pixel point, obtaining the pixel height accumulation value of the target area on the workpiece; Determine whether the pixel height accumulation value is greater than a height threshold; If it is greater than the height threshold, it is determined that the flatness of the workpiece is unqualified.

[0016] In a third aspect, an embodiment of the present application provides a system, comprising processing equipment, the processing quality control device described in the third aspect, and the process quality cause finding device described in the fourth aspect, wherein the processing equipment sends parameter information to the processing quality control device.

[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program executable by a computer device. When the program runs on the computer device, the computer device executes the steps of the method described in any one of the first and second aspects above.

[0018] In the embodiment of the present application, if the workpiece is deformed, the grayscale values ​​of the grayscale image of the workpiece will be different when light at different angles is irradiated on the workpiece. By constructing a corresponding relationship between the grayscale values ​​of the workpiece under light at different angles, the actual planar size of the workpiece at each pixel point can be obtained, and then the flatness of the workpiece can be detected based on the actual planar size of each pixel point, thereby realizing the flatness detection of the workpiece using a two-dimensional camera. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0020] Figure 1 A schematic diagram of an optical system for flatness visual inspection provided in an embodiment of the present application; Figure 2 A schematic diagram of the overall process of visual flatness inspection provided in an embodiment of the present application; Figure 3A schematic diagram of the actual plane size and the plane calibration size of a target pixel point for flatness visual detection provided in an embodiment of the present application; Figure 4 A schematic diagram of a process for determining the true plane size of a target pixel position by using a geometric relationship in an optical detection system in a flatness visual detection provided in an embodiment of the present application; Figure 5 A schematic diagram of a fitted deformation inclination angle corresponding to a target pixel position for flatness visual detection provided in an embodiment of the present application; Figure 6 A schematic diagram of a process of performing flatness inspection on a workpiece by a flatness visual inspection provided in an embodiment of the present application; Figure 7 Another schematic diagram of a process of flatness detection of a workpiece by a flatness visual detection provided in an embodiment of the present application; Figure 8 A schematic diagram of the height dimensions of a target pixel point for flatness visual detection provided in an embodiment of the present application; Fig. 9 A schematic diagram of a target area for flatness visual inspection provided in an embodiment of the present application; Fig.10 A schematic diagram of a device for visual flatness inspection provided in an embodiment of the present application; Fig.11 An electronic device for visual flatness detection is provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0022] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0023] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0024] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0025] The inventors have found that in the related technology, monocular cameras are widely used in the field of specimen deformation measurement. When using a monocular camera, a light source needs to be set. The light source shines on the product, and the product reflects the light to the photoelectric sensor of the monocular camera. Then the monocular camera measures the product size according to the degree of reflection of the product. However, the monocular camera can only determine the two-dimensional size and contour of the product, and cannot determine whether the product has undergone three-dimensional deformation.

[0026] In view of the above problems, the embodiments of the present application provide a flatness visual detection method, device, electronic device and storage medium for solving the above problems. An optical detection system is provided in the present application, which includes a monocular camera perpendicular to the area to be detected, and a first light source and a second light source located on both sides of the monocular camera and facing the area to be detected. Based on the optical detection system, the inventive concept of the present application can be summarized as follows: first, a first image of the workpiece under the first light source and a second image under the second light source are obtained; a first grayscale image corresponding to the first image and a second grayscale image corresponding to the second image are obtained; a first grayscale value of a target pixel point in the first grayscale image and a second grayscale value of a target pixel point in the second grayscale image are determined; based on the plane calibration size corresponding to the target pixel point, the plane real size, and the relative geometric relationship of the optical detection system, a characterization correspondence relationship including the first grayscale value and the second grayscale value is characterized, and the plane real size corresponding to the target pixel point of the workpiece at the target pixel point is confirmed; wherein the plane calibration size is the pixel measurement size of the monocular camera after calibration; according to the plane real size of the target pixel point, the flatness of the workpiece is detected.

[0027] In the present application, if the workpiece is deformed, the grayscale values ​​of the grayscale image of the workpiece will be different when light at different angles is irradiated on the workpiece. By constructing a corresponding relationship between the grayscale values ​​of the workpiece under light at different angles, the actual planar size of the workpiece at each pixel point can be obtained, and then the flatness of the workpiece can be detected based on the actual planar size of each pixel point.

[0028] For ease of understanding, a flatness visual inspection method, device, electronic device, and storage medium provided in an embodiment of the present application are described in detail below in conjunction with the accompanying drawings: First, an optical detection system 10 provided in an embodiment of the present application is described. Figure 1FIG. 1 is a schematic diagram of the structure of an optical detection system 10, which includes a monocular camera 101, a first light source 102, and a second light source 103, wherein: The monocular camera 101 is perpendicular to the area to be detected, and is used to capture a first image of a workpiece in the area to be detected under a first light source 102, and is used to capture a second image of the workpiece under a second light source 103; The first light source 102 is located at one side of the area to be detected and faces the area to be detected. The light intensity is recorded as , the luminous angle is recorded as ; The second light source 103 is located at the other side of the area to be detected and faces the area to be detected. The light intensity is recorded as , the luminous angle is recorded as .

[0029] The light emitting angle is the angle between the light source and the parallel lines corresponding to the area to be detected.

[0030] The overall process of a flatness visual inspection method provided in an embodiment of the present application is described below. Figure 2 As shown, where: In step 201: a first image of a workpiece under a first light source and a second image of a workpiece under a second light source are acquired.

[0031] In an embodiment of the present application, when acquiring the first image, the first light source needs to be in a luminous state, while the second light source is in a non-luminous state. Similarly, when acquiring the second image, the first light source needs to be in a non-luminous state, while the second light source is in a luminous state.

[0032] In step 202: a first grayscale image corresponding to the first image and a second grayscale image corresponding to the second image are obtained.

[0033] In the embodiment of the present application, a method of obtaining a first grayscale image based on the first image and a method of obtaining a second grayscale image based on the second image are the same as a method of obtaining a grayscale image in the related art, and will not be described in detail here.

[0034] For the same workpiece, the brightness of the surface of the workpiece is the same. Under the same brightness, the surface layer height of the material with a larger reflectivity is lower, and the surface layer height of the material with a smaller reflectivity is higher. Therefore, the grayscale values ​​of different pixel points in the grayscale image can be mapped to the height value of the pixel point on the workpiece.

[0035] In step 203: determine a first grayscale value of a target pixel in the first grayscale image and a second grayscale value of a target pixel in the second grayscale image.

[0036] In the embodiment of the present application, after obtaining the first grayscale image and the second grayscale image, the grayscale value of the same pixel under illumination of light sources at different angles can be obtained based on the first grayscale image and the second grayscale image respectively.

[0037] In step 204: based on the plane calibration size corresponding to the target pixel position, the plane real size (at this time the plane real size can be regarded as an unknown quantity), and the relative geometric relationship of the optical detection system, a characterization correspondence relationship including the first grayscale value and the second grayscale value is characterized, and the plane real size of the workpiece corresponding to the target pixel position is confirmed; wherein the plane calibration size is the pixel measurement size after the monocular camera is calibrated.

[0038] In the embodiment of the present application, by constructing a representation correspondence relationship including a first grayscale value and a second grayscale value, the grayscale value of a target pixel under light sources at different angles can be mapped to the actual plane size corresponding to the pixel.

[0039] For example: Figure 3 As shown, the actual plane size of the target pixel point is L, and the pixel measurement size measured by the monocular camera after calibration is the plane calibration size. .

[0040] In some possible embodiments, according to the plane calibration size, the first grayscale value and the second grayscale value corresponding to the target pixel position, the plane real size of the target pixel position is determined by using the geometric relationship in the optical detection system, which can be specifically implemented as follows: Figure 4 The steps shown, where: In step 401: based on the plane calibration size and the plane real size corresponding to the target pixel point, and combined with the relative geometric relationship of the optical detection system, a first fitting undulating area of ​​the workpiece under the first light source and a second fitting undulating area of ​​the workpiece under the second light source are characterized.

[0041] In an embodiment of the present application, when the first light source is turned on, the target pixel point will generate a projection area in the direction of the first light source, and the projection area is the first fitting undulation area of ​​the workpiece under the first light source. When the second light source is turned on, the projection area generated by the target pixel point in the direction of the second light source is the enemy fitting undulation area.

[0042] For example: Figure 5 As shown, the actual plane size of the target pixel point is recorded as L, and the plane calibration size is recorded as , the fitting deformation inclination angle corresponding to the target pixel position is recorded as , based on the trigonometric function relationship, the true size of the plane can be obtained , according to the inverse trigonometric function, the fitting deformation inclination angle can be obtained According to the area formula and the obtained deformation inclination angle, the first fitting undulation area of ​​the target pixel under the first light can be obtained. Similarly, the second fitting fluctuation area of ​​the target pixel under the second light is obtained ,in As shown in formula 1, As shown in Formula 2: , (Formula 1) , (Formula 2) in, is the first fitting undulation area; Calibrate the dimensions for the plane; is the light-emitting angle of the first light source, the first light source may be a parallel light source, and the light-emitting angle is the angle between the light emitted by the first light source and the vertical direction; is the true size of the plane; is the second fitting undulation area; is the light-emitting angle of the second light source. The second light source may be a parallel light source. The light-emitting angle is the angle between the light emitted by the second light source and the vertical direction.

[0043] In step 402: based on the first fitting undulation area and the second fitting undulation area, the first grayscale value and the second grayscale value are characterized to obtain the plane real size of the target pixel position.

[0044] In the embodiment of the present application, since the gray value of the workpiece in the area to be detected is positively correlated with the light source projection area generated under the irradiation of the light source, that is, ,in is the gray value of the workpiece, is the conversion factor, is the light intensity of the light source, It is the light source projection area generated by the workpiece under the illumination of the light source. Therefore, after obtaining the first fitting undulation area and the second fitting undulation area, the real size of the plane can be obtained according to the relationship between the first fitting undulation area, the second fitting undulation area and the grayscale value.

[0045] In some possible embodiments, Formula 3 may be used to characterize the relationship between the first fitting undulation area and the first grayscale value, and Formula 4 may be used to characterize the relationship between the second fitting undulation area and the second grayscale value: , (Formula 3) , (Formula 4) in, is the first gray value, is the second gray value, is the conversion factor, is the light intensity of the first light source, is the light intensity of the second light source, is the luminous angle of the first light source, is the luminous angle of the second light source, is the true size of the plane, is the second fitting fluctuation area, is the luminous angle of the second light source, Calibrate the dimensions for the plane.

[0046] In Formula 3 and Formula 4, , , , , , , All are known parameters, so only the actual size of the plane is And plane calibration dimensions is an unknown parameter. At this time, the true size of the plane can be obtained by combining formula 3 and formula 4. And plane calibration dimensions .

[0047] In step 205: the flatness of the workpiece is detected according to the actual plane size of the target pixel point.

[0048] In the embodiment of the present application, after obtaining the plane real size and the plane calibration size of the target pixel point, the flatness of the workpiece can be detected according to the plane real size and the plane calibration size of the target pixel point.

[0049] In some possible embodiments, the flatness detection of the workpiece is performed according to the real plane size of the target pixel point, which can be specifically implemented as follows: Figure 6 The steps shown, where: In step 601: according to the plane calibration size and the plane real size of the target pixel point, the fitting deformation inclination angle of the target pixel point is obtained.

[0050] In the embodiment of the present application, after obtaining the plane calibration size and the plane real size of the target pixel point, the fitting deformation inclination angle can be obtained based on trigonometric functions and inverse trigonometric functions.

[0051] For example: Figure 5 As shown, the actual plane size of the target pixel point is recorded as L, and the plane calibration size is recorded as , the deformation inclination angle corresponding to the target pixel position is recorded as , based on the trigonometric function relationship, the true size of the plane can be obtained , according to the inverse trigonometric function, the fitting deformation inclination angle can be obtained . In step 602: determine whether the fitting deformation inclination angle is greater than the light emitting angle of the first light source , if it is greater than the luminous angle of the first light source Then proceed to step 603 , otherwise, proceed to step 604 .

[0052] In the embodiment of the present application, if there is a fitting deformation inclination angle greater than If the target pixel point is not calibrated, it means that the difference between the plane actual size and the plane calibration size of the target pixel point is too large, that is, the deformation of the target pixel point is serious, so the workpiece can be judged as unqualified.

[0053] In step 603: the flatness of the workpiece is determined to be unqualified.

[0054] In step 604: determine whether the fitting deformation inclination angle is greater than the light emitting angle of the second light source , if it is greater than the luminous angle of the second light source , then go to step 603, otherwise go to step 605.

[0055] In the embodiment of the present application, if there is a fitting deformation in the workpiece whose inclination angle is greater than the luminous angle of the second light source If the target pixel point is not calibrated, it means that the difference between the actual plane size and the plane calibration size of the target pixel point is too large, that is, the deformation of the target pixel point is serious, so it can be judged that the flatness of the workpiece is unqualified.

[0056] In step 605: the flatness of the workpiece is determined to be acceptable.

[0057] In the embodiment of the present application, if there is no fitting deformation inclination angle greater than the light emitting angle of the second light source in the workpiece There is no target pixel point, and there is no fitting deformation angle greater than the luminous angle of the first light source. If there are target pixel points, it means that the difference between the plane actual size and the plane calibration size of all target pixel points in the workpiece is not large, that is, there are no target pixel points with serious deformation, so it can be judged that the flatness of the workpiece is qualified.

[0058] In some other possible embodiments, in addition to using the above Figure 6 In addition to the method shown in the figure, the flatness of the workpiece can also be detected by Figure 7 The steps shown are used to detect the flatness of the workpiece, where: In step 701: according to the plane calibration size and the plane real size of the target pixel point, the height size of the target pixel point is obtained.

[0059] In the embodiment of the present application, after obtaining the plane calibration size and the plane real size of the target pixel point, the height size of the target pixel point can be obtained according to the Pythagorean theorem.

[0060] For example: Figure 8 As shown, the plane calibration size is , the actual size of the plane is L, then the height size of the target pixel point Can be characterized as .

[0061] In step 702: according to the height size of the target pixel point, the accumulated value of the pixel height of the target area on the workpiece is obtained.

[0062] In an embodiment of the present application, the target area can be divided on the workpiece in advance, and then after obtaining the height dimension corresponding to each target pixel point in the target area, the height dimensions corresponding to each target pixel point in the target area are accumulated, and then the flatness of the workpiece is detected based on the accumulated pixel height value.

[0063] For example: Fig. 9 As described above, the target area of ​​the workpiece 1 is A, and the target area A includes 25 target pixel points. Then the accumulated value of the pixel height of the target area A can be represented as: .

[0064] In step 703: determine whether the accumulated pixel height value is greater than the height threshold.

[0065] In the embodiment of the present application, if the accumulated value of the pixel height is greater than a threshold value, it means that the target pixel point in the target area has large fluctuations, and therefore it can be determined that the flatness of the workpiece is unqualified.

[0066] In step 704: if it is greater than the height threshold, it is determined that the flatness of the workpiece is unqualified.

[0067] In some other possible embodiments, if Figure 7 The method shown in the figure determines that the flatness of the workpiece is qualified. In order to improve the accuracy of flatness detection, the following can be implemented Figure 8 The steps shown, where: In step 801: a second target area is selected from the workpiece, and a height dimension corresponding to each target pixel point in the second target area is determined.

[0068] That is, in the embodiment of the present application, according to Figure 7If the steps shown determine that the cumulative pixel height value of the target area is less than the height threshold, another area can be selected in the workpiece as the target area again, and the cumulative pixel height value of the target area this time can be determined. If the cumulative pixel height value of the target area this time is also less than the height threshold, the workpiece can be judged to be qualified.

[0069] In step 802: according to the height size of the target pixel point, the pixel height accumulation value of the second target area is obtained.

[0070] The specific implementation of this step is the same as step 702 and will not be described again here.

[0071] In step 803: determine whether the accumulated pixel height value is greater than the height threshold.

[0072] The specific implementation of this step is the same as step 703 and will not be described again here.

[0073] In step 804: if it is greater than the height threshold, the flatness of the workpiece is deemed unqualified.

[0074] The specific implementation of this step is the same as step 704 and will not be described again here.

[0075] Based on the same inventive concept, the present application also provides a flatness visual inspection device, such as Fig.10 As shown, the device comprises: An image acquisition module 10001 is used to acquire a first image of the workpiece under the first light source and a second image of the workpiece under the second light source; A grayscale processing module 10002 is configured to obtain a first grayscale image corresponding to the first image and a second grayscale image corresponding to the second image; A grayscale value determination module 10003 is used to determine a first grayscale value of a target pixel in the first grayscale image and a second grayscale value of the target pixel in the second grayscale image; The size determination module 10004 is used to characterize the corresponding relationship including the first grayscale value and the second grayscale value based on the plane calibration size corresponding to the target pixel point, the plane real size, and the relative geometric relationship of the optical detection system, and confirm the plane real size of the workpiece corresponding to the target pixel point; wherein the plane calibration size is the pixel measurement size of the monocular camera after calibration; The flatness detection module 10005 is used to determine whether the flatness of the workpiece is qualified according to the actual plane size of the target pixel point.

[0076] In some possible embodiments, the size determination module 10004 is specifically used to: Based on the plane calibration size and the plane real size corresponding to the target pixel point, and in combination with the relative geometric relationship of the optical detection system, characterize a first fitted undulating area of ​​the workpiece under the first light source and a second fitted undulating area of ​​the workpiece under the second light source; Based on the first fitting undulating area and the second fitting undulating area, the first grayscale value and the second grayscale value are characterized to obtain the plane real size of the target pixel position.

[0077] In some possible embodiments, the size determination module 10004 is specifically used to: Calculate the plane real size L of the target pixel point; wherein the specific calculation formula includes: in, is the first gray value, is the second gray value, is the conversion factor, is the light intensity of the first light source, is the light intensity of the second light source, is the light emitting angle of the first light source, is the luminous angle of the second light source, Calibrate the dimensions for the plane.

[0078] In some possible embodiments, the flatness detection module 10005 is specifically used to: Acquire a fitting deformation inclination angle of the target pixel position according to the plane calibration size and the plane real size of the target pixel position; Determine whether the fitting deformation inclination angle is greater than the luminous angle of the first light source ; If it is greater than the luminous angle of the first light source , it is determined that the flatness of the workpiece is unqualified; If it is not greater than the luminous angle of the first light source , it is determined whether the fitting deformation inclination angle is greater than the luminous angle of the second light source ; If it is greater than the luminous angle of the second light source , it is determined that the flatness of the workpiece is unqualified.

[0079] In some possible embodiments, the flatness detection module 10005 is specifically used to: Calculate the fitting deformation inclination angle of the target pixel point ; Among them, the specific calculation formula includes: .

[0080] In some possible embodiments, the flatness detection module 10005 is specifically used to: According to the plane calibration size and the plane real size of the target pixel point, obtaining the height size of the target pixel point; According to the height size of the target pixel point, obtaining the pixel height accumulation value of the target area on the workpiece; Determine whether the pixel height accumulation value is greater than a height threshold; If it is greater than the height threshold, it is determined that the flatness of the workpiece is unqualified.

[0081] Corresponding to the above embodiments, the present application also provides an electronic device. Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention, the electronic device 1100 may include: a processor 1101, a memory 1102 and a communication unit 1103. These components communicate through one or more buses. Those skilled in the art can understand that the structure of the electronic device shown in the figure does not constitute a limitation on the embodiment of the present invention, it can be a bus structure or a star structure, and can also include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0082] The communication unit 1103 is used to establish a communication channel so that the electronic device can communicate with other devices, receive user data sent by other devices or send user data to other devices.

[0083] The processor 1101 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It runs or executes software programs and / or modules stored in the memory 1102, and calls data stored in the memory to perform various functions of the electronic device and / or process data. The processor can be composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or it can be composed of multiple packaged ICs with the same or different functions. For example, the processor 1101 can only include a central processing unit (CPU). In an embodiment of the present invention, the CPU can be a single computing core or multiple computing cores.

[0084] The memory 1102 is used to store the execution instructions of the processor 1101. The memory 1102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0085] When the execution instructions in the memory 1102 are executed by the processor 1101, the electronic device 1100 can execute Figure 7 Some or all of the steps in the illustrated embodiments.

[0086] In a specific implementation, the present invention further provides a computer storage medium, wherein the computer storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment of the calling method provided by the present invention. The storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0087] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.

[0088] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the device embodiment and the terminal embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiment.

Claims

1. A flatness visual inspection method, characterized in that: Applied to an optical detection system, the optical detection system comprises: a monocular camera perpendicular to the area to be detected, and a first light source and a second light source located on both sides of the monocular camera and facing the area to be detected; the method comprises: Acquire a first image of the workpiece under the first light source and a second image of the workpiece under the second light source; Acquire a first grayscale image corresponding to the first image, and a second grayscale image corresponding to the second image; Determine a first grayscale value of a target pixel in the first grayscale image, and a second grayscale value of the target pixel in the second grayscale image; Based on the plane calibration size corresponding to the target pixel position, the plane real size, and the relative geometric relationship of the optical detection system, a characterization correspondence relationship including the first grayscale value and the second grayscale value is characterized, and the plane real size corresponding to the target pixel position of the workpiece is confirmed; wherein the plane calibration size is the pixel measurement size of the monocular camera after calibration; Whether the flatness of the workpiece is qualified is determined according to the true plane size of the target pixel point.

2. The flatness visual inspection method according to claim 1, characterized in that: The determining the plane real size of the target pixel position according to the plane calibration size corresponding to the target pixel position, the first grayscale value and the second grayscale value by using the geometric relationship in the optical detection system comprises: Based on the plane calibration size corresponding to the target pixel position and in combination with the relative geometric relationship of the optical detection system, characterize a first fitting undulating area of ​​the workpiece under the first light source and a second fitting undulating area of ​​the workpiece under the second light source; Based on the first fitting undulating area and the second fitting undulating area, the first grayscale value and the second grayscale value are characterized to obtain the plane real size of the target pixel position.

3. The flatness visual inspection method according to claim 2, characterized in that: Characterizing the first grayscale value and the second grayscale value based on the first fitting undulating area and the second fitting undulating area, and acquiring the plane real size of the target pixel position, includes: Calculate the plane real size L of the target pixel point; wherein the calculation formula includes: in, is the first gray value, is the second gray value, is the conversion factor, is the light intensity of the first light source, is the light intensity of the second light source, is the luminous angle of the first light source, is the luminous angle of the second light source, Calibrate the dimensions for the plane.

4. The flatness visual inspection method according to claim 3, characterized in that: The step of determining whether the flatness of the workpiece is qualified according to the real plane size of the target pixel point comprises: Acquire a fitting deformation inclination angle of the target pixel position according to the plane calibration size and the plane real size of the target pixel position; Determine whether the fitting deformation inclination angle is greater than the luminous angle of the first light source ; If it is greater than the luminous angle of the first light source , it is determined that the flatness of the workpiece is unqualified; If it is not greater than the luminous angle of the first light source , it is determined whether the fitting deformation inclination angle is greater than the luminous angle of the second light source ; If it is greater than the luminous angle of the second light source , it is determined that the flatness of the workpiece is unqualified.

5. The flatness visual inspection method according to claim 4, characterized in that: The step of obtaining the fitting deformation inclination angle of the target pixel position according to the plane calibration size and the plane real size of the target pixel position includes: Calculate the fitting deformation inclination angle of the target pixel point ; The calculation formula includes: 。 6. The flatness visual inspection method according to claim 1, characterized in that: The step of determining whether the flatness of the workpiece is qualified according to the real plane size of the target pixel point comprises: According to the plane calibration size and the plane real size of the target pixel point, obtaining the height size of the target pixel point; According to the height size of the target pixel point, obtaining the pixel height accumulation value of the target area on the workpiece; Determine whether the pixel height accumulation value is greater than a height threshold; If it is greater than the height threshold, it is determined that the flatness of the workpiece is unqualified.

7. A flatness visual inspection device, characterized in that: Applied to an optical detection system, the optical detection system comprises: a monocular camera perpendicular to the area to be detected, and a first light source and a second light source located on both sides of the monocular camera and facing the area to be detected; the device comprises: An image acquisition module, used to acquire a first image of the workpiece under the first light source and a second image of the workpiece under the second light source; A grayscale processing module, configured to obtain a first grayscale image corresponding to the first image and a second grayscale image corresponding to the second image; A grayscale value determination module, used to determine a first grayscale value of a target pixel in the first grayscale image, and a second grayscale value of the target pixel in the second grayscale image; A size determination module is used to characterize the corresponding relationship including the first grayscale value and the second grayscale value based on the plane calibration size corresponding to the target pixel position, the plane real size, and the relative geometric relationship of the optical detection system, and confirm the plane real size of the workpiece corresponding to the target pixel position; wherein the plane calibration size is the pixel measurement size of the monocular camera after calibration; The flatness detection module is used to determine whether the flatness of the workpiece is qualified according to the real plane size of the target pixel point.

8. The device according to claim 7, characterized in that The size determination module is specifically used for: Based on the plane calibration size and the plane real size corresponding to the target pixel point, and in combination with the relative geometric relationship of the optical detection system, characterize a first fitted undulating area of ​​the workpiece under the first light source and a second fitted undulating area of ​​the workpiece under the second light source; Based on the first fitting undulating area and the second fitting undulating area, the first grayscale value and the second grayscale value are characterized to obtain the plane real size of the target pixel position.

9. An electronic device, characterized in that: The electronic device comprises a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 6.