Workpiece edge measurement method, device, electronic equipment and storage medium

Line matching is performed through the binocular structure light measurement system to determine the coordinates of the workpiece edge, solving the problems of low measurement efficiency and large errors in the prior art, and achieving more efficient and accurate edge measurement.

CN116883445BActive Publication Date: 2025-04-08ZG TECH CO LTD

Patent Information

Application Number
CN202311008382.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-10
Publication Date
2025-04-08
Estimated Expiration
2043-08-10

AI Technical Summary

Technical Problem

Existing sheet metal edge measurement methods are inefficient and easy to introduce measurement errors, especially contact measurement and stereo vision-based methods that have errors caused by deformation errors and illumination differences.

Method used

A binocular line structured light measurement system is used to collect the left and right images of the workpiece edge through a binocular camera, and line matching is performed to determine the line matching pairing, thereby determining the coordinates of the workpiece edge.

Benefits of technology

Improve the accuracy and efficiency of workpiece edge measurement, avoid deformation errors caused by contact measurement, and reduce errors caused by light and field of view in stereoscopic visual measurements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116883445B_ABST
    Figure CN116883445B_ABST
Patent Text Reader

Abstract

The present application provides a workpiece edge measurement method, device, electronic device and storage medium, the method comprising: obtaining a left image and a right image of the edge of a workpiece to be detected collected by a binocular camera; performing line-to-line matching according to at least one ray in the left image and at least one ray in the right image, and determining at least one line matching pair; determining the target first edge point and the target tail edge point of the projection light corresponding to each line matching pair according to the initial first edge point of the first ray, the initial first edge point of the second ray, the initial tail edge point of the first ray, the initial tail edge point of the second ray, the grayscale gradient value of each point in the first ray and the grayscale gradient value of each point in the second ray; determining the edge coordinates of the workpiece to be detected according to the target first edge point and the target tail edge point of the projection light corresponding to each line matching pair. The measurement error caused by the difference in viewing angle and illumination can be avoided, and the accuracy of the workpiece edge measurement can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of industrial measurement technology, and in particular to a workpiece edge measurement method, device, electronic equipment and storage medium. Background Art

[0002] Sheet metal parts are common components in industries such as automobiles, and sheet metal edge detection is an important part of sheet metal part inspection.

[0003] In the prior art, the common sheet metal edge measurement method is mostly contact single-point measurement, which has low measurement efficiency and is difficult to meet the production efficiency requirements; and the contact measurement method is prone to deformation of the sheet metal during the measurement process, introducing measurement errors. In addition, the prior art can also be based on binocular stereo vision for edge measurement, but the edge measurement method based on binocular stereo vision is easily affected by lighting conditions and camera field of view differences, resulting in large matching errors of the same-name points. In addition, when there are many edges, the edge matching based on binocular stereo is prone to mismatching, resulting in large measurement errors. Summary of the invention

[0004] The purpose of this application is to provide a workpiece edge measurement method, device, electronic device and storage medium to improve the accuracy of workpiece edge measurement in order to address the deficiencies in the above-mentioned prior art.

[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0006] In a first aspect, an embodiment of the present application provides a workpiece edge measurement method, which is applied to a control device in a binocular line structured light measurement system, wherein the binocular line structured light measurement system includes a line structured light device, a posture measurement device, and a control device, wherein the line structured light device includes a binocular camera and a line structured light emitter, and the method includes:

[0007] Acquire a left image and a right image of the edge of the workpiece to be detected captured by the binocular camera, wherein the left image and the right image respectively include at least one light beam projected by the line structured light emitter;

[0008] Performing line-to-line matching according to at least one light ray in the left image and at least one light ray in the right image to determine at least one line matching pair, wherein the line matching pair includes a first light ray in the left image and a second light ray in the right image, and the first light ray and the second light ray come from the same light ray projected by the line structured light emitter;

[0009] Determine, according to the coordinate information of each endpoint of the first ray and the coordinate information of each endpoint of the second ray in each line matching pair, the initial leading edge point of the first ray and the initial leading edge point of the second ray, as well as the initial trailing edge point of the first ray and the initial trailing edge point of the second ray in each line matching pair;

[0010] Determine the target first edge point and the target tail edge point of the projection light corresponding to each line matching pair according to the initial first edge point of the first light, the initial first edge point of the second light, the initial tail edge point of the first light, the initial tail edge point of the second light, the gray gradient value of each point in the first light, and the gray gradient value of each point in the second light;

[0011] The edge coordinates of the workpiece to be inspected are determined according to the target leading edge point and the target trailing edge point of the projection light corresponding to each line matching pair.

[0012] Optionally, performing line-to-line matching according to at least one light ray in the left image and at least one light ray in the right image to determine at least one line matching pair includes:

[0013] Determine, according to the ordinate of each first point in the current light ray in the left image, a second point in the right image having the same ordinate as the first point;

[0014] Determine the three-dimensional point coordinates corresponding to each first point according to the coordinates of each first point and the coordinates of each second point;

[0015] Each line matching pair is determined according to the three-dimensional point coordinates corresponding to each first point and the coordinates of each structured light surface corresponding to the line structured light emitter.

[0016] Optionally, determining each line matching pair according to the three-dimensional coordinates corresponding to each first point and the coordinates of the structured light surface corresponding to the line structured light emitter includes:

[0017] If the three-dimensional point coordinates corresponding to all the first points of the current light fall on any structured light surface, the line where the current light and the second points corresponding to the first points of the current light are located is determined to be a line matching pair.

[0018] Optionally, determining the initial leading edge point of the first ray and the initial leading edge point of the second ray in each line matching pair, as well as the initial trailing edge point of the first ray and the initial trailing edge point of the second ray in each line matching pair according to the coordinate information of each endpoint of the first ray and the coordinate information of each endpoint of the second ray, comprises:

[0019] Determine the starting point coordinates and the ending point coordinates of the first ray and the starting point coordinates and the ending point coordinates of the second ray of each line matching pair respectively;

[0020] If the difference between the ordinate in the first point coordinate of the first light ray and the ordinate in the first point coordinate of the second light ray is less than a first preset threshold, and the ordinate in the first point coordinate of the first light ray is not located at the boundary of the left image, and the ordinate in the first point coordinate of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the first point coordinate of the first light ray and the first point coordinate of the second light ray;

[0021] If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the first point of the first light are used as the coordinates of the initial first edge point of the first light, and the coordinates of the first point of the second light are used as the coordinates of the initial first edge point of the second light;

[0022] If the difference between the ordinate in the tail point coordinates of the first light ray and the ordinate in the tail point coordinates of the second light ray is less than a first preset threshold, and the ordinate in the tail point coordinates of the first light ray is not located at the boundary of the left image, and the ordinate in the tail point coordinates of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the tail point coordinates of the first light ray and the tail point coordinates of the second light ray;

[0023] If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the tail point of the first light ray are used as the coordinates of the initial tail edge point of the first light ray, and the coordinates of the tail point of the second light ray are used as the coordinates of the initial tail edge point of the second light ray.

[0024] Optionally, determining a target first edge point and a target tail edge point of the projection light corresponding to each line matching pair according to an initial first edge point of the first light, an initial first edge point of the second light, an initial tail edge point of the first light, an initial tail edge point of the second light, a gray gradient value of each point in the first light, and a gray gradient value of each point in the second light in each line matching pair includes:

[0025] Determine the target first edge point of the projection light corresponding to the line matching pair according to the initial first edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light;

[0026] The target tail edge point of the projection light corresponding to the line matching pair is determined according to the initial tail edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial tail edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light.

[0027] Optionally, determining the target first edge point of the projection light corresponding to the line matching pair according to the initial first edge point coordinates of the first light, the grayscale gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the grayscale gradient values ​​of each point in the second light, includes:

[0028] Selecting a first preset number of first edge points in the first light ray according to the coordinates of the initial first edge points of the first light ray;

[0029] Determine the middle first edge point of the first light ray according to the gray gradient value on the coordinates of the initial first edge point of the first light ray and the gray gradient values ​​of each first edge point;

[0030] selecting a second preset number of second edge points in the second light ray according to the coordinates of the initial first edge point of the second light ray;

[0031] Determine the middle first edge point of the second light according to the gray value at the coordinates of the initial first edge point of the second light and the gray value of each second edge point;

[0032] According to the middle first edge point of the first light ray and the middle first edge point of the second light ray, a target first edge point of the projection light ray corresponding to the line matching pair is determined.

[0033] Optionally, determining the target first edge point of the projection light corresponding to the line matching pair according to the target first edge point of the first light and the target first edge point of the second light includes:

[0034] Calculate the average of the ordinate of the middle first edge point of the first light ray and the ordinate of the middle first edge point of the second light ray to obtain an average ordinate;

[0035] Determine a point in the first light ray whose ordinate is the average ordinate as a target first edge point of the first light ray;

[0036] Determine a point in the second light ray whose ordinate is the average ordinate as a target first edge point of the second light ray;

[0037] The target first edge point of the projection light corresponding to the line matching pair is determined according to the target first edge point of the first light and the target first edge point of the second light.

[0038] In a second aspect, an embodiment of the present application further provides a workpiece edge measuring device, the device comprising:

[0039] An acquisition module, used to acquire a left image and a right image of the edge of the workpiece to be detected captured by the binocular camera, wherein the left image and the right image respectively include at least one light beam projected by the line structured light emitter;

[0040] a determination module, configured to perform line-to-line matching according to at least one ray in the left image and at least one ray in the right image, and determine at least one line matching pair, wherein the line matching pair includes a first ray in the left image and a second ray in the right image, and the first ray and the second ray come from the same ray projected by the line structured light emitter;

[0041] a determination module, configured to determine an initial leading edge point of the first ray and an initial leading edge point of the second ray in each line matching pair, as well as an initial trailing edge point of the first ray and an initial trailing edge point of the second ray in each line matching pair according to coordinate information of each endpoint of the first ray and coordinate information of each endpoint of the second ray in each line matching pair;

[0042] a determination module, for determining a target first edge point and a target tail edge point of the projection light corresponding to each line matching pair according to an initial first edge point of the first light, an initial first edge point of the second light, an initial tail edge point of the first light, an initial tail edge point of the second light, a gray gradient value of each point in the first light, and a gray gradient value of each point in the second light in each line matching pair;

[0043] The determination module is used to determine the edge coordinates of the workpiece to be detected according to the target leading edge point and the target trailing edge point of the projection light corresponding to each line matching pair.

[0044] Optionally, the determining module is specifically used to:

[0045] Determine, according to the ordinate of each first point in the current light ray in the left image, a second point in the right image having the same ordinate as the first point;

[0046] Determine the three-dimensional point coordinates corresponding to each first point according to the coordinates of each first point and the coordinates of each second point;

[0047] Each line matching pair is determined according to the three-dimensional point coordinates corresponding to each first point and the coordinates of each structured light surface corresponding to the line structured light emitter.

[0048] Optionally, the determining module is specifically used to:

[0049] If the three-dimensional point coordinates corresponding to all the first points of the current light fall on any structured light surface, the line where the current light and the second points corresponding to the first points of the current light are located is determined to be a line matching pair.

[0050] Optionally, the determining module is specifically used to:

[0051] Determine the starting point coordinates and the ending point coordinates of the first ray and the starting point coordinates and the ending point coordinates of the second ray of each line matching pair respectively;

[0052] If the difference between the ordinate in the first point coordinate of the first light ray and the ordinate in the first point coordinate of the second light ray is less than a first preset threshold, and the ordinate in the first point coordinate of the first light ray is not located at the boundary of the left image, and the ordinate in the first point coordinate of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the first point coordinate of the first light ray and the first point coordinate of the second light ray;

[0053] If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the first point of the first light are used as the coordinates of the initial first edge point of the first light, and the coordinates of the first point of the second light are used as the coordinates of the initial first edge point of the second light;

[0054] If the difference between the ordinate in the tail point coordinates of the first light ray and the ordinate in the tail point coordinates of the second light ray is less than a first preset threshold, and the ordinate in the tail point coordinates of the first light ray is not located at the boundary of the left image, and the ordinate in the tail point coordinates of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the tail point coordinates of the first light ray and the tail point coordinates of the second light ray;

[0055] If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the tail point of the first light ray are used as the coordinates of the initial tail edge point of the first light ray, and the coordinates of the tail point of the second light ray are used as the coordinates of the initial tail edge point of the second light ray.

[0056] Optionally, the determining module is specifically used to:

[0057] Determine the target first edge point of the projection light corresponding to the line matching pair according to the initial first edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light;

[0058] The target tail edge point of the projection light corresponding to the line matching pair is determined according to the initial tail edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial tail edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light.

[0059] Optionally, the determining module is specifically used to:

[0060] Selecting a first preset number of first edge points in the first light ray according to the coordinates of the initial first edge points of the first light ray;

[0061] Determine the middle first edge point of the first light ray according to the gray gradient value on the coordinates of the initial first edge point of the first light ray and the gray gradient values ​​of each first edge point;

[0062] selecting a second preset number of second edge points in the second light ray according to the coordinates of the initial first edge point of the second light ray;

[0063] Determine the middle first edge point of the second light according to the gray value at the coordinates of the initial first edge point of the second light and the gray value of each second edge point;

[0064] According to the middle first edge point of the first light ray and the middle first edge point of the second light ray, a target first edge point of the projection light ray corresponding to the line matching pair is determined.

[0065] Optionally, the determining module is specifically used to:

[0066] Calculate the average of the ordinate of the middle first edge point of the first light ray and the ordinate of the middle first edge point of the second light ray to obtain an average ordinate;

[0067] Determine a point in the first light ray whose ordinate is the average ordinate as a target first edge point of the first light ray;

[0068] Determine a point in the second light ray whose ordinate is the average ordinate as a target first edge point of the second light ray;

[0069] The target first edge point of the projection light corresponding to the line matching pair is determined according to the target first edge point of the first light and the target first edge point of the second light.

[0070] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when an application is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of the workpiece edge measurement method described in the first aspect above.

[0071] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is read and executes the steps of the workpiece edge measurement method described in the first aspect above.

[0072] The beneficial effects of this application are:

[0073] The present application provides a workpiece edge measurement method, device, electronic device and storage medium. The left image and right image of the light projected by line structured light on the edge of the workpiece to be detected are respectively obtained by left and right cameras, and line matching is performed on the light collected in the left image and the right image to obtain line matching pairs, and the target leading edge point and the target trailing edge point of the projection light corresponding to each line matching pair are obtained according to the first light and the second light in each line matching pair, so as to obtain the edge coordinates of the workpiece to be detected. In this process, the edge of the workpiece can be measured by line matching and edge point recognition. This process does not require contact with the workpiece, thus avoiding measurement errors introduced by deformation of the workpiece due to contact with the workpiece. In addition, compared with edge measurement of stereoscopic vision, measurement errors caused by differences in viewing angle and illumination can be effectively avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] 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. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0075] Figure 1 A schematic diagram of the structure of a binocular line structured light measurement system provided in an embodiment of the present application;

[0076] Figure 2 A schematic diagram of a workpiece edge measurement method provided in an embodiment of the present application;

[0077] Figure 3 A schematic diagram of images captured by left and right cameras provided in an embodiment of the present application;

[0078] Figure 4 A schematic diagram of a process for determining line matching pairs provided in an embodiment of the present application;

[0079] Figure 5 A schematic diagram of a process flow of another workpiece edge measurement method provided in an embodiment of the present application;

[0080] Figure 6 A schematic flow chart of another workpiece edge measurement method provided in an embodiment of the present application;

[0081] Figure 7 A schematic diagram of a process flow of another workpiece edge measurement method provided in an embodiment of the present application;

[0082] Figure 8 A complete schematic diagram of a workpiece edge measurement method provided in an embodiment of the present application;

[0083] Fig. 9 A schematic diagram of a device for a workpiece edge measurement method provided in an embodiment of the present application;

[0084] Fig.10 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0085] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0086] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0087] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0088] Figure 1 A structural schematic diagram of a binocular line structured light measurement system provided in an embodiment of the present application, the binocular line structured light measurement system may include a line structured light device, a posture measurement device and a control device, and the line structured light device may include a binocular camera and a line structured light emitter.

[0089] The binocular camera may include a left camera and a right camera, and the left camera and the right camera are respectively connected to the line structured light emitter. When the line structured light emitter emits light to the workpiece, the left camera and the right camera can both capture images on the workpiece, and the captured images contain light information emitted by the line structured light. The line structured light emitter can emit one light beam or multiple light beams.

[0090] Optionally, the posture measurement device can be used to obtain the real-time posture information of the line structured light device and convert the data collected by the line structured light device into the same coordinate system, that is, convert the data in the images collected by the left camera and the right camera in the line structured light device into the same coordinate system. This is because the line structured light device needs to move the device multiple times when measuring the edge of the workpiece to obtain complete workpiece edge data. The collected data can be converted into the same coordinate system based on the position and posture of the line structured light device each time, thereby obtaining the complete workpiece edge.

[0091] Optionally, the control device can be used to control light source emission, camera synchronous image acquisition, data storage, edge point detection and coordinate solution, and posture solution, etc.

[0092] Figure 2 A schematic diagram of a workpiece edge measurement method provided in an embodiment of the present application is shown in FIG. Figure 2 As shown, the method is applied to the control device in the aforementioned binocular line structured light measurement system, and the method includes:

[0093] S101, acquiring a left image and a right image of an edge of a workpiece to be detected captured by a binocular camera.

[0094] The left image and the right image may respectively include at least one light ray projected by a line structured light emitter.

[0095] Optionally, the line structured light emitter in the line structured light device can project light toward the edge of the workpiece to be inspected, and the left camera and the right camera in the line structured light device can collect the light information projected on the edge of the workpiece to be inspected and the information of preset mark points on the workpiece to be inspected. The collected left image and right image can also respectively include the information of preset mark points on the workpiece to be inspected, wherein the preset mark points can be mark points pre-set on or around the edge of the workpiece to be inspected, and posture solution can be performed based on the information of these preset mark points, so that the coordinates described below can be converted.

[0096] Optionally, the collected left image may be corrected for the epipolar line according to the distortion parameters and internal and external parameters of the left camera, and the plane coordinate system of the left image is established with the lower left corner of the left image as the origin, the row direction as the y-axis of the vertical coordinate, and the column direction as the x-axis of the horizontal coordinate; the collected right image may be corrected for the epipolar line according to the distortion parameters and internal and external parameters of the right camera, and the plane coordinate system of the right image is established with the lower left corner of the right image as the origin, the row direction as the y-axis of the vertical coordinate, and the column direction as the x-axis of the horizontal coordinate. The plane coordinate system of the left image and the plane coordinate system of the right image may be different.

[0097] For example, you can use Figure 3To show the images captured by the left and right cameras, Figure 3 A schematic diagram of an image captured by left and right cameras provided in an embodiment of the present application, such as Figure 3 As shown, the left image refers to Figure 3 The left camera kernel diagram in the figure, and the right image refers to Figure 3 The right camera kernel diagram in Figure 3 It can be seen that the left and right images can respectively include the light projected by the line structured light emitter and the marking points on the workpiece to be detected. For the left image, a plane coordinate system is established for the left image, and for the right image, a coordinate system is established for the right image. It is worth noting that Figure 3 The number of light rays and the number of marking points shown in the figure are merely examples, and other numbers of light rays and other numbers of marking points may also be used, without limitation.

[0098] S102: Perform line-to-line matching according to at least one light ray in the left image and at least one light ray in the right image to determine at least one line matching pair.

[0099] The line matching pair may include the first light in the left image and the second light in the right image, and the first light and the second light come from the same light projected by the line structured light emitter, the first light may be any light in the left image, and the second light may be any light in the right image. In other words, for the same light projected by the line structured light emitter on the edge of the workpiece to be detected, the first light of the light can be collected in the left image, and the second light of the light can be collected in the right image, then the first light in the left image and the second light in the right image can be matched into a line matching pair.

[0100] Optionally, the number of light rays collected in the left image and the number of light rays collected in the right image may be the same or different.

[0101] For example, the above Figure 3 For example, the rays in the left image can be represented by The rays in the right image can be represented using but Figure 3 The three rays from left to right in the left image can be expressed as The light from left to right in the right image can be expressed as but Can be used with Determined as line matching pair 1; Can be used with Determined as line matching pair 2; Can be used with Determined as line matching pair 3.

[0102] S103, determining the initial first edge point of the first ray and the initial first edge point of the second ray in each line matching pair, as well as the initial tail edge point of the first ray and the initial tail edge point of the second ray in each line matching pair according to the coordinate information of each endpoint of the first ray and the coordinate information of each endpoint of the second ray.

[0103] The endpoints may refer to the starting point and the ending point of each light ray.

[0104] For example, Figure 3 As an example, the first light and the second light in the line matching pair 1 shown in FIG. The coordinate information of each endpoint and The coordinate information of The initial first edge point and The initial tail edge point of the right image The initial first edge point and The initial tail edge point.

[0105] S104, determine the target first edge point and target tail edge point of the projection light corresponding to each line matching pair based on the initial first edge point of the first light, the initial first edge point of the second light, the initial tail edge point of the first light, the initial tail edge point of the second light, the grayscale gradient value of each point in the first light, and the grayscale gradient value of each point in the second light.

[0106] Among them, the projected light corresponding to each line matching pair refers to the light projected by the above-mentioned center line structured light emitter at the edge of the workpiece to be inspected. The left camera can collect the light to obtain the first light of the light in the left image, and the right camera can collect the light to obtain the second light of the light in the right image. That is to say, the first light in the left image and the second light in the right image come from the same light projected by the line structured light emitter.

[0107] Optionally, the target first edge point and target tail edge point of the light ray can be determined based on the initial first edge point of the first light ray, the initial tail edge point of the first light ray, and the grayscale gradient value of each point in the first light ray collected in the left image, and the initial first edge point of the second light ray, the initial tail edge point of the second light ray, and the grayscale gradient value of each point in the second light ray collected in the right image.

[0108] S105 , determining edge coordinates of the workpiece to be inspected according to the target leading edge point and the target trailing edge point of the projection light rays corresponding to each line matching pair.

[0109] Optionally, each line matching pair corresponds to a light beam projected by a line structured light emitter. According to the above S103, the target leading edge point and the target trailing edge point of each projection light beam can be determined. The edge coordinates of the workpiece to be inspected can be determined according to the target leading edge point and the target trailing edge point of each projection light beam. Specifically, the leading edge coordinates of the workpiece to be inspected can be determined according to the target leading edge point of each projection light beam, and the trailing edge coordinates of the workpiece to be inspected can be determined according to the target trailing edge point of each projection light beam.

[0110] In this embodiment, the left image and the right image of the light projected by the line structured light on the edge of the workpiece to be inspected are respectively obtained by the left and right cameras, and the light collected in the left image and the right image are matched line by line to obtain line matching pairs, and the target leading edge point and the target trailing edge point of the projection light corresponding to each line matching pair are obtained according to the first light and the second light in each line matching pair, so as to obtain the edge coordinates of the workpiece to be inspected. In this process, the edge of the workpiece can be measured by line matching and edge point recognition. This process does not require contact with the workpiece, thus avoiding measurement errors introduced by deformation of the workpiece due to contact with the workpiece. Moreover, compared with the edge measurement of stereoscopic vision, it can effectively avoid measurement errors caused by differences in viewing angle and illumination.

[0111] Figure 4 A schematic diagram of a process for determining a line matching pair provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the above S102 performs line-to-line matching according to at least one light ray in the left image and at least one light ray in the right image to determine at least one line matching pair, which may include:

[0112] S201. Determine, according to the longitudinal coordinates of each first point in the current light ray in the left image, a second point in the right image having the same longitudinal coordinate as the first point.

[0113] Optionally, each ray in the left image and the right image is composed of a number of points. For example, For light It can include k points. For each ray in the left image Every point (x m ,y m ) li , for each ray on the right image Find the point on the left image with the same ordinate (x n ,y n ) rj .

[0114] Optionally, the first point in the current ray in the left image can be (x m ,y m ) li, find the ordinate y of the point on each ray in the right image m The same second point (x n ,y n ) rj That is, the y of the first point m and the y of the second point n The coordinates of the first point and the coordinates of the second point refer to the coordinates in the device coordinate system.

[0115] S202: Determine the three-dimensional point coordinates corresponding to each first point according to the coordinates of each first point and the coordinates of each second point.

[0116] The three-dimensional point coordinates refer to the three-dimensional point coordinates in the device coordinate system, and the device refers to the line structured light device. Specifically, the three-dimensional coordinates can be calculated by the following formula (1).

[0117]

[0118] The three-dimensional point coordinates corresponding to each first point are (X mn , Y mn , Z mn ), x 0l is the horizontal coordinate of the principal point of the left image, x 0r is the horizontal coordinate of the principal point of the right image, x m is the horizontal coordinate of the first point of the left image, x n is the horizontal coordinate of the second point in the right image that has the same vertical coordinate as each first point.

[0119] S203 , determining each line matching pair according to the three-dimensional point coordinates corresponding to each first point and the coordinates of each structured light surface corresponding to the line structured light emitter.

[0120] Among them, each structured light surface corresponding to the line structured light emitter refers to a surface with boundaries formed by the light source extending in space when the line structured light emitter projects light to the workpiece to be inspected, such as Figure 1 As shown in the figure, the number of structured light surfaces corresponding to the line structured light emitter is the same as the number of light rays projected by the line structured light emitter. That is to say, if the line structured light emitter projects 3 light rays, three structured light surfaces are generated in space. For example, in the figure, the boundary of π1 can be calculated using l 1上 , l 1下 To express, the boundary of π2 can be expressed as l 2上 , l 2下 To express, the boundary of π3 can be expressed as l 3上 , l 3下 To express.

[0121] Optionally, the above S203, determining each line matching pair according to the three-dimensional point coordinates corresponding to each first point and the coordinates of each structured light surface corresponding to the line structured light emitter, includes:

[0122] Optionally, if the three-dimensional point coordinates corresponding to all first points of the current light fall on any structured light surface, the line where the current light and the second point corresponding to each first point of the current light are located is determined to be a line matching pair, and the corresponding structured light surface is determined to be a matching surface.

[0123] Specifically, if according to and The calculated three-dimensional point coordinates corresponding to all the first points fall on one of the structured light surfaces among π1, π2, and π3. and is a line matching pair, and The structured light surface on which the calculated three-dimensional point coordinates corresponding to all the first points fall is the matching surface.

[0124] In this embodiment, each line matching pair is determined by each point on each light beam collected by the left and right images and each structured light surface, which can effectively avoid measurement errors caused by vision and illumination differences.

[0125] Optionally, in the above S103, determining the initial leading edge point of the first ray and the initial leading edge point of the second ray in each line matching pair, as well as the initial trailing edge point of the first ray and the initial trailing edge point of the second ray according to the coordinate information of each endpoint of the first ray in each line matching pair and the coordinate information of each endpoint of the second ray may include:

[0126] Optionally, the first point coordinates and the last point coordinates of the first ray and the first point coordinates and the last point coordinates of the second ray in each line matching pair are determined respectively, wherein the first point coordinates and the last point coordinates of the first ray and the first point coordinates and the last point coordinates of the second ray are coordinates in the device coordinate system.

[0127] For each line matching pair and Determine separately The first and last point coordinates and The coordinates of the first and last points of the ray. The first point coordinates can be used To indicate that the tail point coordinates can be used To represent; the second ray The first point coordinates can be used To indicate that the tail point coordinates can be used To express.

[0128] Optionally, if the difference between the vertical coordinate in the first point coordinate of the first light ray and the vertical coordinate in the first point coordinate of the second light ray is less than a first preset threshold, and the vertical coordinate in the first point coordinate of the first light ray is not located at the boundary of the left image, and the vertical coordinate in the first point coordinate of the second light ray is not located at the boundary of the right image, then the first three-dimensional point corresponding to the first point coordinate of the first light ray and the first point coordinate of the second light ray is determined.

[0129] The first preset threshold can be, for example, 0.01, 0.02, etc., that is, the ordinate of the first point coordinate of the first ray is approximately equal to the ordinate of the first point coordinate of the second ray. The image boundary refers to the upper and lower, left and right boundaries of the left image and the right image.

[0130] The coordinates of the first point of the first ray and the coordinates of the first three-dimensional point corresponding to the coordinates of the first point of the second ray can be calculated using the above formula (I).

[0131] Optionally, if the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the first point of the first light ray are used as the coordinates of the initial first edge point of the first light ray, and the coordinates of the first point of the second light ray are used as the coordinates of the initial first edge point of the second light ray.

[0132] Among them, the structured light surface corresponding to the line matching pair refers to the structured light surface according to the above and The calculated three-dimensional point coordinates corresponding to all the first points fall on the structured light surface, that is, the matching surface of the line matching pair. The second preset threshold can refer to a distance value, for example, it can be 0.1cm, 0.2cm, etc., or it can be set to other values. In other words, when the first three-dimensional point is located within the boundary of the matching surface corresponding to the three-dimensional point and has a certain distance from the upper and lower and left and right boundaries of the matching structured light surface, the position of the first three-dimensional point is determined as an edge point, and the first light is The first point coordinates As the coordinates of the initial edge point of the first ray, the second ray The first point coordinates As the coordinates of the initial edge point of the second ray, and Determine the initial first edge point pair.

[0133] Optionally, if the difference between the vertical coordinates in the tail point coordinates of the first light ray and the vertical coordinates in the tail point coordinates of the second light ray is less than a first preset threshold, and the vertical coordinates in the tail point coordinates of the first light ray is not located at the boundary of the left image, and the vertical coordinates in the tail point coordinates of the second light ray is not located at the boundary of the right image, then determine the second three-dimensional point corresponding to the tail point coordinates of the first light ray and the tail point coordinates of the second light ray.

[0134] The first preset threshold value may be, for example, 0.01, 0.02, etc., that is, the ordinate of the tail point coordinates of the first ray is approximately equal to the ordinate of the tail point coordinates of the second ray. The image boundary refers to the upper and lower, left and right boundaries of the left image and the right image.

[0135] The coordinates of the tail point of the first light ray and the coordinates of the second three-dimensional point corresponding to the tail point of the second light ray can be calculated using the above formula (I).

[0136] Optionally, if the second three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the tail point of the first light ray are used as the coordinates of the initial tail edge point of the first light ray, and the coordinates of the tail point of the second light ray are used as the coordinates of the initial tail edge point of the second light ray.

[0137] Among them, the structured light surface corresponding to the line matching pair refers to the structured light surface according to the above and The calculated three-dimensional point coordinates corresponding to all the first points fall on the structured light surface, that is, the matching surface of the line matching pair. The second preset threshold can refer to a distance value, for example, it can be 0.1cm, 0.2cm, etc., or it can be set to other values. In other words, when the second three-dimensional point is located within the boundary of the matching surface corresponding to the three-dimensional point and has a certain distance from the upper and lower and left and right boundaries of the matching structured light surface, the position of the second three-dimensional point is determined as an edge point, and the first light is The tail point coordinates As the coordinates of the initial tail edge point of the first ray, the second ray The tail point coordinates As the coordinates of the initial trailing edge point of the second ray, and Determined as the initial tail edge point pair.

[0138] It is worth noting that, for each line matching pair, the initial first edge point pair and / or initial tail edge point pair of each line matching pair can be determined according to the above method, that is, for each line matching pair, if the coordinates of the first point of the first light ray and the first point of the second light ray, the coordinates of the tail point of the first light ray and the tail point of the second light ray in the line matching pair all meet the above conditions, the initial first edge point pair and the initial tail edge point pair of the line matching pair can be determined; if the coordinates of the first point of the first light ray and the first point of the second light ray in the line matching pair meet the above conditions, but the coordinates of the tail point of the first light ray and the tail point of the second light ray do not meet the above conditions, the initial first edge point pair of the line matching pair can be determined; if the coordinates of the first point of the first light ray and the first point of the second light ray in the line matching pair do not meet the above conditions, but the coordinates of the tail point of the first light ray and the tail point of the second light ray meet the above conditions, the initial tail edge point pair of the line matching pair can be determined. Among them, the above condition means that if the difference between the vertical coordinate in the first point coordinate of the first light ray and the vertical coordinate in the first point coordinate of the second light ray is less than the first preset threshold, and the vertical coordinate in the first point coordinate of the first light ray is not located at the boundary of the left image, and the vertical coordinate in the first point coordinate of the second light ray is not located at the boundary of the right image, then the first three-dimensional point corresponding to the first point coordinate of the first light ray and the first point coordinate of the second light ray is determined; if the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than the second preset threshold.

[0139] For example, continue with the above Figure 3 For example, if the coordinates of the first point of the first ray and the first point of the second ray in each line matching pair in the left image and the right image meet the above conditions, the coordinates of the first point of the first ray in each line matching pair can be used as the initial first edge point of the first ray, and the coordinates of the first point of the second ray can be used as the initial first edge point of the second ray. If the coordinates of the tail point of the first ray and the tail point of the second ray in each line matching pair are at the edge of the field of view of the line light source, then there is no initial tail edge point for the first ray and the second ray in each line matching pair, that is, Figure 3 It can be determined in.

[0140] Figure 5 A schematic diagram of a process flow of another workpiece edge measurement method provided in an embodiment of the present application, such as Figure 5 As shown, in the above S104, according to the initial leading edge point of the first ray, the initial leading edge point of the second ray, the initial trailing edge point of the first ray, the initial trailing edge point of the second ray, the grayscale gradient value of each point in the first ray, and the grayscale gradient value of each point in the second ray in each line matching pair, determining the target leading edge point and the target trailing edge point of the projection ray corresponding to each line matching pair may include:

[0141] S301, determining a target first edge point of a projection light corresponding to a line matching pair according to the initial first edge point coordinates of a first light ray, the grayscale gradient values ​​of each point in the first light ray, the initial first edge point coordinates of a second light ray, and the grayscale gradient values ​​of each point in the second light ray.

[0142] It can be seen from the above-mentioned S104 that the projected light corresponding to each line matching pair refers to the same light projected by the line structured light emitter at the edge of the workpiece to be inspected and captured by the left camera and the right camera, that is, the first light in the left image and the second light in the right image come from the same light projected by the line structured light emitter.

[0143] Specifically, according to the first light The initial edge point coordinates The grayscale gradient value of each point in the first light, the grayscale gradient value of each point in the second light The initial edge point coordinates and the grayscale gradient value of each point in the second light, determine the target first edge point of the projection light corresponding to the line matching pair of the first light and the second light. The determined target first edge point refers to the three-dimensional coordinates of the target first edge point in the device coordinate system.

[0144] S302, determining a target tail edge point of the projection light corresponding to the line matching pair according to the initial tail edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial tail edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light.

[0145] Specifically, according to the first light The initial tail edge point coordinates The grayscale gradient value of each point in the first light, the grayscale gradient value of each point in the second light The initial tail edge point coordinates and the grayscale gradient value of each point in the second light, determine the target tail edge point of the projection light corresponding to the line matching pair of the first light and the second light. The determined target tail edge point refers to the three-dimensional coordinates of the target tail edge point in the device coordinate system.

[0146] Figure 6 A schematic diagram of a flow chart of another workpiece edge measurement method provided in an embodiment of the present application, such as Figure 6 As shown, in the above S301, according to the initial first edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light, the target first edge point of the projection light corresponding to the line matching pair is determined, including:

[0147] S401 . Select a first preset number of first edge points in the first light according to the coordinates of the initial first edge point of the first light.

[0148] The first preset number may be other edge points near the initial first edge point. The first preset number may be, for example, 3, 4, 5, etc., or other values, which are not limited here.

[0149] For example, four first edge points that are close to the initial first edge point can be selected in the first ray. The initial first edge point coordinates are According to the coordinates of the initial first edge point, the coordinates of the other four edge points can be selected as follows:

[0150] For example, if the first light The initial first edge point coordinates are According to the coordinates of the initial first edge point, the coordinates of the other four edge points selected can be, for example,

[0151] S402: Determine the middle first edge point of the first light ray according to the grayscale gradient value on the coordinates of the initial first edge point of the first light ray and the grayscale gradient values ​​of each first edge point.

[0152] Specifically, the gradient grayscale value at each point coordinate can be calculated using the following formula (II).

[0153]

[0154] Among them, ads() means taking the average value, max() means taking the maximum value, g1 refers to the grayscale gradient value of the first edge point of the light along the direction of light projection, g k Refers to the gradient grayscale value of the last edge point of the light along the direction of light projection, g t Refers to the gradient grayscale value of the edge point between the first edge point and the last edge point.

[0155] Optionally, when the grayscale gradient value on the coordinates of the initial first edge point of the first light and the grayscale gradient value of each first edge point are calculated, the edge point with the maximum sub-pixel gradient can be selected as the intermediate first edge point of the first light by using a weighted mean or function fitting method, and the coordinates of the intermediate first edge point of the first light are determined, and the coordinates refer to the coordinates in the device coordinate system.

[0156] S403: Select a second preset number of second edge points in the second light according to the coordinates of the initial first edge point of the second light.

[0157] The second preset number may be other edge points near the initial first edge point. The second preset number may be, for example, 3, 4, 5, etc., or other values, which are not limited here.

[0158] The method for selecting the second edge point is the same as the method for selecting the first edge point in S401 above, and will not be described in detail here.

[0159] S404: Determine the middle first edge point of the second light ray according to the gray gradient value on the coordinates of the initial first edge point of the second light ray and the gray gradient value of each second edge point.

[0160] The method for determining the middle first edge point of the second light ray is the same as the method for determining the middle first edge point of the first light ray in S402 described above, and will not be described in detail here.

[0161] S405 , determining a target first edge point of the projection light corresponding to the line matching pair according to the middle first edge point of the first light and the middle first edge point of the second light.

[0162] Specifically, the coordinates of the target first edge point of the projection light corresponding to the line matching pair may be determined according to the coordinates of the middle first edge point of the first light and the coordinates of the middle first edge point of the second light.

[0163] It is worth noting that the target first edge point corresponding to a line matching pair is calculated through the above S401 to S405, and the target tail edge point of the projection light corresponding to the line matching pair can also be calculated through the above method. No further details are given here. For each line matching pair, the target first edge point and / or target tail edge point of the projection light corresponding to the line matching pair can be obtained.

[0164] Figure 7 A schematic diagram of a process flow of another workpiece edge measurement method provided in an embodiment of the present application is shown as follows: Figure 7 As shown, in the above S405, determining the target first edge point of the projection light corresponding to the line matching pair according to the middle first edge point of the first light and the middle first edge point of the second light may include:

[0165] S501. Calculate the average of the ordinate of the middle first edge point of the first light ray and the ordinate of the middle first edge point of the second light ray to obtain an average ordinate.

[0166] Specifically, if the ordinate of the middle first edge point of the first light ray is y i , the ordinate of the middle first edge point of the second ray is y j , then calculate y i With y j The average value of

[0167] S502: Determine a point in the first light ray whose ordinate is the average ordinate as a target first edge point of the first light ray.

[0168] Optionally, the sub-pixel grayscale maximum value column, that is, the horizontal coordinate of the point with the sub-pixel grayscale maximum value, is found in the first light through the grayscale centroid or function fitting according to the calculated average vertical coordinate.

[0169] For example, for the left image, in the light L i l Found The horizontal coordinate of the point, for example, x l , we can get the upper left image Gray value I 1l ,I 2l ,I 3l ,I 4l ,I 5l , through the least squares fitting parabola I = f (x) = ax 2 +bx+c, take As the horizontal coordinate of the grayscale maximum point. Then the coordinate of the target first edge point of the first light can be obtained as

[0170] S503: Determine a point in the second light ray whose ordinate is the average ordinate as the target first edge point of the second light ray.

[0171] Optionally, the method for determining the target first edge point of the second light ray is the same as the method in S502 above, which is not described in detail here.

[0172] For example, if the coordinates of the target first edge point of the second light ray can be obtained according to the above method as

[0173] The coordinates of the target first edge point of the first light ray and the coordinates of the target first edge point of the second light ray are both two-dimensional coordinates in the device coordinate system.

[0174] S504 , determining the target first edge point of the projection light corresponding to the line matching pair according to the target first edge point of the first light and the target first edge point of the second light.

[0175] Among them, the target first edge point of the projection light corresponding to the determined line matching pair refers to the three-dimensional coordinates in the device coordinate system. Specifically, the above formula (1) can be used to calculate the three-dimensional coordinates of the target first edge point of the projection light corresponding to the line matching pair in the device coordinate system.

[0176] Specifically, the coordinates of the target first edge point of the first light ray can be And the coordinates of the target first edge point of the second ray are Substituting into the above formula (1), we can get the three-dimensional coordinates of the target first edge point of the projection light corresponding to the line matching pair as P C (X C ,Y C ,Z C ).

[0177] It is worth noting that the target leading edge point of the projection light corresponding to a line matching pair is calculated by the above S501~S502, and the target leading edge points of the projection light corresponding to other line matching pairs are the same; the calculation method for the target trailing edge point of the projection light corresponding to each line matching pair is also the same, which will not be elaborated here.

[0178] According to this embodiment, the three-dimensional coordinates of the target leading edge point and / or the target trailing edge point of the projection light corresponding to each line matching pair in the device coordinate system can be obtained.

[0179] The three-dimensional coordinates of the target leading edge point and / or target trailing edge point of the projection light corresponding to each line matching pair obtained above in the device coordinate system refer to the target leading edge point and / or target trailing edge point of at least one light projected by the line structured light device at different positions at different times to the edge of the workpiece to be detected. The three-dimensional coordinates of the target leading edge point and / or target trailing edge point in the device coordinate system. The three-dimensional coordinates of the target leading edge point and / or target trailing edge point of the projection light corresponding to each line matching pair obtained by the line structured light device at different positions at different times in the device coordinate system need to be converted into the world coordinate system, so as to obtain the complete edge of the workpiece to be detected.

[0180] Optionally, when converting the three-dimensional coordinates of the target first edge point in the device coordinate system into world coordinates, the three-dimensional coordinates of the target first edge point in the device coordinate system acquired and calculated by the line structured light device are converted into world coordinates according to the real-time position of the line structured light device.

[0181] Optionally, in the above S101, it can be known that the image acquired by the line structured light at different positions also includes information of a preset marker point. The world three-dimensional coordinate information of the preset marker point can be acquired in advance and can be denoted as M w = {P w1 , P w2 ,…,P wn} to indicate.

[0182] When the left and right cameras in the line structured light device are used to capture images of the edge of the workpiece to be detected, the first marker point coordinates of each marker point in the left image captured by the left camera and the second marker point coordinates of each marker point in the right image captured by the right camera at the same time can be obtained, wherein the first marker point in the captured left image and the second marker point in the captured right image are derived from the same marker point on the edge of the workpiece to be detected. The first marker point coordinates and the second marker point coordinates refer to the two-dimensional coordinates in the device coordinate system.

[0183] Optionally, solving the coordinates of the collected marker points to obtain the three-dimensional coordinates of each marker point in the device coordinate system may include:

[0184] Optionally, the three-dimensional coordinates of each marker point in the device coordinate system can be obtained according to the first marker point coordinates of each marker point in the left image and the second marker point coordinates of each marker point in the right image. Specifically, the three-dimensional coordinates of each marker point in the device coordinate system can be calculated using the above formula (1). For example, the three-dimensional coordinates of each marker point in the device coordinate system at a certain time t are calculated as M C t = {P c1 t , P c2 t ,…,P ck t}.

[0185] Optionally, the three-dimensional coordinates of each marker point in the device coordinate system and the world coordinates of each marker point are spliced ​​to solve the posture parameters of the line structured light device at different times.

[0186] Specifically, the three-dimensional coordinates P of each marker point in the device coordinate system can be ci t And the world coordinates P of each landmark point i Get the rotation matrix and translation vector at time t, where the rotation matrix can be used R t To represent the translation vector, we can use T t To express it, we can get the coordinate transformation formula in, is the three-dimensional coordinate of each point in the device coordinate system, P w is the world coordinate of each point. In other words, the marker point M in the device coordinate system C t , and the landmark point M in the world coordinate system w After splicing, we can get the pose parameters of the structured light device in the world coordinate system at time t, that is, the rotation matrix R t and the translation vector T t .

[0187] Optionally, according to the posture parameters of the line structured light device at different times, the three-dimensional coordinates of the target leading edge point and / or the target trailing edge point of the projection light corresponding to each line matching pair obtained by the line structured light device at different times in the device coordinate system are converted into world coordinates.

[0188] Specifically, the three-dimensional coordinates of the target first edge point of the projection light corresponding to each line matching pair can be expressed as C (X C ,Y C ,Z C ) is brought into the above conversion formula to obtain the world coordinates P of the first edge point of the target w , so that the first edge coordinates of the workpiece to be inspected can be determined according to the world coordinates of the target first edge point of the projection light corresponding to each line matching pair obtained by the line structured light device at different positions at different times.

[0189] The world coordinates of the target tail edge points corresponding to each line matching pair are also obtained through the conversion formula, so that the tail edge coordinates of the workpiece to be inspected can be determined based on the world coordinates of the target tail edge points of the projection light corresponding to each line matching pair obtained by the line structured light device at different positions at different times.

[0190] In order to more clearly demonstrate the method for determining the edge of the workpiece to be detected in the above embodiment, it can be used Figure 8 To explain, Figure 8 A complete flow chart of a method for measuring the edge of a workpiece provided in an embodiment of the present application is shown in FIG. Figure 8 As shown:

[0191] S601, calibrate the line structured light device.

[0192] S602, pre-collecting the world coordinates of each mark point on the edge of the workpiece to be inspected.

[0193] S603: Image acquisition.

[0194] Get the left image and the right image captured by the binocular camera.

[0195] S604: extract the device coordinates of each marker point in the image and perform coordinate calculation.

[0196] Specifically, the coordinates of each marker point in the left image and the right image are extracted and the coordinates are solved to obtain the three-dimensional coordinates of each marker point in the device coordinate system, which will not be described in detail here.

[0197] S605, stitching the landmark points together to calculate the pose.

[0198] It refers to the above-mentioned three-dimensional coordinates of each identification point in the device coordinate system and the world coordinates of each identification point collected in advance, solving the posture parameters of the line structured light device when capturing images. The specific process has been described in detail in the above embodiment and will not be repeated here.

[0199] S606, line-to-line matching.

[0200] Optionally, the line-to-line matching process has been described in detail in the above specific embodiments and will not be repeated here.

[0201] S607: edge point identification and coordinate calculation.

[0202] Among them, edge point identification refers to the process of determining the middle first edge point and / or middle tail edge point of the first light ray and the middle first edge point and / or middle tail edge point of the second light ray in each line matching pair; coordinate solution refers to the process of determining the three-dimensional coordinates of the target first edge point and / or target tail edge point of the projection light ray corresponding to each line matching pair in the device coordinate system, which will not be elaborated here.

[0203] S608: Edge point coordinate conversion.

[0204] Optionally, this process refers to the process of converting the three-dimensional coordinates of the target first edge point and / or target tail edge point of the projection light corresponding to each line matching pair in the device coordinate system into world coordinates according to the posture parameters of the line structured light device at each moment, which is not elaborated here.

[0205] S609: Determine whether the edge point measurement is completed.

[0206] If the edge of the workpiece to be detected has not been completely detected, the position of the line structured light device is changed, and the above S603 to S609 are performed again until the edge of the workpiece to be detected is completely detected.

[0207] S6010, output the edge of the workpiece to be detected.

[0208] The above S604-S605 and S606-S607 can be calculated simultaneously.

[0209] Fig. 9 A schematic diagram of a device for measuring a workpiece edge provided in an embodiment of the present application, such as Fig. 9 As shown, the device comprises:

[0210] An acquisition module 701 is used to acquire a left image and a right image of the edge of the workpiece to be detected captured by the binocular camera, wherein the left image and the right image respectively include at least one light beam projected by the line structured light emitter;

[0211] A determination module 702 is used to perform line-to-line matching according to at least one light ray in the left image and at least one light ray in the right image to determine at least one line matching pair, wherein the line matching pair includes a first light ray in the left image and a second light ray in the right image, and the first light ray and the second light ray come from the same light ray projected by the line structured light emitter;

[0212] A determination module 702 is used to determine an initial leading edge point of the first ray and an initial leading edge point of the second ray in each line matching pair, as well as an initial trailing edge point of the first ray and an initial trailing edge point of the second ray in each line matching pair according to the coordinate information of each endpoint of the first ray and the coordinate information of each endpoint of the second ray in each line matching pair;

[0213] A determination module 702 is used to determine a target first edge point and a target tail edge point of the projection light corresponding to each line matching pair according to an initial first edge point of the first light, an initial first edge point of the second light, an initial tail edge point of the first light, an initial tail edge point of the second light, a gray gradient value of each point in the first light, and a gray gradient value of each point in the second light in each line matching pair;

[0214] The determination module 702 is used to determine the edge coordinates of the workpiece to be detected according to the target leading edge point and the target trailing edge point of the projection light corresponding to each line matching pair.

[0215] Optionally, the determining module 702 is specifically configured to:

[0216] Determine, according to the ordinate of each first point in the current light ray in the left image, a second point in the right image having the same ordinate as the first point;

[0217] Determine the three-dimensional point coordinates corresponding to each first point according to the coordinates of each first point and the coordinates of each second point;

[0218] Each line matching pair is determined according to the three-dimensional point coordinates corresponding to each first point and the coordinates of each structured light surface corresponding to the line structured light emitter.

[0219] Optionally, the determining module 702 is specifically configured to:

[0220] If the three-dimensional point coordinates corresponding to all the first points of the current light fall on any structured light surface, the line where the current light and the second points corresponding to the first points of the current light are located is determined to be a line matching pair.

[0221] Optionally, the determining module 702 is specifically configured to:

[0222] Determine the starting point coordinates and the ending point coordinates of the first ray and the starting point coordinates and the ending point coordinates of the second ray of each line matching pair respectively;

[0223] If the difference between the ordinate in the first point coordinate of the first light ray and the ordinate in the first point coordinate of the second light ray is less than a first preset threshold, and the ordinate in the first point coordinate of the first light ray is not located at the boundary of the left image, and the ordinate in the first point coordinate of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the first point coordinate of the first light ray and the first point coordinate of the second light ray;

[0224] If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the first point of the first light are used as the coordinates of the initial first edge point of the first light, and the coordinates of the first point of the second light are used as the coordinates of the initial first edge point of the second light;

[0225] If the difference between the ordinate in the tail point coordinates of the first light ray and the ordinate in the tail point coordinates of the second light ray is less than a first preset threshold, and the ordinate in the tail point coordinates of the first light ray is not located at the boundary of the left image, and the ordinate in the tail point coordinates of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the tail point coordinates of the first light ray and the tail point coordinates of the second light ray;

[0226] If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the tail point of the first light ray are used as the coordinates of the initial tail edge point of the first light ray, and the coordinates of the tail point of the second light ray are used as the coordinates of the initial tail edge point of the second light ray.

[0227] Optionally, the determining module 702 is specifically configured to:

[0228] Determine the target first edge point of the projection light corresponding to the line matching pair according to the initial first edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light;

[0229] The target tail edge point of the projection light corresponding to the line matching pair is determined according to the initial tail edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial tail edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light.

[0230] Optionally, the determining module 702 is specifically configured to:

[0231] Selecting a first preset number of first edge points in the first light ray according to the coordinates of the initial first edge points of the first light ray;

[0232] Determine the middle first edge point of the first light ray according to the gray gradient value on the coordinates of the initial first edge point of the first light ray and the gray gradient values ​​of each first edge point;

[0233] selecting a second preset number of second edge points in the second light ray according to the coordinates of the initial first edge point of the second light ray;

[0234] Determine the middle first edge point of the second light according to the gray value at the coordinates of the initial first edge point of the second light and the gray value of each second edge point;

[0235] According to the middle first edge point of the first light ray and the middle first edge point of the second light ray, a target first edge point of the projection light ray corresponding to the line matching pair is determined.

[0236] Optionally, the determining module 702 is specifically configured to:

[0237] Calculate the average of the ordinate of the middle first edge point of the first light ray and the ordinate of the middle first edge point of the second light ray to obtain an average ordinate;

[0238] Determine a point in the first light ray whose ordinate is the average ordinate as a target first edge point of the first light ray;

[0239] Determine a point in the second light ray whose ordinate is the average ordinate as a target first edge point of the second light ray;

[0240] The target first edge point of the projection light corresponding to the line matching pair is determined according to the target first edge point of the first light and the target first edge point of the second light.

[0241] Fig.10 FIG. 8 is a structural block diagram of an electronic device 800 provided in an embodiment of the present application. Fig.10 As shown, the electronic device may include: a processor 801 and a memory 802 .

[0242] Optionally, a bus 803 may also be included, wherein the memory 802 is used to store machine-readable instructions executable by the processor 801. When the electronic device 800 is running, the processor 801 communicates with the memory 802 through the bus 803. When the machine-readable instructions are executed by the processor 401, the method steps in the above method embodiment are performed.

[0243] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method steps in the above-mentioned workpiece edge measurement method embodiment are executed.

[0244] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0245] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.

[0246] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A method for measuring the edge of a workpiece, characterized in that: A control device applied to a binocular line structured light measurement system, wherein the binocular line structured light measurement system comprises a line structured light device, a posture measurement device and a control device, wherein the line structured light device comprises a binocular camera and a line structured light emitter, and the method comprises: Acquire a left image and a right image of the edge of the workpiece to be detected captured by the binocular camera, wherein the left image and the right image respectively include at least one light beam projected by the line structured light emitter; Performing line-to-line matching according to at least one light ray in the left image and at least one light ray in the right image to determine at least one line matching pair, wherein the line matching pair includes a first light ray in the left image and a second light ray in the right image, and the first light ray and the second light ray come from the same light ray projected by the line structured light emitter; Determine, according to the coordinate information of each endpoint of the first ray and the coordinate information of each endpoint of the second ray in each line matching pair, the initial leading edge point of the first ray and the initial leading edge point of the second ray, as well as the initial trailing edge point of the first ray and the initial trailing edge point of the second ray in each line matching pair; Determine the target first edge point and the target tail edge point of the projection light corresponding to each line matching pair according to the initial first edge point of the first light, the initial first edge point of the second light, the initial tail edge point of the first light, the initial tail edge point of the second light, the gray gradient value of each point in the first light, and the gray gradient value of each point in the second light; Determine the edge coordinates of the workpiece to be inspected according to the target leading edge point and the target trailing edge point of the projection light corresponding to each line matching pair; The method of determining a target first edge point and a target tail edge point of a projection light corresponding to each line matching pair according to an initial first edge point of the first light, an initial first edge point of the second light, an initial tail edge point of the first light, an initial tail edge point of the second light, a grayscale gradient value of each point in the first light, and a grayscale gradient value of each point in the second light in each line matching pair comprises: Determine the target first edge point of the projection light corresponding to the line matching pair according to the initial first edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light; The target tail edge point of the projection light corresponding to the line matching pair is determined according to the initial tail edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial tail edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light.

2. The workpiece edge measurement method according to claim 1, characterized in that: The performing line-to-line matching according to at least one light ray in the left image and at least one light ray in the right image to determine at least one line matching pair comprises: Determine, according to the ordinate of each first point in the current light ray in the left image, a second point in the right image having the same ordinate as the first point; Determine the three-dimensional point coordinates corresponding to each first point according to the coordinates of each first point and the coordinates of each second point; Each line matching pair is determined according to the three-dimensional point coordinates corresponding to each first point and the coordinates of each structured light surface corresponding to the line structured light emitter.

3. The workpiece edge measurement method according to claim 2, characterized in that: Determining each line matching pair according to the three-dimensional coordinates corresponding to each first point and the coordinates of the structured light surface corresponding to the line structured light emitter includes: If the three-dimensional point coordinates corresponding to all the first points of the current light fall on any structured light surface, the line where the current light and the second points corresponding to the first points of the current light are located is determined to be a line matching pair.

4. The workpiece edge measurement method according to claim 1, characterized in that: The step of determining the initial leading edge point of the first ray and the initial leading edge point of the second ray in each line matching pair, and the initial trailing edge point of the first ray and the initial trailing edge point of the second ray in each line matching pair according to the coordinate information of each endpoint of the first ray and the coordinate information of each endpoint of the second ray, comprises: Determine the starting point coordinates and the ending point coordinates of the first ray and the starting point coordinates and the ending point coordinates of the second ray of each line matching pair respectively; If the difference between the ordinate in the first point coordinate of the first light ray and the ordinate in the first point coordinate of the second light ray is less than a first preset threshold, and the ordinate in the first point coordinate of the first light ray is not located at the boundary of the left image, and the ordinate in the first point coordinate of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the first point coordinate of the first light ray and the first point coordinate of the second light ray; If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the first point of the first light ray are used as the coordinates of the initial first edge point of the first light ray, and the coordinates of the first point of the second light ray are used as the coordinates of the initial first edge point of the second light ray; If the difference between the ordinate in the tail point coordinates of the first light ray and the ordinate in the tail point coordinates of the second light ray is less than a first preset threshold, and the ordinate in the tail point coordinates of the first light ray is not located at the boundary of the left image, and the ordinate in the tail point coordinates of the second light ray is not located at the boundary of the right image, then determining a first three-dimensional point corresponding to the tail point coordinates of the first light ray and the tail point coordinates of the second light ray; If the first three-dimensional point is located within the boundary of the structured light surface corresponding to the line matching pair, and the distance from the boundary of the structured light surface is greater than a second preset threshold, the coordinates of the tail point of the first light ray are used as the coordinates of the initial tail edge point of the first light ray, and the coordinates of the tail point of the second light ray are used as the coordinates of the initial tail edge point of the second light ray.

5. The workpiece edge measurement method according to claim 1, characterized in that: The step of determining the target first edge point of the projection light corresponding to the line matching pair according to the initial first edge point coordinates of the first light, the grayscale gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the grayscale gradient values ​​of each point in the second light comprises: Selecting a first preset number of first edge points in the first light ray according to the coordinates of the initial first edge points of the first light ray; Determine the middle first edge point of the first light ray according to the gray gradient value on the coordinates of the initial first edge point of the first light ray and the gray gradient values ​​of each first edge point; selecting a second preset number of second edge points in the second light ray according to the coordinates of the initial first edge point of the second light ray; Determine the middle first edge point of the second light according to the gray value at the coordinates of the initial first edge point of the second light and the gray value of each second edge point; According to the middle first edge point of the first light ray and the middle first edge point of the second light ray, a target first edge point of the projection light ray corresponding to the line matching pair is determined.

6. The workpiece edge measurement method according to claim 1, characterized in that: Determining the target first edge point of the projection light corresponding to the line matching pair according to the target first edge point of the first light and the target first edge point of the second light, comprises: Calculate the average of the ordinate of the middle first edge point of the first light ray and the ordinate of the middle first edge point of the second light ray to obtain an average ordinate; Determine a point in the first light ray whose ordinate is the average ordinate as a target first edge point of the first light ray; Determine a point in the second light ray whose ordinate is the average ordinate as a target first edge point of the second light ray; The target first edge point of the projection light corresponding to the line matching pair is determined according to the target first edge point of the first light and the target first edge point of the second light.

7. A workpiece edge measuring device, characterized in that: include: An acquisition module, used to acquire a left image and a right image of the edge of the workpiece to be detected collected by a binocular camera, wherein the left image and the right image respectively include at least one light beam projected by a line structured light emitter; a determination module, configured to perform line-to-line matching according to at least one ray in the left image and at least one ray in the right image, and determine at least one line matching pair, wherein the line matching pair includes a first ray in the left image and a second ray in the right image, and the first ray and the second ray come from the same ray projected by the line structured light emitter; a determination module, configured to determine an initial leading edge point of the first ray and an initial leading edge point of the second ray in each line matching pair, as well as an initial trailing edge point of the first ray and an initial trailing edge point of the second ray in each line matching pair according to coordinate information of each endpoint of the first ray and coordinate information of each endpoint of the second ray in each line matching pair; a determination module, for determining a target first edge point and a target tail edge point of the projection light corresponding to each line matching pair according to an initial first edge point of the first light, an initial first edge point of the second light, an initial tail edge point of the first light, an initial tail edge point of the second light, a gray gradient value of each point in the first light, and a gray gradient value of each point in the second light in each line matching pair; Determine the edge coordinates of the workpiece to be inspected according to the target leading edge point and the target trailing edge point of the projection light corresponding to each line matching pair; The determination module is specifically used for: Determine the target first edge point of the projection light corresponding to the line matching pair according to the initial first edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial first edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light; The target tail edge point of the projection light corresponding to the line matching pair is determined according to the initial tail edge point coordinates of the first light, the gray gradient values ​​of each point in the first light, the initial tail edge point coordinates of the second light, and the gray gradient values ​​of each point in the second light.

8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor implements the steps of the workpiece edge measurement method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the workpiece edge measurement method according to any one of claims 1 to 6 are executed.

Citation Information

Patent Citations

  • Heterogeneous image registration method and system

    WO2021248270A1

  • Calibration method and apparatus for distance measurement device and camera fusion system

    WO2022262332A1

Cited By

  • Workpiece edge measurement method and apparatus, and electronic device and storage medium

    EP4607461A1