Polarity detection method and sorting system for intelligent instrument components
Through multi-angle light source illumination, image processing and improved YOLOv5 model, the problems of low polarity detection efficiency and poor accuracy of smart instrument components are solved, and efficient and accurate polarity recognition and automated sorting are achieved.
Patent Information
- Application Number
- CN202510328133.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-19
- Publication Date
- 2025-07-18
AI Technical Summary
In the prior art, the polarity detection efficiency of smart instrument components is low and susceptible to human factors, resulting in inaccurate detection results, especially in large-scale production, which is difficult to meet the requirements of high precision and high efficiency.
Multi-angle light source irradiation is used to obtain component images, combine histogram equalization and dynamic exposure compensation processing, extract chromaticity and geometric features, use the improved YOLOv5 model for polarity recognition, and realize automated detection and sorting through the sorting system.
It improves the accuracy of component polarity detection and the efficiency of the sorting system, ensures the factory pass rate of components, and reduces the impact of human error and reflective interference.
Smart Images

Figure CN120339682A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic component detection, and particularly to a method for detecting the polarity of components of an intelligent meter and a sorting system. Background Art
[0002] As an indispensable device in modern industrial, household and commercial environments, intelligent meters are widely used in the metering and management of resources such as electricity, water, and gas. Their core functions rely on the efficient and stable operation of various precision components. These components include, but are not limited to, sensors, integrated circuits, capacitors, resistors, diodes, etc., which undertake key tasks such as signal acquisition, data processing, and communication transmission in intelligent meters. The performance of components directly affects the accuracy, reliability, and service life of intelligent meters. For example, the sensitivity of sensor components determines the accuracy of data acquisition, while the stability of integrated circuits affects the speed and reliability of data processing. Therefore, the correct selection and application of components are key links in the design and manufacture of intelligent meters.
[0003] In intelligent meters, many components have polarity, such as electrolytic capacitors, diodes, transistors, etc. Whether the positive and negative poles of these components are connected correctly is directly related to the normal operation of the circuit. Incorrect polarity connection may cause component damage, circuit function failure, and even safety accidents. Taking an electrolytic capacitor as an example, incorrect connection of its positive and negative poles will cause the internal electrolyte of the capacitor to decompose, generate gas, and ultimately cause the capacitor to expand, leak liquid, or even explode. This not only damages the intelligent meter but also may pose a safety hazard to the use environment. Similarly, incorrect polarity connection of diodes and transistors will cause the circuit to malfunction, affecting the overall performance of the intelligent meter. Therefore, it is of great significance to detect the polarity of components of intelligent meters.
[0004] Currently, the polarity detection of traditional components mainly relies on manual visual inspection and simple test tools. This method is not only inefficient but also easily affected by human factors, resulting in inaccurate detection results. Especially in large-scale production, manual detection is difficult to meet the requirements of high precision and high efficiency. With the development of machine vision technology, there have gradually emerged solutions for detecting the polarity of components through vision detection technology. However, since the surface of components usually reflects light, this reduces the accuracy of image feature extraction, and thus the accuracy of component polarity detection is relatively low. Summary of the Invention
[0005] In view of this, in order to improve the accuracy of polarity detection of components of intelligent meters, it is necessary to propose a method for detecting the polarity of components of intelligent meters and a sorting system for the above deficiencies.
[0006] In a first aspect, the present invention provides a method for detecting the polarity of components of an intelligent meter, including:
[0007] Obtain the component image of the intelligent meter component to be measured under the illumination of multi-angle light sources;
[0008] Perform histogram equalization and dynamic exposure compensation processing on the component image to reduce the reflection interference of the metal shell and obtain a preprocessed component image;
[0009] Extract features from the preprocessed component image based on the chromaticity space to obtain chromaticity features;
[0010] Extract features from the preprocessed component image based on local binary pattern and morphological edge detection to obtain geometric features;
[0011] Input the chromaticity features and the geometric features into a pre-trained classification decision model, and output the final polarity detection result; wherein, the processing logic of the classification decision model is: based on the features after weighted fusion of the chromaticity features and geometric features, output the polarity recognition result of the intelligent meter component to be measured.
[0012] Preferably, the obtaining the component image of the intelligent meter component to be measured under the illumination of multi-angle light sources includes:
[0013] Adopt a ring-shaped LED light source and an oblique infrared light source as the illumination light sources for the intelligent meter component;
[0014] Use a CCD camera equipped with a polarization filter to collect images of the intelligent meter component to be measured.
[0015] Preferably, the performing histogram equalization and dynamic exposure compensation processing on the component image includes:
[0016] Perform grayscale processing on the component image to obtain a grayscale image:
[0017] Initialize a histogram array hist with a length of 256, and traverse each pixel point in the grayscale image, and map and update it in the histogram array hist according to the brightness condition in the grayscale image;
[0018] Calculate the average brightness value of the grayscale image according to the histogram array hist;
[0019] Dynamically adjust the exposure parameters of the grayscale image based on the average brightness value and the PID control algorithm.
[0020] Preferably, the following calculation formula is used to perform grayscale processing on the component image:
[0021] I gray(x, y) = 0.299 * R(x, y) + 0.587 * G(x, y) + 0.114 * B(x, y)
[0022] Wherein, I gray (x, y) is the gray value of the pixel point (x, y), and R(x, y), G(x, y), and B(x, y) are the red, green, and blue channel values of the pixel point (x, y) respectively;
[0023] And / or,
[0024] Calculate the average brightness value using the following calculation formula:
[0025]
[0026] Wherein, I avg is the average brightness value, I hist (k) is the updated gray value corresponding to the pixel point (x i , y i ) in the updated histogram array hist, and N is the number of elements in the histogram array hist;
[0027] And / or,
[0028] Dynamically adjust the exposure parameter of the grayscale image using the following calculation formula:
[0029]
[0030] Wherein, ΔE is the adjustment amount of the exposure parameter, e(t) = I target -I avg is the brightness error, I target is the target brightness value, and K p , K i , K d are PID control parameters.
[0031] Preferably, the feature extraction of the preprocessed component image based on the chromaticity space includes:
[0032] Extract features from the preprocessed component image from three aspects of hue, saturation, and brightness respectively to identify the color information of the intelligent meter components;
[0033] Wherein, the hue is used to characterize the basic attribute of the color, and its value range is from 0° to 360°, or normalized to 0 to 1; the saturation is used to characterize the purity or vividness of the color, and its value range is from 0 to 1, where 0 represents gray scale and 1 represents a fully saturated color; the brightness is used to characterize the brightness of the color, and its value range is from 0 to 1, where 0 represents black and 1 represents the brightest color.
[0034] Preferably, the feature extraction of the preprocessed component image based on local binary pattern and morphological edge detection includes:
[0035] Calculating local binary pattern values based on the preprocessed component image to obtain texture features;
[0036] Detecting the edges of the positions to be detected representing intelligent meter components in the preprocessed component image based on Canny edge detection to obtain edge features;
[0037] Performing contour detection on the preprocessed component image and calculating the area and perimeter of the contour to obtain area features and perimeter features.
[0038] Preferably, the calculating of local binary pattern values based on the preprocessed component image includes:
[0039] For each pixel in the preprocessed component image, take it as the central pixel;
[0040] Determine a neighborhood with a radius of R centered on the central pixel. There are P sampling points in this neighborhood, and obtain the gray values of these neighborhood points;
[0041] For each neighborhood point, compare its gray value with the gray value of the central pixel, and obtain a value of 0 or 1 according to the sign function; where, when the neighborhood gray value is not less than the central pixel gray value, the sign function outputs 1; when the neighborhood gray value is less than the central pixel gray value, the sign function outputs 0;
[0042] Arrange the output 0 / 1 values in order to form a binary sequence;
[0043] Convert the binary sequence to a decimal number to obtain the local binary pattern value of the central pixel;
[0044] And / or,
[0045] The detecting of the edges of the positions to be detected representing intelligent meter components in the preprocessed component image based on Canny edge detection includes:
[0046] Performing Gaussian smoothing on the preprocessed component image based on the Gaussian function to obtain a denoised component image;
[0047] Calculating the gradient magnitude and direction of the denoised component image;
[0048] On the gradient direction, compare the gradient magnitude of the current pixel point with the gradient magnitudes of adjacent pixel points, and set the pixel points whose gradient magnitudes of the current pixel point are not local maxima to 0;
[0049] Set two thresholds \(T_{low}<T_{high}\), mark the pixels with gradient magnitude greater than \(T_{high}\) as strong edges, mark the pixels with gradient magnitude between \(T_{low}\) and \(T_{high}\) as weak edges, and set the pixels with gradient magnitude less than \(T_{low}\) to 0; and form complete edges by connecting weak edges and strong edges to obtain edge features.
[0050] Preferably, the classification decision model uses an improved YOLOv5 model; wherein, the improved YOLOv5 model adds an output layer for detecting small targets to the Head part of the YOLOv5 model to improve the detection ability of small-scale polarity markers; and embeds a CBAM module in the Backbone to enhance the importance of both the channel dimension and the spatial dimension of the feature map simultaneously.
[0051] Preferably, the following loss function is used for the training of the classification decision model:
[0052]
[0053] where \(I\) ou is the intersection over union of the predicted bounding box \(b\) pred and the ground truth bounding box \(b\) gt , with a value range of \([0, 1]\), \(\rho\) is the Euclidean distance between the center points of the predicted bounding box and the ground truth bounding box, \(c\) is the diagonal length of the minimum bounding rectangle of the predicted bounding box and the ground truth bounding box, \(v\) is the similarity measure of the width-to-height ratio of the predicted bounding box and the ground truth bounding box, \(\alpha\) is the weight coefficient used to balance the contribution of \(v\) to the total loss, \(\theta\) is the angular error between the predicted bounding box and the ground truth bounding box, and \(\beta\) is the weight coefficient used to balance the contribution of \(\theta\) to the total loss.
[0054] In a second aspect, the present invention also provides a sorting system for intelligent instrument components, including a support mechanism, a conveyor belt, a camera, a ring light source, a stopping device, a sensor, a component tray, and a control module;
[0055] The conveyor belt is arranged below the support mechanism, the camera and the ring light source are fixed on the support mechanism, and the shooting direction of the camera and the irradiation direction of the ring light source both face the conveyor belt; a sensor and a stopping device are respectively arranged in front of and behind the shooting position of the camera; the control module is electrically connected to the camera, the stopping device, and the sensor respectively;
[0056] The component tray is used to place intelligent instrument components and is placed on the conveyor belt for transportation;
[0057] The sensor is used to collect the position information of the component tray and upload the collected tray position information to the control module;
[0058] The control module is used to determine whether the current tray is in place according to the tray position information, and when it is determined that the tray is in place, control the baffle of the stop device to rise to stop the tray below the camera and the annular light source; and, send an image acquisition instruction to the camera.
[0059] The camera is used to collect images of the components in the component tray and upload them to the control module.
[0060] The control module is further used to judge whether the polarity of the current component is correct based on the polarity detection method of the intelligent meter component as described in any one of the first aspects; when the polarity of the current component is correct, control the baffle of the stop device to lower, so that the component tray continues to convey and detect the next component; when the polarity of the component is incorrect, sort the current component to the designated area.
[0061] As can be seen from the above technical solutions, when detecting the polarity of intelligent meter components in this solution, first obtain the images of the components of the intelligent meter components to be detected under the illumination of multi-angle light sources, and then perform histogram equalization and dynamic exposure compensation processing on the component images to obtain preprocessed component images; further, perform feature extraction on the preprocessed component images based on the chromaticity space to obtain chromaticity features, and at the same time perform feature extraction on the preprocessed component images based on local binary pattern and morphological edge detection to obtain geometric features, and finally output the polarity detection result through the classification decision model. It can be seen that through histogram equalization processing in this solution, the contrast and detail clarity of the image can be improved, and through dynamic exposure compensation processing, the exposure parameters of the image can be dynamically adjusted, thereby eliminating the reflection interference of the metal shell of the component as much as possible. Furthermore, based on the preprocessed component image for feature extraction and polarity recognition, the accuracy of polarity recognition can be greatly improved, and then the accuracy of sorting intelligent meter components can be improved, ensuring the qualified rate of intelligent meter components leaving the factory. In addition, this solution performs feature extraction from different levels such as chromaticity and geometry, and realizes polarity recognition based on the fusion of multi-features, enabling the model to capture more details and semantic information at the same time, thereby further improving the accuracy of component polarity detection. Description of the Drawings
[0062] Figure 1 It is a flowchart of a method for detecting the polarity of intelligent meter components provided by an embodiment of the present invention.
[0063] Figure 2 It is a schematic diagram of a sorting system for intelligent meter components provided by an embodiment of the present invention.
[0064] In the figure: support mechanism 10, conveyor belt 20, camera 30, annular light source 40, stop device 50, sensor 60, component tray 70, control module 80. Specific Embodiments
[0065] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for use in the embodiments. Obviously, the accompanying drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.
[0066] As Figure 1 shown, the present invention provides a method for detecting the polarity of intelligent meter components, and the method may include the following steps:
[0067] Step 101: Obtain a component image of the intelligent meter component to be measured under multi-angle light source illumination;
[0068] Step 102: Perform histogram equalization and dynamic exposure compensation processing on the component image to reduce the reflection interference of the metal shell and obtain a preprocessed component image;
[0069] Step 103: Extract features from the preprocessed component image based on the chromaticity space to obtain chromaticity features;
[0070] Step 104: Extract features from the preprocessed component image based on local binary pattern and morphological edge detection to obtain geometric features;
[0071] Step 105: Input the chromaticity features and geometric features into a pre-trained classification decision model, and output the final polarity detection result; wherein, the processing logic of the classification decision model is: based on the features after weighted fusion of the chromaticity features and geometric features, output the polarity recognition result of the intelligent meter component to be measured.
[0072] In this embodiment, through histogram equalization processing, the contrast and detail clarity of the image can be improved, and through dynamic exposure compensation processing, the exposure parameters of the image can be dynamically adjusted, thereby eliminating the reflection interference of the metal shell of the component as much as possible. Furthermore, based on this preprocessed component image for feature extraction and polarity recognition, the accuracy of polarity recognition can be greatly improved, and then the accuracy of sorting intelligent meter components can be improved, ensuring the qualified rate of intelligent meter components leaving the factory. In addition, this solution extracts features from different levels such as chromaticity and geometry, and realizes polarity recognition based on the fusion of multiple features, enabling the model to capture more details and semantic information at the same time, thereby further improving the accuracy of component polarity detection.
[0073] For step 101, obtain a component image of the intelligent meter component to be measured under multi-angle light source illumination;
[0074] This step aims to obtain high-resolution images of the components of the intelligent meter. Specifically, a CCD camera with 20 million pixels can be used, and a polarization filter is equipped to eliminate the reflection interference as much as possible. At the same time, a multi-angle light source environment is considered for layout. For example, it consists of a ring-shaped LED light source and a 45° oblique infrared light source, with adjustable wavelength support to ensure clear surface features of the components under different lighting conditions.
[0075] For step 102, perform histogram equalization and dynamic exposure compensation on the component image to reduce the reflection interference of the metal shell and obtain a preprocessed component image;
[0076] In this step, it aims to enhance the image contrast and detail clarity through image enhancement and reflection suppression, while eliminating the reflection interference of the metal shell of the component. Specifically, step 102 can be achieved in the following ways:
[0077] First, perform grayscale processing on the component image to obtain a grayscale image; for example, when analyzing the image brightness, the grayscale histogram of the image can be calculated to count the brightness distribution; use the formula I gray (x,y) = 0.299*R(x,y) + 0.587*G(x,y) + 0.114*B(x,y) for grayscale processing, where I gray (x,y) is the grayscale value of the pixel point (x,y), and R(x,y), G(x,y), and B(x,y) are the red, green, and blue channel values of the pixel point (x,y) respectively;
[0078] Furthermore, initialize a histogram array hist with a length of 256, and all elements are initialized to 0; then traverse each pixel point in the grayscale image and map and update it in the histogram array hist according to the brightness situation in the grayscale image; for example, if it needs to be brightened, the grayscale value of each pixel point is increased by 1 and then mapped to the histogram array hist. Of course, the specific increase and decrease amounts are determined according to the actual image brightness situation, aiming to improve the image contrast and detail clarity. After the mapping is completed, normalization processing can also be considered for the histogram array by dividing the number of pixels at each grayscale level by the total number of pixels in the image to achieve the normalization of the histogram array.
[0079] Calculate the average brightness value of the grayscale image according to the histogram array hist; for example, the average brightness value can be specifically obtained through the following calculation formula: where, I avg is the average brightness value, I hist (k) is the updated grayscale value corresponding to the pixel point (x i ,y i ) in the updated histogram array hist, and N is the number of elements in the histogram array hist;
[0080] Further, exposure judgment can be made according to the average brightness value. If the average brightness value I avg is greater than the high brightness threshold, it is considered that the image is overexposed, and the image brightness can be reduced by reducing the exposure time or aperture size; if the average brightness is less than the low brightness threshold, it is considered that the image is underexposed, and the image brightness can be increased by increasing the exposure time or aperture size; if the average brightness value is between the high brightness threshold and the low brightness threshold, it is considered that the exposure is normal. In addition, when the exposure time is limited, the gain value can also be adjusted to compensate for the brightness.
[0081] Of course, in one embodiment, autonomous feedback control of exposure can also be performed, that is, considering based on the average brightness value and the PID control algorithm, the exposure parameters of the grayscale image are dynamically adjusted. For example, the exposure parameters of the grayscale image can be dynamically adjusted as follows: where ΔE is the adjustment amount of the exposure parameter, and e(t) = I target - I avg is the brightness error, I target is the target brightness value, and K p , K i , K d are the PID control parameters.
[0082] In this embodiment, through image brightness analysis and feedback adjustment of exposure parameters, the brightness processing and exposure parameter adjustment can be actually performed according to the quality of the image, so as to improve the contrast and detail clarity of the image, and eliminate the reflection interference of the component housing, so that more critical and accurate features can be extracted during subsequent feature extraction for feature analysis and decision-making, and the accuracy of component polarity detection is improved.
[0083] Step 103: Extract features from the preprocessed component image based on the chromaticity space to obtain chromaticity features;
[0084] In this step, the principle of HSV chromaticity space analysis is considered to identify the color and position of the component color ring. Specifically, feature extraction is considered from three levels of hue, saturation, and brightness for the preprocessed component image respectively to identify the color information of the intelligent meter components; among them, the hue is used to represent the basic attributes of the color, such as red, green, blue, etc., and the value range is 0° to 360°, or normalized to 0 to 1; for example, 0° or 0 represents red; 120° or 0.33 represents green; 240° or 0.66 represents blue. Saturation is used to represent the purity or vividness of the color, and the value range is 0 to 1. For example, 0 represents gray, and 1 represents a fully saturated color; brightness is used to represent the brightness of the color, and the value range is 0 to 1. For example, 0 represents black, and 1 represents the brightest color.
[0085] Of course, in this embodiment, it is possible to consider using the original color image for feature extraction.
[0086] Step 104: Perform feature extraction on the preprocessed component image based on local binary pattern and morphological edge detection to obtain geometric features;
[0087] The purpose of this step is to extract the geometric features of the polarity mark, such as texture, area, perimeter, etc., through local binary pattern texture features and morphological edge detection. Specifically, feature extraction can be considered to be performed in the following manner:
[0088] S41: Calculate the local binary pattern value based on the preprocessed component image to obtain texture features;
[0089] When calculating the local binary pattern value, first consider determining a neighborhood with a radius of R centered on the central pixel of the preprocessed component image. There are P sampling points in this neighborhood, and the gray values of these neighborhood points are obtained; for each neighborhood point, compare its gray value with the gray value of the central pixel, and obtain a value of 0 or 1 according to the sign function; among them, when the neighborhood gray value is not less than the central pixel gray value, the sign function outputs 1; when the neighborhood gray value is less than the central pixel gray value, the sign function outputs 0; arrange the output 0 / 1 values in order to form a binary sequence; then convert the binary sequence into a decimal number to obtain the local binary pattern value of the central pixel.
[0090] S42: Detect the edges of the positions to be detected in the preprocessed component image that represent the intelligent meter components based on Canny edge detection to obtain edge features;
[0091] When calculating the edge features, consider performing Gaussian smoothing on the preprocessed component image based on the Gaussian function to obtain a denoised component image; then calculate the gradient magnitude and direction of the denoised component image; further, in the gradient direction, compare the gradient magnitude of the current pixel point with the gradient magnitudes of adjacent pixel points, and set the pixel points whose gradient magnitudes are not local maxima to 0; finally, set two thresholds Tlow < Thigh, mark the pixels with gradient magnitudes greater than Thigh as strong edges, mark the pixel points with gradient magnitudes between Tlow and Thigh as weak edges, set the pixel points with gradient magnitudes less than Tlow to 0; and form a complete edge by connecting the weak edges and strong edges to obtain the edge features.
[0092] Of course, in one embodiment, it is also possible to consider expanding the bright regions in the image. For example, when the structural element B is a 3×3 all - 1 matrix, consider assigning the maximum value within the 3×3 neighborhood around each element to this pixel, so as to expand the bright regions (such as edges) in the image.
[0093] S43: Detect the contour of the preprocessed component image, and calculate the area and perimeter of the contour to obtain the area feature and perimeter feature.
[0094] In this step, when determining the area feature and perimeter feature, consider reading and preprocessing the image, then finding the contour, and calculating the area and perimeter of the contour. When calculating the area, the open-source function cv2.contourArea() can be used to calculate the area of each contour. When calculating the perimeter, the open-source function cv2.arcLength() can be used to calculate the perimeter of each contour, and it is necessary to specify whether the contour is closed.
[0095] Step 105: Input the chromaticity feature and geometric feature into the pre-trained classification and decision-making model, and output the final polarity detection result. Among them, the processing logic of the classification and decision-making model is: based on the feature after weighted fusion of the chromaticity feature and geometric feature, output the polarity recognition result of the component of the intelligent meter to be measured.
[0096] In this step, the classification and decision-making model aims to achieve polarity detection through cascaded classification and decision fusion. For cascaded classification, consider using the improved YOLOv5 model for rough positioning and combining with the Siamese network for micron-level difference comparison. When improving, first consider adding a small target detection layer, that is, adding an output layer dedicated to detecting small targets in the Head part of YOLOv5, such as an output layer with a resolution of 160×160, to improve the detection ability of small-scale polarity markers. In addition, consider introducing an attention mechanism, that is, embedding the CBAM (Convolutional Block Attention Module) module in the Backbone, which can enhance the importance of both the channel dimension and spatial dimension of the feature map at the same time, so as to pay attention to which channels are more important through channel attention and which regions of the feature map are more important through spatial attention. For example, weight the key channels through channel attention and focus on the polarity marker region through spatial attention to enhance the model's ability to extract key features.
[0097] For example, first, for the input feature map F∈RC×H×W, perform global average pooling GAP and global maximum pooling GMP on the feature map to obtain two C×1×1 vectors. Then, input the two vectors into the shared multi-layer perceptron MLP respectively to obtain the channel attention weight Mc∈RC×1×1. Further, multiply Mc by the original feature map to obtain the channel attention enhanced feature map Mc(F) = σ(MLP(GAP(F)) + MLP(GMP(F))), where σ is the Sigmoid activation function.
[0098] When making decision fusion, consider combining features at different levels or from different sources to make up for the deficiencies of single features, thereby improving the performance of the model. Features at different levels can include low-level features such as color, edge, texture, and geometry that contain rich detailed information, as well as high-level features such as object categories that contain rich semantic information. By fusing low-level and high-level features, the model can capture both detailed and semantic information simultaneously, thereby improving the accuracy of detection or segmentation. When performing specific fusion, consider adjusting the contributions of different features by learning weights, and then output the final fused features through weighted averaging. For example, it can be implemented according to the following calculation formula:
[0099]
[0100] where ω1, ω2, …, ω n are weights obtained through network learning, F1, F2, …, F n are different features, and F fused is the fused feature.
[0101] In one embodiment, when making decision fusion, it can be considered to adopt the D-S evidence theory to fuse the multi-feature classification results. In small target detection, due to reasons such as small target size and unclear features, the description of the target by a single feature often has uncertainty. The D-S evidence theory can handle this uncertainty well. It can reasonably fuse the uncertain information provided by different features, and reduce the uncertainty by integrating multiple evidences to improve the accuracy of classification.
[0102] Specifically, it can include the following process:
[0103] 1. Feature extraction: First, extract various features related to small targets from the input image, such as the color feature, texture feature, edge feature, etc. of the image, which can organically combine these different feature information, make full use of the advantages of each feature, and make the final decision result more comprehensive and accurate.
[0104] 2. Basic probability assignment determination: For each extracted feature, determine the corresponding basic probability assignment function according to its support degree for different categories of small targets (including targets and backgrounds). This can be achieved through training data statistics, empirical knowledge, or some machine learning algorithms. For example, for a certain feature, if it appears more frequently in the samples where the small target belongs to a category, then a higher basic probability value can be assigned to the category.
[0105] 3. Evidence Fusion: Using the Dempster combination rule, the basic probability assignment functions from different features are fused. This rule takes into account the conflicts and consistencies between different pieces of evidence and calculates the fused basic probability assignment. If two features both have a high degree of support for a certain category, then the basic probability value of this category will be further increased after fusion; if there are conflicts between two features, the Dempster combination rule will be adjusted according to a certain algorithm to reasonably fuse this conflicting information.
[0106] 4. Decision Classification: According to the fused basic probability assignment, the selected decision rule is used for classification decision. For example, the category with the maximum belief function value or likelihood function value can be selected as the final detection result. If the fused result shows that the probability of a small target belonging to a certain category is significantly higher than other categories, then it can be determined as this category.
[0107] In addition, in order to improve the reliability of the model, data augmentation strategies are considered during model training. For example, simulating reflection interference by randomly adding high-light areas to the training data to simulate the reflection phenomenon on the surface of components; for another example, adding random occlusions in the polarity marking area to improve the model's detection ability for partially visible targets; for another example, randomly scaling the training images to enhance the model's adaptability to targets of different sizes.
[0108] In addition, when training the classification decision model, consider using the following loss function for training the classification decision model:
[0109]
[0110] where I ou is the intersection over union of the predicted bounding box b pred and the ground truth bounding box b gt , with a value range of [0, 1]. The larger the value, the higher the overlap degree between the predicted bounding box and the ground truth bounding box; ρ is the Euclidean distance between the center points of the predicted bounding box and the ground truth bounding box, c is the diagonal length of the minimum bounding rectangle of the predicted bounding box and the ground truth bounding box, v is the similarity measure of the aspect ratio between the predicted bounding box and the ground truth bounding box, α is the weight coefficient used to balance the contribution of v to the total loss, θ is the angular error between the predicted bounding box and the ground truth bounding box, and β is the weight coefficient used to balance the contribution of θ to the total loss.
[0111] In this embodiment, based on the original CIoU loss, an angular penalty term is added, which can improve the detection accuracy for rotated targets.
[0112] As Figure 2 shown, the present invention also provides a sorting system for intelligent meter components, including a support mechanism 10, a conveyor belt 20, a camera 30, an annular light source 40, a stop device 50, a sensor 60, a component tray 70, and a control module 80;
[0113] A conveyor belt 20 is arranged below the support mechanism 10. The camera 30 and the annular light source 40 are fixed on the support mechanism 10, and the shooting direction of the camera 30 and the irradiation direction of the annular light source 40 both face the conveyor belt 20. A sensor 60 and a stop device 50 are respectively arranged in front of and behind the shooting position of the camera 30. The control module 80 is electrically connected to the camera 30, the stop device 50 and the sensor 60 respectively.
[0114] The component tray 70 is used to place intelligent instrument components and is placed on the conveyor belt 20 for transportation.
[0115] The sensor 60 is used to collect the position information of the component tray 70 and upload the collected tray position information to the control module 80.
[0116] The control module 80 is used to determine whether the current tray is in place according to the tray position information, and when it is determined that the tray is in place, control the baffle of the stop device 50 to rise to stop the tray below the camera 30 and the annular light source 40. And issue an image acquisition instruction to the camera 30.
[0117] The camera 30 is used to perform image acquisition on the components in the component tray 70 and upload it to the control module 80.
[0118] The control module 80 is further used to judge whether the polarity of the current component is correct based on the polarity detection method of the intelligent instrument component as described in any one of the first aspect. When the polarity of the current component is correct, control the baffle of the stop device 50 to lower, so that the component tray 70 continues to be transported and the next component is detected. When the polarity of the component is incorrect, sort the current component to the designated area.
[0119] In this embodiment, the component tray 70 is placed on the conveyor belt 20 for transportation. The component tray 70 contains intelligent instrument components, and the control module 80 is configured with instructions to execute the polarity detection method of the intelligent instrument components provided by this solution. The sensor 60 can detect whether the component tray 70 reaches the designated image acquisition position. If it reaches, the control module 80 can control the baffle of the stop device 50 to rise, thereby stopping the component tray 70, and then performing image acquisition. Further, the control module 80 analyzes the image to determine whether the polarity of the current component is correct, so as to determine whether to lower the baffle to let the component pass, or whether the component needs to be sorted to other execution areas. Therefore, compared with the existing solution, the accuracy and efficiency of component sorting can be improved based on this solution.
[0120] Among them, the sensor 60 can be an infrared photoelectric sensor.
[0121] This specification also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed on a computer, the computer is caused to execute the method in any one of the embodiments in the specification.
[0122] This specification also provides a computing device, including a memory and a processor. An executable code is stored in the memory. When the processor executes the executable code, the method in any one of the embodiments in the specification is implemented.
[0123] Since the system embodiment provided by the present invention is based on the same inventive concept as the method embodiment in this specification, for the specific content, reference may be made to the description in the method embodiment of this specification, and details are not repeated here.
[0124] The modules or units in the device embodiments of the present invention can be combined, divided, and deleted according to actual needs. The foregoing disclosure is only a preferred embodiment of the present invention, and of course cannot be used to limit the scope of the rights of the present invention. Those of ordinary skill in the art can understand the entire or partial processes of implementing the above embodiments, and the equivalent changes made according to the claims of the present invention still fall within the scope covered by the present invention.
Claims
1. A method for detecting the polarity of intelligent instrument components, characterized in that, Including: Obtaining an image of the component of the intelligent instrument to be measured under illumination by multi-angle light sources; Performing histogram equalization and dynamic exposure compensation processing on the component image to reduce the reflection interference of the metal shell and obtain a preprocessed component image; Performing feature extraction on the preprocessed component image based on the chromaticity space to obtain chromaticity features; Performing feature extraction on the preprocessed component image based on local binary pattern and morphological edge detection to obtain geometric features; Inputting the chromaticity features and the geometric features into a pre-trained classification decision model, and outputting a final polarity detection result; wherein, the processing logic of the classification decision model is: based on the features after weighted fusion of the chromaticity features and the geometric features, outputting a polarity recognition result of the component of the intelligent instrument to be measured.
2. The polarity detection method of the intelligent instrument component according to claim 1, characterized in that, The obtaining an image of the component of the intelligent instrument to be measured under illumination by multi-angle light sources includes: using a ring-shaped LED light source and an oblique infrared light source as the illumination light sources for the component of the intelligent instrument; using a CCD camera equipped with a polarization filter to collect an image of the component of the intelligent instrument to be measured.
3. The polarity detection method of the intelligent instrument component according to claim 1, wherein, The performing histogram equalization and dynamic exposure compensation processing on the component image includes: performing grayscale processing on the component image to obtain a grayscale image: Initializing a histogram array hist with a length of 256, traversing each pixel point in the grayscale image, mapping and updating it in the histogram array hist according to the brightness condition in the grayscale image; calculating the average brightness value of the grayscale image according to the histogram array hist; Based on the average brightness value and the PID control algorithm, dynamically adjusting the exposure parameters of the grayscale image.
4. The polarity detection method for intelligent instrument components according to claim 3, characterized in that Performing grayscale processing on the component image by using the following calculation formula: I gray (x,y) = 0.299 * R(x,y) + 0.587 * G(x,y) + 0.114 * B(x,y) where I gray (x, y) is the gray value of the pixel point (x, y), and R(x, y), G(x, y), and B(x, y) are the red, green, and blue channel values of the pixel point (x, y), respectively; And / or Calculating the average brightness value by using the following calculation formula: Among them, I avg is the average luminance value, I hist (k) is the updated gray value corresponding to the pixel point (x i , y i ) in the updated histogram array hist, and N is the number of elements in the histogram array hist; And / or Dynamically adjusting the exposure parameters of the grayscale image by using the following calculation formula: Among them, ΔE is the adjustment amount of the exposure parameter, and e(t) = I target -I avg is the brightness error, and I target is the target brightness value, and K p , K i , K d are PID control parameters.
5. The polarity detection method of the intelligent instrument component according to claim 1, characterized in that The performing feature extraction on the preprocessed component image based on the chromaticity space includes: Performing feature extraction on the preprocessed component image from three levels of hue, saturation, and brightness respectively to identify the color information of the component of the intelligent instrument; Wherein, the hue is used to represent the basic attribute of the color, and its value range is from 0° to 360°, or normalized to 0 to 1; the saturation is used to represent the purity or vividness of the color, and its value range is from 0 to 1, 0 representing grayscale, and 1 representing a completely saturated color; the brightness is used to represent the brightness of the color, and its value range is from 0 to 1, 0 representing black, and 1 representing the brightest color.
6. The polarity detection method of the intelligent instrument component according to claim 1, characterized in that The performing feature extraction on the preprocessed component image based on local binary pattern and morphological edge detection includes: Calculating local binary pattern values based on the preprocessed component image to obtain texture features; performing Canny edge detection on the edge of the position to be detected representing the component of the intelligent instrument in the preprocessed component image to obtain edge features; Performing contour detection on the preprocessed component image, and calculating the area and perimeter of the contour to obtain area features and perimeter features.
7. The polarity detection method for intelligent instrument components according to claim 6, characterized in that, Calculating the local binary pattern value based on the preprocessed component image includes: For each pixel in the preprocessed component image, use it as the central pixel; determine a neighborhood with a radius of R centered on the central pixel, where there are P sampling points in this neighborhood, and obtain the gray values of these neighborhood points; For each neighborhood point, compare its gray value with the gray value of the central pixel, and obtain a value of 0 or 1 according to the sign function; where when the neighborhood gray value is not less than the central pixel gray value, the sign function outputs 1; when the neighborhood gray value is less than the central pixel gray value, the sign function outputs 0; Arrange the output 0 / 1 values in order to form a binary sequence; convert the binary sequence into a decimal number to obtain the local binary pattern value of the central pixel; and / or, Detecting the edge of the position to be detected representing the intelligent meter component in the preprocessed component image based on Canny edge detection includes: Perform Gaussian smoothing on the preprocessed component image based on the Gaussian function to obtain a denoised component image; Calculate the gradient amplitude and direction of the denoised component image; On the gradient direction, compare the gradient amplitude of the current pixel point with the gradient amplitudes of adjacent pixel points, and set the pixel points whose gradient amplitudes are not local maxima to 0; set two thresholds Tlow < Thigh, mark the pixel points with gradient amplitudes greater than Thigh as strong edges, mark the pixel points with gradient amplitudes between Tlow and Thigh as weak edges, and set the pixel points with gradient amplitudes less than Tlow to 0; and form a complete edge by connecting weak edges and strong edges to obtain edge features.
8. The polarity detection method of the intelligent instrument component according to claim 1, characterized in that The classification decision model uses an improved YOLOv5 model; where the improved YOLOv5 model adds an output layer for detecting small targets to the Head part of the YOLOv5 model to improve the detection ability for small-scale polar markings; and embeds a CBAM module in the Backbone to enhance the importance of both the channel dimension and the spatial dimension of the feature map simultaneously.
9. The polarity detection method for intelligent instrument components according to claim 1, wherein Use the following loss function for the training of the classification decision model: Among them, I ou is the intersection over union of the predicted bounding box b pred and the ground truth bounding box b gt The value range is [0, 1]. ρ is the Euclidean distance between the center points of the predicted bounding box and the ground truth bounding box. c is the diagonal length of the minimum bounding rectangle of the predicted bounding box and the ground truth bounding box. v is the similarity measure of the width-to-height ratio of the predicted bounding box and the ground truth bounding box. α is the weight coefficient used to balance the contribution of v to the total loss. θ is the angular error between the predicted bounding box and the ground truth bounding box. β is the weight coefficient used to balance the contribution of θ to the total loss.
10. A sorting system for intelligent instrument components, characterized in that, It includes a support mechanism, a conveyor belt, a camera, a ring light source, a stop device, a sensor, a component tray, and a control module; A conveyor belt is arranged below the support mechanism, the camera and the ring light source are fixed on the support mechanism, and the shooting direction of the camera and the irradiation direction of the ring light source both face the conveyor belt; a sensor and a stop device are respectively arranged in front of and behind the camera shooting position; the control module is electrically connected to the camera, the stop device, and the sensor respectively; The component tray is used to place intelligent meter components and is placed on the conveyor belt for conveying; the sensor is used to collect the position information of the component tray and upload the collected tray position information to the control module; The control module is used to determine whether the current tray is in place according to the tray position information, and when it is determined that the tray is in place, control the baffle of the stop device to rise, so as to stop the tray below the camera and the ring light source; and, send an image acquisition instruction to the camera. The camera is used to collect images of the components in the component tray and upload them to the control module. The control module is further used to judge whether the polarity of the current component is correct based on the polarity detection method of the intelligent meter component as described in any one of claims 1-9; when the polarity of the current component is correct, control the baffle of the stop device to lower, so that the component tray continues to convey and detect the next component; when the polarity of the component is incorrect, sort the current component to the designated area.