Part contour splicing method and device, electronic equipment and storage medium
By shooting large-size parts at different locations by multiple cameras and identifying the contours using image segmentation models, combining the camera's distortion and calibration matrix, the problem of positioning and imaging of multiple large-size parts is solved, and high-accurate contour stitching is achieved.
Patent Information
- Application Number
- CN202411771392.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art is difficult to realize positioning imaging of multiple large-size parts, especially because the multi-camera shooting method cannot be applied to the splicing of multiple large-size parts.
By using multiple cameras to capture large-size parts at different locations, using image segmentation models to identify contours, obtain the coordinates of each contour, and combine the camera's distortion matrix and calibration matrix to determine the contours to be spliced, thereby realizing contour splicing of multiple parts.
Positioning imaging of multiple large-size parts is realized, which avoids mechanical errors caused by camera movement and improves the accuracy of positioning imaging.
Smart Images

Figure CN119887510A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of laser processing technology, and in particular to a method, device, electronic equipment and storage medium for splicing the contours of parts. Background Art
[0002] In the laser automatic processing scenario, there are two main ways to position and image large-size parts: 1. Move a single camera to shoot different areas of a single large-size part for positioning imaging; 2. Use multiple cameras to shoot a single large-size part for positioning imaging.
[0003] Since moving the camera will bring certain mechanical errors, the accuracy of positioning and imaging of large-sized parts will be low; and the method of using multiple cameras to shoot large-sized parts is only suitable for the positioning and imaging of a single large-sized part, and cannot achieve the positioning and imaging of multiple large-sized parts.
[0004] Therefore, how to achieve positioning and imaging of multiple large-sized parts is a problem that needs to be solved urgently. Summary of the invention
[0005] The present invention provides a part contour splicing method, device, electronic device and storage medium, which can solve the problem that the method of photographing large-sized parts with multiple cameras is only suitable for the positioning imaging of a single large-sized part, and cannot achieve the positioning imaging of multiple large-sized parts.
[0006] According to a first aspect of the present invention, a method for splicing contours of parts is provided, the method comprising:
[0007] Using a first camera to photograph a part at a first position to obtain a first image, and using a second camera to photograph a part at a second position to obtain a second image;
[0008] Input the first image into an image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and input the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour;
[0009] Obtain a first distortion matrix of the first camera and a second distortion matrix of the second camera, and obtain a first calibration matrix of the first camera and a second calibration matrix of the second camera;
[0010] Determine a first contour to be stitched among the plurality of first contours and a second contour to be stitched among the plurality of second contours based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix;
[0011] The contours of the parts are spliced according to the first contour to be spliced and the second contour to be spliced.
[0012] According to a second aspect of the present invention, there is provided a device for splicing the contours of parts, the device comprising:
[0013] A parts photographing module, used to photograph a part at a first position using a first camera to obtain a first image, and to photograph a part at a second position using a second camera to obtain a second image;
[0014] An image input module, used for inputting the first image into an image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and inputting the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour;
[0015] a matrix acquisition module, configured to acquire a first distortion matrix of the first camera and a second distortion matrix of the second camera, and to acquire a first calibration matrix of the first camera and a second calibration matrix of the second camera;
[0016] a contour determination module, configured to determine a first contour to be stitched among the plurality of first contours and a second contour to be stitched among the plurality of second contours based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix;
[0017] A contour splicing module is used to perform contour splicing of the parts according to the first contour to be spliced and the second contour to be spliced.
[0018] According to a third aspect of the present invention, there is provided an electronic device, comprising a processor and a memory.
[0019] The memory is used to store codes and related data;
[0020] The processor is used to execute the code in the memory to implement the part contour splicing method as described in any one of the embodiments of the present invention.
[0021] According to a fourth aspect of the present invention, there is provided a storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for splicing contours of parts as described in any one of the embodiments of the present invention.
[0022] In an embodiment of the present invention, a first camera is used to photograph a part at a first position to obtain a first image, and a second camera is used to photograph the part at a second position to obtain a second image, the first image is input into an image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and the second image is input into an image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour; a first distortion matrix of the first camera and a second distortion matrix of the second camera are obtained, and a first calibration matrix of the first camera and a second calibration matrix of the second camera are obtained; based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, the second calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are determined; and contour splicing of the part is performed according to the first contour to be spliced and the second contour to be spliced. That is, the technical solution of the present invention can use multiple cameras to shoot multiple large-size parts on a machine tool at different positions (first position and second position) to obtain a first image and a second image including multiple parts, and then respectively input the first image and the second image into an image segmentation model to obtain the first contour coordinates of the multiple parts in the first image and the second contour coordinates of the multiple parts in the second image, that is, the contour coordinates of different parts in different part images are obtained, and according to the camera's distortion matrix, calibration matrix and contour coordinates of different parts, the first contours to be spliced of the multiple parts in the first image and the second contours to be spliced of the multiple parts in the second image are determined, and finally, the contours of the multiple parts are spliced according to the first contours to be spliced and the second contours to be spliced, so as to complete the contour splicing of the multiple large-size parts in the different part images and realize the positioning imaging of the multiple large-size parts; and, since there is no need to move the first camera and the second camera, the mechanical error caused by moving the camera is avoided, and the accuracy of the positioning imaging of the multiple large-size parts is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0024] Figure 1 It is a schematic flow chart of a method for splicing the contours of parts provided by an embodiment of the present invention;
[0025] Figure 2 is a schematic diagram of the shooting position of the camera provided in an embodiment of the present invention;
[0026] Figure 3 is a schematic diagram of the shooting angle of view of a camera provided by an embodiment of the present invention;
[0027] Figure 4 is a schematic diagram of a part profile provided by an embodiment of the present invention;
[0028] Figure 5 is a schematic diagram of a method for fixing a calibration object provided in an embodiment of the present invention;
[0029] Figure 6 is another schematic flow chart of the method for splicing the contours of parts provided by an embodiment of the present invention;
[0030] Figure 7 is another schematic diagram of a part profile provided by an embodiment of the present invention;
[0031] Figure 8 is a schematic diagram of deleting boundary lines with the same boundary attributes provided by an embodiment of the present invention;
[0032] Fig. 9 This is a schematic diagram of the effect of splicing the part contours provided by an embodiment of the present invention;
[0033] Fig.10 is another schematic flow chart of the method for splicing the contours of parts provided by an embodiment of the present invention;
[0034] Fig.11 It is a structural schematic diagram of a contour splicing device for parts provided by an embodiment of the present invention;
[0035] Fig.12 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0038] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0039] Figure 1 The present invention provides a schematic flow chart of a method for splicing the contours of parts provided in an embodiment of the present invention. The method can be executed by a device for splicing the contours of parts, and the device can be implemented in software and / or hardware. In a specific embodiment, the device can be integrated into an electronic device, such as a computer, a server, etc. The following embodiments will be described by taking the device integrated into an electronic device as an example. Figure 1 , the method may specifically include the following steps:
[0040] Step 101: photograph a part at a first position using a first camera to obtain a first image, and photograph a part at a second position using a second camera to obtain a second image.
[0041] The first position can be understood as a preset shooting position of the first camera; the second position can be understood as a preset shooting position of the second camera; Figure 2 As shown, the first position and the second position may be positions directly above the machine tool. Figure 3 As shown, it is a perspective diagram of a first camera installed at a first position. Figure 3It can be seen that the shooting angle of the first camera at the first position is the same as the front view angle of the part. The part can be understood as a large-sized metal part placed on the machine tool. The first image can be understood as a part image obtained by the first camera photographing the part at the first position. The second image can be understood as a part image obtained by the second camera photographing the part at the second position. Since multiple large-sized parts can be placed on the machine tool, the first image obtained by the first camera photographing the part at the first position may include multiple first area images of large-sized parts, and the second image obtained by the second camera photographing the part at the second position may include multiple second area images of large-sized parts. Among them, the first area image can be understood as a partial area of the complete image of a large-sized part, and the second area image can be understood as a partial area of the complete image of a large-sized part. The first area image and the second area image can be spliced to obtain a complete image of a large-sized part.
[0042] Step 102: Input the first image into the image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and input the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour.
[0043] Among them, the image segmentation model can be understood as a model that divides an image into different regions or objects; the image segmentation model can be based on any one of the network frameworks of PP-matting, Deep Dual Resolution Network (DDRNET), and Mask2Former (Mask-attention Mask Transformer), so that high-precision positioning based on the contour coordinates in the image taken by each camera at an ultra-high object distance can be achieved, that is, the position determination within 5mm of the contour coordinates in the image taken by each camera at an ultra-high object distance is achieved, and the accuracy of the first contour to be spliced in the multiple first contours and the second contour to be spliced in the multiple second contours determined based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix is improved, thereby improving the accuracy of positioning imaging of multiple large-sized parts. The first contour can be understood as a partial contour of a large-sized part in the first image; multiple first contours can be understood as partial contours of different large-sized parts in the first image. The second contour can be understood as a partial contour of a large-sized part in the second image; multiple second contours can be understood as partial contours of different large-sized parts in the second image. The first contour coordinates can be understood as the pixel coordinates of each point on each first contour, and there can be multiple first contour coordinates. The second contour coordinates can be understood as the pixel coordinates of each point on each second contour, and there can be multiple second contour coordinates.
[0044] For example, the image segmentation model is a network framework based on PP-Matting; the first image can be input into the image segmentation model based on the network framework based on PP-Matting for contour recognition to obtain multiple first contours and first contour coordinates of each first contour, and the second image can be input into the image segmentation model based on the network framework based on PP-Matting for contour recognition to obtain multiple second contours and second contour coordinates of each second contour. Figure 4 The black lines in the figure are the part contours obtained by contour recognition using the image segmentation model.
[0045] Step 103: Obtain a first distortion matrix of the first camera and a second distortion matrix of the second camera, and obtain a first calibration matrix of the first camera and a second calibration matrix of the second camera.
[0046] Among them, the first distortion matrix can be understood as a matrix obtained after the first camera is distorted. The second distortion matrix can be understood as a matrix obtained after the second camera is distorted. The first calibration matrix can be understood as a matrix obtained by extrinsic calibration of the first camera. The second calibration matrix can be understood as a matrix obtained by extrinsic calibration of the second camera.
[0047] Step 104 : determining a first contour to be stitched among the plurality of first contours and a second contour to be stitched among the plurality of second contours based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix.
[0048] The first contour to be spliced can be understood as a partial contour of a large-sized part in the first image, and the second contour to be spliced can be understood as a partial contour of the same large-sized part in the second image that is complementary to the first contour to be spliced. The first contour to be spliced and the second contour to be spliced are contours of the same large-sized part.
[0049] In an optional embodiment, the first machine tool coordinates corresponding to each first contour coordinate can be determined according to the first contour coordinates, the first distortion matrix and the first calibration matrix; the second machine tool coordinates corresponding to each second contour coordinate can be determined according to the second contour coordinates, the second distortion matrix and the second calibration matrix; based on the first machine tool coordinates and the second machine tool coordinates, the first contour to be spliced among the multiple first contours and the second contour to be spliced among the multiple second contours are determined.
[0050] Specifically, each first contour coordinate, the first distortion matrix and the first calibration matrix can be multiplied to obtain the first machine tool coordinates corresponding to each first contour coordinate; then each second contour coordinate, the second distortion matrix and the second calibration matrix can be multiplied to obtain the second machine tool coordinates corresponding to each second contour coordinate. In this way, the coordinate transformation of the image obtained by photographing the part by multiple cameras at an ultra-high object distance can be realized, and the pixel coordinates of the contours of the parts in the images obtained by photographing the part by multiple cameras at an ultra-high object distance can be uniformly converted into machine tool coordinates, thereby achieving the purpose of determining the first contour to be spliced and the second contour to be spliced according to the first machine tool coordinates and the second machine tool coordinates in the same coordinate system.
[0051] The intersection-and-union ratio can be understood as the overlap rate of the candidate box generated in the target detection and the original marked box, that is, the ratio of the intersection of the candidate box and the original marked box to the union of the candidate box and the original marked box. The intersection-and-union ratio can be used to evaluate the degree of overlap between the bounding box predicted by the model and the true bounding box. In an embodiment of the present invention, the first contour to be spliced among multiple first contours and the second contour to be spliced among multiple second contours can be determined according to the intersection-and-union ratio of the first contour and the second contour. Therefore, when the first contour belonging to the first machine tool coordinate and the second contour belonging to the second machine tool coordinate intersect, the intersection-and-union ratio of the first contour and the second contour can be determined according to the first machine tool coordinate and the second machine tool coordinate; based on the intersection-and-union ratio and the preset intersection-and-union ratio, the first contour to be spliced among multiple first contours and the second contour to be spliced among multiple second contours are determined.
[0052] Step 105 , splicing the contours of the parts according to the first contour to be spliced and the second contour to be spliced.
[0053] In an optional implementation, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are spliced to obtain complete contour images of a plurality of large-size parts.
[0054] In an embodiment of the present invention, multiple cameras can be used to photograph multiple large-size parts on a machine tool at different positions (a first position and a second position) to obtain a first image and a second image including the multiple parts, and then the first image and the second image are respectively input into an image segmentation model to obtain first contour coordinates of the multiple parts in the first image and second contour coordinates of the multiple parts in the second image, that is, contour coordinates of different parts in different part images are obtained, and according to the distortion matrix of the camera, the calibration matrix and the contour coordinates of different parts, the first contours to be spliced of the multiple parts in the first image and the second contours to be spliced of the multiple parts in the second image are determined, and finally, contour splicing of the multiple parts is performed according to the first contour to be spliced and the second contour to be spliced, so as to complete the contour splicing of the multiple large-size parts in the different part images and realize the positioning imaging of the multiple large-size parts; and, since there is no need to move the first camera and the second camera, the mechanical error caused by moving the camera is avoided, and the accuracy of the positioning imaging of the multiple large-size parts is improved.
[0055] In some embodiments, before using the first camera to photograph the part at the first position to obtain the first image, it can also include: using the first camera to photograph the calibration object in different postures to obtain a preset number of first calibration object images, and performing camera distortion matrix calculation based on the first calibration object images to obtain the first distortion matrix; using the second camera to photograph the calibration object in different postures to obtain a preset number of second calibration object images, and performing camera distortion matrix calculation based on the second calibration object images to obtain the second distortion matrix. In this way, distortion correction of multiple cameras can be achieved, and the accuracy of the machine tool coordinates corresponding to each contour coordinate can be improved, so as to avoid the problem of low accuracy of the determined machine tool coordinates due to the ultra-high object distance between the camera and the machine tool, resulting in large distortion generated by the camera.
[0056] In an optional implementation, the calibration object may be photographed with a first camera at different positions to obtain a preset number of first calibration object images, then the checkerboard corner points in each first calibration object image are determined, the first external parameter, the first internal parameter and the first distortion coefficient of the first camera are determined, and the camera distortion matrix is calculated based on the checkerboard corner points, the first external parameter, the first internal parameter and the first distortion coefficient in each first calibration object image to obtain the first distortion matrix. The calibration object may be photographed with a second camera at different positions to obtain a preset number of second calibration object images, then the checkerboard corner points in each second calibration object image are determined, the second external parameter, the second internal parameter and the second distortion coefficient of the second camera are determined, and the second distortion matrix is obtained by reverse parameterization based on the checkerboard corner points, the second external parameter, the second internal parameter and the second distortion coefficient in each second calibration object image.
[0057] For example, the preset number may be 15. Figure 5As shown, the calibration plate can be placed in a fixed position, and then the first camera is used to shoot the calibration object in different postures to obtain 15 first calibration object images, and the first external parameter, the first internal parameter and the first distortion coefficient of the first camera are determined. The first distortion matrix is obtained by reversely calculating the checkerboard corner points, the first external parameter, the first internal parameter and the first distortion coefficient in each first calibration object image.
[0058] In some embodiments, before using the first camera to photograph the part at the first position to obtain the first image, it can also include: performing extrinsic calibration on the first camera to obtain a first calibration matrix, and performing extrinsic calibration on the second camera to obtain a second calibration matrix. In this way, extrinsic calibration of multiple cameras can be achieved, thereby improving the accuracy of the machine tool coordinates corresponding to each contour coordinate.
[0059] In an optional implementation, a calibration object can be placed within the shooting range of the first camera, and a first offset from the identification point on the calibration object to the end of the actuator is obtained. The actuator is controlled to move along a first predetermined trajectory to obtain first three-dimensional coordinates of N marking points in a base coordinate system and first two-dimensional pixel coordinates in a camera coordinate system; wherein N is an integer and N≥6: and every 4 marking points constitute a calibration plane, and the N marking points constitute at least two calibration planes with different heights; based on the first offset, the first three-dimensional coordinates of the N marking points in the base coordinate system and the first two-dimensional pixel coordinates in the camera coordinate system, a point pair data group corresponding to the identification point on the first predetermined trajectory and the N marking points is obtained, the point pair data group includes N first point pair data, and the first point pair data includes the first two-dimensional pixel coordinates of the identification point in the camera coordinate system and the first three-dimensional machine tool coordinates of the identification point in the base coordinate system; a first hand-eye calibration equation is constructed based on the point pair data group; the first hand-eye calibration equation is solved to obtain a first calibration matrix from the camera coordinate system to the base coordinate system. Place the calibration object within the shooting range of the second camera, obtain the second offset from the identification point on the calibration object to the end of the actuator, control the actuator to move along the second predetermined trajectory, obtain the second three-dimensional coordinates of the N marking points in the base coordinate system and their second two-dimensional pixel coordinates in the camera coordinate system; wherein N is an integer and N≥6: and every 4 marking points constitute a calibration plane, and the N marking points constitute at least two calibration planes with different heights; based on the second offset, the second three-dimensional coordinates of the N marking points in the base coordinate system and their second two-dimensional pixel coordinates in the camera coordinate system, obtain a point pair data group corresponding to the identification point on the second predetermined trajectory and the N marking points, the point pair data group includes N second point pair data, the second point pair data includes the second two-dimensional pixel coordinates of the identification point in the camera coordinate system, and the second three-dimensional machine tool coordinates of the identification point in the base coordinate system; construct a second hand-eye calibration equation based on the point pair data group; solve the second hand-eye calibration equation to obtain a second calibration matrix from the camera coordinate system to the base coordinate system.
[0060] The following further describes the contour splicing method of parts provided by the embodiment of the present invention. Figure 6 As shown, Figure 6 FIG. 4 is another flow chart of the method for splicing the contours of parts provided by an embodiment of the present invention, which may specifically include the following steps:
[0061] Step 201 : photographing a part at a first position using a first camera to obtain a first image, and photographing the part at a second position using a second camera to obtain a second image.
[0062] Step 202: Input the first image into the image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and input the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour.
[0063] For example, Figure 7 As shown, the first image is input into the image segmentation model for contour recognition to obtain the first contour L1 and the first contour coordinates of the first contour L1, and the second image is input into the image segmentation model for contour recognition to obtain the second contour L2 and the second contour coordinates of the second contour.
[0064] Step 203: Obtain a first distortion matrix of the first camera and a second distortion matrix of the second camera, and obtain a first calibration matrix of the first camera and a second calibration matrix of the second camera.
[0065] Step 204 : determining first machine tool coordinates corresponding to each first contour coordinate according to the first contour coordinates, the first distortion matrix and the first calibration matrix.
[0066] Step 205 , determining the second machine tool coordinates corresponding to each second contour coordinate according to the second contour coordinates, the second distortion matrix and the second calibration matrix.
[0067] Step 206, when the first contour belonging to the first machine tool coordinates intersects with the second contour belonging to the second machine tool coordinates, determine the intersection-and-joint ratio of the first contour and the second contour according to the first machine tool coordinates and the second machine tool coordinates.
[0068] In an optional embodiment, when the first contour and the second contour intersect, the first intersection coordinates, the second intersection coordinates, the first endpoint coordinates and the second endpoint coordinates can be determined according to the first machine tool coordinates and the second machine tool coordinates; then the intersection and union ratio of the first contour and the second contour can be determined according to the first intersection coordinates, the second intersection coordinates, the first endpoint coordinates and the second endpoint coordinates. Among them, the first intersection coordinates can be understood as the upper left corner machine tool coordinates where the first contour and the second contour intersect. The second intersection coordinates can be understood as the lower right corner machine tool coordinates where the first contour and the second contour intersect. The first endpoint coordinates can be understood as the upper left corner machine tool coordinates of the first contour. The second endpoint coordinates can be understood as the lower right corner machine tool coordinates of the second contour.
[0069] Specifically, when the first contour and the second contour intersect, the maximum horizontal coordinate of the first horizontal coordinate of the first machine coordinate of the first contour and the second horizontal coordinate of the second machine coordinate of the second contour can be determined as the first intersection horizontal coordinate, the maximum vertical coordinate of the first vertical coordinate of the first machine coordinate of the first contour and the second vertical coordinate of the second machine coordinate of the second contour can be determined as the first intersection vertical coordinate, and the first intersection horizontal coordinate and the first intersection vertical coordinate can be determined as the first intersection coordinate. The minimum horizontal coordinate of the first horizontal coordinate of the first machine coordinate of the first contour and the second horizontal coordinate of the second machine coordinate of the second contour can be determined as the second intersection horizontal coordinate, the minimum vertical coordinate of the first vertical coordinate of the first machine coordinate of the first contour and the second vertical coordinate of the second machine coordinate of the second contour can be determined as the second intersection vertical coordinate, and the second intersection horizontal coordinate and the second intersection vertical coordinate can be determined as the second intersection coordinate. Determine the first intersection coordinate and the second intersection coordinate where the first contour and the second contour intersect. The intersection area of the first contour and the second contour is determined according to the first intersection point coordinates and the second intersection point coordinates, and then the first area of the first contour is determined according to the first endpoint coordinates and the second intersection point coordinates, and the second area of the second contour is determined according to the second endpoint coordinates and the first intersection point coordinates. The combined area of the first contour and the second contour is determined according to the first area, the second area and the intersection area; finally, the intersection ratio of the first contour and the second contour is determined according to the intersection area and the combined area.
[0070] Further, the first endpoint coordinates may include the first endpoint horizontal coordinate and the first endpoint ordinate, and the second endpoint coordinates may include the second endpoint horizontal coordinate and the second endpoint ordinate. The second intersection horizontal coordinate, the first intersection horizontal coordinate, the first intersection ordinate, and the second intersection ordinate may be substituted into the intersection area calculation formula to calculate the intersection area of the first contour and the second contour; then the second intersection horizontal coordinate, the first endpoint horizontal coordinate, the first endpoint ordinate, and the second intersection ordinate may be substituted into the first area calculation formula to calculate the first area, and the first intersection horizontal coordinate, the first intersection ordinate, the second endpoint horizontal coordinate, and the second endpoint ordinate may be substituted into the second area calculation formula to calculate the second area; finally, the first area, the second area, and the intersection area may be substituted into the combined area calculation formula to calculate the combined area. The first area may be understood as the area of the first contour, and the second area may be understood as the area of the second contour.
[0071] The calculation formula for the intersection area is:
[0072] ∩=(X a2 -X b1 )*(Y b1 -Y a2 );
[0073] ∩ represents the intersection area, X a2 Indicates the horizontal coordinate of the second intersection point, X b1 Indicates the horizontal coordinate of the first intersection point, Y b1 Indicates the ordinate of the first intersection point, Y a2 Indicates the ordinate of the second intersection point.
[0074] The first area calculation formula is:
[0075] S1=(X a2 -X a1 )*(Y a1 -Y a2 );
[0076] S1 represents the first area, X a1 Indicates the horizontal coordinate of the first endpoint, Y a1 Indicates the vertical coordinate of the first endpoint.
[0077] The second area calculation formula is:
[0078] S2=(X b2 -X b1 )*(Y b1 -Y b2 );
[0079] S2 represents the second area, X b1 Indicates the horizontal coordinate of the second endpoint, Y b1 Indicates the ordinate of the second endpoint.
[0080] The calculation formula of intersection-over-union ratio is:
[0081] IoU = ∩ / (S1+S2-∩)
[0082] IoU stands for Intersection over Union.
[0083] Step 207 : determining a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours based on the intersection-over-union ratio and the preset intersection-over-union ratio.
[0084] If two contours intersect, when the intersection-and-union ratio of the two contours is greater than the preset intersection-and-union ratio, it can be determined that the two contours overlap, and the two contours belong to the same part; when the intersection-and-union ratio of the two contours is less than or equal to the preset intersection-and-union ratio, the Euclidean distance difference between the centroids of the two boundary lines of the two intersecting contours can be determined. If the Euclidean distance difference is less than the preset distance difference, it can be determined that the two intersecting contours belong to the same part. Among them, the centroid of the boundary line can be understood as the centroid of the straight line. Therefore, in an optional embodiment, when the intersection-and-union ratio is greater than the preset intersection-and-union ratio, the first contour to which the first intersection point coordinates belong is determined to be the first contour to be spliced, and the second contour to which the second intersection point coordinates belong is determined to be the second contour to be spliced. When the intersection-and-union ratio is less than or equal to the preset intersection-and-union ratio, the first centroid coordinates of each first centroid of the multiple first boundary lines of the first contour and the second centroid coordinates of each second centroid of the multiple second boundary lines of the second contour are determined; the Euclidean distance difference between the first centroid and the second centroid is determined according to the first centroid coordinate and the second centroid coordinate; based on the Euclidean distance difference and the preset distance difference, the first contour to be spliced in the multiple first contours and the second contour to be spliced in the multiple second contours are determined, so that the first contour to be spliced and the second contour to be spliced can be determined more accurately according to the intersection-and-union ratio and the Euclidean distance difference, and the accuracy of the determined first contour to be spliced and the second contour to be spliced is improved, and then the contours of multiple parts are spliced according to the first contour to be spliced and the second contour to be spliced, so as to complete the contour splicing of multiple large-sized parts in different part images, and realize the positioning imaging of multiple large-sized parts; and since there is no need to move the first camera and the second camera, the mechanical error caused by moving the camera is avoided, and the accuracy of the positioning imaging of multiple large-sized parts is improved.
[0085] Specifically, each first boundary line includes two boundary line endpoints, and the first centroid coordinates of the first centroid of each first boundary line can be determined based on the two boundary line endpoints of each first boundary line. The specific determination process refers to the centroid determination method of the line segment, which will not be repeated here; each second boundary line includes two boundary line endpoints, and the second centroid coordinates of the second centroid of each second boundary line can be determined based on the two boundary line endpoints of each second boundary line. The specific determination process also refers to the centroid determination method of the line segment, which will not be repeated here. The first centroid coordinates can include the first centroid horizontal coordinate and the first centroid vertical coordinate, and the second centroid coordinates can include the second centroid horizontal coordinate and the second centroid vertical coordinate; the first centroid coordinates and the second centroid coordinates can be substituted into the Euclidean distance difference calculation formula to calculate the Euclidean distance difference.
[0086] Among them, the calculation formula of Euclidean distance difference is:
[0087] D=((x1-x2) 2 +(y1-y2) 2 ) 1 / 2 ;
[0088] D represents the Euclidean distance difference, x1 represents the abscissa of the first centroid, x2 represents the abscissa of the second centroid, y1 represents the ordinate of the first centroid, and y2 represents the ordinate of the second centroid.
[0089] For example, the preset intersection-and-union ratio is U, the first image includes the first contour L1 of the part P1, and the second image includes the second contour L2 of the part P. When the first contour and the second contour intersect, the intersection-and-union ratio IoU 1 of the first contour and the second contour can be determined according to the first machine tool coordinates corresponding to the first contour and the second machine tool coordinates corresponding to the second contour. When IoU 1>U, the first contour L1 is determined as the first contour to be spliced, and the second contour L2 is determined as the second contour to be spliced.
[0090] As another example, the preset intersection-and-union ratio is U, the preset distance difference is d, the first image includes a first contour L1 of part P2, and the first contour L1 includes a first boundary line L11; the second image includes a second contour L2 of part P, and the second contour L2 includes a second boundary line L21. When the first contour and the second contour intersect, the intersection-and-union ratio IoU 1 of the first contour and the second contour can be determined according to the first machine tool coordinates corresponding to the first contour and the second machine tool coordinates corresponding to the second contour. When IoU 1≤U, the first centroid coordinates of the first centroid of the first boundary line (L11) of the first contour and the second centroid coordinates of the second centroid of the second boundary line (L21) of the second contour are determined, and then the Euclidean distance difference D between the first centroid and the second centroid is determined according to the first centroid coordinates and the second centroid coordinates. When D<d, the first contour L1 to which the first centroid coordinates belong is confirmed to be the first contour to be spliced, and the second contour L2 to which the second centroid coordinates belong is determined to be the second contour to be spliced.
[0091] Step 208 , splicing the contours of the parts according to the first contour to be spliced and the second contour to be spliced.
[0092] In an embodiment of the present invention, multiple cameras can be used to photograph multiple large-size parts on a machine tool at different positions (a first position and a second position) to obtain a first image and a second image including the multiple parts, and then the first image and the second image are respectively input into an image segmentation model to obtain first contour coordinates of the multiple parts in the first image and second contour coordinates of the multiple parts in the second image, that is, contour coordinates of different parts in different part images are obtained, and according to the distortion matrix of the camera, the calibration matrix and the contour coordinates of different parts, the first contours to be spliced of the multiple parts in the first image and the second contours to be spliced of the multiple parts in the second image are determined, and finally, contour splicing of the multiple parts is performed according to the first contour to be spliced and the second contour to be spliced, so as to complete the contour splicing of the multiple large-size parts in the different part images and realize the positioning imaging of the multiple large-size parts; and, since there is no need to move the first camera and the second camera, the mechanical error caused by moving the camera is avoided, and the accuracy of the positioning imaging of the multiple large-size parts is improved.
[0093] The following further describes the contour splicing method of parts provided by the embodiment of the present invention. Fig.10 As shown, Fig.10 FIG. 1 is another flow chart of the method for splicing the contours of parts provided by an embodiment of the present invention, which may specifically include the following steps:
[0094] Step 301: Use a first camera to photograph a calibration object in different postures to obtain a preset number of first calibration object images, and perform camera distortion matrix calculation based on the first calibration object images to obtain a first distortion matrix.
[0095] Step 302: Use a second camera to photograph the calibration object in different postures to obtain a preset number of second calibration object images, and perform camera distortion matrix calculation based on the second calibration object images to obtain a second distortion matrix.
[0096] Step 303: Perform extrinsic calibration on the first camera to obtain a first calibration matrix, and perform extrinsic calibration on the second camera to obtain a second calibration matrix.
[0097] Step 304: photograph the part at a first position using a first camera to obtain a first image, and photograph the part at a second position using a second camera to obtain a second image.
[0098] Step 305: Input the first image into the image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and input the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour.
[0099] Step 306: Obtain a first distortion matrix of the first camera and a second distortion matrix of the second camera, and obtain a first calibration matrix of the first camera and a second calibration matrix of the second camera.
[0100] Step 307 : determining first machine tool coordinates corresponding to each first contour coordinate according to the first contour coordinates, the first distortion matrix and the first calibration matrix.
[0101] Step 308: Determine the second machine tool coordinates corresponding to each second contour coordinate according to the second contour coordinates, the second distortion matrix and the second calibration matrix.
[0102] Step 309, when the first contour belonging to the first machine tool coordinates intersects with the second contour belonging to the second machine tool coordinates, determine the intersection-and-joint ratio of the first contour and the second contour according to the first machine tool coordinates and the second machine tool coordinates.
[0103] Step 310: determining a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours based on the intersection-over-union ratio and a preset intersection-over-union ratio.
[0104] Step 311, determining the boundary attribute of the first boundary line according to the first machine tool coordinate.
[0105] Among them, the first machine tool coordinates include first coordinates of multiple first boundary lines and second coordinates of multiple second boundary lines, the first coordinates include a first horizontal coordinate and a first vertical coordinate, the second coordinates include a second horizontal coordinate and a second vertical coordinate, and the boundary attributes include an upper boundary, a lower boundary, a left boundary and a right boundary.
[0106] In an optional embodiment, the first boundary line to which the first ordinate whose ordinate value is equal to 0 belongs is determined as the upper boundary; the first boundary line to which the first ordinate whose ordinate value is equal to the height of the first image belongs is determined as the lower boundary; the first boundary line to which the first abscissa whose abscissa value is equal to the width of the first image belongs is determined as the right boundary; the first boundary line to which the first abscissa whose abscissa value is equal to 0 belongs is determined as the left boundary.
[0107] Step 312: Determine the boundary attribute of the second boundary line according to the second machine tool coordinate.
[0108] In an optional embodiment, the second boundary line to which the second ordinate whose ordinate value is equal to 0 belongs is determined as the upper boundary; the second boundary line to which the second ordinate whose ordinate value is equal to the height of the second image belongs is determined as the lower boundary; the second boundary line to which the second abscissa whose ordinate value is equal to the width of the second image belongs is determined as the right boundary; and the second boundary line to which the second abscissa whose ordinate value is equal to 0 belongs is determined as the left boundary.
[0109] Step 313: When the boundary attributes of the first boundary line and the boundary attributes of the second boundary line are the same, the first boundary line and the second boundary line having the same boundary attributes are deleted.
[0110] For example, Figure 8 As shown, delete Figure 8 The first boundary line L3 and the second boundary line L4 with the same boundary attribute in a are obtained Figure 8 b.
[0111] In an embodiment of the present invention, the boundary attributes of the first boundary line are determined according to the first machine tool coordinates, and the boundary attributes of the second boundary line are determined according to the second machine tool coordinates; when the boundary attributes of the first boundary line and the boundary attributes of the second boundary line are the same, the first boundary line and the second boundary line with the same boundary attributes are deleted, so that redundant boundary lines in multiple first contours and multiple second contours can be deleted, reducing the interference of redundant boundary lines on the contour splicing of parts, and improving the accuracy of positioning and imaging of large-size parts.
[0112] Step 314 , splicing the contours of the parts according to the first contour to be spliced and the second contour to be spliced.
[0113] For example, Fig. 9 As shown, the final spliced image is obtained by splicing the contours of the parts according to the first contour to be spliced L1 and the second contour to be spliced L2.
[0114] In an embodiment of the present invention, multiple cameras can be used to photograph multiple large-size parts on a machine tool at different positions (a first position and a second position) to obtain a first image and a second image including the multiple parts, and then the first image and the second image are respectively input into an image segmentation model to obtain first contour coordinates of the multiple parts in the first image and second contour coordinates of the multiple parts in the second image, that is, contour coordinates of different parts in different part images are obtained, and according to the distortion matrix of the camera, the calibration matrix and the contour coordinates of different parts, the first contours to be spliced of the multiple parts in the first image and the second contours to be spliced of the multiple parts in the second image are determined, and finally, contour splicing of the multiple parts is performed according to the first contour to be spliced and the second contour to be spliced, so as to complete the contour splicing of the multiple large-size parts in the different part images and realize the positioning imaging of the multiple large-size parts; and, since there is no need to move the first camera and the second camera, the mechanical error caused by moving the camera is avoided, and the accuracy of the positioning imaging of the multiple large-size parts is improved.
[0115] Fig.11 1 is a schematic diagram of a structure of a device for splicing the contours of parts provided in an embodiment of the present invention, and the device is suitable for executing a method for splicing the contours of parts provided in an embodiment of the present invention. Fig.10 As shown, the device may specifically include:
[0116] A part photographing module 401, configured to photograph a part at a first position using a first camera to obtain a first image, and photograph a part at a second position using a second camera to obtain a second image;
[0117] An image input module 402 is used to input the first image into an image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and to input the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour;
[0118] A matrix acquisition module 403 is used to acquire a first distortion matrix of the first camera and a second distortion matrix of the second camera, and to acquire a first calibration matrix of the first camera and a second calibration matrix of the second camera;
[0119] a contour determining module 404, configured to determine a first contour to be stitched among the plurality of first contours and a second contour to be stitched among the plurality of second contours based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix;
[0120] The contour splicing module 405 is used to splice the contours of the parts according to the first contour to be spliced and the second contour to be spliced.
[0121] Optionally, the contour determination module 404 is specifically configured to:
[0122] Determining first machine tool coordinates corresponding to each of the first contour coordinates according to the first contour coordinates, the first distortion matrix, and the first calibration matrix;
[0123] Determining second machine tool coordinates corresponding to each second contour coordinate according to the second contour coordinates, the second distortion matrix and the second calibration matrix;
[0124] Based on the first machine tool coordinate and the second machine tool coordinate, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are determined.
[0125] Optionally, the contour determining module 404 determines a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours based on the first machine tool coordinate and the second machine tool coordinate, including:
[0126] When a first contour to which the first machine tool coordinate belongs intersects with a second contour to which the second machine tool coordinate belongs, determining an intersection-and-joint ratio of the first contour to the second contour according to the first machine tool coordinate and the second machine tool coordinate;
[0127] Based on the IoU ratio and a preset IoU ratio, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are determined.
[0128] Optionally, the contour determining module 404 determines, based on the intersection-and-union ratio and a preset intersection-and-union ratio, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours, including:
[0129] When the intersection-and-anneal ratio is greater than the preset intersection-and-anneal ratio, the first contour to which the first intersection point coordinates belong is determined as the first contour to be spliced, and the second contour to which the second intersection point coordinates belong is determined as the second contour to be spliced.
[0130] Optionally, when the intersection-and-annex ratio is less than or equal to the preset intersection-and-annex ratio, determining first centroid coordinates of each first centroid of a plurality of first boundary lines of the first contour and second centroid coordinates of each second centroid of a plurality of second boundary lines of the second contour;
[0131] Determine a Euclidean distance difference between the first centroid and the second centroid according to the first centroid coordinates and the second centroid coordinates;
[0132] Based on the Euclidean distance difference and the preset distance difference, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are determined.
[0133] Optionally, the contour determining module 404 determines, based on the Euclidean distance difference and the preset distance difference, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours, including:
[0134] When the Euclidean distance difference is less than the preset distance difference, the first contour to which the first centroid coordinates belong is determined as the first contour to be spliced, and the second contour to which the second centroid coordinates belong is determined as the second contour to be spliced.
[0135] Optionally, after determining the first contour to be spliced among the plurality of first contours and the second contour to be spliced among the plurality of second contours based on the intersection-over-union ratio, the contour determining module 404 further includes:
[0136] determining a boundary attribute of the first boundary line according to the first machine tool coordinate;
[0137] determining a boundary attribute of the second boundary line according to the second machine tool coordinates;
[0138] When the boundary attribute of the first boundary line is the same as the boundary attribute of the second boundary line, the first boundary line and the second boundary line having the same boundary attribute are deleted.
[0139] Optionally, the first machine tool coordinates include first coordinates of the plurality of first boundary lines and second coordinates of the plurality of second boundary lines, the first coordinates include a first horizontal coordinate and a first vertical coordinate, the second coordinates include a second horizontal coordinate and a second vertical coordinate, the boundary attributes include an upper boundary, a lower boundary, a left boundary and a right boundary, and the contour determination module 404 determines the boundary attributes of the first boundary line according to the first machine tool coordinates, including:
[0140] Determine the first boundary line to which the first ordinate value of which is equal to 0 belongs as the upper boundary;
[0141] Determine a first boundary line to which a first ordinate value equal to the height of the first image belongs as the lower boundary;
[0142] Determine a first boundary line to which a first horizontal coordinate having a horizontal coordinate value equal to the width of the first image belongs as the right boundary;
[0143] Determine the first boundary line to which the first abscissa value of which is equal to 0 belongs as the left boundary;
[0144] Determining the boundary attribute of the second boundary line according to the second machine tool coordinates includes:
[0145] Determine the second boundary line to which the second ordinate value of which is equal to 0 belongs as the upper boundary;
[0146] Determine a second boundary line to which a second ordinate value equal to the height of the second image belongs as the lower boundary;
[0147] Determine a second boundary line to which a second horizontal coordinate having a horizontal coordinate value equal to the width of the second image belongs as the right boundary;
[0148] The second boundary line to which the second abscissa whose abscissa value is equal to 0 belongs is determined as the left boundary.
[0149] Furthermore, the device further comprises:
[0150] A first calculation module, configured to use the first camera to photograph the calibration object in different postures to obtain a preset number of first calibration object images, and perform camera distortion matrix calculation based on the first calibration object images to obtain the first distortion matrix;
[0151] The second calculation module is used to use the second camera to shoot the calibration object in different postures to obtain a preset number of second calibration object images, and perform camera distortion matrix calculation based on the second calibration object images to obtain the second distortion matrix.
[0152] Furthermore, the device also includes:
[0153] An extrinsic calibration module is used to perform extrinsic calibration on the first camera to obtain the first calibration matrix, and to perform extrinsic calibration on the second camera to obtain the second calibration matrix.
[0154] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the functional modules described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0155] The part contour splicing device provided in the embodiment of the present invention can use multiple cameras to shoot multiple large-size parts on a machine tool at different positions (first position and second position) to obtain a first image and a second image including multiple parts, and then respectively input the first image and the second image into the image segmentation model to obtain the first contour coordinates of the multiple parts in the first image and the second contour coordinates of the multiple parts in the second image, that is, the contour coordinates of different parts in different part images are obtained, and the first contours to be spliced of the multiple parts in the first image and the second contours to be spliced of the multiple parts in the second image are determined according to the distortion matrix, calibration matrix and contour coordinates of different parts of the camera, and finally, the contours of the multiple parts are spliced according to the first contour to be spliced and the second contour to be spliced, so as to complete the contour splicing of the multiple large-size parts in the different part images and realize the positioning imaging of the multiple large-size parts; and since there is no need to move the first camera and the second camera, the mechanical error caused by moving the camera is avoided, and the accuracy of the positioning imaging of the multiple large-size parts is improved.
[0156] Fig.12 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0157] Please refer to Fig.12 , an electronic device 50 is provided, comprising:
[0158] a processor 51; and
[0159] A memory 52, used to store executable instructions of the processor;
[0160] The processor 51 is configured to execute the above-mentioned method by executing the executable instructions.
[0161] The processor 51 can communicate with the memory 52 via a bus 53 .
[0162] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned method is implemented.
[0163] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0164] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for splicing the contours of parts, characterized in that: The method comprises: Using a first camera to photograph a part at a first position to obtain a first image, and using a second camera to photograph a part at a second position to obtain a second image; Input the first image into an image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and input the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour; Obtain a first distortion matrix of the first camera and a second distortion matrix of the second camera, and obtain a first calibration matrix of the first camera and a second calibration matrix of the second camera; Determine a first contour to be stitched among the plurality of first contours and a second contour to be stitched among the plurality of second contours based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix; The contours of the parts are spliced according to the first contour to be spliced and the second contour to be spliced.
2. The method according to claim 1, characterized in that The determining, based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix, a first contour to be stitched among the plurality of first contours and a second contour to be stitched among the plurality of second contours comprises: Determining first machine tool coordinates corresponding to each of the first contour coordinates according to the first contour coordinates, the first distortion matrix, and the first calibration matrix; Determining second machine tool coordinates corresponding to each second contour coordinate according to the second contour coordinates, the second distortion matrix and the second calibration matrix; Based on the first machine tool coordinate and the second machine tool coordinate, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are determined.
3. The method according to claim 2, characterized in that The step of determining a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours based on the first machine tool coordinate and the second machine tool coordinate comprises: When a first contour to which the first machine tool coordinate belongs intersects with a second contour to which the second machine tool coordinate belongs, determining an intersection-and-joint ratio of the first contour to the second contour according to the first machine tool coordinate and the second machine tool coordinate; Based on the IoU ratio and a preset IoU ratio, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are determined.
4. The method according to claim 3, characterized in that The determining, based on the intersection-and-union ratio and the preset intersection-and-union ratio, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours comprises: When the intersection-and-anneal ratio is greater than the preset intersection-and-anneal ratio, the first contour to which the first intersection point coordinates belong is determined as the first contour to be spliced, and the second contour to which the second intersection point coordinates belong is determined as the second contour to be spliced.
5. The method according to claim 4, characterized in that The method further comprises: When the intersection-and-annex ratio is less than or equal to the preset intersection-and-annex ratio, determining first centroid coordinates of each first centroid of a plurality of first boundary lines of the first contour and second centroid coordinates of each second centroid of a plurality of second boundary lines of the second contour; Determine a Euclidean distance difference between the first centroid and the second centroid according to the first centroid coordinates and the second centroid coordinates; Based on the Euclidean distance difference and the preset distance difference, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours are determined.
6. The method according to claim 5, characterized in that The determining, based on the Euclidean distance difference and the preset distance difference, a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours comprises: When the Euclidean distance difference is less than the preset distance difference, the first contour to which the first centroid coordinates belong is determined as the first contour to be spliced, and the second contour to which the second centroid coordinates belong is determined as the second contour to be spliced.
7. The method according to claim 5, characterized in that After determining a first contour to be spliced among the plurality of first contours and a second contour to be spliced among the plurality of second contours based on the intersection-over-union ratio, the method further includes: determining a boundary attribute of the first boundary line according to the first machine tool coordinate; determining a boundary attribute of the second boundary line according to the second machine tool coordinates; When the boundary attribute of the first boundary line is the same as the boundary attribute of the second boundary line, the first boundary line and the second boundary line having the same boundary attribute are deleted.
8. The method according to claim 7, characterized in that The first machine tool coordinates include first coordinates of the plurality of first boundary lines and second coordinates of the plurality of second boundary lines, the first coordinates include a first horizontal coordinate and a first vertical coordinate, the second coordinates include a second horizontal coordinate and a second vertical coordinate, the boundary attributes include an upper boundary, a lower boundary, a left boundary and a right boundary, and determining the boundary attributes of the first boundary line according to the first machine tool coordinates includes: Determine the first boundary line to which the first ordinate value of which is equal to 0 belongs as the upper boundary; Determine a first boundary line to which a first ordinate value equal to the height of the first image belongs as the lower boundary; Determine a first boundary line to which a first horizontal coordinate having a horizontal coordinate value equal to the width of the first image belongs as the right boundary; Determine the first boundary line to which the first abscissa value of which is equal to 0 belongs as the left boundary; Determining the boundary attribute of the second boundary line according to the second machine tool coordinates includes: Determine the second boundary line to which the second ordinate value of which is equal to 0 belongs as the upper boundary; Determine a second boundary line to which a second ordinate value equal to the height of the second image belongs as the lower boundary; Determine a second boundary line to which a second horizontal coordinate having a horizontal coordinate value equal to the width of the second image belongs as the right boundary; The second boundary line to which the second abscissa whose abscissa value is equal to 0 belongs is determined as the left boundary.
9. The method according to claim 1, characterized in that: Before using the first camera to photograph the part at the first position to obtain the first image, the method further includes: Using the first camera to photograph the calibration object in different postures to obtain a preset number of first calibration object images, and performing camera distortion matrix calculation based on the first calibration object images to obtain the first distortion matrix; The calibration object is photographed with the second camera in different postures to obtain a preset number of second calibration object images, and a camera distortion matrix is calculated according to the second calibration object images to obtain the second distortion matrix.
10. The method according to claim 1, characterized in that Before using the first camera to photograph the part at the first position to obtain the first image, the method further includes: The first camera is calibrated with external parameters to obtain the first calibration matrix, and the second camera is calibrated with external parameters to obtain the second calibration matrix.
11. A device for splicing the contour of parts, characterized in that: The device comprises: A parts photographing module, used to photograph a part at a first position using a first camera to obtain a first image, and to photograph a part at a second position using a second camera to obtain a second image; An image input module, used for inputting the first image into an image segmentation model for contour recognition to obtain a plurality of first contours and first contour coordinates of each first contour, and inputting the second image into the image segmentation model for contour recognition to obtain a plurality of second contours and second contour coordinates of each second contour; a matrix acquisition module, configured to acquire a first distortion matrix of the first camera and a second distortion matrix of the second camera, and to acquire a first calibration matrix of the first camera and a second calibration matrix of the second camera; a contour determination module, configured to determine a first contour to be stitched among the plurality of first contours and a second contour to be stitched among the plurality of second contours based on the first contour coordinates, the first distortion matrix, the first calibration matrix, the second contour coordinates, the second distortion matrix, and the second calibration matrix; A contour splicing module is used to perform contour splicing of the parts according to the first contour to be spliced and the second contour to be spliced.
12. An electronic device, characterized in that: Including processor and memory, The memory is used to store codes and related data; The processor is used to execute the code in the memory to implement the part contour splicing method described in any one of claims 1 to 10.
13. A storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for splicing the contours of parts as claimed in any one of claims 1 to 10 is implemented.