Trajectory path extraction method, device and computer storage medium
By acquiring the target product image, extracting and segmenting the trajectory edge points, performing smoothing processing, and generating smooth key points, the problem of low quality of trajectory edge point extraction is solved, and high-precision trajectory path generation is achieved, which meets the motion requirements of the actuator and improves the operating speed.
Patent Information
- Application Number
- CN202111500536.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-09
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-12-09
AI Technical Summary
The existing technology has low quality in extracting edge points of the track and cannot meet the motion requirements of the actuator, especially when the soft object is deformed, and cannot automatically adjust the position of the track points.
By acquiring the target product image, extracting the trajectory edge points, performing straight line segmentation and sampling smoothing processing, generating smooth key points, and forming the target trajectory path.
The quality and accuracy of trajectory path extraction are improved, ensuring that the actuator maintains high precision at key inflection points, meeting motion requirements and increasing operating speed.
Smart Images

Figure CN114299095B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a trajectory path extraction method, device, and computer storage medium. Background Art
[0002] With the development and maturity of machine vision, the application of visual recognition technology in industrial robots has become a hot topic in the field of robotics research.
[0003] In traditional applications of machine vision trajectory extraction, the process usually involves manually drawing multiple consecutive teaching trajectory points in an image after capturing an incoming product. These points are then connected in sequence to form the final teaching trajectory path. However, manually drawing the positions of the teaching points based on experience involves many steps and takes a long time, which can easily lead to low drawing accuracy. Furthermore, since the teaching trajectory points cannot change according to changes in the product's appearance, when the incoming product itself is not a rigid body but soft and will slightly deform under force, the position of the trajectory points cannot be automatically modified, resulting in low-quality extraction of the trajectory edge points and an inability to meet the motion requirements of the actuator. Summary of the Invention
[0004] The main purpose of this application is to provide a trajectory path extraction method, device and computer storage medium, aiming to solve the technical problem in the prior art that the trajectory edge point extraction quality is low and cannot meet the motion requirements of the actuator.
[0005] To achieve the above objectives, the present application provides a trajectory path extraction method, which includes:
[0006] Obtain a target image corresponding to a target product, and extract edge points of each track corresponding to the target image;
[0007] Perform straight segment segmentation on the edge points of each trajectory to obtain smooth segmentation results;
[0008] Based on the smooth segment segmentation result, sampling and smoothing processing is performed on each of the trajectory edge points to obtain each smooth key point;
[0009] Based on the smooth key points, a target trajectory path is generated.
[0010] The present application also provides a trajectory path extraction device, which is a virtual device and includes:
[0011] An extraction module, configured to obtain a target image corresponding to a target product and extract edge points of each track corresponding to the target image;
[0012] The segmentation module is used to segment the edge points of each trajectory into straight segments and obtain smooth segmentation results;
[0013] A sampling and smoothing module is used to perform sampling and smoothing processing on each of the edge points of the trajectory based on the smooth segment segmentation result to obtain each smooth key point;
[0014] A generation module is used to generate a target trajectory path based on each of the smooth key points.
[0015] The present application also provides a trajectory path extraction device, which is a physical device. The trajectory path extraction device includes: a memory, a processor, and a trajectory path extraction program stored on the memory. The trajectory path extraction program is executed by the processor to implement the steps of the trajectory path extraction method as described above.
[0016] The present application also provides a storage medium, which is a computer-readable storage medium. The computer-readable storage medium stores a trajectory path extraction program, and the trajectory path extraction program is executed by a processor to implement the steps of the trajectory path extraction method as described above.
[0017] The present application also provides a computer program product, comprising a computer program, which implements the steps of the above-mentioned trajectory path extraction method when executed by a processor.
[0018] The present application provides a trajectory path extraction method, device, and computer storage medium. Compared to the prior art technical approach of directly manually drawing multiple continuous teaching trajectory points in an image and connecting the teaching trajectory points in sequence to form a final teaching trajectory path, the present application first obtains a target image corresponding to a target product and extracts each trajectory edge point corresponding to the target image. Then, each trajectory edge point is segmented into a straight line segment to obtain a smooth segmentation result. Furthermore, based on the smooth segmentation result, each trajectory edge point is sampled and smoothed to obtain each smooth key point. This achieves a sparse number of sampled key points within the smooth approximate straight line segment and a relatively dense number of sampled key points near the segmentation corner point. While retaining the key points of the smooth approximate straight line segment, a maximally smooth curve is obtained. Furthermore, based on each smooth key point, a target trajectory path is generated. This achieves a maximally smooth curve while retaining the key path nodes, thereby improving the quality of trajectory path extraction and ensuring that the actuator maintains high accuracy at key inflection points, meeting the motion requirements of the actuator, and thus improving the operating speed of the actuator. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without any creative work.
[0021] Figure 1 This is a flow chart of the first embodiment of the trajectory path extraction method of the present application;
[0022] Figure 2 This is a flow chart of the second embodiment of the trajectory path extraction method of the present application;
[0023] Figure 3 This is a flow chart of the third embodiment of the trajectory path extraction method of the present application;
[0024] Figure 4 This is a flowchart of the fourth embodiment of the trajectory path extraction method of the present application;
[0025] Figure 5 Schematic diagram of the trajectory path extraction device structure of the hardware operating environment involved in the trajectory path extraction method in the embodiment of the present application;
[0026] Figure 6 This is a schematic diagram of the functional modules of the trajectory path extraction device of this application.
[0027] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0028] It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application.
[0029] The present application provides a trajectory path extraction method. In the first embodiment of the trajectory path extraction method of the present application, referring to Figure 1 , the trajectory path extraction method includes:
[0030] Step S10, obtaining a target image corresponding to a target product, and extracting edge points of each track corresponding to the target image;
[0031] In this embodiment, it should be noted that for different target products or scenes, different edge point extraction methods are required to extract trajectory edge points by vision, wherein the edge point extraction methods include extracting the edge position of the target product, extracting the center trajectory position of the target product, and extracting the outer contour of the target product. It should be noted that extracting the edge position of the target product is suitable for edge extraction of the target product, extracting the center trajectory position of the target product is suitable for products with smaller width measurements, such as welding equipment or glue line equipment, and extracting the outer contour of the target product is suitable for situations where the brightness of the target product has a large contrast with the background, such as the edge extraction of the contour to be polished in the application of polishing equipment, such as polishing the periphery of a lens or a specific product. Since the path required by the robot or motion mechanism is generally a series of small line segments, that is, the first and last vertices of a series of small line segments need to be given, and then the motion mechanism will interpolate the continuous small line segments to complete the motion operation of the entire path.
[0032] A target image corresponding to a target product is obtained, and each track edge point corresponding to the target image is extracted. Specifically, after the target image of the target product is photographed by an industrial camera, first, based on the target image, a reference area of the target image to be detected is manually drawn, and then with the reference area as the center, a fixed interval is preset, or the fixed interval is automatically calculated by setting the number of search points, and then based on the fixed interval, a series of continuous target search areas are calculated at the angle of the reference area, and then an optimal edge point position is calculated in each of the target search areas according to a preset search direction and edge polarity, thereby obtaining a series of track edge points, or edge points on both sides of the target product edge are extracted in each of the target search areas according to a preset search direction and edge polarity, and then based on the edge points on both sides of the target product edge, the average center position between the edge points on both sides of the target product edge is calculated, and the calculated average center positions are used as the track edge points corresponding to the target image.
[0033] In addition, when the brightness of the product is greatly different from that of the background, the preset foreground-background segmentation method can be used to directly determine the contour edges corresponding to the target image and calculate the trajectory edge points of each contour edge.
[0034] Step S20, performing straight segment segmentation on each track edge point to obtain a smooth segment segmentation result;
[0035] In this embodiment, it should be noted that every two trajectory edge points can form a curve segment, and the straight line segment is segmented into curve segments in a processing manner so that the maximum distance from all trajectory edge points in each curve segment after segmentation to the straight line segment formed by the two end points of the curve segment is less than the normal similarity distance.
[0036] Perform straight segment segmentation on each trajectory edge point to obtain a smooth segment segmentation result. Specifically, based on the number of each trajectory edge point, determine the node index table corresponding to each trajectory edge point. It should be noted that each trajectory edge point has its corresponding node index. Select the first target index and the second target index in the node index table, and then determine the first target edge point and the second target edge point corresponding to the first target index and the second target index respectively, wherein the first target index is the initial index, the first target edge point is the trajectory edge point corresponding to the initial index, and the second target edge point corresponding to the second target index is the trajectory edge point farthest from the trajectory edge point of the initial index. Further, based on the first target edge point and the second target edge point, form a target straight line segment, and then traverse all trajectory edge points between the first target index and the second target index, so as to select the target straight line segment. The trajectory edge point with the largest chord distance between the straight line segments is marked to obtain the third target edge point, and then the chord distance is compared with the preset normal similarity distance. If the chord distance is greater than the preset normal similarity distance, the curve segment to be segmented is segmented based on the third target edge point, and then the curve segments corresponding to the third target edge point, the first target edge point, and the second target edge point are obtained, and the target straight line segments corresponding to the third target edge point, the first target edge point, and the second target edge point are determined. Further, the chord distance between each trajectory edge point and the target straight line segment is calculated again to select the trajectory edge point with the largest chord distance, until the maximum chord distance of the target straight line segment composed of all trajectory edge points in each curve segment to be segmented to the two end points of the curve segment is less than the preset normal similarity distance, and then the smooth segment segmentation result is obtained, thereby controlling the accuracy of the normal direction of the trajectory edge point.
[0037] The step of segmenting each track edge point into straight segments to obtain a smooth segmentation result includes:
[0038] Step S21, based on each track edge point, selecting a first target edge point and a second target edge point, and determining the to-be-segmented curve segments corresponding to the first target edge point and the second target edge point;
[0039] In this embodiment, it should be noted that based on the number of edge points of each trajectory edge point, the node index table corresponding to the trajectory edge point list is determined, the first target edge point is the trajectory edge point corresponding to the initial index in the node index table, and the second target edge point is the trajectory edge point farthest from the first target edge point. For example, the number of edge points is 30, and the node index range in the node index table is 0 to 29, 0 is the initial index, and 29 is the ending index.
[0040] Based on each trajectory edge point, a first target edge point and a second target edge point are selected, and the to-be-segmented curve segments corresponding to the first target edge point and the second target edge point are determined. Specifically, based on the number of each trajectory edge point, a node index table corresponding to each trajectory edge point is created, and then the trajectory edge point corresponding to the initial index in the node index table is used as the first target edge point, and then the distance between other trajectory edge points and the first target edge point is calculated, and then the trajectory edge point with the farthest distance is selected as the second target edge point, and the to-be-segmented curve segments corresponding to the first target edge point and the second target edge point are determined.
[0041] Step S22, forming a target straight line segment based on the first target edge point and the second target edge point;
[0042] In this embodiment, it should be noted that any two edge points form a straight line segment.
[0043] Step S23, traversing each track edge point between the first target edge point and the second target edge point, and selecting the track edge point with the largest chord distance from the target straight line segment to obtain a third target edge point;
[0044] In this embodiment, it should be noted that the third target edge point is the track edge point having the largest chord distance from the target straight line segment.
[0045] Traverse each track edge point between the first target edge point and the second target edge point to select the track edge point with the largest chord distance to the target straight line segment to obtain a third target edge point. Specifically, traverse each track edge point between the first target edge point and the second target edge point, calculate the chord distance between each track edge point and the target straight line segment, and then select the track edge point with the largest chord distance to the target straight line segment, and group the track edge points with the largest chord distance as the third target edge point.
[0046] In step S24, if the chord distance between the third target edge point and the target straight line segment is greater than the preset normal similarity distance, the curve segment to be segmented is segmented based on the third target edge point to obtain target straight line segments corresponding to the third target edge point, the first target edge point, and the second target edge point, respectively, until the chord distance between each trajectory edge point and the target straight line segment is no greater than the preset normal similarity distance, thereby obtaining the smooth segment segmentation result.
[0047] In this embodiment, specifically, if the chord distance between the third target edge point and the target straight line segment is greater than the preset normal similarity distance, it proves that the curve segment to be segmented corresponding to the first target edge point and the second target edge point needs to be segmented, and then based on the third target edge point, the curve segment to be segmented is segmented, and then the curve segments to be segmented corresponding to the third target edge point and the first target edge point and the second target edge point are obtained, and the target straight line segments corresponding to the third target edge point and the first target edge point and the second target edge point are determined, so as to select the trajectory edge point with the largest chord distance from the target straight line segment based on the target straight line segment, until the maximum chord distance from all trajectory edge points in each of the curve segments to be segmented to the target straight line segment composed of the two end points of the curve segment to be segmented is less than the preset normal similarity distance, thereby obtaining the smooth segment segmentation result.
[0048] Step S30, based on the smooth segment segmentation result, performing sampling smoothing processing on each of the trajectory edge points to obtain each smooth key point;
[0049] In this embodiment, it should be noted that the sampling smoothing process is a processing method of sampling edge points at each edge point of the trajectory and performing smoothing filtering on the sampled edge points, and the smooth segment segmentation result includes each smooth approximate straight line segment and each segmentation corner point.
[0050] Based on the smooth segment segmentation result, sampling and smoothing processing is performed on each of the trajectory edge points to obtain each smooth key point. Specifically, the following steps are performed for each smooth approximate straight line segment:
[0051] According to the smooth approximate straight line segment, all trajectory edge points located between the smooth approximate straight line segments are traversed, and then sampling is performed according to a preset sampling rule to obtain each sampling node, wherein the sampling according to the preset sampling rule includes sampling according to a preset fixed sampling distance or sampling according to a preset tangent sampling distance, and then the node distance between each sampling node and the segmentation corner point corresponding to the smooth approximate straight line segment is calculated respectively, so as to adjust the sampling distance according to the node distance, for example, when it is close to the segmentation intersection, the sampling distance is reduced, so as to obtain the final sampling key point, so that the sampling key point is dense when it is close to the segmentation corner point and relatively sparse inside the smooth approximate straight line segment. Further, the smooth approximate straight line segment is calculated for straight line fitting to obtain the target baseline corresponding to the smooth approximate straight line, and then based on the target baseline, the position smoothing processing is performed on each sampling key point in the smooth approximate straight line to obtain each smooth key point, thereby achieving the maximum provision of a smooth curve while retaining the key path nodes.
[0052] The smooth segment segmentation result includes smooth approximate straight line segments and segmentation corner points. The step of performing sampling and smoothing processing on the edge points of the trajectory based on the smooth segment segmentation result to obtain smooth key points includes:
[0053] Step S31, calculating the target reference line corresponding to each smooth approximate straight line segment;
[0054] In this embodiment, it should be noted that the purpose of calculating the target baseline is to use the angle of the target baseline as the tangent angle of each track edge point to prevent the angle of each track edge point from being affected by local image noise.
[0055] Calculate the target reference line corresponding to each smooth approximate straight line segment. Specifically, after segmenting the straight line segment, multiple smooth approximate straight line segments are obtained. Linear fitting is performed on each smooth approximate straight line segment to obtain the target reference line corresponding to each smooth approximate straight line segment.
[0056] The step of calculating the target reference line corresponding to each smooth approximate straight line segment includes:
[0057] Step S311 : performing straight line fitting on each of the smooth approximate straight line segments to obtain a target reference line corresponding to each of the smooth approximate straight line segments.
[0058] In this embodiment, straight line fitting is performed on each of the smooth approximate straight line segments to obtain a target baseline corresponding to each of the smooth approximate straight line segments. Specifically, straight line fitting is performed on each of the smooth approximate straight line segments to obtain a target baseline corresponding to each of the smooth approximate straight line segments. The straight line fitting includes a least squares method, a gradient descent method, a Gauss-Newton-Lehmann algorithm, and other straight line fitting methods to obtain a target baseline corresponding to each of the smooth approximate straight line segments.
[0059] Step S32, based on each of the smooth approximate straight line segments, each of the segmentation corner points and a preset tangential sampling distance, edge point sampling is performed on each of the edge points of the trajectory to obtain each sampling key point;
[0060] In this embodiment, it should be noted that the characteristic of the motion mechanism is that it has a faster speed when walking on a straight path. When it needs to turn or change the running angle, the motion mechanism needs to reduce the speed to ensure the accuracy of the running trajectory. Excessive density or sparseness of the edge points of the trajectory will cause the running speed and acceleration of the motion mechanism to rise and fall frequently and significantly when actually performing the operation. In severe cases, it will also cause the actuator to shake frequently, the mechanism to be noisy and easy to wear, and it will not be able to complete the operation quickly and smoothly. The preset tangential sampling distance is used to control the sampling distance of the tangential direction of the edge points of the trajectory, thereby controlling the sampling of the edge points of the trajectory.
[0061] Based on each smooth approximate straight line segment, each segmentation corner point and a preset tangential sampling distance, edge point sampling is performed on each edge point of the trajectory to obtain each sampling key point. Specifically, for each smooth approximate straight line segment, the following steps are performed:
[0062] Based on the smooth approximate straight line segment, all trajectory edge points located between the smooth approximate straight line segments are traversed, and then sampling is performed according to the preset tangential sampling distance to obtain each sampling node, and then the node distance between each sampling node and the segmentation corner point corresponding to the smooth approximate straight line segment is calculated respectively, and then according to the node distance, when the node distance between the sampling node and the key corner point is less than the preset node distance threshold, the preset tangential sampling distance is distance-weighted based on the node distance, wherein the distance weighted processing is a processing method based on the node distance weighted according to the preset ratio, when the sampling node The node distance between the node and the key corner point is not less than the preset node distance threshold, and the preset tangential sampling distance remains unchanged. Then, edge point sampling is performed according to the weighted preset tangential sampling distance to obtain each of the sampling key points, so that the final sampling key points are relatively dense when they are close to the segmentation corner point, and relatively sparse inside the smooth approximate straight line segment. For example, when the sampling node is close to the node distance of the segmentation corner point, the preset tangential sampling distance is multiplied by a coefficient greater than 0 and less than 1. When the node distance is far, the preset tangential sampling distance remains unchanged. The calculation of the coefficient can be automatically calculated by adding the weight of the point distance.
[0063] Step S33, based on the target baseline of each smooth approximate straight line segment, smoothing each of the sampled key points to obtain each of the smoothed key points;
[0064] In this embodiment, it should be noted that the smoothing process is a processing method of performing position smoothing filtering on the sampling key points, thereby reducing the noise impact at the smooth position or turning position of the path.
[0065] Based on the target baseline of each smooth approximate straight line segment, each sampling key point is smoothed to obtain each smooth key point. Specifically, based on the target baseline of each smooth approximate straight line segment, the target distance between each sampling key point and the target baseline corresponding to the sampling key point is calculated respectively, and then the preset smoothing intensity coefficient corresponding to the target distance is determined according to the mapping relationship between the target distance and the preset smoothing intensity coefficient. Furthermore, the position of each sampling key point is smoothed by the preset smoothing intensity coefficient to obtain each smooth key point, so as to reduce the noise impact at the smooth position or turning position of the path and improve the operation speed of the actuator.
[0066] Step S40: generating a target trajectory path based on each of the smooth key points.
[0067] In this embodiment, a target trajectory path is generated based on each of the smooth key points. Specifically, the target trajectory path is formed according to each of the smooth key points, and then the target trajectory path is calibrated and converted, and the running trajectory of the motion mechanism is calculated and sent to the motion mechanism for execution in sequence.
[0068] The embodiment of the present application provides a trajectory path extraction method. Compared with the technical means used in the prior art of directly manually drawing multiple continuous teaching trajectory points in an image and connecting the teaching trajectory points in sequence to form a final teaching trajectory path, the embodiment of the present application first obtains a target image corresponding to the target product and extracts each trajectory edge point corresponding to the target image, and then performs straight line segmentation on each trajectory edge point to obtain a smooth segmentation result. Furthermore, based on the smooth segment segmentation result, each trajectory edge point is sampled and smoothed to obtain each smooth key point, so that the number of sampled key points in the smooth approximate straight line segment is sparse, and the number of sampled key points near the segmentation corner point is relatively dense. While retaining the key points of the smooth approximate straight line segment, a maximally smooth curve is obtained. Furthermore, based on each smooth key point, a target trajectory path is generated, so that a maximally smooth curve is provided while retaining the key path nodes, thereby improving the quality of trajectory path extraction and ensuring that the actuator maintains a high accuracy at the key inflection points, meeting the motion requirements of the actuator, and thus improving the operating speed of the actuator.
[0069] Further, refer to Figure 2 Based on the first embodiment of the present application, in another embodiment of the present application, the step of extracting edge points of each track corresponding to the target image includes:
[0070] Step A10, obtaining a reference area corresponding to the target image;
[0071] In this embodiment, it should be noted that the reference area is a target area for manually drawing and extracting edge points.
[0072] The reference area corresponding to the target image is obtained. Specifically, the target image of the target product is captured by an industrial camera or a camera device, and the reference area of the detection area in the target image is manually drawn.
[0073] Step A20, calculating each target search area corresponding to the reference area;
[0074] In this embodiment, it should be noted that the target search area is an area in the reference area where edge points of the trajectory are searched.
[0075] Calculate the target search areas corresponding to the reference area. Specifically, with the reference area as the center, according to a pre-set fixed interval, or by setting the number of search points to obtain a fixed interval, and then calculate a series of continuous target search areas based on the fixed interval and the angle of the reference area.
[0076] Step A30, based on the preset search direction and edge polarity, calculate the trajectory edge points corresponding to each of the target search areas; or based on the preset search direction and edge polarity, extract the edge points on both sides of the target product edge in each of the target search areas, and calculate the average center position between the edge points on both sides of the target product edge, so as to use each of the average center positions as the trajectory edge points of the target image.
[0077] In this embodiment, it should be noted that each of the target search areas corresponds to at least one track edge point.
[0078] Based on the preset search direction and edge polarity, the trajectory edge points corresponding to each target search area are calculated. Specifically, in each target search area, the corresponding trajectory edge points are calculated according to the preset search direction and edge polarity, thereby obtaining the trajectory edge points in each target search area.
[0079] Additionally, it should be noted that when extracting edge points of products such as weld equipment or glue line equipment, the target product line width is relatively small, and the width of the target search area is greater than the width of the target product line area.
[0080] Specifically, in each of the target search areas, the edge points corresponding to both sides of the edge of the line area of the target product are extracted according to the preset search direction and edge polarity, that is, two edge points corresponding to both sides of the edge of the target product are included in a target search area, and the average center position of the edge points corresponding to both sides of the edge of the line area is calculated, that is, the average center position between the two edge points in each of the target search areas is calculated, and then each of the average center positions is used as the final trajectory edge point, thereby obtaining each trajectory edge point corresponding to the target image.
[0081] Furthermore, the step of extracting edge points of each track corresponding to the target image further includes:
[0082] Step B10: Based on a preset foreground-background segmentation method, each contour edge corresponding to the target image is determined, and the trajectory edge points of each contour edge are calculated.
[0083] In this embodiment, it should be noted that, for the target product corresponding to the polishing equipment, since the target product is a closed entity and the key information to be extracted is also the outline of the target product, there is no need to manually draw the reference area.
[0084] Specifically, due to the large contrast between the brightness of the target product and the background, a preset foreground-background segmentation method is set to obtain a continuous contour edge to the current target and calculate the sub-pixel precision position information and tangent direction corresponding to the contour edge.
[0085] It is possible to extract trajectory paths according to different target products or scenarios. When the incoming products are deformed within a large range, it can also automatically adapt to the product deformation, thereby better improving the effect of trajectory path extraction for different products.
[0086] Further, refer to Figure 3 Based on the first embodiment of the present application, in another embodiment of the present application, the step of sampling edge points of each trajectory edge point based on each smooth approximate straight line segment, each segmentation corner point, and a preset tangential sampling distance to obtain each sampling key point includes:
[0087] Step C10, based on each of the smooth approximate straight line segments, edge point sampling is performed on each of the trajectory edge points according to a preset tangential sampling distance to obtain each sampling node;
[0088] In this embodiment, based on each of the smooth approximate straight line segments, edge point sampling is performed on each of the trajectory edge points according to a preset tangential sampling distance to obtain each sampling node. Specifically, each of the trajectory edge points corresponding to each of the smooth approximate straight line segments is traversed, and then based on the preset tangential sampling distance, edge point sampling is performed on each of the trajectory edge points corresponding to each of the smooth approximate straight line segments to obtain each sampling node corresponding to each of the smooth approximate straight line segments.
[0089] Step C20, calculating the node distance between each sampling node and each segmentation corner point;
[0090] In this embodiment, the node distance between each sampling node and each segmentation corner point is calculated. Specifically, for each sampling node of each smooth approximate straight line segment, the node distance between each sampling node and the segmentation corner point corresponding to the sampling node is calculated respectively, and then it is determined based on the node distance whether the preset tangential sampling distance needs to be adjusted so as to perform sampling again.
[0091] Step C30 : performing distance weighting processing on the preset tangential sampling distance based on the node distance, so as to perform edge point sampling according to the weighted preset tangential sampling distance to obtain each of the sampling key points.
[0092] In this embodiment, based on the node distance, the preset tangential sampling distance is distance-weighted, so as to sample edge points according to the weighted preset tangential sampling distance to obtain each sampling key point. Specifically, based on the node distance, it is determined whether the preset tangential sampling distance needs to be adjusted. If the node distance is less than the preset node distance threshold, it is proved that the sampling node is far away from the segmentation corner point, and there is no need to adjust the preset tangential sampling distance. The sampling node is directly used as the sampling key point. Furthermore, if the node distance is less than the preset node distance threshold, the sampling node is directly used as the sampling key point. From the threshold, the preset tangential sampling distance is distance-weighted based on the node distance, that is, the calculation of the preset tangential sampling distance can be calculated by the weight ratio of the node distance, and can also be calculated according to the preset weight coefficient, and then the edge points of each trajectory within the preset node distance threshold are sampled according to the preset tangential sampling distance after the weighted processing, so as to obtain each of the sampling key points, so that the sampling key points finally obtained are dense when the distance is close to the segmentation corner point, and relatively sparse inside the smooth straight line segment, thereby improving the running speed of the actuator.
[0093] Further, refer to Figure 4 Based on the first embodiment of the present application, in another embodiment of the present application, the step of smoothing each of the sampled key points based on the target baseline of each of the smooth approximate straight line segments to obtain each of the smoothed key points includes:
[0094] Step D10, respectively calculating the target distance between each of the sampling key points and the target reference line corresponding to the sampling key point;
[0095] In this embodiment, specifically, the following steps are performed for each of the sampling key points: calculating a target distance between the sampling key point and the target baseline of the sampling key point.
[0096] Step D20 , based on the target distance, performing position smoothing processing on each of the sampled key points by using a preset smoothing strength coefficient to obtain each of the smoothed key points.
[0097] In this embodiment, based on the target distance, each of the sampled key points is positionally smoothed using a preset smoothing strength coefficient to obtain each of the smoothed key points. Specifically, based on the target distance, a preset smoothing strength coefficient corresponding to the target distance is determined, wherein a mapping relationship is pre-set between the target distance and the preset smoothing strength coefficient, and then each of the sampled key points is positionally smoothed according to the preset smoothing strength coefficient to obtain each of the smoothed key points. For example, when the preset smoothing strength coefficient is 0, the sampled key point remains unchanged. When the preset smoothing strength coefficient is equal to 1, the foot point of the sampled key point on its target baseline is calculated, and the foot point is used as the final smoothed key point. When the preset smoothing strength coefficient is between 0 and 1, the linear position point between the sampled key point and the target baseline is taken as the smoothed key point, and then each of the smoothed key points is obtained, thereby achieving the maximum provision of a smooth curve while retaining the key path nodes, thereby improving the accuracy of trajectory path extraction.
[0098] Reference Figure 5 , Figure 5 It is a structural diagram of the trajectory path extraction device of the hardware operating environment involved in the embodiment of the present application.
[0099] like Figure 5 As shown, the trajectory path extraction device may include: a processor 1001, such as a CPU, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to connect and communicate between the processor 1001 and the memory 1005. The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as a disk storage device. The memory 1005 may also be a storage device independent of the processor 1001.
[0100] Optionally, the trajectory path extraction device may further include a rectangular user interface, a network interface, a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, and the like. The rectangular user interface may include a display screen and an input submodule such as a keyboard. Optionally, the rectangular user interface may also include a standard wired interface and a wireless interface. The network interface may optionally include a standard wired interface and a wireless interface (such as a WiFi interface).
[0101] Those skilled in the art will understand that Figure 5 The structure of the trajectory path extraction device shown in the figure does not constitute a limitation to the trajectory path extraction device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0102] like Figure 5 As shown, memory 1005, a computer storage medium, may include an operating device, a network communication module, and a trajectory path extraction program. The operating device is a program that manages and controls the hardware and software resources of the trajectory path extraction device, supporting the operation of the trajectory path extraction program and other software and / or programs. The network communication module is used to enable communication between the various components within memory 1005, as well as communication with other hardware and software in the trajectory path extraction device.
[0103] exist Figure 5 In the trajectory path extraction device shown, the processor 1001 is used to execute the trajectory path extraction program stored in the memory 1005 to implement the steps of any of the above-mentioned trajectory path extraction methods.
[0104] The specific implementation of the trajectory path extraction device of the present application is basically the same as the embodiments of the trajectory path extraction method described above, and will not be repeated here.
[0105] In addition, this application also provides a trajectory path extraction device, referring to Figure 6 , Figure 6 This is a functional module diagram of the trajectory path extraction device of the present application, which includes:
[0106] An extraction module, configured to obtain a target image corresponding to a target product and extract edge points of each track corresponding to the target image;
[0107] The segmentation module is used to segment the edge points of each trajectory into straight segments and obtain smooth segmentation results;
[0108] A sampling and smoothing module is used to perform sampling and smoothing processing on each of the edge points of the trajectory based on the smooth segment segmentation result to obtain each smooth key point;
[0109] A generation module is used to generate a target trajectory path based on each of the smooth key points.
[0110] Optionally, the sampling and smoothing module is further configured to:
[0111] Calculating the target reference line corresponding to each of the smooth approximate straight line segments;
[0112] Based on each of the smooth approximate straight line segments, each of the segmentation corner points and a preset tangential sampling distance, edge point sampling is performed on each of the edge points of the trajectory to obtain each sampling key point;
[0113] Based on the target baseline of each smooth approximate straight line segment, each sampling key point is smoothed to obtain each smooth key point.
[0114] Optionally, the extraction module is further configured to:
[0115] Acquire a reference area corresponding to the target image;
[0116] Calculating target search areas corresponding to the reference area;
[0117] Calculating the trajectory edge points corresponding to each target search area based on the preset search direction and edge polarity;
[0118] Or based on the preset search direction and edge polarity, edge points on both sides of the target product edge are extracted in each target search area, and the average center position between the edge points on both sides of each target product edge is calculated, so as to use each average center position as each track edge point of the target image.
[0119] Optionally, the extraction module is further configured to:
[0120] Based on a preset foreground-background segmentation method, each contour edge corresponding to the target image is determined, and the trajectory edge point of each contour edge is calculated.
[0121] Optionally, the segmentation module is further configured to:
[0122] Based on each track edge point, a first target edge point and a second target edge point are selected, and the to-be-segmented curve segments corresponding to the first target edge point and the second target edge point are determined;
[0123] forming a target straight line segment based on the first target edge point and the second target edge point;
[0124] Traversing each track edge point between the first target edge point and the second target edge point to select the track edge point with the largest chord distance to the target straight line segment to obtain a third target edge point;
[0125] If the chord distance between the third target edge point and the target straight line segment is greater than the preset normal similarity distance, the curve segment to be segmented is segmented based on the third target edge point to obtain target straight line segments corresponding to the third target edge point and the first target edge point and the second target edge point respectively, until the chord distance between each trajectory edge point and the target straight line segment is no greater than the preset normal similarity distance, and the smooth segment segmentation result is obtained.
[0126] Optionally, the trace path extraction device is further configured to:
[0127] Linear fitting is performed on each of the smooth approximate straight line segments to obtain a target reference line corresponding to each of the smooth approximate straight line segments.
[0128] Optionally, the trace path extraction device is further configured to:
[0129] Based on each of the smooth approximate straight line segments, edge point sampling is performed on each of the trajectory edge points according to a preset tangential sampling distance to obtain each sampling node;
[0130] Calculating the node distance between each of the sampling nodes and each of the segmentation corner points;
[0131] Based on the node distance, the preset tangential sampling distance is subjected to distance weighting processing, so as to perform edge point sampling according to the weighted preset tangential sampling distance to obtain each of the sampling key points.
[0132] Optionally, the trace path extraction device is further configured to:
[0133] Calculating the target distance between each of the sampling key points and the target reference line corresponding to the sampling key point;
[0134] Based on the target distance, position smoothing processing is performed on each of the sampled key points using a preset smoothing strength coefficient to obtain each of the smoothed key points.
[0135] The specific implementation of the trajectory path extraction device of the present application is basically the same as the various embodiments of the trajectory path extraction method described above, and will not be repeated here.
[0136] An embodiment of the present application provides a storage medium, which is a computer-readable storage medium, and the computer-readable storage medium stores one or more programs, and the one or more programs can also be executed by one or more processors to implement the steps of any of the above-mentioned trajectory path extraction methods.
[0137] The specific implementation of the computer-readable storage medium of the present application is basically the same as the embodiments of the trajectory path extraction method described above, and will not be repeated here.
[0138] An embodiment of the present application provides a computer program product, and the computer program product includes one or more computer programs, and the one or more computer programs can also be executed by one or more processors to implement the steps of any of the above-mentioned trajectory path extraction methods.
[0139] The specific implementation of the computer program product of the present application is basically the same as the embodiments of the above-mentioned trajectory path extraction method, and will not be repeated here.
[0140] The above are only preferred embodiments of the present application and do not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent processing scope of the present application.
Claims
1. A trajectory path extraction method, characterized in that: The trajectory path extraction method comprises: Obtain a target image corresponding to a target product, and extract edge points of each track corresponding to the target image; Perform straight segment segmentation on the edge points of each trajectory to obtain smooth segmentation results; Based on the smooth segment segmentation result, sampling and smoothing processing is performed on each of the trajectory edge points to obtain each smooth key point; Based on each of the smooth key points, a target trajectory path is generated to perform calibration conversion on the target trajectory path, a running trajectory of the motion mechanism is calculated, and the running trajectory is sent to the motion mechanism in sequence for execution; The smooth segment segmentation result includes smooth approximate straight line segments and segmentation corner points. The step of performing sampling and smoothing processing on the edge points of the trajectory based on the smooth segment segmentation result to obtain smooth key points includes: Calculating the target reference line corresponding to each of the smooth approximate straight line segments; Based on each of the smooth approximate straight line segments, each of the segmentation corner points and a preset tangential sampling distance, edge point sampling is performed on each of the edge points of the trajectory to obtain each sampling key point; Based on the target baseline of each smooth approximate straight line segment, each sampling key point is smoothed to obtain each smooth key point, wherein the sampling key points are sparse in the smooth approximate straight line segment and are relatively dense near the segmentation corner point.
2. The trajectory path extraction method according to claim 1, wherein: The step of extracting edge points of each track corresponding to the target image comprises: Acquire a reference area corresponding to the target image; Calculating target search areas corresponding to the reference area; Calculating the trajectory edge points corresponding to each target search area based on the preset search direction and edge polarity; Or based on the preset search direction and edge polarity, edge points on both sides of the target product edge are extracted in each target search area, and the average center position between the edge points on both sides of each target product edge is calculated, so as to use each average center position as each track edge point of the target image.
3. The trajectory path extraction method according to claim 1, wherein: The step of extracting edge points of each track corresponding to the target image comprises: Based on a preset foreground-background segmentation method, each contour edge corresponding to the target image is determined, and the trajectory edge point of each contour edge is calculated.
4. The trajectory path extraction method according to claim 1, wherein: The step of segmenting each track edge point into a straight segment to obtain a smooth segment segmentation result comprises: Based on each track edge point, a first target edge point and a second target edge point are selected, and the to-be-segmented curve segments corresponding to the first target edge point and the second target edge point are determined; forming a target straight line segment based on the first target edge point and the second target edge point; Traversing each track edge point between the first target edge point and the second target edge point to select the track edge point with the largest chord distance to the target straight line segment to obtain a third target edge point; If the chord distance between the third target edge point and the target straight line segment is greater than the preset normal similarity distance, the curve segment to be segmented is segmented based on the third target edge point to obtain target straight line segments corresponding to the third target edge point and the first target edge point and the second target edge point respectively, until the chord distance between each trajectory edge point and the target straight line segment is no greater than the preset normal similarity distance, and the smooth segment segmentation result is obtained.
5. The trajectory path extraction method according to claim 1, wherein: The step of calculating the target reference line corresponding to each smooth approximate straight line segment comprises: Linear fitting is performed on each of the smooth approximate straight line segments to obtain a target reference line corresponding to each of the smooth approximate straight line segments.
6. The trajectory path extraction method according to claim 1, wherein: The step of sampling edge points of each trajectory edge point based on each smooth approximate straight line segment, each segmentation corner point and a preset tangential sampling distance to obtain each sampling key point includes: Based on each of the smooth approximate straight line segments, edge point sampling is performed on each of the trajectory edge points according to a preset tangential sampling distance to obtain each sampling node; Calculating the node distance between each of the sampling nodes and each of the segmentation corner points; Based on the node distance, the preset tangential sampling distance is subjected to distance weighting processing, so as to perform edge point sampling according to the weighted preset tangential sampling distance to obtain each of the sampling key points.
7. The trajectory path extraction method according to claim 1, wherein: The step of smoothing each of the sampled key points based on the target baseline of each of the smooth approximate straight line segments to obtain each of the smoothed key points comprises: Calculating the target distance between each of the sampling key points and the target reference line corresponding to the sampling key point; Based on the target distance, position smoothing processing is performed on each of the sampled key points using a preset smoothing strength coefficient to obtain each of the smoothed key points.
8. A trajectory path extraction device, characterized in that: The trajectory path extraction device includes: a memory, a processor, and a trajectory path extraction program stored in the memory. The trajectory path extraction program is executed by the processor to implement the steps of the trajectory path extraction method according to any one of claims 1 to 7.
9. A storage medium, wherein the storage medium is a computer-readable storage medium, characterized in that: The computer-readable storage medium stores a trajectory path extraction program, which is executed by a processor to implement the steps of the trajectory path extraction method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image edge smoothing method and device
CN110689492A