Workpiece pole positioning method and device, electronic equipment and storage medium
By constructing the matching of the template circle with the polar column arc segment, the pole column positioning problem is solved, the welding accuracy and quality are improved, and the performance and safety of the battery module are ensured.
Patent Information
- Application Number
- CN202510280865.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2025-07-04
AI Technical Summary
During the welding process of the battery module, it is difficult for the prior art to accurately locate the pole pillars, especially when the pole pillars are blocked by the pole pillars, resulting in difficult to ensure welding accuracy and quality.
By constructing a template circle to match the arc segment of the pole cylinder in the target image, calculate the matching score, determine the position and radius of the pole cylinder, and achieve rapid positioning of the pole cylinder of the workpiece.
It improves the accuracy and quality of welding of pole columns and bar sheets, ensures the performance and safety of the battery module, reduces the complexity of manual operation, and improves the efficiency and stability of automated welding.
Smart Images

Figure CN120259197A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of workpiece welding, and particularly relates to a positioning method, device, electronic device, and storage medium for workpiece poles. Background Art
[0002] In order to improve the battery life of battery modules, in industrial production, bar pieces are often fixedly connected to the poles of different numbers of batteries so that multiple batteries form a series-parallel relationship. During the welding of bar pieces to battery poles, pole positioning is required.
[0003] In related technologies, the method of using the Hough transform to find circles is often used to locate and search for circles in an image. Due to the occlusion of the bar piece, only a part of the central contour of the pole is exposed, and the exposed position is also random, which brings difficulties to the positioning of the pole. Therefore, how to achieve accurate positioning of the pole during the welding of the bar piece to the pole has become an urgent problem to be solved. Summary of the Invention
[0004] Embodiments of the present application disclose a positioning method, device, electronic device, and storage medium for workpiece poles. By constructing a template circle to match the pole arc segment in the target image, and determining the position of the pole circle according to the template circle with the highest matching score, rapid positioning of the workpiece pole during the bar piece welding process is achieved, and the welding accuracy and quality are improved.
[0005] Embodiments of the present application disclose a positioning method for workpiece poles, which is applied to an electronic device. The method includes:
[0006] Obtain an original image and perform binarization processing on the original image to obtain a target image. The original image includes a bar piece for welding a workpiece and a partial circular area of the workpiece pole, and a partial circular area of the workpiece pole is exposed through a through hole in the bar piece;
[0007] Traverse each first template circle in the first template circle set, and calculate the matching score of the first template circle according to whether the pixel value of the target pixel point located on the first template circle in the target image is a preset value, to obtain a plurality of first matching scores corresponding to the plurality of first template circles in the first template circle set. The more pixel points with the pixel value being the preset value, the higher the matching score. The radius of each first template circle is less than or equal to a preset maximum radius and greater than or equal to a preset minimum radius;
[0008] Determine the parameters of the workpiece pole according to the parameters of the first target template circle with the highest score among the plurality of first matching scores. The parameters include the center position and the radius.
[0009] In the above technical solution, a high-quality image acquisition device is used to ensure that a clear image of the workpiece is captured; by converting the image into black and white, noise is removed and key features, such as the bar piece and the workpiece terminal post, are highlighted, making subsequent processing more accurate; the clear image features enable the positioning algorithm of the workpiece terminal post to better identify and locate, improving the accuracy of recognition.
[0010] In a possible implementation manner, calculating the matching score of the first template circle according to whether the pixel value of the target pixel point located on the first template circle in the target image is a preset value includes:
[0011] Obtain the pixel value of the target pixel point and the pixel values of the target adjacent pixel points, where the target adjacent pixel points are obtained by translating the abscissa and ordinate of the target pixel point by a preset distance respectively;
[0012] When the pixel value of the target pixel point is the first pixel value and the pixel values of the target adjacent pixel points are the second pixel values, the score of the target template circle is incremented by 1, and the difference between the second pixel value and the first pixel value is greater than or equal to the pixel threshold;
[0013] Traverse each target pixel point on the first template circle, and calculate the ratio of the score of the first template circle to the total number of pixel points of the target pixel points to obtain the matching score of the first template circle.
[0014] In the above technical solution, a more detailed evaluation mechanism is established by comparing pixel values, thereby improving the overall matching performance of the algorithm. By calculating the ratio of the score to the total number of pixel points, the score is made more representative, which is beneficial to selecting the optimal template circle.
[0015] In a possible implementation manner, the target pixel point is each pixel point located on the first template circle, or the target pixel point is each pixel point located on the matching arc segment of the first template circle, and the matching arc segment is determined according to the occlusion rate of the first template circle blocked by the through hole.
[0016] In the above technical solution, the pixel points used to calculate the matching score can be all the pixel points located on the template circle, or they can also be the pixel points located on a certain arc segment of the template circle, and the calculation method is relatively flexible.
[0017] Furthermore, in the case of calculating the matching score by using the pixel points on a certain arc segment of the template circle, since the number of pixel points participating in the calculation is reduced, the operation efficiency can be improved.
[0018] In a possible implementation, when the target pixel points are each pixel point located on the matching arc segment of the first template circle, the method further includes:
[0019] Calculating the occlusion rate of the first template circle occluded by the through hole according to the radius of the first template circle, the center of the first template circle, the radius of the through hole, and the center of the through hole;
[0020] Determining the corresponding matching arc segment on the first template circle according to the occlusion rate and a preset mapping relationship between the occlusion rate and the central angle.
[0021] In the above technical solution, the design of the template circle takes into account different pole shapes, increasing adaptability. By calculating the occlusion rate in real time, the matching strategy can be dynamically adjusted, optimized for different pole shapes and different occlusion situations, and the occlusion problem can be flexibly handled to ensure that even under complex conditions, a suitable matching arc segment can still be found, thereby improving the overall accuracy.
[0022] In a possible implementation, the calculating the occlusion rate of the first template circle occluded by the through hole according to the radius of the first template circle, the center of the first template circle, the radius of the through hole, and the center of the through hole includes:
[0023] Calculating the center distance between the first template circle and the through hole according to the center of the first template circle and the center of the through hole;
[0024] Calculating the occlusion rate according to the center distance, the radius of the first template circle, and the radius of the through hole, where the occlusion rate is equal to the ratio of the difference between the radius of the through hole and the center distance to the radius of the first template circle.
[0025] In the above technical solution, the center distance is accurately calculated, combined with the geometric properties of the circle, to ensure the accuracy of the occlusion rate calculation. According to the occlusion rate calculation, the influence in different situations can be reasonably evaluated, providing effective data support for the subsequent matching steps.
[0026] In a possible implementation, the determining the corresponding matching arc segment on the first template circle according to the occlusion rate and a preset mapping relationship between the occlusion rate and the central angle range includes:
[0027] When the occlusion rate is less than or equal to a first threshold, determining the arc segment of the first template circle corresponding to the first central angle to the second central angle as the matching arc segment;
[0028] When the occlusion rate is greater than the first threshold and less than or equal to the second threshold, determine the arc segment of the first template circle corresponding to the third central angle to the fourth central angle as the matching arc segment;
[0029] When the occlusion rate is greater than the second threshold, determine the entire circumference of the first template circle as the matching arc segment.
[0030] In the above technical solution, multiple occlusion rate thresholds are set according to experience or experimental data to flexibly handle different situations where the pole columns are occluded. Through conditional judgment, the appropriate matching arc segment is automatically selected, enabling the algorithm to adapt to various occlusion degrees and avoiding incorrect matching.
[0031] In a possible implementation manner, the obtaining the original image and performing binarization processing on the original image to obtain a target image includes:
[0032] Collect the original image and perform binarization processing on the original image to obtain a high-resolution image;
[0033] Perform downsampling on the high-resolution image to obtain a target image.
[0034] In the above technical solution, the high-resolution image can retain more details, which is helpful for subsequent image processing and analysis. The downsampling technique can effectively reduce the computational amount while ensuring that the image quality will not be significantly reduced. The target image suitable for processing is obtained through downsampling to ensure the efficient and accurate operation of the algorithm.
[0035] In a possible implementation manner, the determining the parameters of the workpiece pole column according to the parameters of the target template circle with the highest matching score among the multiple matching scores includes:
[0036] According to the first template circle with the highest matching score, determine the center position and radius of the fitted circle;
[0037] Obtain the center region corresponding to the center position of the fitted circle in the high-resolution image;
[0038] Traverse each second template circle in the second template circle set, and calculate the matching score of the second template circle according to whether the pixel value of the target pixel point located on the second template circle in the high-resolution image is the preset value, to obtain multiple second matching scores corresponding to the multiple second template circles in the second template circle set. The radius of the second template circle is the ratio of the radius of the fitted circle to the sampling ratio of the upsampling, and the centers of the multiple second template circles in the second template circle set traverse all pixel points in the center region;
[0039] Determine the parameters of the second target template circle with the highest score among the multiple second matching scores as the parameters of the workpiece pole post.
[0040] In the above technical solution, by selecting the template circle with the highest matching score for further analysis, the accuracy of the final positioning result is ensured, more accurate fitting circle parameters are obtained in the high-resolution image, and thus the positioning accuracy of the workpiece pole post is improved. This method can flexibly cope with different image qualities and pole post shapes, enhancing the applicability of the algorithm.
[0041] An embodiment of the present application discloses a positioning device for a workpiece pole post, including:
[0042] An image acquisition module, configured to acquire an original image and perform binarization processing on the original image to obtain a target image;
[0043] A score calculation module, configured to traverse each first template circle in the first template circle set, calculate the matching score of the first template circle according to whether the pixel value of the target pixel point located on the first template circle in the target image is a preset value, and obtain a plurality of first matching scores corresponding to the plurality of first template circles in the first template circle set. The more pixel points with the pixel value being the preset value, the higher the matching score. The radius of each first template circle is less than or equal to a preset maximum radius and greater than or equal to a preset minimum radius;
[0044] A pole post positioning module, configured to determine the parameters of the workpiece pole post according to the parameters of the first template circle with the highest score among the plurality of first matching scores, where the parameters include the center position and the radius.
[0045] An embodiment of the present application discloses an electronic device, including a memory and a processor, where the memory is used to store code instructions; the processor is used to run the code instructions to implement the method as described above.
[0046] An embodiment of the present application discloses a computer-readable storage medium, used to store a computer program, where the computer program includes instructions for implementing the method as described above.
[0047] Compared with the method of using the Hough transform to find a complete circle in an image in the related art, the method provided by the embodiment of the present application can accurately locate the pole post circle when the circle in the image is blocked or only part of the circular arc is exposed in the image, realizing the rapid positioning of the pole post circle and improving the accuracy and quality of the bar chip welding. Description of the Drawings
[0048] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required in the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0049] Figure 1 Schematic diagram of an application scenario of a workpiece positioning method provided by an embodiment of the present application;
[0050] Figure 2 Schematic flowchart of a method for positioning a workpiece pole column provided by an embodiment of the present application;
[0051] Figure 3 Schematic flowchart of a method for positioning a workpiece pole column by constructing a template circle provided by an embodiment of the present application;
[0052] Figure 4 Schematic flowchart of another method for positioning a workpiece pole column by constructing a template circle provided by an embodiment of the present application;
[0053] Figure 5 Schematic diagram of constructing a first template circle provided by an embodiment of the present application;
[0054] Figure 6 Schematic diagram of the matching between the first template circle and the pole column circle provided by an embodiment of the present application;
[0055] Figure 7 Schematic diagram of the matching between the second template circle and the pole column circle provided by an embodiment of the present application;
[0056] Figure 8 Schematic block diagram of a device provided by an embodiment of the present application;
[0057] Figure 9 Schematic block diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0058] The following will describe the technical solutions in the present application in conjunction with the accompanying drawings.
[0059] To facilitate a clear description of the technical solutions in the embodiments of the present application, in the embodiments of the present application, terms such as "first" and "second" are used to distinguish the same items or similar items with basically the same functions and effects. For example, the first instruction and the second instruction are used to distinguish different user instructions, and the order between them is not limited. Those skilled in the art can understand that the terms "first" and "second" do not limit the quantity and execution order, and the terms "first" and "second" do not necessarily mean different.
[0060] It should be noted that in this application, words such as "exemplarily" or "for example" are used to give examples, illustrations or explanations. Any embodiment or design solution described as "exemplarily" or "for example" in this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplarily" or "for example" is intended to present relevant concepts in a specific manner.
[0061] In addition, "at least one" means one or more, and "a plurality" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (item)" or its similar expression refers to any combination of these items, including any combination of single item (s) or plural items (s). For example, at least one (item) of a, b, and c can represent: a, or b, or c, or a and b, or a and c, or b and c, or a, b, and c, where a, b, and c can be single or multiple.
[0062] In addition, the terms "comprising" and "having" and any variations thereof in the embodiments and drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.
[0063] A single battery usually cannot provide sufficient power or electrical energy, especially in applications that require high energy output (such as electric vehicles, energy storage systems). Different applications have different voltage requirements, so multiple batteries are often connected in series or in parallel to form a battery module, which is widely used in fields such as electric vehicles, energy storage systems, and portable devices. The battery terminals of multiple batteries are often welded together through bus bars, thereby achieving the series or parallel connection of multiple batteries. There are multiple through holes on the bus bar for positioning and fixing the battery terminals.
[0064] During the bus bar welding of battery terminals in actual industrial production, the bus bar often blocks a part of the terminal, and the other part of the terminal is exposed through the through holes on the bus bar. Therefore, it is necessary to position the battery terminals. Positioning can ensure the accurate docking of the terminals and the bus bar, avoiding poor welding or poor contact caused by deviation, thereby affecting the battery performance. During the bus bar welding process of the battery module, the machine first adjusts the industrial camera lens above the terminal and adjusts it to the best clear state, takes an image of the terminal, and positions the terminal according to the image.
[0065] In related technologies, the method of using the Hough transform to find circles is often adopted for circle recognition in images. The basic idea of the Hough transform is to transform each edge point in the image space into the parameter space, where voting is carried out to determine the existence of circles. First, an edge detection algorithm (such as Canny edge detection) is used to extract the edges of the figure from the input image. Then, for each edge point, the possible radii are traversed, and the corresponding center of the circle is calculated. For each pair of the center of the circle and the radius, voting is carried out in a three-dimensional parameter space to increase the corresponding count value. An accumulator array is created to store the voting results, and the dimension of the array is (center of the circle, radius). Each edge point of the edge image is traversed, the possible center of the circle and the radius are calculated, and an increment operation is performed in the accumulator. The local maximum values are found in the accumulator array, and these maximum values correspond to the parameters of the possible circles in the image. Finally, according to the found center of the circle and the radius, the detected circles are drawn on the original image. The Hough transform circle detection method requires that the circles in the image are complete circles and are greatly affected by the noise in the image. In actual industrial production, the bus bar will block part of the pole column, and the exposed part of the pole column through the through hole on the bus bar is uncertain. There may also be noise and errors in industrial images. The incomplete arc of the pole column in the image may lead to the loss of local features, affecting the voting process of the Hough transform, making it difficult for the algorithm to accumulate enough votes to determine the existence of circles. In an industrial scenario, a positioning algorithm that is robust to noise and occlusion is needed.
[0066] In the embodiments of the present application, by constructing a template circle, the matching arc segments on the template circle are matched with the arc segments exposed by the pole column in the image, and the matching score of each template circle is calculated. According to the template circle with the highest matching score, the center position and radius of the pole column are determined. This method can achieve the rapid positioning of the pole column in industrial production, improving the accuracy and quality of the welding of the pole column and the bus bar.
[0067] To implement the above method, first, the application scenario of the positioning method of the workpiece pole column in the embodiments of the present application is introduced to fully understand how the pole column and the bus bar are welded in industrial production.
[0068] As Figure 1 shown, FIG. 100 is a schematic diagram of an application scenario of a workpiece pole column positioning method provided by the embodiments of the present application. The schematic diagram 100 includes a bus bar 101, an upper cover 102, a through hole 103, a base 104, a pole column 105, and an electric core 106.
[0069] In some possible embodiments, the bus bar 101 is used to connect multiple battery units, transfer current, and ensure the electrical connection of the battery pack. The bus bar 101 is usually a metal strip or sheet, and its surface is treated to improve conductivity. The bus bar 101 is generally made of copper or aluminum due to its good electrical conductivity. The bus bar 101 is connected to the pole column of the battery unit by welding.
[0070] In some possible embodiments, the upper cover 102 is used to protect the battery pack, prevent foreign objects from entering, and at the same time provide structural support. The upper cover 102 is usually made of plastic or metal and needs to have good heat resistance and insulation. The upper cover 102 is connected to the base 104 of the battery module by screws or snaps to ensure tightness.
[0071] In some possible embodiments, the through hole 103 provides a channel for the electrical connection between the tab 101 and the battery terminal 105, enabling the tab 101 to be welded to the terminal 105, thereby achieving effective current transmission and connection.
[0072] In some possible embodiments, the base 104 is used to support the entire battery module and provide a stable installation platform. The base 104 is usually plastic or metal, has good strength and rigidity. The base 104 is fixed to the upper cover by screws or snaps, and the internal components are connected by embedding or fixing methods.
[0073] In some possible embodiments, the terminals 105 are the positive and negative electrodes of the battery, providing external power connection points. The terminals 105 are metal posts protruding outside the battery module, usually with threads to facilitate connection of cables. The material of the terminals 105 is generally copper or aluminum and is nickel-plated to prevent corrosion. The terminals 105 are directly connected to the positive and negative electrodes of the battery cell 106 and are connected to other battery units through tabs.
[0074] In some possible embodiments, the battery cell 106 is used to store and release electrical energy and is the core component of the battery module. The battery cell 106 is composed of electrolyte, positive and negative electrode materials, and a separator, usually cylindrical or square. The electrode materials in the battery cell 106 are usually lithium, cobalt, nickel, etc., and the electrolyte is an organic solvent or a solid material. At the same time, the battery cell 106 is connected to other battery units through terminals and tabs.
[0075] In some possible embodiments, the terminal post 105 must be accurately aligned with the through hole 103 of the bus bar 101 to ensure the welding quality and the stability of the electrical connection. An inaccurate position of the terminal post 105 may result in poor contact, affecting the current conduction. Good positioning helps the solder joints to form uniformly and firmly, thereby reducing welding defects such as solder bridging or cold welding, which will affect the performance and safety of the battery. If the central position of the terminal post 105 is misaligned, it may cause uneven stress during the welding process, which will increase the fatigue risk of the terminal post 105 and the bus bar 101, thus shortening the service life of the battery. At the same time, accurate positioning of the terminal post 105 can improve the efficiency and stability of automated welding, reduce the difficulty of manual operation, and ensure the repeatability and consistency of the production process. Incorrect connection may lead to safety hazards such as short circuit and overheating. Through positioning, these problems can be effectively avoided to ensure the safety of the battery module. In the actual industrial production process, when the terminal post 105 is welded to the bus bar 101, the bus bar 101 often blocks a part of the area of the terminal post 105, and a part of the circular area of the terminal post 105 is exposed through the through hole 103 on the bus bar 101, making it impossible for the machine to accurately identify the entire circular contour of the terminal post 105, which also results in the inability to achieve precise welding between the terminal post 105 and the bus bar 101.
[0076] In the above embodiments, by accurately positioning the through hole of the terminal post and the bus bar, it can be ensured that the two are well aligned during the welding process, reducing poor contact and welding defects (such as solder bridging or cold welding), thereby improving the overall performance and safety of the battery module. Accurate positioning of the terminal post can avoid uneven stress during the welding process, reduce the fatigue risk, reduce the performance degradation caused by poor contact, and extend the service life of the battery. An effective positioning method can improve the efficiency and stability of automated welding, reduce the complexity of manual operation, ensure the consistency and repeatability of the production process, and thus improve the overall production efficiency. By ensuring correct connection and welding, safety hazards such as short circuit and overheating can be effectively avoided, ensuring the safety and reliability of the battery module. In actual industrial production, an optimized positioning method can reduce the dependence on the machine recognition accuracy, reduce production problems caused by recognition errors, and thus simplify the production process. Next, a positioning method for the workpiece terminal post will be further introduced.
[0077] As Figure 2 shown, FIG. 200 is a schematic flowchart of a positioning method for a workpiece terminal post provided by an embodiment of the present application. The flowchart includes the following steps:
[0078] S201, obtain an original image and perform binarization processing on the original image to obtain a target image. The original image includes a bus bar for a welding workpiece and a part of the circular area of the workpiece terminal post, and a part of the circular area of the workpiece terminal post is exposed through the through hole in the bus bar.
[0079] In some possible embodiments, an industrial camera is installed at an appropriate position to ensure clear capture of the image of the terminal post. The shooting angle and distance are optimized according to the position and size of the terminal post to avoid distortion or perspective deviation. Usually, the camera is fixed on the welding equipment or bracket to ensure stable shooting; the shooting process is usually synchronized with the automation system of the production line so that the camera is triggered to shoot when the terminal post enters the welding position. The triggering method can be sensor detection (such as an optoelectronic sensor detecting the position of the terminal post), or directly triggered by the signal of the control system. To ensure clear images, the industrial camera is usually equipped with a suitable light source. Commonly used light sources include LED ring lights, backlights, etc., aiming to eliminate reflection, shadows or ambient light interference, making the terminal post have an obvious contrast with the surrounding structure, facilitating subsequent image processing. The lens of the camera needs to be precisely focused to ensure the clarity of the terminal post in the captured image. At the same time, image enhancement techniques such as autofocus and exposure adjustment can also be used to capture the details of the terminal post.
[0080] In some possible embodiments, the image of the terminal post position captured by the industrial camera is usually in color. At this time, the color image needs to be binarized to eliminate environmental errors. Adaptive binarization can effectively separate the terminal post in the image from the background, making the edges and contours of the terminal post more obvious, facilitating subsequent feature extraction and recognition; compared with global binarization, adaptive binarization can dynamically adjust the threshold according to the local illumination conditions, thus better dealing with the influence brought by uneven illumination or complex background; by converting the image into a binary image, adaptive binarization can effectively remove some small noise points, making the main features of the terminal post more prominent and improving the accuracy of subsequent processing; the binary image usually contains less information and the data volume is reduced, thus simplifying subsequent image analysis and processing steps, such as shape recognition and position detection; compared with processing grayscale images, processing binary images has less computational complexity, which can speed up the speed of real-time image processing and analysis and is suitable for fast detection in industrial applications.
[0081] In some possible embodiments, after the industrial camera captures the original color image of the terminal post, first, an image processing software or library is used to read the original image file. The original image is usually in color and contains three color channels: red, green, and blue. Color images usually use the RGB (red, green, blue) color model. Grayscale images only contain luminance information and no longer have color components. During the conversion process, the RGB values of each pixel are converted into a luminance value. The commonly used conversion formula is:
[0082] Gray value = 0.2989 × R + 0.5870 × G + 0.1140 × B; (1) This formula is derived based on the sensitivity of the human eye to different colors. The weight of green light is the highest, followed by red light, and the weight of blue light is the lowest. Use formula (1) to calculate the gray value of each pixel in the original image and generate a new image with this value. In the new image, the gray value ranges from 0 to 255, where 0 represents black and 255 represents white. After the conversion is completed, you can choose to save this grayscale image or directly display it for subsequent processing. Apply smoothing processing to the grayscale image, such as using Gaussian blur. The blur operation can reduce the noise in the image, making the subsequent binarization effect more obvious and reducing misjudgments caused by noise. Use an adaptive threshold algorithm to binarize the processed image. This algorithm dynamically calculates the threshold based on the local area of the image, so it can effectively handle the situation of uneven illumination. During this process, compare the brightness of each pixel in the image with the brightness of its surrounding pixels to generate a black-and-white binary image, where black represents the area below the threshold (pole post) and white represents the area above the threshold (background). To further optimize the binary image, morphological operations such as erosion and dilation can be performed. These operations can remove small noise points and fill small holes in the pole post, thereby enhancing the contour of the pole post. Finally, display the binarized image or save it as a file for subsequent analysis. The original image is binarized to obtain a target image, and the target image includes the through-hole circle on the wafer and a part of the arc of the pole post exposed through the through-hole.
[0083] S202, traverse each first template circle in the first template circle set, and calculate the matching score of the first template circle according to whether the pixel value of the target pixel point located on the first template circle in the target image is a preset value, so as to obtain a plurality of first matching scores corresponding to the plurality of first template circles in the first template circle set.
[0084] In some possible embodiments, the first set of template circles includes at least one group of first template circles. The radii of each group of first template circles are the same, but the positions of the centers are different. The centers of the multiple template circles included in each group of template circles are located at different pixels in the target image, so that the multiple template circles in each group of template circles traverse the target image. The radius of each group of first template circles is less than or equal to a preset maximum radius and greater than or equal to a preset minimum radius, that is, the radii of different groups of first template circles vary between the preset maximum radius and the preset minimum radius. The preset maximum radius and minimum radius can be set by those skilled in the art according to the actual usage. As an example, the maximum radius and minimum radius can be set according to the radius of the terminal post. For example, if it is known that the radius of the terminal post is between 5 - 6 cm, the maximum radius can be set to 6 cm or 7 cm, and the minimum radius can be set to 5 cm or 4 cm, etc., so that the operation rate can be increased. Of course, those skilled in the art can also use other methods to set the maximum radius and minimum radius, which is not limited herein.
[0085] For each first template circle, it is necessary to calculate the matching score of the first template circle according to the pixel value of the target pixel points on the target image located on the first template circle and a preset value. For example, whether the pixel value of the pixel points on the target image located on the first template circle is the preset value is used to determine whether the pixel points score. If the pixel value of the pixel points is the preset value, it can score; if the pixel value of the pixel points is not the preset value, it does not score, and then the scores of all the pixel points are counted to obtain the matching score of the first template circle. The preset value can also be pre-set. For example, the preset value can be the gray value 0 of black or a value whose difference from the gray value of black is less than or equal to a threshold value. The threshold value can be 2, so the preset value can be any value between 0 - 2; or, the preset value can also be the gray value 255 of white, or a value whose difference from the gray value of white is less than or equal to the threshold value, which is not limited herein.
[0086] In addition, the target pixel points used to calculate the matching score can be all the pixel points on the target image located on the first template circle, or can be some pixel points on the target image located in the first template circle, which is not limited herein.
[0087] As an example, the target pixel points are each pixel point located on the matching arc segment of the first template circle, and the matching arc segment is determined according to the occlusion rate of the first template circle occluded by the through hole. It can be understood that since it is necessary to find a template circle that matches the workpiece pole in the embodiments of the present application, then, in the case where the workpiece pole is partially occluded by the through hole, the template circle that matches the workpiece pole should also be partially occluded, so that a partial arc segment that may be exposed after being occluded by the through hole on the template circle can be determined, and then only the pixel points located on this partial arc segment on the target image are calculated, thereby further reducing the amount of calculation and improving the calculation efficiency.
[0088] Specifically, since the contour of the through hole circle in the target image is clear and complete, the center position and radius of the through hole circle can be directly determined by the circle finding method using the Hough transform. Calculate the center distance between the target template circle and the through hole circle according to the center position of the target template circle and the running position of the through hole circle. Calculate the occlusion rate of the target template circle occluded by the through hole circle according to the center distance, the center position of the target template circle, and the center position of the through hole circle, and then judge the occlusion rate range where the occlusion rate of the target template circle is located. There is a mapping relationship between the occlusion rate of the template circle and the central angle range. Determine the central angle range of the target template circle according to the occlusion rate of the target template circle and this mapping relationship. This central angle range is used to determine which arc segment of the template circle is selected as the target matching arc segment. Then, for each first template circle in the first template circle set, calculate the matching score of the target template circle according to whether the pixel value of the pixel points on the matching arc segment of the first template circle is a preset value, and obtain a plurality of matching scores.
[0089] If the first template circle set includes multiple groups of first template circles, each group of first template circles in the first template circle set can be traversed in sequence according to the group, so as to obtain the matching score corresponding to each first template circle in the first template circle set.
[0090] S203. Determine the parameters of the workpiece pole according to the parameters of the first target template circle with the highest score among the multiple first matching scores.
[0091] In the embodiments of the present application, the parameters of the first target template circle and the parameters of the workpiece pole may include the center position and the radius. That is to say, the center position of the workpiece pole can be determined according to the center position of the first target template circle, and the radius of the workpiece pole can be determined according to the radius of the first target template circle.
[0092] In some possible embodiments, each first template circle in the first template circle set can be sorted according to its matching score, and the first target template circle with the highest matching score is taken as the pole post circle. Then, the center position of the first target template circle with the highest matching score is the center position of the pole post circle, and the radius of the first target template circle with the highest matching score is the radius of the pole post circle.
[0093] In the above embodiment, by obtaining the original image and performing binarization processing, the contour and features of the pole post can be effectively extracted, enhancing the accuracy of subsequent feature extraction and recognition. The adaptive binarization method can dynamically adjust the threshold, process uneven illumination or complex backgrounds, reduce the influence of noise, and thus improve the reliability of image analysis. Next, further introduce how to locate the workpiece pole post by constructing template circles.
[0094] As Figure 3 shown, FIG. 300 is a schematic flowchart of a method for locating a workpiece pole post by constructing template circles provided by an embodiment of the present application. The flowchart includes the following steps:
[0095] S301, obtain the original image and perform binarization processing on the original image to obtain a target image.
[0096] Step S301 is similar to step S201 and will not be described in detail here.
[0097] S302, traverse the un-traversed pixels in the target image as the center of the circle, and determine the radius of the first template circle according to the number of groups of the first template circles to construct the first template circle.
[0098] In some possible embodiments, if the template circle to be constructed is the first group of template circles, the radius of the template circle takes the preset maximum radius. To avoid the first template circle matching successfully with the through-hole circle when performing the matching between the first template circle and the target image later, the preset maximum radius should be less than the radius of the through-hole circle. If the template circle to be constructed is not the first group of template circles, the radius of the first template circle = maximum radius - search step × the number of groups of the current template circle, and the search step is a preset value used to indicate the amplitude of the change of the radius of the first template circle each time. The radii of the first template circles belonging to the same group of template circles are the same.
[0099] In some possible embodiments, if the first template circle to be constructed is the first one among the group of first template circles, the center of the first template circle can be the first pixel point in the upper left corner, or the first pixel point in the lower left corner, or the first pixel point in the upper right corner, or the first pixel point in the lower right corner of the target image, or any pixel point randomly selected from the target image. If the first template circle to be constructed is not the first one among the group of first template circles, move the sliding step length in any direction (where there are unvisited pixel points) from the center of the previous first template circle. If the pixel point obtained after the movement is a visited point, continue to move the sliding step length in any direction (where there are unvisited pixel points); if the pixel point obtained after the movement is an unvisited point, take this point as the center of the first template circle.
[0100] S303. Calculate the center distance between the first template circle and the through hole according to the center of the first template circle and the center of the through hole.
[0101] In some possible embodiments, denote the center of the first template circle as (x1, y1) and the center of the through hole as (x2, y2), then the center distance d is:
[0102]
[0103] S304. Calculate the occlusion rate according to the center distance, the radius of the first template circle, and the radius of the through hole.
[0104] In some possible embodiments, denote the radius of the first template circle as r and the radius of the through hole circle as R, then the occlusion rate is:
[0105]
[0106] Where the occlusion rate can be negative. When the occlusion rate is greater than or equal to 1, the first template circle is completely exposed in the through hole; when the occlusion rate is less than or equal to -1, the first template circle is completely blocked by the through hole.
[0107] S305. Calculate the included angle between the centers of the first template circle and the through hole according to the center of the first template circle and the center of the through hole.
[0108] In some possible embodiments, the included angle α between the centers of the first template circle and the through hole circle is calculated by the following formula:
[0109]
[0110] S306. Determine the matching arc segment on the first template circle according to the occlusion rate and the mapping relationship between the preset occlusion rate range and the central angle range.
[0111] In some possible embodiments, the mapping relationship between the occlusion rate range and the central angle range is shown in Table 1.
[0112] Table 1
[0113] Occlusion rate range Central angle range (0.7,+∞] [0,2π] (0.2,0.7] [α-2π / 3,4π / 3] (-∞,0.2] [α-π / 2,π]
[0114] Determine the range where the occlusion rate of the first template circle is located. According to the range where the occlusion rate of the first template circle is located, determine the selected central angle range, and match the arc segment, that is, the arc segment on the first template circle corresponding to the selected central angle range.
[0115] S307, Traverse the un-traversed pixels on the matched arc segment as target pixel points.
[0116] In some possible embodiments, the matched arc segment of the first template circle corresponds to several pixel points in the target image. Select one of the pixels that has not been selected and is used to calculate the score of the first template circle as the template pixel point.
[0117] S308, Offset the target pixel point by a preset distance to obtain a target adjacent point.
[0118] In some possible embodiments, select the pixel point obtained by moving the target pixel point in any direction by a preset distance as the target adjacent point, where the preset distance is a very small value. Exemplarily, the preset distance can be 1, that is, moving the target pixel point in any direction by a distance of one pixel can obtain the target adjacent point.
[0119] S309, Whether the pixel value of the target pixel point is the first pixel value and the pixel value of the target adjacent point is the second pixel value.
[0120] In some possible embodiments, the difference between the second pixel value and the first pixel value is greater than or equal to the pixel threshold, and this pixel threshold can be the difference between the grayscale value of white and the grayscale value of black. After obtaining the pixel values of the target pixel point and the target adjacent point, judge whether the pixel value of the target pixel point is 0 and the pixel value of the target adjacent point is 255. In the case where the pixel value of the target pixel point is 0 and the pixel value of the target adjacent point is 255, the score of the first template circle corresponding to this matched arc segment is incremented by 1; in the case where the pixel value of the target pixel point is not 0 or the pixel value of the target adjacent point is not 255, the score of the first template circle corresponding to this matched arc segment remains unchanged.
[0121] S310, Increment the score of the first template circle by 1.
[0122] In some possible embodiments, when the pixel value of the target pixel point is 0 and the pixel value of the target adjacent point is 255, that is, the target pixel point is black and the pixel point obtained after the target pixel point moves a short distance is white, it indicates that the target pixel point falls within the exposed arc segment of the terminal post. At this time, the score of the first template circle corresponding to the target pixel point should be incremented by 1 to indicate an improvement in the matching degree between the first template circle and the terminal post.
[0123] S311, the score of the first template circle remains unchanged.
[0124] In some possible embodiments, when the pixel value of the target pixel point is not 0 or the pixel value of the target adjacent point is not 255, that is, the template pixel point is white and the target adjacent point is white, or, the target pixel point is white and the target adjacent point is black, or, the template pixel point is black and the target adjacent point is black. When the template pixel point is white and the target adjacent point is white, the target pixel point falls within the background area; when the target pixel point is white and the target adjacent point is black, the target pixel point is adjacent to the exposed arc segment of the terminal post circle or the circumference of the through-hole circle or the target pixel point is adjacent to the black background area; when the template pixel point is black and the target adjacent point is black, the target pixel point falls within the black background area rather than the exposed arc segment of the terminal post circle. In these three cases, the matching between the target pixel point and the exposed arc segment of the terminal post circle fails, and the score of the first template circle corresponding to the target pixel point remains unchanged.
[0125] S312, check whether there are un-traversed pixel points on the matching arc segment.
[0126] After determining whether one of the pixel points on the matching arc segment of the first template circle matches successfully with the exposed arc segment of the terminal post circle, select the un-traversed pixel points on the matching arc segment of the first template circle as the target pixel points to match with the exposed arc segment of the terminal post circle again. If all the pixel points on the matching arc segment of the first template circle have completed the matching with the exposed arc segment of the terminal post circle, calculate the matching score of the first template circle.
[0127] S313, calculate the matching score of the first template circle.
[0128] In some possible embodiments, the matching score of the first template circle is equal to the ratio of the total score of the first template circle to the total number of pixel points on the matching arc segment of the first template circle.
[0129] S314, check whether there are unconstructed template circles.
[0130] In some possible embodiments, after the previous set of template circles is constructed, calculate whether the difference between the radius of the previous set of template circles and the search step is less than a preset minimum radius. If the difference between the radius of the previous set of template circles and the search step is less than the preset minimum radius, stop constructing the exposed arc segments of the template circles and the pole column circles from being matched, and then obtain the pole column circle according to the matching scores of the constructed template circles. If the difference between the radius of the previous set of template circles and the search step is greater than or equal to the preset minimum radius, use the difference between the radius of the previous set of template circles and the search step as the radius of the current set of template circles, and continue to traverse the pixel points in the target image as the centers to construct the first template circle. If the previous set of template circles is not constructed completely, continue to use the radius of the previous set of template circles as the radius of the current first template circle, and move the center of the previous template circle by a sliding step in any direction (where there are untraversed pixel points) to obtain the center of the currently constructed first template circle.
[0131] S315, Take the first target template circle with the highest matching score as the pole column circle.
[0132] In some possible embodiments, if all the constructed first template circles are completely matched with the exposed arc segments of the pole column circle, finally take the first target template circle with the highest matching score as the pole column circle.
[0133] In the above embodiments, traversing the first template circle set for matching helps to accurately locate the center position and radius of the pole column according to the mapping relationship between the occlusion rate and the central angle, improving the positioning accuracy. By defining multiple template circles and combining the calculation of the occlusion rate, the matching score can be effectively improved, facilitating the quick finding of the optimal match and simplifying the subsequent processing. Next, a second template circle is introduced on the basis of the first template circle for secondary matching.
[0134] As Figure 4 shown, FIG. 400 is a schematic flowchart of another method for positioning the workpiece pole column by constructing template circles provided by the embodiments of the present application. The flowchart includes the following steps:
[0135] S401, Obtain the original image and perform binarization processing on the original image to obtain a high-resolution image.
[0136] Step S401 is similar to step S201 and will not be elaborated here.
[0137] S402, Perform downsampling on the high-resolution image to obtain a target image.
[0138] In some possible embodiments, first, determine the resolution reduction ratio by which the image is desired to be reduced. For example, it can be selected to reduce both the width and height of the image by half, or set other ratios according to specific requirements. Algorithms such as nearest neighbor interpolation, bilinear interpolation, and bicubic interpolation can be selected for image sampling. Among them, nearest neighbor interpolation is simple and fast, but may cause jagged edges in the image; bilinear interpolation obtains new pixel values by calculating the weighted average of the neighboring four pixels, with good results; bicubic interpolation uses 16 neighboring pixels for calculation, capable of providing a smoother image effect. Apply the selected downsampling algorithm to the original high-resolution image to generate a new low-resolution image.
[0139] S403, Traverse the un-traversed pixels in the target image as the center of a circle, and determine the radius of the first template circle according to the number of groups of the first template circle, and construct the first template circle.
[0140] S404, Calculate the center distance between the first template circle and the through hole according to the center of the first template circle and the center of the through hole.
[0141] S405, Calculate the occlusion rate according to the center distance, the radius of the first template circle, and the radius of the through hole.
[0142] S406, Calculate the included angle between the first template circle and the through hole according to the center of the first template circle and the center of the through hole.
[0143] S407, Determine the matching arc segment on the first template circle according to the occlusion rate and the mapping relationship between the preset occlusion rate range and the central angle range.
[0144] S408, Traverse the un-traversed pixels on the matching arc segment as target pixel points.
[0145] S409, Offset the target pixel point by a preset distance to obtain a target neighboring point.
[0146] S410, Whether the pixel value of the target pixel point is the first pixel value and the pixel value of the target neighboring point is the second pixel value.
[0147] S411, Increment the score of the first template circle by 1.
[0148] S412, Keep the score of the first template circle unchanged.
[0149] S413, Whether there are un-traversed pixel points on the matching arc segment.
[0150] S414, Calculate the matching score of the first template circle.
[0151] S415, Whether there is an unconstructed template circle.
[0152] S416, Take the first target template circle with the highest matching score as the fitting circle.
[0153] Steps S403 - S416 are similar to steps S302 - S315, and will not be elaborated here.
[0154] S417. Obtain the center region corresponding to the center position of the fitted circle in the high - resolution image.
[0155] In some possible embodiments, according to the sampling ratio, the center of the fitted circle of the target image with lower resolution corresponds to a center region in the high - resolution image, which includes multiple pixel points.
[0156] S418. Traverse the un - traversed pixels in the center region of the high - resolution image as the center, determine the radius of the second template circle according to the ratio of the radius of the fitted circle to the sampling ratio of down - sampling, and construct the second template circle.
[0157] In some possible embodiments, the radius of the constructed second template circle is the ratio of the radius of the fitted circle to the sampling ratio of down - sampling. If the second template circle to be constructed is the first second template circle, the center of this second template circle can be the first pixel point in the upper - left corner or the first pixel point in the lower - left corner or the first pixel point in the upper - right corner or the first pixel point in the lower - right corner of the center region, or any pixel point randomly selected from the target image. If the first template circle is not the first second template circle, move the sliding step length in any direction (where there are un - traversed pixel points) from the center of the previous second template circle. If the pixel point obtained after the movement is a traversed point, continue to move the sliding step length in any direction (where there are un - traversed pixel points); if the pixel point obtained after the movement is an un - traversed point, take this point as the center of the second template circle. The centers of the multiple second template circles in the second template circle set traverse all pixel points in the center region.
[0158] S419. Calculate the matching score of the second template circle.
[0159] Step S419 calculates the matching score of the second template circle in a similar method to steps S303 - S313, and will not be elaborated here.
[0160] S420. Whether there is an un - constructed template circle.
[0161] S421. Take the second target template circle with the highest matching score as the pole column circle.
[0162] Steps S420 - S421 are similar to steps S314 - S315, and will not be elaborated here.
[0163] In the above embodiments, by downsampling the high-resolution image and constructing the template circle, the positioning accuracy can be improved, making the detail processing more refined. The use of the low-resolution image reduces the computational burden and improves the processing speed, which is suitable for rapid detection in industrial applications. Next, how to construct the template circle will be further introduced in combination with specific illustrations.
[0164] As Figure 5 shown, FIG. 500 is a schematic diagram of constructing a first template circle provided by an embodiment of the present application. The schematic diagram 500 includes a target image 501, a first center trajectory 502, a first group of first template circles 503, a second group of first template circles 504, and a second center trajectory 505.
[0165] In some possible embodiments, assume that the preset maximum radius is 2, the preset minimum radius is 1, the search step is 0.7, and the pixels of the target image 501 are 8×8. When constructing the template circle, the radius of the first group of first template circles 503 takes the maximum radius 2, and its center traverses the entire target image 501 according to the first center trajectory 502. Finally, the first group of first template circles 503 obtained contains 64 first template circles with a radius of 2. Since 2 - 0.7 = 1.3 > 1, the second group of first template circles 504 is continued to be constructed. The radius of the second group of first template circles 504 is 1.3, and its center traverses the entire target image 501 according to the second center trajectory 505. Finally, the second group of first template circles obtained contains 64 first template circles with a radius of 1.3. Since 1.3 - 0.7 = 0.6 < 1, the construction of the first template circle is stopped at this time. There are 128 first template circles in the first template circle set. The 128 first template circles are respectively matched with the exposed arc segment of the pole column circle to calculate their matching scores, and the first template circle with the highest matching score is taken as the fitting circle.
[0166] In the above embodiments, the relationship between the target image and the construction of the template circle is shown through a schematic diagram, making the development and optimization process more visible and facilitating understanding and analysis. Displaying the center trajectory and the traversal path of the template circle helps to clarify the matching logic and optimize the selection strategy of the template circle. Next, how the first template circle matches the pole column circle will be further introduced.
[0167] As Figure 6 shown, FIG. 600 is a schematic diagram of the matching between the first template circle and the pole column circle provided by an embodiment of the present application. The schematic diagram 600 includes a first template circle 601, a matching arc 602, a through hole 603, a pole column arc 604, and a matching point 605.
[0168] In some possible embodiments, for a certain first template circle 601 in the first template circle set, calculate the center distance between the center of the first template circle 601 and the center of the through hole 603. Calculate the occlusion rate of the first template circle 601 based on the center distance, the radius of the first template circle 601, and the radius of the through hole 603. Then, combined with Table 1, the matching arc 602 of the first template circle 601 can be obtained. Match the matching arc 602 with the pole arc 604. There is a matching point 605. The pixel value at the matching point 605 is 0, and the pixel value at a distance of 1 to the right of the matching point is 255. Then, the score of the first template circle 601 is incremented by 1. The total number of pixel points passed by the matching arc is 6. Then, the matching score of the first template circle 601 is 1 / 6 = 0.167.
[0169] In the above embodiments, the relationship between the matching point and the arc segment is clearly shown through the schematic diagram, making the calculation of the matching score more transparent, facilitating the evaluation of the positioning effect, quantifying the matching scores of each template circle, being able to quickly identify the optimal match, and improving the efficiency of recognition and positioning. Next, the construction of the second template circle and how the second template circle matches the pole circle will be introduced in combination with the drawings.
[0170] As Figure 7 shown, it is a schematic diagram 700 of the matching between the second template circle and the pole circle provided by the embodiment of the present application. The schematic diagram 700 includes a fitted circle 701, a fitted center 702, a target image 703, a center region 704, and a high-resolution image 705.
[0171] In some possible embodiments, the fitted circle 701 is the first target template circle with the highest matching score in the first template circle set. The fitted center 702 of the target image 703 corresponds to the center region 704 in the high-resolution image 705. The center region 704 includes 4 pixel points. The pixel points of the target image 703 are 8×8, and the pixel points of the high-resolution image 705 are 16×16. Then, the downsampling rate from the high-resolution image 705 to the target image 703 is 0.5. Then, the number of pixel points included in the center region 704 corresponding to the fitted center 702 in the target image 703 in the high-resolution image 705 is the reciprocal of the square of the sampling rate. Divide the radius of the fitted circle 701 in the target image 703 by the sampling rate to obtain the radius of the actual pole circle in the high-resolution image 705. Using the quotient of the radius of the fitted circle 701 in the target image 703 and the sampling rate as the radius, traverse any pixel point in the center region 704 as the center to construct the second template circle, and continue to calculate the matching score between the second template circle and the arc segment exposed by the pole in the high-resolution image 705. Take the second target template circle with the highest matching score as the pole circle.
[0172] In the above embodiments, by constructing a second template circle in the high-resolution image, the positioning accuracy of the pole post is further improved, ensuring accurate recognition even in complex environments. The phased matching strategy effectively combines the advantages of low-resolution and high-resolution images, enhancing the flexibility and accuracy of the overall detection.
[0173] To implement the positioning method of the workpiece pole post as described above in an electronic device, some functional modules are essential. The following description of the device embodiments is similar to that of the above method embodiments and has similar beneficial effects. For the technical details not disclosed in the device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0174] As Figure 8 shown, it is a schematic block diagram of a device 800 provided by an embodiment of the present application. The device 800 may include an image acquisition module 810, a score calculation module 820, and a pole post positioning module 830.
[0175] The image acquisition module 810 is configured to acquire an original image and perform binarization processing on the original image to obtain a target image.
[0176] In some possible embodiments, the image acquisition module 810 may also perform downsampling on the high-resolution image after binarization processing to reduce the resolution of the image.
[0177] The score calculation module 820 traverses each first template circle in the first template circle set, and calculates the matching score of the first template circle according to whether the pixel value of the target pixel points located on the first template circle in the target image is a preset value, obtaining a plurality of first matching scores corresponding to the plurality of first template circles in the first template circle set. The more pixel points with the pixel value being the preset value, the higher the matching score. The radius of each first template circle is less than or equal to a preset maximum radius and greater than or equal to a preset minimum radius.
[0178] In some possible embodiments, the score calculation module 820 may also calculate the center distance and the included angle between the centers of the first template circle and the through hole.
[0179] In some possible embodiments, the score calculation module 820 may also traverse the second template circles in the second template circle set. For each second template circle in the second template circle set, according to the occlusion rate of the second template circle blocked by the through hole and the preset mapping relationship between the occlusion rate and the central angle, determine the matching arc segment on the corresponding second template circle. And the score calculation module 820 may also be configured to calculate the matching score of the first template circle according to whether the pixel value of the pixel points on the matching arc segment of the first template circle is a preset value, obtaining a plurality of matching scores.
[0180] In some possible embodiments, the score calculation module 820 may also traverse the pixel points on the first template circle or the second template circle, obtain the pixel values of the pixel points, and obtain the pixel values of the pixel points after offsetting a preset distance.
[0181] In some possible embodiments, the score calculation module 820 calculates the first matching score of the first template circle corresponding to the matching arc segment or the second matching score of the second template circle according to the pixel values of the pixel points on the matching arc segment and the pixel values of the offset points of the corresponding pixel points.
[0182] The pole positioning module 830 is configured to determine the parameters of the workpiece pole according to the parameters of the first target template circle with the highest score among multiple first matching scores, and the parameters are, for example, the center position and radius.
[0183] In some possible embodiments, the pole positioning module 830 may also determine the center position and radius of the fitting circle according to the first template circle with the highest score among multiple matching scores, then determine the center area and radius corresponding to the fitting circle in the high-resolution image, construct the second template circle according to the center area, and calculate the second matching scores of multiple second template circles respectively. The center position and radius of the pole circle are determined according to the second target template circle with the highest matching score among multiple matching scores.
[0184] The above-mentioned various functional modules cooperate with each other to improve the positioning efficiency of the workpiece pole. Finally, the composition of the electronic device is introduced.
[0185] As Figure 9 shown, it is a schematic block diagram of an electronic device 900 provided by an embodiment of the present application. The control electronic device 900 may include a processor 910, a memory 920, a bus 930, and a device interface 940.
[0186] Among them, the processor 910 calls the executable program code stored in the memory 920 and executes any one of the workpiece pole positioning methods disclosed in the embodiments of the present application.
[0187] The memory 920 stores executable program code, and the execution of the executable code by the processor 910 can implement any one of the workpiece pole positioning methods disclosed in the embodiments of the present application.
[0188] The bus 930 is used to transfer the program code data stored in the memory 920 to the processor 910 for execution.
[0189] The device interface 940 is connected to the bus 930 and is used to realize the connection between the processor 910 and the memory 920 and other devices.
[0190] Optionally, the memory 920 may include a read-only memory and a random access memory, and provide instructions and data to the processor 910. A part of the memory 920 may also include a non-volatile random access memory. For example, the memory 920 may also store information about the device type. The processor 910 may be used to execute the instructions stored in the memory, and when the processor executes the instructions, the processor 910 may execute each step and / or process corresponding to the terminal device in the foregoing method embodiments.
[0191] It should be understood that in the embodiments of the present application, the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0192] It should be noted that Figure 9 The illustrated electronic device 900 may also include components not shown such as a power supply, which will not be elaborated in this embodiment.
[0193] In the implementation process, each step of the foregoing method may be completed by an integrated logic circuit of the hardware in the processor or an instruction in software form. The steps of the method disclosed in combination with the embodiments of the present application may be directly embodied as being executed and completed by the hardware processor, or executed and completed by a combination of the hardware and software modules in the processor. The software module may be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor executes the instructions in the memory and combines its hardware to complete the steps of the foregoing method. To avoid repetition, it will not be described in detail here.
[0194] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. A professional person may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0195] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above may refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.
[0196] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical, or other forms.
[0197] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0198] In addition, in each embodiment of the present application, each functional unit can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.
[0199] If the above functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the related technology, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.
[0200] The above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, and all should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A positioning method for a workpiece pole column, characterized in that, Applied to an electronic device, the method includes: Obtain an original image and perform binarization processing on the original image to obtain a target image. The original image includes a tab for welding a workpiece and a partial circular area of the workpiece pole post, and the partial circular area of the workpiece pole post is exposed through a through hole in the tab. Traverse each first template circle in the first template circle set, and calculate the matching score of the first template circle according to whether the pixel value of the target pixel point located on the first template circle in the target image is a preset value, to obtain a plurality of first matching scores corresponding to the plurality of first template circles in the first template circle set. The more pixel points with the pixel value being the preset value, the higher the matching score. The radius of each first template circle is less than or equal to a preset maximum radius and greater than or equal to a preset minimum radius. Determine the parameters of the workpiece pole post according to the parameters of the first target template circle with the highest score among the plurality of first matching scores. The parameters include the center position and the radius.
2. The method according to claim 1, characterized in that, The calculating the matching score of the first template circle according to whether the pixel value of the target pixel point located on the first template circle in the target image is a preset value includes: Obtain the pixel value of the target pixel point and the pixel value of the target adjacent pixel point. The target adjacent pixel point is obtained by translating the abscissa and ordinate of the target pixel point by a preset distance respectively. When the pixel value of the target pixel point is the first pixel value and the pixel value of the target adjacent pixel point is the second pixel value, the score of the target template circle is incremented by 1, and the difference between the second pixel value and the first pixel value is greater than or equal to a pixel threshold. Traverse each target pixel point on the first template circle, and calculate the ratio of the score of the first template circle to the total number of pixel points of the target pixel point to obtain the matching score of the first template circle.
3. The method according to claim 1 or 2, characterized in that, The target pixel point is each pixel point located on the first template circle, or the target pixel point is each pixel point located on the matching arc segment of the first template circle. The matching arc segment is determined according to the occlusion rate of the first template circle blocked by the through hole.
4. The method according to claim 3, characterized in that, When the target pixel point is each pixel point located on the matching arc segment of the first template circle, the method further includes: Calculate the occlusion rate of the first template circle blocked by the through hole according to the radius of the first template circle, the center of the first template circle, the radius of the through hole, and the center of the through hole. Determine the matching arc segment on the corresponding first template circle according to the occlusion rate and the mapping relationship between the occlusion rate and the central angle preset.
5. The method according to claim 4, characterized in that, The calculating the occlusion rate of the first template circle blocked by the through hole according to the radius of the first template circle, the center of the first template circle, the radius of the through hole, and the center of the through hole includes: Calculate the center distance between the first template circle and the through hole according to the center of the first template circle and the center of the through hole. Calculate the occlusion rate according to the center distance, the radius of the first template circle, and the radius of the through hole. The occlusion rate is equal to the ratio of the difference between the radius of the through hole and the center distance to the radius of the first template circle.
6. The method according to claim 4, characterized in that, Determining the matching arc segment on the first template circle corresponding to the occlusion rate according to the mapping relationship between the occlusion rate and the central angle range includes: When the occlusion rate is less than or equal to the first threshold, determining the arc segment of the first template circle corresponding to the first central angle to the second central angle as the matching arc segment; When the occlusion rate is greater than the first threshold and less than or equal to the second threshold, determining the arc segment of the first template circle corresponding to the third central angle to the fourth central angle as the matching arc segment; When the occlusion rate is greater than the second threshold, determining the entire circumference of the first template circle as the matching arc segment.
7. The method according to claim 1, wherein Obtaining the original image and performing binarization processing on the original image to obtain a target image includes: Collecting the original image and performing binarization processing on the original image to obtain a high-resolution image; Performing downsampling on the high-resolution image to obtain a target image.
8. The method according to claim 7, characterized in that, Determining the parameters of the workpiece pole according to the parameters of the target template circle with the highest matching score among the multiple matching scores includes: Determining the center position and radius of the fitting circle according to the first template circle with the highest matching score; Obtaining the center region corresponding to the center position of the fitting circle in the high-resolution image; Traversing each second template circle in the second template circle set, and calculating the matching score of the second template circle according to whether the pixel value of the target pixel point located on the second template circle in the high-resolution image is the preset value, to obtain a plurality of second matching scores corresponding to the plurality of second template circles in the second template circle set. The radius of the second template circle is the ratio of the radius of the fitting circle to the sampling ratio of the downsampling, and the centers of the plurality of second template circles in the second template circle set traverse all pixel points in the center region; Determining the parameters of the second target template circle with the highest score among the plurality of second matching scores as the parameters of the workpiece pole.
9. A positioning device for a workpiece terminal post, which is applied to an electronic device, is characterized in that The device includes: An image acquisition module for obtaining an original image and performing binarization processing on the original image to obtain a target image; A score calculation module for traversing each first template circle in the first template circle set, and calculating the matching score of the first template circle according to whether the pixel value of the target pixel point located on the first template circle in the target image is the preset value, to obtain a plurality of first matching scores corresponding to the plurality of first template circles in the first template circle set. The more pixel points with the preset pixel value, the higher the matching score. The radius of each first template circle is less than or equal to the preset maximum radius and greater than or equal to the preset minimum radius; A pole positioning module for determining the parameters of the workpiece pole according to the parameters of the first template circle with the highest score among the plurality of first matching scores, where the parameters include the center position and the radius.
10. An electronic device, characterized in that, Comprising a processor and a memory, the memory being used for storing code instructions; the processor being used for running the code instructions to execute the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, For storing a computer program, the computer program comprising instructions for implementing the method according to any one of claims 1 to 8.