A projection pattern generation method, working distance determination method and medium
By generating and processing projection patterns, and using the system parameters and distortion elimination formulas of the three-dimensional measurement system, the problem of quickly determining the optimal working distance of the workpiece is solved, and efficient and accurate measurement system operation is achieved.
Patent Information
- Application Number
- CN202410907332.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-07-08
AI Technical Summary
It is a challenge to quickly determine the optimal working distance of the workpiece without changing the original system of the 3D measurement system.
By generating a reference conversion pattern that meets the preset image requirements, and using the system parameters and distortion elimination formula in the three-dimensional measurement system to convert the pixel points into the final mapping point, fill in the template of the projection device, generate the projection pattern, and calculate the projection pattern according to the projection pattern The coincidence situation determines the optimal working distance of the workpiece.
It is possible to quickly and accurately determine the optimal working distance of the workpiece without changing the structure of the three-dimensional measurement system, which improves the efficiency and accuracy of the measurement system.
Smart Images

Figure CN118442947B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of optical measurement technology, and in particular to a projection pattern generating method, a working distance determining method and a medium. Background Art
[0002] When using a 3D measurement system to measure workpieces, there is generally an optimal working distance, at which the performance indicators of the 3D measurement system are at their best. Therefore, in an actual production environment, the height of the workpiece surface needs to be adjusted to meet the working distance requirements of the 3D measurement system. Summary of the invention
[0003] The main technical problem solved by the present invention is to realize the rapid determination of the optimal working distance of the workpiece by means of a projection device including a set pattern without changing the original system of the three-dimensional measurement system.
[0004] According to a first aspect, an embodiment provides a projection pattern generation method, which is applied in a three-dimensional measurement system, wherein the three-dimensional measurement system includes a plurality of projection devices, including:
[0005] Generate a reference conversion pattern that meets preset image requirements based on the workpiece to be inspected;
[0006] Based on multiple system parameters in the three-dimensional measurement system and a preset distortion elimination formula, multiple pixel points in the reference conversion pattern are converted into multiple final mapping points; wherein the final mapping points represent pixel points mapped to the projection device after distortion elimination, and the multiple system parameters include calibration parameters corresponding to the multiple projection devices;
[0007] The multiple final mapping points are filled into the projection templates corresponding to the multiple projection devices to obtain multiple projection device images; the projection device images represent images to be stored in the multiple projection devices.
[0008] In some embodiments, generating a reference conversion pattern that meets preset image requirements based on the workpiece to be inspected includes:
[0009] Determine the corresponding image peripheral coordinates according to the workpiece peripheral coordinates of the workpiece to be detected and a preset coordinate mapping rule;
[0010] Determine a pattern peripheral area according to the image peripheral coordinates, and form a reference workpiece pattern based on the pattern peripheral area and a preset reference pattern;
[0011] The reference workpiece pattern is converted into a reference conversion pattern that meets preset image requirements.
[0012] In some embodiments, converting the reference workpiece pattern into a reference conversion pattern that meets preset image requirements includes:
[0013] Constructing a reference size pattern that satisfies a preset pixel bit depth corresponding to the reference workpiece pattern;
[0014] The pixel value of the target line of the pattern in the reference size pattern is set to a first reference value, and the pixel value of the pattern background outside the target line in the reference size pattern is set to a second reference value to obtain a reference conversion pattern that meets the preset image requirements.
[0015] In some embodiments, the converting of the plurality of pixel points in the reference conversion pattern into the plurality of final mapping points based on the plurality of system parameters in the three-dimensional measurement system and a preset distortion elimination formula comprises:
[0016] Constructing a mapping reference formula according to a plurality of system parameters in the three-dimensional measurement system; the plurality of system parameters include calibration parameters corresponding to the plurality of projection devices;
[0017] Mapping a plurality of pixel points in the reference conversion pattern to pixel points of a projection device respectively using the mapping reference formula;
[0018] The pixel points of the projection device are subjected to distortion elimination processing according to a preset distortion elimination formula to obtain a plurality of final mapping points.
[0019] In some embodiments, before filling the multiple final mapping points into the projection templates corresponding to the multiple projection devices, the method further includes:
[0020] Constructing a corresponding initial template according to the resolution of the projection device; wherein the resolution of the initial template is consistent with the resolution of the projection device;
[0021] The pixel values in the initial template are set as second reference values to obtain a projection template corresponding to the projection device.
[0022] In some embodiments, the step of filling the multiple final mapping points into projection templates corresponding to the multiple projection devices to obtain multiple projection device images includes:
[0023] Filling the multiple final mapping points into the projection templates corresponding to the multiple projection devices respectively according to a preset filling rule to obtain a filled image;
[0024] The filling image is subjected to image erosion and image expansion processing to obtain a plurality of projection device images.
[0025] According to a second aspect, an embodiment provides a working distance determination method, which is applied in a three-dimensional measurement system, wherein the three-dimensional measurement system includes at least two projection devices, including:
[0026] Using the projection device to project the reference image pre-stored in the projection device onto the surface of the workpiece to be inspected, to obtain a plurality of target projection images;
[0027] Determining whether the multiple target projection images on the workpiece to be inspected meet a preset coincidence condition;
[0028] The distance between the workpiece to be detected and the projection device when the preset overlap condition is met is used as the optimal working distance of the workpiece to be detected.
[0029] In some embodiments, before using the projection device to project the reference image pre-stored in the projection device onto the surface of the workpiece to be inspected, the reference image is acquired, including:
[0030] Generating a reference conversion pattern that meets preset image requirements based on the workpiece to be inspected;
[0031] Based on multiple system parameters in the three-dimensional measurement system and a preset distortion elimination formula, multiple pixel points in the reference conversion pattern are converted into multiple final mapping points; wherein the final mapping points represent pixel points mapped to the projection device after distortion elimination, and the multiple system parameters include calibration parameters corresponding to the multiple projection devices;
[0032] The multiple final mapping points are filled into projection templates corresponding to the multiple projection devices to obtain a reference image.
[0033] In some embodiments, generating a reference conversion pattern that meets preset image requirements based on the workpiece to be inspected includes:
[0034] Determine the corresponding image peripheral coordinates according to the workpiece peripheral coordinates of the workpiece to be detected and a preset coordinate mapping rule;
[0035] Determine a pattern peripheral area according to the image peripheral coordinates, and form a reference workpiece pattern based on the pattern peripheral area and a preset reference pattern;
[0036] Constructing a reference size pattern that satisfies a preset pixel bit depth corresponding to the reference workpiece pattern;
[0037] The pixel value of the target line of the pattern in the reference size pattern is set to a first reference value, and the pixel value of the pattern background outside the target line in the reference size pattern is set to a second reference value to obtain a reference conversion pattern that meets the preset image requirements.
[0038] According to the third aspect, an embodiment provides a computer-readable storage medium, characterized in that a program is stored on the medium, and the program can be executed by a processor to implement a projection pattern generating method and a working distance determining method.
[0039] According to the projection pattern generation method, working distance determination method and medium of the above-mentioned embodiment, since a corresponding reference conversion pattern is generated based on the workpiece to be detected, and multiple pixel points in the reference conversion pattern are converted into multiple final mapping points according to multiple system parameters and distortion elimination formulas in the three-dimensional measurement system, the final mapping points combine the system parameters of the three-dimensional measurement system and have a corresponding relationship with the workpiece to be detected, so the workpiece can be accurately described and is suitable for the three-dimensional measurement system. The multiple final mapping points are filled into the projection template corresponding to the projection device to obtain multiple projection device images. The multiple projection device images can be stored in the projection device and projected onto the surface of the workpiece, and the optimal working distance of the workpiece to be detected can be quickly determined based on whether the projected images overlap. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A structural diagram of a three-dimensional measurement system according to an embodiment of the present application;
[0041] Figure 2 A flowchart for generating a projection pattern for an embodiment;
[0042] Figure 3 A flowchart for generating a projection pattern for another embodiment;
[0043] Figure 4 A plan view of a reference workpiece pattern of one embodiment;
[0044] Figure 5 A flowchart for generating a projection pattern for another embodiment;
[0045] Figure 6 A flowchart for generating a projection pattern for another embodiment;
[0046] Figure 7 A flowchart for generating a projection pattern for another embodiment;
[0047] Figure 8 A flowchart for generating a projection pattern for another embodiment;
[0048] Fig. 9 A flowchart of determining a working distance according to an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0049] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to the description in the specification and the general technical knowledge in the art.
[0050] In addition, the features, operations or characteristics described in the specification can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.
[0051] The serial numbers assigned to the components herein, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning. The "connection" and "coupling" mentioned in this application, unless otherwise specified, include direct and indirect connections (couplings).
[0052] Please refer to Figure 1 The system structure diagram of the three-dimensional measurement system includes multiple projection devices. At the same time, the three-dimensional measurement system also includes a camera and a lens. Device 0 is a camera and a lens, and devices 1, 2, 3, and 4 are all projection devices for projecting structured light patterns. Among them, the lens of device 0 can be a telecentric lens or a pinhole model lens, and the same is true for the projection device.
[0053] In some embodiments, the pinhole imaging model corresponding to the pinhole lens can be expressed as:
[0054] ,
[0055] in, represents the scaling factor, Represents the coordinates of a point in the pixel coordinate system, represents the focal length of the pinhole camera, Indicates the pixel length, Indicates pixel width, Represents the coordinates of the distortion center in pixel units, Represents multiple different components in different rows and columns in the rotation and translation matrix, represents the translation vector in different directions, Represents the coordinates of a point in the world coordinate system. represents the camera intrinsic parameter matrix, represents the rotation and translation matrix, Represents the homography matrix of the pinhole model camera.
[0056] Please refer to Figure 2 In an embodiment of the present invention, a projection pattern generation method is provided, which is applied in a three-dimensional measurement system, wherein the projection pattern generation method includes steps S1 to S3, which are described in detail below.
[0057] Step S1: generating a reference conversion pattern that meets preset image requirements based on the workpiece to be inspected.
[0058] Please refer to Figure 3 In some embodiments, step S1 generates a reference conversion pattern that meets preset image requirements based on the workpiece to be inspected, including steps S11 to S13, which are described in detail below.
[0059] Step S11: determining corresponding image peripheral coordinates according to the workpiece peripheral coordinates of the workpiece to be detected and a preset coordinate mapping rule.
[0060] In some embodiments, the periphery of the workpiece to be detected is composed of a plurality of workpiece periphery coordinates, and the target periphery coordinates are selected from the workpiece periphery coordinates. The target periphery coordinates may be the corresponding coordinates at the positions of the four corners of the workpiece to be detected. There may be a corresponding relationship between the workpiece to be detected and its corresponding pattern in size or other dimensions. For example, a pattern corresponding to the workpiece to be detected is constructed according to a preset ratio. This corresponding relationship is expressed by a preset coordinate mapping rule. Therefore, the image periphery coordinates on the corresponding pattern may be determined according to the selected target periphery coordinates and the preset coordinate mapping rule.
[0061] Step S12: determining a pattern peripheral area according to the image peripheral coordinates, and constructing a reference workpiece pattern based on the pattern peripheral area and a preset reference pattern.
[0062] Please refer to Figure 4 In some embodiments, the pattern peripheral area is determined according to the image peripheral coordinates, and a reference pattern can be selected, and the reference workpiece pattern can be constructed according to the pattern peripheral area and the reference pattern. For example, the reference pattern is a cross pattern.
[0063] Step S13: converting the reference workpiece pattern into a reference conversion pattern that meets preset image requirements.
[0064] Please refer to Figure 5In some embodiments, step S13 converts the reference workpiece pattern into a reference conversion pattern that meets the preset image requirements, including steps S131 to S132, which are described in detail below.
[0065] Step S131: constructing a reference size pattern that satisfies a preset pixel bit depth and corresponds to the reference workpiece pattern.
[0066] In some embodiments, a reference size pattern having a pixel bit depth of 8 bits is constructed corresponding to the reference workpiece pattern.
[0067] Step S132: setting the pixel value of the target line of the pattern in the reference size pattern to a first reference value, and setting the pixel value of the pattern background outside the target line in the reference size pattern to a second reference value, to obtain a reference conversion pattern that meets the preset image requirements.
[0068] In some embodiments, the first reference value is 255 and the second reference value is 0.
[0069] Step S2: based on multiple system parameters in the three-dimensional measurement system and a preset distortion elimination formula, multiple pixel points in the reference conversion pattern are converted into multiple final mapping points; wherein the final mapping points represent pixel points mapped to the projection device after distortion elimination, and the multiple system parameters include calibration parameters corresponding to the multiple projection devices.
[0070] Please refer to Figure 6 In some embodiments, step S2 converts multiple pixel points in the reference conversion pattern into multiple final mapping points based on multiple system parameters in the three-dimensional measurement system and a preset distortion elimination formula, including steps S21 to S23, which are described in detail below.
[0071] Step S21: constructing a mapping reference formula according to a plurality of system parameters in the three-dimensional measurement system; the plurality of system parameters include calibration parameters corresponding to a plurality of projection devices.
[0072] In some embodiments, a mapping reference formula is constructed according to a plurality of system parameters in a three-dimensional measurement system, and the mapping reference formula is as follows:
[0073] ,
[0074] in, Indicates that after The projection device maps the Pixel coordinates, Indicates The first calibration parameter corresponding to the projection device, Indicates The second calibration parameter corresponding to the projection device, Indicates the first Pixels.
[0075] Step S22: using a mapping reference formula to map a plurality of pixel points in the reference conversion pattern to pixel points of the projection device respectively.
[0076] In some embodiments, a plurality of pixel points in the reference conversion pattern are respectively mapped to pixel points of the projection device using a mapping reference formula. For example, the pixel points in the reference conversion pattern are , then it is mapped to .
[0077] Step S23: performing distortion elimination processing on the pixel points of the projection device according to a preset distortion elimination formula to obtain a plurality of final mapping points.
[0078] In some embodiments, the preset distortion elimination formula includes:
[0079] ,
[0080] ,
[0081] ,
[0082] in, represents the horizontal coordinate of the pixel point of the projection device, Represents the ordinate of the pixel point of the projection device, Represents the horizontal coordinate of the final mapping point, Represents the ordinate of the final mapping point, represents the radius in the distortion model, and Represents the distortion parameters in the distortion model.
[0083] Step S3: Fill the multiple final mapping points into the projection templates corresponding to the multiple projection devices to obtain multiple projection device images; the projection device images represent the images to be stored in the multiple projection devices.
[0084] Please refer to Figure 7 In some embodiments, before step S3 fills the multiple final mapping points into the projection templates corresponding to the multiple projection devices, it also includes steps S31 to S32, which are described in detail below.
[0085] Step S31: constructing a corresponding initial template according to the resolution of the projection device; wherein the resolution of the initial template is consistent with the resolution of the projection device.
[0086] Step S32: setting the pixel values in the initial template as the second reference values to obtain a projection template corresponding to the projection device.
[0087] In some embodiments, the second reference value is 0.
[0088] Please refer to Figure 8 In some embodiments, step S3 fills multiple final mapping points into projection templates corresponding to multiple projection devices to obtain multiple projection device images, including steps S33 to S34, which are described in detail below.
[0089] Step S33: filling the multiple final mapping points into the projection templates corresponding to the multiple projection devices respectively according to the preset filling rule to obtain a filled image.
[0090] Step S34: performing image erosion and image dilation processing on the filled image to obtain a plurality of projection device images.
[0091] In some embodiments, image jaggedness in the filled image can be eliminated by performing image erosion and image dilation processing on the filled image.
[0092] Please refer to Fig. 9 In an embodiment of the present invention, a working distance determination method is provided, which is applied in a three-dimensional measurement system. The three-dimensional measurement system includes at least two projection devices. The working distance determination method includes steps S4 to S6, which are described in detail below.
[0093] Step S4: using a projection device to project the reference image pre-stored in the projection device onto the surface of the workpiece to be inspected, to obtain a plurality of target projection images.
[0094] In some embodiments, before a reference image pre-stored in a projection device is projected onto the surface of a workpiece to be inspected using a projection device, a reference image is first acquired. The steps of acquiring the reference image are as follows: a reference conversion pattern that meets the preset image requirements is generated according to the workpiece to be inspected, and multiple pixel points in the reference conversion pattern are converted into multiple final mapping points based on multiple system parameters in the three-dimensional measurement system and a preset distortion elimination formula, and the multiple final mapping points are filled into projection templates corresponding to multiple projection devices to obtain a reference image.
[0095] In some embodiments, a mapping reference formula is constructed according to multiple system parameters in a three-dimensional measurement system, and multiple pixel points in a reference conversion pattern are respectively mapped to pixel points of a projection device using the mapping reference formula. The pixel points of the projection device are subjected to distortion elimination processing according to a preset distortion elimination formula to obtain multiple final mapping points. A corresponding initial template is constructed according to the resolution of the projection device, and the pixel values in the initial template are set to a second reference value to obtain a projection template corresponding to the projection device. The multiple final mapping points are respectively filled into the projection templates corresponding to the multiple projection devices according to a preset filling rule to obtain a filled image, and the filled image is subjected to image erosion and image dilation processing to obtain a reference image.
[0096] In some embodiments, the mapping reference formula is as follows:
[0097] ,
[0098] in, Indicates that after The projection device maps the Pixel coordinates, Indicates The first calibration parameter corresponding to the projection device, Indicates The second calibration parameter corresponding to the projection device, Indicates the first Pixels.
[0099] In some embodiments, the preset distortion elimination formula includes:
[0100] ,
[0101] ,
[0102] ,
[0103] in, represents the horizontal coordinate of the pixel point of the projection device, Represents the ordinate of the pixel point of the projection device, Represents the horizontal coordinate of the final mapping point, Represents the ordinate of the final mapping point, represents the radius in the distortion model, and Represents the distortion parameters in the distortion model.
[0104] In some embodiments, the corresponding image peripheral coordinates are determined according to the workpiece peripheral coordinates of the workpiece to be detected and the preset coordinate mapping rules, the pattern peripheral area is determined according to the image peripheral coordinates, and a reference workpiece pattern is constructed based on the pattern peripheral area and the preset reference pattern. A reference size pattern that meets the preset pixel bit depth corresponding to the reference workpiece pattern is constructed, the pixel value of the target line of the pattern in the reference size pattern is set to a first reference value, and the pixel value of the pattern background outside the target line in the reference size pattern is set to a second reference value, so as to obtain a reference conversion pattern that meets the preset image requirements.
[0105] Step S5: determining whether the plurality of target projection images on the workpiece to be inspected meet a preset overlap condition.
[0106] In some embodiments, it is determined whether a plurality of target projection images on the workpiece to be inspected overlap. When the plurality of target projection images overlap, it indicates that a preset overlap condition is satisfied.
[0107] Step S6: taking the distance between the workpiece to be inspected and the projection device when the preset overlap condition is met as the optimal working distance of the workpiece to be inspected.
[0108] Those skilled in the art will appreciate that all or part of the functions of the various methods in the above-mentioned embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, and the storage medium can include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to implement the above-mentioned functions. For example, the program is stored in the memory of the device, and when the program in the memory is executed by the processor, all or part of the above-mentioned functions can be implemented. In addition, when all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can also be stored in a storage medium such as a server, another computer, disk, optical disk, flash disk or mobile hard disk, and can be downloaded or copied and saved in the memory of the local device, or the system of the local device is updated, and when the program in the memory is executed by the processor, all or part of the functions in the above-mentioned embodiments can be implemented.
[0109] The above specific examples are used to illustrate the present invention, which is only used to help understand the present invention and is not intended to limit the present invention. For those skilled in the art, according to the concept of the present invention, some simple deductions, modifications or substitutions can be made.
Claims
1. A method for determining a working distance, applied in a three-dimensional measurement system, wherein the three-dimensional measurement system comprises a plurality of projection devices, characterized in that: include: Generate a reference conversion pattern that meets preset image requirements based on the workpiece to be inspected; Based on multiple system parameters in the three-dimensional measurement system and a preset distortion elimination formula, multiple pixel points in the reference conversion pattern are converted into multiple final mapping points; wherein the final mapping points represent pixel points mapped to the projection device after distortion elimination, and the multiple system parameters include calibration parameters corresponding to the multiple projection devices; Filling the multiple final mapping points into the projection templates corresponding to the multiple projection devices to obtain multiple projection device images; the projection device images represent images to be stored in the multiple projection devices; Using the projection device to project the projection device image stored in the projection device onto the surface of the workpiece to be inspected, so as to obtain a plurality of target projection images; Determining whether the multiple target projection images on the workpiece to be inspected meet a preset coincidence condition; The distance between the workpiece to be detected and the projection device when the preset overlap condition is met is used as the optimal working distance of the workpiece to be detected.
2. The method according to claim 1, characterized in that The step of generating a reference conversion pattern that meets preset image requirements based on the workpiece to be detected includes: Determine the corresponding image peripheral coordinates according to the workpiece peripheral coordinates of the workpiece to be detected and a preset coordinate mapping rule; Determine a pattern peripheral area according to the image peripheral coordinates, and form a reference workpiece pattern based on the pattern peripheral area and a preset reference pattern; The reference workpiece pattern is converted into a reference conversion pattern that meets preset image requirements.
3. The method according to claim 2, characterized in that The step of converting the reference workpiece pattern into a reference conversion pattern that meets preset image requirements includes: Constructing a reference size pattern that satisfies a preset pixel bit depth corresponding to the reference workpiece pattern; The pixel value of the target line of the pattern in the reference size pattern is set to a first reference value, and the pixel value of the pattern background outside the target line in the reference size pattern is set to a second reference value to obtain a reference conversion pattern that meets the preset image requirements.
4. The method according to claim 1, characterized in that The converting of the plurality of pixel points in the reference conversion pattern into a plurality of final mapping points based on a plurality of system parameters in the three-dimensional measurement system and a preset distortion elimination formula comprises: Constructing a mapping reference formula according to a plurality of system parameters in the three-dimensional measurement system; the plurality of system parameters include calibration parameters corresponding to the plurality of projection devices; Mapping a plurality of pixel points in the reference conversion pattern to pixel points of a projection device respectively using the mapping reference formula; The pixel points of the projection device are subjected to distortion elimination processing according to a preset distortion elimination formula to obtain a plurality of final mapping points.
5. The method according to claim 1, characterized in that Before filling the multiple final mapping points into the projection templates corresponding to the multiple projection devices, the method further includes: Constructing a corresponding initial template according to the resolution of the projection device; wherein the resolution of the initial template is consistent with the resolution of the projection device; The pixel values in the initial template are set as second reference values to obtain a projection template corresponding to the projection device.
6. The method according to claim 1, characterized in that Filling the multiple final mapping points into projection templates corresponding to the multiple projection devices to obtain multiple projection device images includes: Filling the multiple final mapping points into the projection templates corresponding to the multiple projection devices respectively according to a preset filling rule to obtain a filled image; The filling image is subjected to image erosion and image expansion processing to obtain a plurality of projection device images.
7. A computer-readable storage medium, characterized in that: The medium stores a program, which can be executed by a processor to implement the method according to any one of claims 1 to 6.
