Coil positioning method, apparatus, and computer device
By acquiring a top-view image of the coil, edge feature extraction and key area identification are performed, solving the problem of inaccurate positioning of irregularly shaped coils. This enables precise positioning and automated processing of the coil, improving positioning accuracy and efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHAN HUAGONG SAIBAI DATA SYST CO LTD
- Filing Date
- 2025-12-26
- Publication Date
- 2026-05-08
AI Technical Summary
Existing technologies suffer from inaccurate positioning when locating irregularly shaped coils with side bosses, resulting in high labor intensity, low efficiency, and safety hazards for operators.
By acquiring a top-view image of the coil, key regions are identified using edge feature extraction and a trained region localization model. The coil is then fitted, and the fitted data is used to determine the coil's position information, including rotation angle and gripping position.
It achieves precise coil positioning, improves positioning accuracy and efficiency, reduces the need for manual intervention, is suitable for batch processing of various coil scenarios, and reduces positioning costs.
Smart Images

Figure CN121391998B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to a coil positioning method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology
[0002] In the manufacturing of core components for power equipment, irregularly shaped coils with side bosses have become common key components in power equipment such as transformers and reactors due to their suitability for special operating conditions. Currently, most companies in the industry generally adopt a "clamping equipment combined with manual operation" model when processing and manufacturing such coils, completing the loading, unloading, and transfer of coils between different processes. During this process, operators need to concentrate highly and precisely control the position and angle of the clamping equipment, which places high demands on the precision of manual operation. At the same time, because the entire process relies heavily on manual operation of the equipment, the labor intensity of employees increases significantly, leading to higher labor costs for enterprises. Furthermore, operators need to work continuously for long periods under high precision requirements, which easily leads to fatigue, resulting in a gradual decrease in the efficiency of manual handling and a decline in the precision of clamping operations. This can easily cause unexpected collisions between the clamps and the coil structure. Such collisions often cause physical deformation of the coil, seriously affecting the final quality of the coil and posing significant safety hazards in the actual production environment.
[0003] With the development of artificial intelligence technology, computer vision technology has made breakthroughs in many fields. In the field of industrial automation, object positioning and grasping using computer vision technology can efficiently and accurately calculate the position and orientation of workpieces, guiding robotic arms or gantry to complete tasks such as automatic assembly and handling. This can reduce teaching and programming time, adapt to randomly placed workpieces, and improve production line efficiency. This technology provides a solid foundation for solving the problem of precise positioning and automatic grasping of coils, such as irregularly shaped coils.
[0004] However, existing computer vision positioning and grasping technologies still suffer from inaccurate positioning when dealing with irregularly shaped coils with side protrusions. Summary of the Invention
[0005] Therefore, it is necessary to provide a coil positioning method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the coil positioning accuracy in response to the above-mentioned technical problems.
[0006] In a first aspect, this application provides a coil positioning method, the method comprising:
[0007] Obtain a top view image of the target coil to be located;
[0008] Based on the prior parameters of the top view image, edge features are extracted from the top view image to obtain the target edge feature set of the top view image;
[0009] The key regions in the top view image are identified by using a trained region localization model.
[0010] Based on the key region and the target edge feature set, coil fitting is performed to obtain the fitting data of the target coil;
[0011] The position information corresponding to the target coil is determined based on the fitted data.
[0012] In one embodiment, the step of extracting edge features from the top-view image based on prior parameters of the top-view image to obtain a target edge feature set of the top-view image includes:
[0013] Edge features are extracted from the top-view image to obtain an initial set of edge features for the top-view image;
[0014] Based on the prior parameters, the initial edge feature set is cleaned to obtain the target edge feature set.
[0015] In one embodiment, the initial edge feature set includes an initial edge contour set and an initial edge segment set; the target edge feature set includes a target edge contour set and a target edge segment set; the step of extracting edge features from the top-view image to obtain the initial edge feature set in the top-view image includes:
[0016] Edge pixels in the top-view image are extracted using an edge rendering algorithm, and all extracted edge pixels are connected to obtain an edge pixel chain; the initial edge contour set includes the edge pixel chain.
[0017] Line segments are fitted to the edge pixels in the initial edge contour set to obtain multiple edge line segments; the initial edge segment set includes multiple edge line segments.
[0018] In one embodiment, the step of fitting straight line segments based on the edge pixels in the initial edge pixel set to obtain multiple edge straight line segments includes:
[0019] The system traces forward along the edge pixel chain, uses the least squares method to fit a straight line to the currently tracked edge pixels, and calculates the cumulative residual. If the cumulative residual is less than or equal to a preset residual threshold, the system continues to track subsequent edge pixels until the cumulative residual is greater than the preset residual threshold, and then outputs the initial fitted line segment of the currently tracked pixel.
[0020] Traverse the remaining edge pixels. If the currently traversed remaining edge pixels meet the preset increment condition, update the initial fitted line segment based on the traversed edge pixels until the currently traversed remaining edge pixels no longer meet the preset increment condition. Obtain the edge line segments corresponding to all currently tracked and currently traversed edge pixels, and return to execute the step of forward tracing along the edge pixel chain.
[0021] In one embodiment, the target coil includes interconnected elliptical structures and boss structures, the boss structures being located on the sides of the elliptical structures; the key region includes at least endpoint regions; wherein, the step of performing coil fitting based on the key region and the target edge feature set to obtain fitting data for the target coil includes:
[0022] Ellipse fitting is performed based on the target edge feature set to obtain ellipse fitting data with an ellipse shape; the ellipse shape is the image of the ellipse structure in the top view image;
[0023] Line segment fitting is performed based on the endpoint region and the target edge feature set to obtain the line segment fitting data of the target edge with a boss shape; the boss shape is the image of the boss structure in the top view image; the target edge is located within the endpoint region.
[0024] In one embodiment, the key region further includes at least one vertex region; the method further includes:
[0025] Line segment fitting is performed based on at least one vertex region and the target edge feature set to obtain line segment fitting data for at least one vertex tangent; the vertex tangent refers to the tangent of the vertex of the elliptical shape.
[0026] In one embodiment, the position information includes the target rotation angle of the target coil and the gripping position information of the gripping device; determining the position information corresponding to the target coil based on the fitted data includes:
[0027] The target rotation angle of the target coil is determined based on the fitted data;
[0028] Based on the target rotation angle and the initial position information of the gripping device, the gripping position information for the gripping device to grip the target coil is determined.
[0029] In one embodiment, the fitting data includes line segment fitting data and ellipse fitting data; determining the target rotation angle of the target coil based on the fitting data includes:
[0030] The target rotation angle is determined using a multi-path algorithm based on the line segment fitting data and the ellipse fitting data.
[0031] Secondly, this application also provides a coil positioning device, the device comprising:
[0032] The acquisition module is used to acquire a top-view image of the target coil to be located;
[0033] The extraction module is used to extract edge features from the top view image based on the prior parameters of the top view image, so as to obtain the target edge feature set of the top view image;
[0034] The identification module is used to identify key regions in the input top-view image using a trained region localization model, thereby obtaining the key regions in the top-view image.
[0035] The fitting module is used to perform coil fitting based on the key region and the target edge feature set to obtain the fitting data of the target coil;
[0036] The determination module is used to determine the position information corresponding to the target coil based on the fitted data.
[0037] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0038] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0039] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the above-described method.
[0040] The aforementioned coil positioning method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire a top-view image of the target coil to be positioned. Based on prior parameters of the top-view image, edge features are extracted to obtain a target edge feature set. A trained region positioning model is used to identify key regions in the input top-view image, revealing key regions within the image. Coil fitting is performed based on the key regions and the target edge feature set to obtain fitting data for the target coil. The position information corresponding to the target coil is determined based on the fitting data. Thus, coil positioning based on key region identification and edge fitting is achieved. Precise positioning not only ensures the accuracy of coil contour capture by leveraging edge features, but also focuses on the core positioning range and reduces irrelevant interference by identifying key areas, effectively improving the noise resistance and robustness of coil positioning in complex scenarios. At the same time, the method of deriving position information based on fitted data avoids the deviation problems that are prone to occur when relying on manual or single features in related technologies, greatly improving positioning accuracy and efficiency. It can realize automated and intelligent positioning of target coil positions without complex manual intervention, and is suitable for batch processing of multiple coil scenarios, significantly reducing positioning costs and providing reliable position support for subsequent coil-related assembly, testing and other processes. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a diagram illustrating the application environment of the coil positioning method in one embodiment;
[0043] Figure 2 This is a flowchart illustrating a coil positioning method in one embodiment;
[0044] Figure 3 This is a schematic diagram of the coil structure in one embodiment;
[0045] Figure 4 This is a flowchart illustrating the coil positioning method in another embodiment;
[0046] Figure 5 This is a flowchart illustrating the coil positioning method in yet another embodiment;
[0047] Figure 6 This is a flowchart illustrating the coil positioning method in another embodiment;
[0048] Figure 7This is a flowchart illustrating the coil positioning method in another embodiment;
[0049] Figure 8 This is a flowchart illustrating the coil positioning method in yet another embodiment;
[0050] Figure 9 This is a flowchart illustrating the coil positioning method in another embodiment;
[0051] Figure 10 This is a structural block diagram of the coil positioning device in one embodiment;
[0052] Figure 11 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0054] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0055] The coil positioning method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, a camera or other device with imaging capabilities can be installed at the location of the vision center to capture images of the target coil 10, obtaining a top-down view of the target coil 10. The coil positioning device can then locate the target coil 10 based on this top-down view, obtaining its position information. A gripping device, such as a mechanical gripper, can control the gripping of the target coil 10 based on this position information, thereby achieving precise positioning and automatic grasping of the coil. The coil positioning device can be various computer devices, or processors, chips, or other devices with data processing capabilities; no further limitations are imposed here. The vision center and the coil positioning device can be integrated or set up separately, depending on the specific application requirements.
[0056] In one exemplary embodiment, such as Figure 2 As shown, a coil positioning method is provided, which is applied to... Figure 1The following explanation will be based on the application environment in the example, including the following steps S202 to S210.
[0057] S202, Obtain a top view image of the target coil to be located.
[0058] The target coil can be a coil to be positioned on the production line. In some exemplary embodiments, the target coil can be an irregularly shaped coil. An irregularly shaped coil may include a coil with a side boss structure. For example, an irregularly shaped coil includes interconnected elliptical structures (or rounded rectangular structures) and boss structures, wherein the boss structure is located on the side of the elliptical structure, which may be the side extending along the major axis of the elliptical structure, such as... Figure 1 As shown, the target coil is located on the side of the short axis extending in the direction of the elliptical structure. In some other exemplary embodiments, the target coil may also be a regular coil. Regular coils include, but are not limited to, coils with elliptical structures, coils with circular structures, or coils with other regular structures.
[0059] The top-down view image can be captured by a preset shooting device. The shooting device can be located at a preset position, such as... Figure 1 The location shown as the visual center is used to photograph the coils on the production line.
[0060] In application, the vision center can take pictures of the target coil to be positioned on the production line to obtain a top view image, and then transmit the top view image to the coil positioning device, so that the coil positioning device can obtain the top view image of the target coil to be positioned.
[0061] S204. Based on the prior parameters of the top view image, edge features are extracted from the top view image to obtain the target edge feature set of the top view image.
[0062] Prior parameters are used to represent parameters related to the top-view image, including but not limited to the position information of the imaging device, the built-in parameters of the imaging device, the height range of the target coil to be located, or other relevant parameters. Prior parameters can be acquired in advance and stored in the coil positioning device.
[0063] A target edge feature set is used to represent the edge features of the target coil. These edge features include, but are not limited to, edge pixels, edge segments, and edge contours. For example, the target edge feature set may include at least one of a target edge contour set N1 and a target edge segment set M1, wherein the target edge contour set N1 includes edge pixel chains, and the edge pixel chains include multiple edge pixels. The target edge segment set M1 includes multiple edge segments.
[0064] The coil positioning device can extract edge features from the top-view image based on prior parameters and a preset edge feature extraction strategy, thereby obtaining a set of target edge features for the top-view image. The edge feature extraction strategy includes, but is not limited to, edge pixel extraction strategies and edge line segment extraction strategies.
[0065] S206. The key regions in the input top-view image are identified by using a trained region localization model.
[0066] A region localization model is a pre-built and trained model. It is used to identify key regions in a top-down image.
[0067] A key region can be understood as a specific area in a top-view image that possesses target attributes or analytical value; it is the area of focus learned by the region localization model through training. A key region may include at least one edge keypoint in the top-view image, where the edge keypoint can be understood as the anchor point of the key region. The key region may also include other non-coiled areas in the top-view image. The shape of the key region can be predefined, for example, it can be a rectangle, square, ellipse, circle, or other suitable shape. The number of regions included in a key region is greater than or equal to one; for example, it can be one, two, three, or other suitable values.
[0068] by Figure 1 Taking the irregularly shaped coil shown as an example, in some exemplary embodiments, such as... Figure 3 As shown, the key region includes an endpoint region T. The endpoint region T includes two edge key points, such as a first endpoint K1 and a second endpoint K2 in the shape of a boss, where the boss shape is the image of the boss structure of the irregular coil in the top view image. In some other exemplary embodiments, the key region may include the endpoint region T, and may also include a vertex region R, such as at least one of a first vertex region R1 and a second vertex region R2. The first vertex region R1 may include at least one edge key point, such as a first vertex K3 in the shape of an ellipse, and the second vertex region R2 may include at least one edge key point, such as a second vertex K4 in the shape of an ellipse, where the elliptical shape is the image of the elliptical structure of the irregular coil in the top view image.
[0069] It should be noted that the above example uses an irregularly shaped coil. In actual applications, appropriate key areas can be set according to the specific structure of the coil. For example, if the coil has an elliptical structure, the corresponding key areas may include the first vertex area and / or the second vertex area. No further restrictions are imposed here.
[0070] In some exemplary embodiments, an initial region localization model, KeyAreaModel, can be constructed based on the U-NET network. The training process of the initial region localization model is as follows: Image data of the coil is acquired, including top-view images from various rotation angles. The coil can be a regular irregular coil and / or a regular coil, specifically determined according to the type of coil to be localized. For ease of explanation, an irregular coil will be used as an example below. Then, key regions are marked on the acquired image dataset. For example, key regions include the long side region of the side boss and the straight line regions on both sides of the irregular coil, denoted as T, R1, and R2 respectively. Figure 3 As shown. Subsequently, based on the image dataset and labeled key regions, training, testing, and validation sets can be constructed, and the initial region localization model can be trained to obtain the network model parameters W used for inference, thus obtaining the trained region localization model. In application, the top-view image I of the target coil captured on the production line can be input into the trained region localization model to obtain the key region corresponding to the top-view image I, which can be represented as (T, R1, R2) = KeyAreaModel (I, W).
[0071] S208, perform coil fitting based on the key region and target edge feature set to obtain the fitting data of the target coil.
[0072] The fitted data can be used to fit at least one of the following in the top-view image: the edge contour, key points, and edge coil of the target coil. The coil positioning device can employ fitting techniques, such as edge contour fitting techniques and line fitting techniques, to perform coil fitting based on the key region and the target edge feature set, thereby obtaining the fitted data of the target coil.
[0073] by Figure 1 and Figure 3 Taking the irregularly shaped coil shown as an example, the fitting data may include ellipse fitting data and line segment fitting data. The ellipse fitting data can be used to fit the edge contour of the irregularly shaped coil in the top-view image, such as an ellipse, and can also fit the key points of the ellipse. The key points of the ellipse include at least one of the midpoint and vertices of the ellipse, where the vertex may include the minor axis vertex (e.g.,...). Figure 3 (as shown in K3 and K4) and / or the major axis vertices. The line segment fitting data can be used to fit the edge line segments of the irregular coil in the top view image, such as the straight line segment where the long side L of the boss, i.e., the endpoint connection line K1K2, is located, the vertex tangent L1 through vertex K3, and the vertex tangent L2 through vertex K4, at least one of these.
[0074] It should be noted that the above is only an illustrative example. In actual application, the appropriate fitting method can be selected based on the specific structure of the coil. For example, if the target coil is a circular coil, a circular fitting technique can be used to obtain circular fitting data, which may include the circular outline and the midpoint of the circle. Adaptive adjustments can be made according to the specific application scenario.
[0075] S210, determine the position information corresponding to the target coil based on the fitted data.
[0076] Position information may include the target rotation angle θ of the target coil and / or the gripping position information of the gripping device when gripping the target coil. The target rotation angle θ may be the angle between the line connecting the midpoint of the target coil and the visual center, and the midpoint of the target coil and the target axis of the target coil. The target axis may be the major axis or the minor axis of the target coil. For example, Figure 1 In the irregularly shaped coil shown, the target axis is the major axis. The gripping position information indicates the target position that the gripping device needs to move to; the gripping device can grip the target coil at the target position, such as... Figure 1 The gripping device shown is located at the center of the gripper.
[0077] The coil positioning method provided in the above embodiments acquires a top-view image of the target coil to be positioned. Based on the prior parameters of the top-view image, edge features are extracted to obtain a target edge feature set of the top-view image. A trained region positioning model is used to identify key regions in the input top-view image to obtain key regions in the top-view image. Coil fitting is performed based on the key regions and the target edge feature set to obtain fitting data of the target coil. The position information corresponding to the target coil is determined based on the fitting data. In this way, precise coil positioning based on key region identification and edge fitting is achieved. It not only ensures the accuracy of coil contour capture by leveraging edge features, but also focuses on the core positioning range and reduces irrelevant interference by identifying key regions, effectively improving the noise resistance and robustness of coil positioning in complex scenarios. At the same time, the method of deriving position information based on fitting data avoids the deviation problems that are prone to occur when relying on manual or single features in related technologies, greatly improving positioning accuracy and efficiency. Automated and intelligent positioning of the target coil position can be achieved without complex manual intervention. It is suitable for batch processing of multiple coil scenarios, significantly reducing positioning costs and providing reliable position support for subsequent coil-related assembly, testing and other processes.
[0078] In some exemplary embodiments, such as Figure 4 As shown in S204, edge features are extracted from the top view image based on the prior parameters of the top view image to obtain the target edge feature set of the top view image, including the following S402 and S404.
[0079] S402, extract edge features from the top view image to obtain the initial edge feature set of the top view image.
[0080] The initial edge feature set refers to the set of edge features obtained after edge feature extraction based on the top-view image. For example, the initial edge feature set may include an initial edge contour set N0 and an initial edge line segment set M0.
[0081] For example, before extracting edge features from the top-view image, the coil localization method may further include preprocessing the top-view image. This allows for edge feature extraction from the preprocessed top-view image. For instance, the coil localization device may use a bilateral filter to preprocess the top-view image, thereby suppressing noise and smoothing the image. The bilateral filter is a non-linear filtering algorithm that, while smoothing the image and suppressing noise, accurately preserves edge details in the image. Its core difference from ordinary filtering such as Gaussian filtering lies in that it considers not only the physical distance of pixels but also the similarity of their grayscale values, ultimately achieving the effect of smoothing out noise and preventing blurred edges. The weights of the bilateral filter can be related to spatial distance weights and grayscale similarity weights. For example, the weights of the bilateral filter can be a weighted average of spatial distance weights and grayscale similarity weights. The spatial distance weight represents the influence of the position of surrounding pixels on the current pixel, while the grayscale similarity weight represents the influence of the color (grayscale) of surrounding pixels on the current pixel.
[0082] In applications, the coil positioning device can preprocess the top view image and then use a preset edge feature extraction algorithm to extract the edge features of the preprocessed top view image, thereby obtaining the initial edge feature set of the top view image.
[0083] S404. Based on prior parameters, the initial edge feature set is cleaned to obtain the target edge feature set.
[0084] It is understandable that, since the relative positions of the shooting device and the production line are fixed, and the size of the coil is relatively fixed, the projection of the coil onto the pixel plane has a fixed range according to the pinhole projection model of the shooting device, and the pixel length of its edge also has a relative range. Based on this information, edge features that do not belong to the coil can be filtered out from the initial edge feature set, such as filtering out edge pixels and edge segments that do not belong to the coil, thereby obtaining the target edge feature set.
[0085] For example, the target edge feature set may include a target edge contour set N1 and a target edge segment set M1. The target edge contour set N1 is the edge contour set obtained by data cleaning of the initial edge contour set N0, or by filtering out edge pixels that do not belong to the target coil from the initial edge contour set N0. The target edge segment set M1 is the edge segment set obtained by data cleaning of the initial edge segment M0, or by filtering out edge segments that do not belong to the target coil from the initial edge segment M0.
[0086] In applications, the coil positioning device can acquire prior parameters of the top-view image and, based on these prior parameters and the initial edge feature set, use a preset data cleaning algorithm to obtain the target edge feature set. Specifically, the target edge contour set N1 can be represented as: N1 = ExtractEllipseContour(N0, M0, PriorParams).
[0087] The coil localization method provided in the above embodiments extracts edge features from a top-view image to obtain an initial edge feature set. Based on prior parameters, the initial edge feature set is then cleaned to obtain a target edge feature set. This method first extracts the initial edge feature set to retain potential contour information related to the coil in the image, and then cleans the initial set using prior parameters to obtain the target edge feature set. This ensures the comprehensiveness of the coil edge features through initial extraction, avoiding the omission of key contour details, while also using prior parameters to specifically remove invalid information such as noise and interfering edges, significantly improving the purity and effectiveness of the edge features. This staged processing approach overcomes the problem of direct extraction being easily interfered with by complex backgrounds and avoids the feature bias that may result from relying solely on prior parameters. It provides high-quality edge data support for subsequent coil fitting, thereby further improving the accuracy and stability of coil localization. It is particularly suitable for industrial scenarios with complex backgrounds or interfering elements, reducing the impact of invalid features on the localization results and enhancing the practical value of the method.
[0088] In some exemplary embodiments, the initial edge feature set includes an initial edge contour set N0 and an initial edge segment set M0; the target edge feature set includes a target edge contour set N1 and a target edge segment set M1. For example... Figure 5 As shown in S402, edge features are extracted from the top view image to obtain an initial set of edge features in the top view image, including the following S502 and S504.
[0089] S502, use the edge drawing algorithm to extract edge pixels in the top view image, and connect all the extracted edge pixels to obtain the edge pixel chain; the initial edge contour set includes the edge pixel chain.
[0090] In applications, the coil positioning device can use the edge drawing algorithm to extract continuous pixel-level edge points, i.e., edge pixels, in the top view image, and connect all the extracted edge pixels to obtain an edge pixel chain, which can be used as an initial edge contour set.
[0091] Specifically, for the grayscale image corresponding to the top-view image (e.g., obtained during preprocessing), the coil positioning device can use the Sobel operator to calculate the horizontal and vertical gradients of each pixel in the grayscale image. Based on these gradients, the gradient magnitude and pixel orientation of each pixel can be obtained, resulting in the gradient magnitude map and pixel orientation map corresponding to the grayscale image. Then, based on the pixel orientation map, local peak pixels in the gradient map can be selected as anchor points, and all anchor points are connected to form a continuous chain of edge pixels, i.e., the initial edge contour set N0. The Sobel operator includes two 3x3 convolution kernels, one corresponding to the horizontal direction and the other to the vertical direction, used to scan the image and calculate the grayscale changes of each pixel.
[0092] For example, the above-mentioned selection of local peak pixels in the gradient map as anchor points may include: for each pixel in the gradient magnitude map, taking two adjacent pixels along its pixel direction, comparing the gradient magnitude of the current pixel with the gradient magnitude of the two adjacent pixels, if the gradient magnitude of the current pixel is greater than the gradient magnitude of the two adjacent pixels, the current pixel can be determined as a local peak pixel, i.e., an anchor point; if not, the current pixel is determined not to be an anchor point, and may be a non-centerline pixel on the edge or a background pixel.
[0093] For example, connecting all anchor points may include connecting spatially adjacent and directionally consistent anchor points. Spatially adjacent can be understood as the pixel positions of two anchor points being close in distance, such as a distance less than or equal to a preset distance threshold. Directional consistency can be understood as the pixel directions of two anchor points being the same or close, such as the difference between pixel directions being less than or equal to a preset direction threshold. During the connection process, starting from the first anchor point in the image, surrounding anchor points that satisfy both spatial adjacency and directional consistency are searched sequentially and connected one by one. When no next anchor point meeting the conditions is found, a continuous anchor point chain is formed; this chain is the edge pixel chain. This process is repeated for all anchor points in the image until at least one continuous edge pixel chain is obtained. For example, the contours of the elliptical circumference and protrusions corresponding to irregular coils can be collectively referred to as the initial edge contour set N0.
[0094] S504, perform line segment fitting based on the edge pixels in the initial edge contour set to obtain multiple edge line segments; the initial edge segment set includes multiple edge line segments.
[0095] In applications, the coil positioning device can employ a line segment extraction method, which uses edge pixels in the initial edge contour set N0 to fit straight line segments, resulting in multiple edge straight line segments, i.e., the initial edge segment set M0. For example, the line segment extraction method can be based on a dynamic recursive least squares fitting method.
[0096] The coil positioning method provided in the above embodiments extracts edge pixels from the top-view image using an edge rendering algorithm and connects them to form an edge pixel chain. Combined with the continuity features of the initial edge contour set, such as spatially adjacent and oriented edge pixels, it effectively avoids edge breakage and false edge interference problems that are prone to occur in edge detection in related technologies, ensuring the integrity and accuracy of coil edge positioning and providing a high-quality pixel foundation for subsequent line segment fitting. Furthermore, it simplifies the edge structure through straight line fitting, reduces the computational complexity of subsequent coil positioning, and improves the efficiency and accuracy of the positioning process, providing reliable technical support for the accurate positioning of the coil.
[0097] In some exemplary embodiments, such as Figure 6 As shown, in S504, straight line segments are fitted based on the edge pixels in the initial edge pixel set to obtain multiple edge straight line segments, including the following S602 and S604.
[0098] S602, along the edge pixel chain, tracks forward, uses the least squares method to fit a straight line to the currently tracked edge pixels, and calculates the cumulative residual. If the cumulative residual is less than or equal to the preset residual threshold, it continues to track subsequent edge pixels until the cumulative residual is greater than the preset residual threshold, and outputs the initial fitted line segment of the currently tracked pixel.
[0099] S604, Traverse the remaining edge pixels. If the currently traversed remaining edge pixels meet the preset increment condition, update the initial fitted line segment based on the traversed edge pixels until the currently traversed remaining edge pixels no longer meet the preset increment condition. Obtain the edge line segments corresponding to all currently tracked and currently traversed edge pixels, and return to execute the step of forward tracing along the edge pixel chain.
[0100] The coil positioning device can use the above-mentioned S602 and S604, that is, the least squares fitting method based on dynamic recursion to fit straight line segments.
[0101] The above S602 can be understood as the processes of tracking initialization, forward tracking, least squares fitting, residual accumulation, and decision output. Specifically, during the tracking initialization process, the coil positioning device can select the starting edge pixel of the current edge pixel chain (for ease of description, the edge pixel is simply referred to as a pixel) as the tracking starting point and include this pixel in the currently tracked pixel sequence. During the forward tracking process, starting from the starting pixel, the next edge pixel is tracked forward along the extension direction of the edge pixel chain (in ascending order of pixel coordinates, such as from left to right or from top to bottom), and added to the currently tracked pixel sequence. The coordinate information of each currently tracked pixel can be recorded. Least squares fitting is then performed, i.e., a straight line model is constructed for the currently tracked pixel sequence. Furthermore, residual accumulation is performed, i.e., the residual from each pixel in the currently tracked pixel sequence to the straight line is calculated, and the sum of the residuals is the accumulated residual. Then, during the output determination process, it is determined whether the calculated cumulative residual is less than or equal to a preset residual threshold. If so, it indicates that the distribution trend of the currently tracked pixel sequence conforms to the linear characteristic, and forward tracking of the next edge pixel can continue. That is, the process of forward tracking described above is returned to perform the next round of forward tracking, least squares fitting, residual accumulation, and output determination. If the cumulative residual is greater than the preset residual threshold, it is determined that the currently tracked pixel has deviated from the linear trend, and the current tracking is immediately terminated. The fitted straight lines corresponding to all pixels in the currently tracked pixel sequence except for the last deviated pixel are determined as the initial fitted line segment, and the initial geometric parameters of the line segment are recorded. The initial geometric parameters may include the initial start coordinates, the initial end coordinates, the initial slope, and the initial intercept.
[0102] After outputting the optimal fitted line segment that currently satisfies the error constraint in S602, S604 can be used, that is, recursively processing the remaining edge pixels based on the divide-and-conquer strategy until the entire pixel chain is parsed. Specifically, S604 can be understood as the processes of traversal initialization, incremental condition determination, line segment update, and loop execution triggering. Specifically, in the traversal initialization process, the coil positioning device can take the last deviated pixel that terminated tracking in S602 as the starting point for traversing the remaining edge pixels, and sequentially select subsequent pixels as the currently traversed pixels, recording their coordinates and gradient directions. Then, incremental condition determination is performed, that is, for each currently traversed pixel, two preset incremental conditions are verified respectively: Condition 1: Calculate the geometric deviation (such as vertical distance) from the pixel to the current initial fitted line segment, and determine whether the geometric deviation is less than or equal to a preset deviation threshold; Condition 2: Calculate the absolute value of the angle deviation between the pixel's gradient direction and the current initial fitted line segment, and determine whether the absolute value of the angle deviation is less than or equal to a preset angle threshold; if both conditions are satisfied, it is determined that the currently traversed remaining pixel meets the preset incremental conditions. If any of the aforementioned conditions is not met, the preset increment condition is determined to be unqualified. The preset increment condition includes that the set deviation of the currently traversed remaining edge pixels is less than or equal to a preset deviation threshold, and that the pixel direction of the currently traversed remaining edge pixels deviates from the initial fitted line segment (i.e., the absolute value of the aforementioned included angle deviation) less than or equal to a preset angle threshold.
[0103] During the initial fitting of the line segment update process, if the currently traversed pixel meets the preset increment condition, the pixel is included in the sequence of tracked pixels, and the line segment parameters are updated using incremental least squares optimization. That is, it is not necessary to refit all pixels, but only based on the coordinates of the newly added pixels, the slope and intercept are updated through an iterative formula, so that the updated line segment fits the overall distribution of the original tracked pixels and the newly added pixels. If the currently traversed pixel does not meet the preset increment condition, the traversal is terminated, and the updated line segment is determined as the final edge straight line segment. This line segment covers the tracked pixels and the traversed pixels that meet the increment condition, and its final geometric parameters are recorded, including the final start coordinates, the final end coordinates, the final slope, and the final intercept.
[0104] During the loop triggering process, after the current edge line segment is generated, it checks whether there are still untraversed remaining edge pixels in the current edge pixel chain, that is, pixels after the pixel that terminates the traversal. If there are untraversed pixels, it returns to the tracking initialization step in S602, using the pixel that terminates the traversal as the new tracking starting point, and restarts the generation of the initial fitted line segment; if there are no untraversed pixels, it means that the current edge pixel chain has been completely parsed, and it enters the processing of the next edge pixel chain (if the initial edge contour set contains multiple pixel chains).
[0105] The coil positioning method provided in the above embodiments, when tracing forward along the edge pixel chain, uses the least squares method to fit and determine the accumulated residual in real time, and terminates and outputs the initial fitted line segment after the residual exceeds the limit. This effectively avoids the problems of wasted data due to excessively short line segments or insufficient accuracy due to excessively large residuals caused by fixed-length fitting, ensuring that the initial line segment satisfies the error constraint and maximizes the coverage of continuous edge pixels, laying the foundation for accurate positioning of the coil edge. Furthermore, when traversing the remaining edge pixels, the initial fitted line segment is dynamically updated through preset incremental conditions (dual constraints of geometric deviation and directional consistency), ensuring that the expanded line segment always fits the coil edge pixels. The geometric trend can be filtered to remove interference pixels caused by abrupt changes in direction, and to avoid distortion of the coil outline caused by forced extension of line segments. In this way, a two-iteration mechanism combining forward tracking fitting and incremental update optimization is formed. That is, the first iteration determines the initial line segment, and the second iteration expands and optimizes, further improving the integrity and accuracy of the line segment fitting, ensuring that the regular edges of the coil, such as straight lines, can be completely extracted. At the same time, through the direction change detection mechanism, the problem of mixed segmentation of curved segments and broken line segments in the coil edge is accurately solved, and the line segment is accurately truncated at geometric inflection points, such as coil corners and edge turning points, which can adapt to the positioning needs of coils of different sizes and postures.
[0106] In some exemplary embodiments, such as Figure 1 and Figure 3 As shown, the target coil includes interconnected elliptical structures and boss structures. The boss structures are located on the sides of the elliptical structures. For example, in... Figure 1 In the irregularly shaped coil shown, the boss structure is located on the side of the elliptical structure along the major axis. In applications, the boss structure can also be located on the side of the elliptical structure along the minor axis.
[0107] The key region includes at least the endpoint region T. This endpoint region T can be used to represent the region corresponding to the target edge of the boss shape, or in other words, the target edge of the boss shape is within the endpoint region T. The boss shape is the image of the boss structure in the top-view image. For example, the target edge is the line connecting the first endpoint K1 and the second endpoint of the boss shape, abbreviated as the long edge of the boss.
[0108] like Figure 7 As shown in S208, coil fitting is performed based on the key region and target edge feature set to obtain the fitting data of the target coil, including the following S702 and S704.
[0109] S702, perform ellipse fitting based on the target edge feature set to obtain ellipse fitting data with an ellipse shape; the ellipse shape is the imaging of the ellipse structure in the top view image.
[0110] The coil positioning device can fit the elliptical shape of the target coil in the top-view image using RANSAC (Random Sample Consensus) ellipse fitting technology based on the target edge contour set N1 in the target edge feature set, and obtain the corresponding ellipse fitting data. The RANSAC ellipse fitting process can include the following iterative process, each iteration comprising five steps: random sampling, model building, interior point calculation, iterative optimization, and final fitting.
[0111] Understandably, parameter estimation for an elliptical model requires at least five non-collinear pixels. Therefore, during random sampling, five edge pixels can be randomly selected from all edge pixels in the target edge contour set N1, and the coordinates (x, y, y) of these five edge pixels can be obtained. i , y i (1≤i≤5), as the initial sample set, is used to initially construct the elliptical model. A coordinate system can be established based on a preset origin, such as the initial position of the gripping device.
[0112] In model construction, the coordinates of the five extracted edge pixels are used to fit an ellipse equation, and the parameters of the ellipse equation are obtained. The general equation of an ellipse is:
[0113] (1)
[0114] Then we have:
[0115] (i=1,2,3,4,5) (2)
[0116] Written in matrix form: MV=0
[0117] (3)
[0118] Based on the above, performing Singular Value Decomposition (SVD) on matrix M, M=UΣV, yields the vector corresponding to the smallest eigenvalue, which is the solution vector. This provides the elliptical model corresponding to the five currently extracted edge pixels, denoted as the current elliptical model. Furthermore, according to the general equation of an ellipse, the coordinates of the ellipse center (x0, y0) can be obtained, along with at least one of the major axis, its slope, its minor axis, and its slope.
[0119] Based on the current elliptical model obtained from the above solution, during the interior point calculation process, all edge pixels in the target edge contour set N1 are traversed. The geometric distance from each edge pixel to the current elliptical model is calculated, and the geometric distance is compared with a preset distance threshold. If the geometric distance is less than or equal to the preset distance threshold, the point is determined to be an interior point, i.e., a valid pixel belonging to the outer edge of the coil. If the geometric distance is greater than the preset distance threshold, the point is determined to be an exterior point, which may be a noise point, a background interference point, or an irrelevant point inside the coil. Based on this, the total number of current interior points corresponding to the current elliptical model is counted, and the current interior point set is recorded. The geometric distance can be a normalized geometric distance, which can be expressed by the formula:
[0120] (4)
[0121] Where, d normalized d represents the normalized geometric distance. algebraic This represents the algebraic distance from the edge pixel to the initial elliptical model, where A, B, C, D, and E are the parameters of the current elliptical model.
[0122] During the iterative optimization process, it can be determined whether the total number of interior points corresponding to the current ellipse model is greater than the total number of interior points in the previous iteration. If so, the optimal ellipse model is updated to the current ellipse model, the optimal set of interior points is updated to the current set of interior points, and the optimal total number of interior points is updated to the current total number of interior points.
[0123] During the final fitting process, it can be determined whether the total number of optimal interior points has reached a preset threshold. If so, the loop exits, and the optimal ellipse model, along with the corresponding ellipse center coordinates and major and minor axes, is output, thus obtaining the ellipse fitting data. This ellipse fitting data may include ellipse parameters, ellipse center coordinates, and may also include the major axis E, major axis slope, and major axis angle θ. E The parameters include the minor axis, minor axis slope, and minor axis angle. If not, proceed to the next iteration and return to perform the random sampling process.
[0124] S704, perform line segment fitting based on the endpoint region and target edge feature set to obtain the line segment fitting data of the target edge with the boss shape; the target edge is located within the endpoint region.
[0125] The coil positioning device can obtain the target edge feature set, such as the target edge contour set N1 and the target edge line segment set M1, from the target edge feature set in the endpoint region T. Then, it uses RANSAC line fitting technology to fit the line segments, obtaining the line segment fitting data of the target edge. The target edge is located within the endpoint region. The target edge refers to any edge of the boss shape, and its number can be 1, 2, or other suitable values.
[0126] For example, if the target side is the long side L of the boss, which is the straight line connecting the first endpoint K1 and the second endpoint of the boss shape, then the corresponding line segment fitting data may include the coordinates of the first endpoint K1 and the second endpoint K2, as well as the lengths of the first endpoint K1 and the second endpoint K2, the slope of the long side L of the boss (i.e., the slope of the line connecting the endpoints K1 and K2), and the angle θ of the long side of the boss. L At least one of them.
[0127] The coil positioning method provided in the above embodiments, for coil outer edges such as elliptical structures, obtains elliptical fitting data by fitting the target edge feature set to accurately reconstruct the coil's imaging shape in the top-view image. This method uses elliptical parameters (such as center coordinates, major and minor axes, and rotation angles) to clarify the core position, size, and placement of the coil, and uses robust fitting algorithms such as RANSAC to eliminate background noise and local deformation interference, ensuring a high degree of fit between the elliptical shape and the actual outer edge of the coil. Furthermore, for the target edge of the boss shape, line segment fitting data is generated by combining the endpoint region and the target edge feature set to accurately lock the effective range of the boss edge, avoiding the inclusion of irrelevant edges of the boss in the fitting, providing crucial basis for determining the relative position of the coil and the boss. This method achieves collaborative positioning of the elliptical coil body and the boss auxiliary structure. It ensures the positioning accuracy of the coil core area through elliptical fitting, and supplements the detailed features of the boss edge through line segment fitting. The fitting data formed by both methods corroborate and complement each other, effectively supporting subsequent coil assembly and calibration scenarios, significantly improving the method's adaptability and engineering application value, while avoiding information loss or deviation problems caused by single feature positioning.
[0128] In some exemplary embodiments, the key region further includes at least one vertex region. Each vertex region can be used to represent a region corresponding to a vertex of an elliptical shape, or in other words, a vertex of an elliptical shape is located within a vertex region. The vertex can be any vertex of an elliptical shape. The number of vertex regions can be one, two, or other suitable values, and is not limited herein. For example, the key region includes a first vertex region R1, and the key region may also include a second vertex region R2.
[0129] The coil localization method further includes: performing line segment fitting based on at least one vertex region and a set of target edge features to obtain line segment fitting data for at least one vertex tangent. A vertex tangent refers to the tangent at a vertex of an elliptical shape, such as... Figure 3 The diagram shows L1 and L2. The extension direction of the vertex tangent can be perpendicular or parallel to the extension direction of the target edge, for example, Figure 3 In the diagram, the extension directions of the vertex tangents L1 and L2 are perpendicular to the extension direction of the long side L of the boss, respectively. The line segment fitting data for the vertex tangents may include vertex coordinates such as K3 and K4 coordinates, and may also include the vertex tangent slope and vertex tangent angle such as θ.L1 θ L2 .
[0130] For example, taking at least one vertex region including a first vertex region R1 and a second vertex region R2 as an example, line segment fitting can be performed based on the first vertex region R1 and the target edge feature set to obtain the line segment fitting data of the vertex tangent L1, and line segment fitting can be performed based on the second vertex region R2 and the target edge feature set to obtain the line segment fitting data of the vertex tangent L2.
[0131] In applications, the coil positioning device can obtain target edge feature sets such as target edge contour sets and target edge line segment sets in the target edge feature set from the target edge feature set based on at least one vertex region such as R1 and R2, and perform line segment fitting using RANSAC line fitting technology based on the target edge feature set in the vertex region to obtain line segment fitting data of at least one vertex tangent, such as line segment fitting data of L1 and L2.
[0132] The coil positioning method provided in the above embodiments, based on fitting the vertex tangent to at least one vertex region and the target edge feature set, can accurately lock the effective edge features near the vertex of the ellipse shape, such as edge contours and edge segments, from the target edge feature set. Simultaneously, combined with the anti-interference characteristics of RANSAC straight-line fitting technology, it effectively eliminates external interference such as noise and local deformation, ensuring that the line segment fitting data of the vertex tangent accurately reflects the true tangent shape at the vertex of the ellipse. Furthermore, by obtaining the line segment fitting data of the vertex tangent, the extension direction of the ellipse vertex tangent is clarified, and this direction is perpendicular to the extension direction of the target edge, such as the edge of a boss. This perpendicular correlation is the relationship between the ellipse and the target edge. The relative attitude verification of the edges provides crucial evidence, such as determining whether the coil positioning is off by the perpendicularity of the tangent to the target edge, and can also assist in calibrating ellipse parameters, such as correcting the ellipse rotation angle based on the tangent direction, further improving the overall positioning accuracy of the coil. Moreover, when there are multiple vertex regions, such as R1 and R2, multiple vertex tangents, such as L1 and L2, can be fitted simultaneously. These tangent data can supplement the geometric feature information of the ellipse from different directions, forming a multi-dimensional complement with the ellipse fitting data and the target edge fitting data, constructing a more complete coil positioning feature system, providing more comprehensive parameter support for subsequent engineering applications such as coil assembly and alignment, and significantly improving the practicality and reliability of the method.
[0133] In some exemplary embodiments, the position information includes the target rotation angle of the target coil and the gripping position information of the gripping device. For example... Figure 8 As shown, S210 determines the position information corresponding to the target coil based on the fitted data, including the following S802 and S804.
[0134] S802, determine the target rotation angle of the target coil based on the fitted data.
[0135] S804, based on the target rotation angle and the initial position information of the gripping device, determine the gripping position information of the gripping device for gripping the target coil.
[0136] The fitting data may include the aforementioned ellipse fitting data, and may also include the aforementioned line segment fitting data. The line segment fitting data may include the line segment fitting data of the target edge of the boss shape, and may also include the line segment fitting data of the vertex tangents. For example, the fitting data includes the ellipse midpoint O, major axis E, long edge L of the boss, and vertex tangents L1 and L2.
[0137] The target rotation angle can be understood as the correction angle of the target coil. For example, as Figure 1 The target coil shown has a rotation angle that is the angle between the line connecting the visual center and the midpoint of the ellipse and the midpoint of the ellipse and the major axis of the ellipse; or, in other words, the target rotation angle is the angle between the line connecting the visual center and the midpoint of the ellipse and the midpoint of the ellipse and the gripping position.
[0138] After determining the target rotation angle of the target coil based on fitted data, the coil positioning device can determine the clamping position information for clamping the target coil based on the target rotation angle, the initial position information of the clamping device, and the shooting position information of the vision center. The clamping device is used to clamp the coil; for example, the clamping device can be a mechanical gripper. The initial position information can be the coordinates of the center of the clamping device. The clamping position information can be the target coordinates of the center of the clamping device. The shooting position information can be the coordinates of the vision center.
[0139] In this system, a coordinate system can be established with the initial position of the clamping device as the origin. Based on the target rotation angle θ, and the fact that the y-axis coordinates of the visual center and the coil center (i.e., the ellipse center O) are the same, the coordinates of the visual center (△) can be determined. x ,△ y The coordinates are prior data and can be adjusted to normal values. Then, measure the rotation radius R of the gripping device, which is the distance between the visual center and the center O of the ellipse. The coordinates of the gripping position (Δ) can be calculated using the following formula. X ,△ Y ):
[0140] (5)
[0141] (6)
[0142] The coil positioning method provided in the above embodiments determines the target rotation angle based on fitted data such as ellipse rotation angle and line segment fitted data. This accurately reflects the actual placement posture of the target coil in the top view image. Furthermore, by combining the initial position information of the clamping device to calculate the clamping position, the positioning result can be dynamically adjusted according to the actual layout of the device. This adapts to the installation scenarios of different models of clamping devices and avoids the impact of the initial position offset of the device on the clamping. Since the final determined clamping position information is directly related to the relative position of the coil and the clamping device, it can guide the device to accurately align the coil, effectively reducing the risk of coil deformation and detachment during the clamping process. At the same time, it provides clear parameter basis for subsequent automated clamping operations, greatly improving the efficiency and reliability of coil clamping and meeting the core needs of automated operations such as coil assembly and handling in industrial scenarios.
[0143] In some exemplary embodiments, the fitting data includes line segment fitting data and ellipse fitting data. S802, determining the target rotation angle of the target coil based on the fitting data includes: determining the target rotation angle using a multi-path algorithm based on the line segment fitting data and ellipse fitting data.
[0144] The coil positioning device can determine the target axis angle based on ellipse fitting data, and at least the target side angle of the boss shape based on line segment fitting data. Then, angles with large errors in the target axis angle and target side angle can be removed, and the target rotation angle of the target coil can be determined based on the remaining angles.
[0145] Taking the boss structure located on the side along the major axis as an example, the major axis angle θ can be determined based on the aforementioned ellipse fitting data. E In applications, if the boss structure is located along the minor axis extension direction, the minor axis slope can be obtained accordingly. Furthermore, based on the line segment fitting data of the target side of the aforementioned boss shape, the angle θ of the target side, such as the boss side angle, can be determined. L When the line segment fitting data also includes line segment fitting data for vertex tangents, the vertex slope can be determined based on the line segment fitting data for the vertex tangents, such as the tangent angle θ corresponding to vertex tangent L1. L1 The tangent angle θ corresponding to the vertex tangent L2 L2 .
[0146] With the aforementioned major axis angle θ E Angle θ of the boss side L Tangent angle θ L1 and tangent angle θ L2 For example, the major axis angle θ E Using this as a reference, compare the angles θ of the boss sides respectively. L Tangent angle θ L1 and tangent angle θ L2 Angle θ relative to the major axis respectively EIf the angle difference between the two exceeds the preset error threshold, it indicates that the error is large. The angle of the boss and / or the tangent angle with the larger error can be removed, and the average value of the remaining angles can be taken as the final angle calculation value.
[0147] The coil positioning method provided in the above embodiments integrates ellipse fitting data and line segment fitting data to obtain angle data of multi-dimensional features such as the major axis of the ellipse, the long side of the side boss, and the tangents L1 and L2 at the coil vertex. This constructs a redundant information system of main trend, auxiliary structure, and local details, avoiding angle misjudgment caused by deformation of a single feature. Furthermore, by introducing an error elimination mechanism and setting a scientific deviation threshold to filter abnormal angles, it accurately eliminates interference data such as that caused by local deformation, ensuring that the effective set of angles participating in the final calculation all come from reliable features, thus guaranteeing the reliability of angle calculation from the source. In addition, it employs… The effective angle mean optimization strategy not only balances the small angle deviations between different features, but also further reduces the impact of random errors on the results. The final output rotation angle can accurately match the actual posture of the coil. In addition, the algorithm has good adaptability to irregularly shaped coils with different degrees of deformation. There is no need to adjust the core logic according to the coil deformation. It can adapt to various scenarios with only threshold fine-tuning. It provides a stable and high-precision angle basis for the posture calibration and precise gripping of the subsequent gripping device, which significantly improves the efficiency and success rate of the automated assembly and handling of coils and reduces the risk of coil damage and gripping failure caused by angle deviation.
[0148] In some exemplary embodiments, such as Figure 9 As shown, a coil positioning method is provided, which includes the following steps S902 to S918.
[0149] S902: Training a key area localization network model based on the U-NET network, KeyAreaModel.
[0150] Specifically, image data of an irregularly shaped coil with side bosses was collected, including image data from various rotation angles. Key regions were labeled on the collected image dataset, including the long side region of the side bosses and the straight lines on both sides of the irregularly shaped coil, labeled as T, R1, and R2 respectively, as follows: Figure 3 As shown. A training set, test set, and validation set are constructed, and the network is trained to obtain the network model parameters W used for inference.
[0151] S904: Obtain a top view image of the irregular coil to be located, and extract the initial edge contour set N0 and the initial edge line segment set M0 from the top view image.
[0152] Specifically, the top-view image is first preprocessed, using a bilateral filter to suppress noise and smooth the input image. Then, the Edge Drawing algorithm is used to extract continuous pixel-level edge points as edge contours. Given a grayscale image, the Edge Drawing detection process includes: first, using the Sobel gradient operator to calculate the magnitude of the image gradient and smooth the direction of each pixel in the image; then, extracting the peak pixels of the gradient map as anchor points, and connecting all anchor points to obtain all continuous edge pixel chains, which is the initial edge contour set N0. Subsequently, the Line segment extraction method is used to fit straight line segments into the edge contour set N0 to obtain the initial edge line segment set M0.
[0153] The initial edge segment combination can be obtained based on a dynamic recursive least squares fitting strategy. Specifically, the algorithm first performs forward tracking along the edge pixels, uses the least squares method to fit a straight line to the current sequence, and calculates the residual from each pixel to the fitted line in real time. When the accumulated residual exceeds a preset threshold, the extension of the current line segment is determined to terminate, and the following operations are performed:
[0154] ① Output the best-fit line segment that currently satisfies the error constraint. Then, recursively process the remaining pixel chain based on a divide-and-conquer strategy until the entire pixel chain is parsed. This process is achieved through two iterative optimizations: the first iteration determines the initial fitted line segment that satisfies the minimum line segment length constraint, and the second iteration expands the fitting based on the initial line segment.
[0155] ② After the initial line segment is generated, the algorithm continuously traverses subsequent pixels, calculating the geometric deviation of each new pixel from the currently fitted line in real time. As long as the deviation remains within the threshold range, the line segment coverage will continue to expand. This process is achieved by dynamically updating the fitted line parameters, and its mathematical essence is incremental least squares optimization.
[0156] ③ When a pixel is detected to deviate from the direction of the currently fitted line by more than an angle threshold, the algorithm determines that a sudden change in direction has occurred, immediately terminates the current line segment expansion, and starts a new round of fitting. This mechanism effectively solves the problem of mixed segmentation of curve segments and polyline segments, ensuring the precise truncation of line segments at geometric inflection points.
[0157] S906: Based on the production line prior parameters, the initial edge contour set N0, and the initial edge segment set M0, extract the target edge contour set N1 and the target edge segment set M1 of the irregular coil.
[0158] The prior parameters (PriorParams) include camera position, camera intrinsic parameters, coil height range, and camera absolute coordinates. N1 = ExtractEllipseContour(N0, M0, PriorParams)
[0159] S908: Input the top view image I into the trained region localization model to obtain the key regions T, R1, and R2.
[0160] Where (T, R1, R2) = KeyAreaModel (I, W).
[0161] S910: Based on the target edge contour set N1, use RANSAC ellipse fitting technology to perform ellipse fitting to obtain the ellipse fitting data of the irregular coil.
[0162] RANSAC Ellipse Fitting Process: ① Randomly select 5 data points (x, y, y) from the target edge contour set N1. i , y i (1≤i≤5) Perform ellipse equation fitting, calculate the ellipse equation parameters according to the above formula (3), and obtain the center coordinates (x0, y0), major and minor axes, and rotation angle according to the general equation of the ellipse. ② According to the above formula (4), use the normalized geometric distance error to evaluate the data points of the obtained ellipse model and determine the set of interior points that conform to the ellipse model. ③ Determine whether the number of interior points obtained in ② is greater than the number of interior points in the previous step. If so, update the optimal interior point set and the optimal ellipse model. ④ Determine whether the optimal interior point set has reached the expected number. If so, exit the loop and output the optimal ellipse model. ⑤ Repeat steps ②-④ until the ellipse fitting is completed and its center point O and major axis E are obtained.
[0163] S912: Obtain all edge pixels and line segments in the endpoint region T from the target edge contour set N1 and the target edge line segment set M1, and use RANSAC line fitting technology to fit the line segments to obtain the line segment fitting data of the long side L of the side boss.
[0164] S914: From the target edge contour set N1 and the target edge line segment set M1, obtain all edge pixels and line segments in the vertex regions R1 and R2, and use RANSAC line fitting technology to fit the line segments to obtain the line segment fitting data of the vertex tangents L1 and L2 of the irregular coil.
[0165] S916: Based on the fitted ellipse center point O and major axis E, the long side of the side boss L, and the vertex tangents L1 and L2 of the irregular coil, calculate the target rotation angle of the irregular coil using a multi-path algorithm.
[0166] Because the coil undergoes compression deformation, it is difficult to determine the optimal rotation angle using only elliptic or linear fitting methods. Therefore, this application comprehensively utilizes the slope of the major axis E, the slopes of L1 and L2, and the slope of the long side of the side boss, while removing calculation results with large errors (assuming the angles of L, L1, and L2 are θ). L θ L1 θ L2 Then θ = arctan(k), where k is the slope of the line), and take the average value of the remaining straight line angles as the final angle calculation value θ of the irregular coil.
[0167] S918: Establish a coordinate system with the initial position of the gripper center. Based on the target rotation angle of the irregular coil and the fact that the y-axis coordinates of the visual center and the coil center are the same, calculate the coordinates of the gripper center clamping position.
[0168] Specifically, the center of the calibrated visual lens is offset by (△) x ,△ y The coordinates are prior data and can be adjusted to normal values. Then, the rotation radius R of the gripper is measured, and the gripping position coordinates (△) can be calculated according to the above formulas (5) and (6). X ,△ Y ).
[0169] The coil positioning method provided in the above embodiments achieves accurate positioning of the gripping position of irregularly shaped coils based on a multi-path method of key area identification and edge fitting. By combining deep learning-based key area positioning technology, real-time edge detection technology with false detection control function, and RANSAC-based line and ellipse fitting technology, it makes full use of the various geometric features of the coil to calculate the coil rotation angle, and calculates the final gripping position of the gripper based on the rotation angle, thereby improving the accuracy and robustness of the gripping position calculation, and ultimately improving the efficiency of automated coil gripping and handling, and achieving an overall improvement in production efficiency.
[0170] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0171] Based on the same inventive concept, this application also provides a coil positioning device for implementing the coil positioning method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more coil positioning device embodiments provided below can be found in the limitations of the coil positioning method described above, and will not be repeated here.
[0172] In one exemplary embodiment, such as Figure 10 As shown, a coil positioning device 1000 is provided, comprising: an acquisition module 1001 for acquiring a top-view image of a target coil to be positioned; an extraction module 1002 for extracting edge features from the top-view image based on prior parameters of the top-view image to obtain a target edge feature set of the top-view image; an identification module 1003 for identifying key regions of the input top-view image using a trained region positioning model to obtain key regions in the top-view image; a fitting module 1004 for fitting the coil based on the key regions and the target edge feature set to obtain fitting data of the target coil; and a determination module 1005 for determining the position information corresponding to the target coil based on the fitting data.
[0173] In an exemplary embodiment, the extraction module is further configured to extract edge features from the top-view image to obtain an initial edge feature set of the top-view image; and to perform data cleaning on the initial edge feature set according to prior parameters to obtain a target edge feature set.
[0174] In an exemplary embodiment, the initial edge feature set includes an initial edge contour set and an initial edge segment set; the target edge feature set includes a target edge contour set and a target edge segment set; the extraction module is further configured to extract edge pixels in the top-view image using an edge drawing algorithm, and connect all extracted edge pixels to obtain an edge pixel chain; the initial edge contour set includes an edge pixel chain; and line segment fitting is performed based on the edge pixels in the initial edge contour set to obtain multiple edge line segments; the initial edge segment set includes multiple edge line segments.
[0175] In an exemplary embodiment, the extraction module is further configured to perform forward tracing along the edge pixel chain, perform line fitting on the currently tracked multiple edge pixels using the least squares method, calculate the cumulative residual, and continue tracking subsequent edge pixels until the cumulative residual is greater than the preset residual threshold, and output the initial fitted line segment of the currently tracked pixel; traverse the remaining edge pixels, and update the initial fitted line segment based on the traversed edge pixels if the currently traversed remaining edge pixels meet the preset increment condition, until the currently traversed remaining edge pixels do not meet the preset increment condition, obtain the edge line segments corresponding to all currently tracked and currently traversed edge pixels, and return to execute the step of forward tracing along the edge pixel chain.
[0176] In an exemplary embodiment, the target coil includes an interconnected elliptical structure and a boss structure, with the boss structure located on the side of the elliptical structure; the key region includes at least the endpoint region; wherein, the fitting module is further configured to perform ellipse fitting based on the target edge feature set to obtain ellipse fitting data of an elliptical shape; the ellipse shape is the image of the elliptical structure in the top view image; and to perform line segment fitting based on the endpoint region and the target edge feature set to obtain line segment fitting data of the target edge of the boss shape; the boss shape is the image of the boss structure in the top view image; the target edge is located within the endpoint region.
[0177] In an exemplary embodiment, the key region further includes at least one vertex region; the fitting module is also used to perform line segment fitting based on at least one vertex region and a set of target edge features to obtain line segment fitting data for at least one vertex tangent; the vertex tangent refers to the tangent of a vertex with an elliptical shape.
[0178] In an exemplary embodiment, the position information includes the target rotation angle of the target coil and the clamping position information of the clamping device; the determining module is further configured to determine the target rotation angle of the target coil based on the fitted data; and determine the clamping position information of the clamping device for clamping the target coil based on the target rotation angle and the initial position information of the clamping device.
[0179] In one exemplary embodiment, the fitting data includes line segment fitting data and ellipse fitting data; the determination module is further configured to determine the target rotation angle using a multi-path algorithm based on the line segment fitting data and ellipse fitting data.
[0180] Each module in the aforementioned coil positioning device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0181] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements a coil positioning method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0182] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0183] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described above.
[0184] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the above-described method.
[0185] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the methods described above.
[0186] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0187] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0188] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0189] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A coil positioning method, characterized in that, The method includes: Obtain a top view image of the target coil to be located; Edge pixels in the top view image are extracted using an edge rendering algorithm, and all extracted edge pixels are connected to obtain an edge pixel chain; The system traces forward along the edge pixel chain, uses the least squares method to fit a straight line to the currently tracked edge pixels, and calculates the cumulative residual. If the cumulative residual is less than or equal to a preset residual threshold, the system continues to track subsequent edge pixels until the cumulative residual is greater than the preset residual threshold, and then outputs the initial fitted line segment of the currently tracked pixel. Traverse the remaining edge pixels. If the currently traversed remaining edge pixels meet the preset increment condition, update the initial fitted line segment based on the traversed edge pixels until the currently traversed remaining edge pixels no longer meet the preset increment condition. Obtain the edge line segments corresponding to all currently tracked and currently traversed edge pixels, and return to execute the step of forward tracing along the edge pixel chain. Based on prior parameters, the initial edge feature set is cleaned to obtain the target edge feature set of the top view image; the initial edge feature set includes an initial edge contour set and an initial edge line segment set; the initial edge contour set includes the edge pixel chain; the initial edge line segment set includes multiple edge straight line segments; the target edge feature set includes a target edge contour set and a target edge line segment set. The key regions in the top view image are identified by using a trained region localization model. Based on the key region and the target edge feature set, coil fitting is performed to obtain the fitting data of the target coil; The position information corresponding to the target coil is determined based on the fitted data.
2. The method according to claim 1, characterized in that, The target coil includes interconnected elliptical structures and boss structures, with the boss structures located on the sides of the elliptical structures; the key region includes at least endpoint regions; wherein, the step of performing coil fitting based on the key region and the target edge feature set to obtain fitting data for the target coil includes: Ellipse fitting is performed based on the target edge feature set to obtain ellipse fitting data with an ellipse shape; the ellipse shape is the image of the ellipse structure in the top view image; Line segment fitting is performed based on the endpoint region and the target edge feature set to obtain the line segment fitting data of the target edge with a boss shape; the boss shape is the image of the boss structure in the top view image; the target edge is located within the endpoint region.
3. The method according to claim 2, characterized in that, The key region further includes at least one vertex region; the method further includes: Line segment fitting is performed based on at least one vertex region and the target edge feature set to obtain line segment fitting data for at least one vertex tangent; the vertex tangent refers to the tangent of the vertex of the elliptical shape.
4. The method according to claim 2, characterized in that, The step of performing ellipse fitting based on the target edge feature set to obtain ellipse-shaped ellipse fitting data includes: Based on the target edge contour set in the target edge feature set, the elliptical shape of the target coil in the top view image is fitted using the random sampling consistency ellipse fitting technique, and the corresponding ellipse fitting data is obtained.
5. The method according to claim 1, characterized in that, The position information includes the target rotation angle of the target coil and the clamping position information of the clamping device; determining the position information corresponding to the target coil based on the fitted data includes: The target rotation angle of the target coil is determined based on the fitted data; Based on the target rotation angle and the initial position information of the gripping device, the gripping position information for the gripping device to grip the target coil is determined.
6. The method according to claim 5, characterized in that, The fitting data includes line segment fitting data and ellipse fitting data; determining the target rotation angle of the target coil based on the fitting data includes: The target rotation angle is determined using a multi-path algorithm based on the line segment fitting data and the ellipse fitting data.
7. The method according to claim 1, characterized in that, The preset incremental conditions include: the geometric deviation is less than or equal to a preset deviation threshold; and the absolute value of the angle deviation between the edge pixel gradient direction and the current initial fitted line segment is less than or equal to a preset angle threshold.
8. The method according to claim 1, characterized in that, The method further includes: Based on the coil-based image dataset and labeled key regions, a training set, a test set, and a validation set are constructed; the image dataset includes top-view images from various rotation angles. The pre-constructed initial region localization model is trained based on the training set, the test set, and the validation set to obtain the trained region localization model.
9. A coil positioning device, characterized in that, The device includes: The acquisition module is used to acquire a top-view image of the target coil to be located; The extraction module is used to extract edge pixels in the top-view image using an edge rendering algorithm, and connect all extracted edge pixels to obtain an edge pixel chain; it traces forward along the edge pixel chain, performs line fitting on the currently tracked edge pixels using the least squares method, and calculates the cumulative residual. If the cumulative residual is less than or equal to a preset residual threshold, it continues to track subsequent edge pixels until the cumulative residual is greater than the preset residual threshold, and outputs the initial fitted line segment of the currently tracked pixel; it traverses the remaining edge pixels, and if the currently traversed remaining edge pixels meet a preset increment condition, it updates the initial fitted line segment based on the traversed edge pixels. The process continues until the remaining edge pixels that have been traversed no longer meet the preset incremental condition, obtaining the edge line segments corresponding to all currently tracked and traversed edge pixels, and then returning to execute the step of forward tracing along the edge pixel chain; based on prior parameters, the initial edge feature set is cleaned to obtain the target edge feature set of the top view image; the initial edge feature set includes an initial edge contour set and an initial edge segment set; the initial edge contour set includes the edge pixel chain; the initial edge segment set includes multiple edge line segments; the target edge feature set includes a target edge contour set and a target edge segment set; The identification module is used to identify key regions in the input top-view image using a trained region localization model, thereby obtaining the key regions in the top-view image. The fitting module is used to perform coil fitting based on the key region and the target edge feature set to obtain the fitting data of the target coil; The determination module is used to determine the position information corresponding to the target coil based on the fitted data.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Object positioning method and device, electronic equipment and readable storage medium
CN114998274A