A visual detection method for internal wiring assembly quality of an electric energy metering box
By using an industrial camera and color space conversion technology in the power metering box, combined with gradient and quadratic curve interpolation, burrs and occlusion interference are eliminated, enabling accurate positioning of the conductor center and automatic detection of wiring defects. This solves the problem of insufficient detection accuracy in existing technologies and improves detection efficiency and product quality.
Patent Information
- Application Number
- CN202611120955.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-27
- Publication Date
- 2026-11-20
AI Technical Summary
Existing technologies cannot accurately distinguish between the actual arc of the conductor and abnormal edges caused by wire stripping burrs or spatial obstruction in the quality inspection of wiring assembly inside the power metering box. This results in interference items mixed in with the boundary data, making it impossible to achieve non-contact automatic quality diagnosis.
By acquiring pixel data from an industrial camera and converting color space, a monochrome grayscale matrix is obtained. Gradient and quadratic curve interpolation is used to calculate and remove abnormal edges formed by burrs and occlusions. Based on least squares circle fitting, the actual center of the wire is extracted. Combined with the terminal reference coordinates, the wiring space deviation is calculated, the wiring defect type is generated, and a warning command is output.
It enables non-contact automatic quality diagnosis of the wiring assembly of the power metering box, improving detection accuracy and efficiency, reducing human error, and ensuring product quality consistency and electrical safety.
Smart Images

Figure CN123141303A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of image processing and quality inspection technology for power metering equipment. More specifically, this invention relates to a visual inspection method for the internal wiring assembly quality of a power metering box. Background Technology
[0002] With the continuous development of smart grids, electricity metering boxes, as key nodes at the end of the power distribution network, directly affect the safety of users' electricity consumption and the stable operation of the power grid. The internal wiring assembly quality of electricity metering boxes typically contains multiple strands of rigid wires of different colors and terminal blocks. These wires require stripping, bending, insertion into terminals, and tightening. During automated or semi-automated assembly lines, due to the rigidity of the wires and the gripping error of robotic arms, assembly defects such as missing connections, incorrect connections, or insufficient insertion depth are very likely to occur. Therefore, quickly and accurately assessing the positional deviation between the wiring and the terminal holes is crucial for identifying potential assembly quality issues.
[0003] In related technologies, for example, Chinese patent application document with publication number CN120746968B discloses a busbar welding inspection method, system, electronic device and medium. This patent document extracts the appearance contour data of components such as busbars through machine vision, and then evaluates the welding or assembly quality. This processing method can achieve basic feature extraction and status assessment in the inspection of simple components with single targets or unobstructed surfaces.
[0004] However, analysis of the performance of existing technologies under complex wiring harness assembly quality inspection conditions inside actual metering boxes reveals that this method, which relies on conventional machine vision to directly extract edge contours, suffers from the flaw of planar indiscriminate extraction calculations that ignore spatial depth occlusion and burr interference. Firstly, the physical micromorphology of wire stripping points and terminal crimping areas exhibits strong irregularities: insulation easily produces burrs, protrusions, or notches at the cut edges during stripping, and the metering box space is confined, with multiple wires frequently crossing and obstructing each other, resulting in severely uneven and discontinuous cross-sections of the exposed wiring edges in the camera's field of view. Existing vision technologies often extract all visible edge pixels uniformly and perform global circle equation fitting when extracting contours. The algorithm cannot distinguish between smooth, real insulation arcs and abrupt edges caused by burrs and occlusions, leading the model to assign higher weights to interference points when calculating the actual geometric center of the wire, thus deviating from the center coordinates. Secondly, existing detection methods commonly use mechanical lever hard-push tests or two-dimensional rectangular frame comparisons to determine the degree of misalignment. Mechanical pry bars can easily cause secondary damage to fragile wire connections, while rectangular frame comparison fails to accurately assess the absolute spatial offset between the wire center and the terminal hole center, leading to missed or false defect reports. This measurement model fails to reflect the physical reality of rough edges and overlapping obstructions at the wiring holes in the metering box, resulting in the system's inability to accurately determine the true state of wiring assembly quality, and it lacks a closed-loop mechanism for non-contact, fully automated diagnostics on high-speed production lines. Summary of the Invention
[0005] To address the technical problem that existing technologies cannot distinguish between smooth, real conductor arcs and abrupt edge changes caused by wire stripping burrs or spatial obstructions when extracting wiring contours, leading to interference terms in boundary data and resulting in inaccurate conductor center fitting, distorted spatial deviation calculations, and the inability to achieve non-contact automatic quality diagnosis, this invention provides a visual inspection method for the wiring assembly quality inside an energy metering box, comprising:
[0006] S1: Obtain a monochrome grayscale matrix by executing an industrial camera pixel data acquisition and color space conversion algorithm; S2: Based on the pixel gradient and grayscale gradient transition features of the monochrome grayscale matrix, perform quadratic curve interpolation calculation to obtain a set of conductor contour coordinate points; according to the local coordinate distribution of the conductor contour coordinate point set, perform differential forward tangential difference operation to obtain the edge bending rate; based on the edge bending rate and global average condition, perform feature data recombination operation to generate a pure conductor point set; S3: Based on the pure conductor point set, perform least squares circle fitting solution to extract the actual center of the conductor; analyze the data stored inside the metering box to obtain the terminal reference coordinates as the reference anchor point; perform spatial calculation based on the actual center of the conductor and the terminal reference coordinates to generate the wiring space deviation; S4: Based on the wiring space deviation, perform tolerance boundary grading judgment to extract the wiring defect type; based on the wiring defect type, perform closed-loop data mapping to output early warning instructions and save records.
[0007] This invention addresses the technical problem of existing technologies that, when extracting wiring contours, cannot distinguish between smooth, real conductor arcs and abnormal edge abrupt changes caused by wire stripping burrs or spatial obstructions. This leads to interference in boundary data, resulting in inaccurate conductor center fitting, distorted spatial deviation calculations, and the inability to achieve non-contact automatic quality diagnosis. By identifying and eliminating abnormal edge abrupt changes caused by burrs and obstructions through curvature variation analysis, accurate extraction of the smooth contours of real conductors is achieved. By fitting the conductor centerline based on clean and effective edge points and calculating spatial position deviations, conductor positioning accuracy is improved. Combined with terminal position verification, quality judgment is completed, enabling non-contact automatic quality diagnosis of metering box wiring assembly.
[0008] Preferably, obtaining a monochrome grayscale matrix includes: The system controls an industrial camera to collect two-dimensional color pixel data of the wiring area inside the metering box online, generating a box wiring image containing the contact features of the wire harness and terminals; the box wiring image is converted from RGB color space to HSV color space, and the image is separated and decoupled into independent monochrome grayscale matrices using preset national standard line color threshold parameters.
[0009] Preferably, obtaining the set of coordinate points for the traverse profile includes: Along the horizontal and vertical directions of the monochrome grayscale matrix, obtain the grayscale partial derivative matrix representing the intensity of the edge jump of the conductor. Find the integer point of the local extreme value of the gradient in the grayscale partial derivative matrix. Taking the pixel of the integer extreme value as the center, take the grayscale values of the three coordinate points that are immediately before and after it along the gradient direction. Perform quadratic curve fitting on the grayscale values of these three coordinate points to generate a set of coordinate points of the conductor contour. For each coordinate point in this set, initialize a geometric fitting weight to represent the confidence of its participation in the subsequent circle fitting. The initial value of the geometric fitting weight is uniformly set to the full value of 1.
[0010] Preferably, obtaining the edge bending strain includes: A local evaluation window is established along the contour coordinate trajectory of the set of contour coordinate points of the conductor. Within the local evaluation window, the angular fluctuation difference between the lines connecting two adjacent sub-pixel coordinate points is calculated to obtain the tangential angular difference value. The absolute values of all tangential angular differences within the local evaluation window are summed and divided by the contour arc length spanned by the window to obtain the directional change per unit arc length, which is used as the edge curvature rate representing the abrupt change in local curvature.
[0011] Preferably, generating a pure set of conductor points includes: The global arithmetic mean of all edge curvature is calculated to generate a curvature abrupt change threshold. The edge curvature of each coordinate point is then compared with this threshold. If the edge curvature is greater than the threshold, the segment is considered to have abrupt change interference. The geometric fitting weight associated with the coordinate point is set to 0 from its initial value, and its coordinate data is removed. If the edge curvature is less than or equal to the threshold, the segment is considered to be a true insulating arc. The geometric fitting weight of the coordinate point is kept at its full value of 1. All high-confidence coordinates with a geometric fitting weight of 1 are summarized, and a pure conductor point set is extracted.
[0012] This invention generates an adaptive mutation threshold by calculating the average value of the global edge curvature rate. Based on this threshold, abnormal edge points formed by burrs and occlusions are filtered out, and only high-confidence coordinates corresponding to the smooth arcs of the true insulation are retained to generate a pure conductor point set. This mechanism performs pre-processing purification at the data level before center fitting, removing interference from factors such as stripped wire edges and spatial occlusion that disturb the contour, thus preventing abnormal points from pulling the geometric center off-center during subsequent fitting.
[0013] Preferably, extracting the actual center of the conductor includes: Substitute the coordinates of each point in the pure conductor point set (i.e., the coordinate data retained from the previous step with a geometric fitting weight of 1) into the quadratic term expression of the quadratic circle fitting model to construct the sum of squared errors from all data points to the theoretical circle boundary. Based on the sum of squared errors function, using the least squares method, calculate the first-order partial derivatives with respect to the horizontal and vertical coordinates of the circle center and set them equal to zero to solve the corresponding residual partial derivative extreme value equations. Analyze the system parameters of the equations through matrix inversion operations and reverse-engineer to extract the actual circle center of the conductor at the conductor crimping point.
[0014] This invention substitutes a pure conductor point set into a quadratic circle fitting model to construct an error sum of squares function. Based on the least squares method, it calculates the actual center coordinates of the conductor crimp by using partial derivatives to find the extrema and matrix inversion.
[0015] Preferably, obtaining the terminal reference coordinates used as the reference anchor point includes: The computer-aided design document of the metering box engineering assembly standard is retrieved, and the geometric reference parameters stored in the file are parsed through the data communication interface. From the parsed geometric reference parameters, the two-dimensional space horizontal and vertical coordinate sequence of the reference insertion hole of the terminal block is located and obtained, and it is output as the terminal reference coordinate.
[0016] This invention extracts the two-dimensional coordinate sequence of the reference insertion holes of the terminal block directly as the terminal reference coordinates by analyzing the standard CAD document of the metering box engineering assembly. This method uses the engineering design document as a unified reference standard, avoiding operational errors and individual differences caused by manual calibration of reference points.
[0017] Preferably, generating wiring space deviation includes: Based on the principles of plane analytical geometry, the difference between the projected coordinates of the actual center of the conductor and the reference coordinates of the terminal in the X and Y axes is calculated to generate the axial absolute difference. Using the Euclidean distance formula, the sum of squares of the projected coordinate differences in the horizontal and vertical axes is calculated and the square root is taken to output the center line distance between the two points. The axial absolute difference and the center line distance are combined and packaged together to generate the wiring space deviation.
[0018] This invention, based on the principles of plane analytical geometry, calculates the axial and transverse differences between the actual center of the conductor and the terminal reference, and uses the Euclidean distance formula to solve for the straight-line distance between the centers of the two points, integrating and outputting the wiring space deviation. This calculation transforms absolute coordinates into machining errors relative to the design reference, including both offset direction information and an assessment of the overall degree of offset.
[0019] Preferably, the types of wiring defects extracted include: Based on the nominal diameter of the insertion hole corresponding to the terminal reference coordinate, a multi-level process tolerance boundary is constructed. The center straight distance contained in the wiring space deviation is extracted, and the center straight distance is compared with the upper limit of acceptance and the upper limit of looseness in turn to determine the assembly error range to which it belongs. If the center straight distance is greater than the upper limit of looseness, it is mapped as a missing or incorrect connection defect. If the center straight distance is greater than the upper limit of acceptance and less than or equal to the upper limit of looseness, it is mapped as a loose wiring defect. If the center straight distance is less than or equal to the upper limit of acceptance, it is mapped as an acceptable assembly. The digital wiring defect type is output according to the above assembly error range mapping rule.
[0020] Preferably, the output of warning commands and the saving of records include: The wiring defect type is parsed and converted into a bright alarm character message that can be recognized by the workshop control screen. Combined with the device address, a low-level warning message is generated and sent out as a visual alarm command. The hardware serial number of the current metering box under test is obtained through an industrial barcode scanner. It is merged and packaged with the complete set of wiring defect types into a record entity with a timestamp, generating an assembly quality inspection ledger and storing it in the system's low-level database.
[0021] The beneficial effects of this invention are as follows: It improves the automation and intelligence level of the assembly and quality inspection process for electricity metering boxes, providing an efficient and reliable visual inspection solution for the mass production of electricity metering equipment. Compared to traditional manual visual inspection, this invention enables full-scale online inspection of products, improving inspection efficiency and reducing human error caused by labor intensity and visual fatigue of quality inspectors. Unified judgment standards ensure the consistency of product quality before shipment, reducing metering deviations and electrical safety accidents caused by wiring errors. Structured inspection data and traceability mechanisms enable digital management of production quality, providing data support for assembly process optimization and quality traceability, and contributing to the intelligent upgrading of the electricity metering equipment manufacturing industry. Attached Figure Description
[0022] Figure 1 This schematically illustrates a flowchart of a visual inspection method for the internal wiring assembly quality of an energy metering box according to the present invention. Figure 2 The schematic diagram illustrates the principle of wire sub-pixel edge extraction in this invention. Detailed Implementation
[0023] This invention discloses a visual inspection method for the internal wiring assembly quality of an electricity metering box, referring to... Figure 1 This includes steps S1-S4: S1: Obtain the monochrome grayscale matrix.
[0024] It should be noted that in the initial stage of the wiring assembly quality inspection inside the power metering box, considering the complex wiring environment and the fact that basic visual features are often mixed with background noise from the terminal blocks, and given the low efficiency of traditional contact-type mechanical prying inspection and its tendency to cause physical damage to fragile wires, this traditional processing paradigm, when facing large-scale continuous production, is prone to serious safety hazards in the subsequent operation of the power supply network due to its lag. This invention adopts a non-contact continuous exposure acquisition scheme using an industrial camera, combined with a color space decoupling algorithm to perform automated image acquisition, thereby eliminating mechanical contact parts and effectively isolating background noise from the terminal blocks. This transforms the physical wiring state into a high signal-to-noise ratio digital matrix for processing by the backend visual algorithm. In the global data chain, this invention serves as the data entry point for the visual measurement system. Its extracted monochrome grayscale matrix directly provides a highly focused grayscale brightness calculation entity for subsequent first-order partial derivative calculations along the gradient direction. The acquisition and region locking of this basic image matrix lays a clean and reliable data reference benchmark for defining the physical contour boundaries of the wires and for subsequent calculation of high-precision floating-point edge coordinates. The monochrome grayscale matrix represents the two-dimensional brightness distribution array of a specific color conductor after it has been independently extracted from a complex background. Extracting the monochrome grayscale matrix aims to increase the color difference contrast between the conductor and the background terminal block in order to eliminate irrelevant environmental interference.
[0025] Specifically, by executing industrial camera pixel data acquisition and color space conversion algorithms, a monochrome grayscale matrix is obtained, including: The system controls an industrial camera to collect two-dimensional color pixel data of the wiring area inside the metering box online, generating a box wiring image containing the contact features of the wire harness and terminals; the box wiring image is converted from RGB color space to HSV color space, and the image is separated and decoupled into independent monochrome grayscale matrices using preset national standard line color threshold parameters.
[0026] It should be noted that the national standard wire color threshold parameters are set according to the power wiring wire color specification. The hue range of the yellow conductor in phase A is 26° to 34°, the hue range of the green conductor in phase B is 35° to 77°, the hue range of the red conductor in phase C is 0° to 10° and 160° to 180°, and the hue range of the blue conductor in neutral is 100° to 124°. In addition, each wire color is also limited to a saturation of not less than 0.35 and a brightness of not less than 0.30, so as to filter out the low-saturation gray terminal block background while covering the hue fluctuation range of standard cables.
[0027] S2: Generate a pure set of wire points.
[0028] It should be noted that, given the inevitable micro-roughness and physical tearing of the insulation layer cross-section during wire stripping and crimping, conventional pixel-level edge detection struggles to obtain high-precision, smooth contours that reflect the true geometric shape. Existing technologies generally employ integer-level pixel gradient operators combined with fixed thresholds for coarse edge extraction when locating wire edges. This approach is limited by the resolution bottleneck of the camera's physical sensor and easily introduces stepped jagged errors in areas where wires cross or curvature changes, causing geometric distortion in the early stages of feature extraction and leading to deviations in subsequent analytical fitting results of the circle center. To address this issue of insufficient low-level positioning accuracy, this invention introduces gradient calculation based on first-order partial derivatives and quadratic curve interpolation algorithms. This enables the analysis system to overcome the limitations of the hardware discrete pixel grid, reducing the edge extreme value positioning accuracy to within the pixel and finding true physical transition points in continuous grayscale transition zones to effectively ensure the accuracy of spatial coordinate extraction of the wire contour point array. The conductor contour coordinate point set in this invention is a set of floating-point coordinates that break through the limitations of physical pixel grids. It represents the absolute position of the conductor stripping edge at a microscopic scale. During the actual sinking execution, the quadratic curve interpolation algorithm uses an existing mathematical model that fits a univariate quadratic polynomial equation along the gradient direction and solves for the coordinates of extreme points to achieve accurate calculation. To clarify the algorithm logic, when constructing this point set, the system deduces and generates floating-point coordinates based on the continuous variation characteristics of pixel grayscale. Algebraic calculations replace coarse rounding logic, eliminating contour jaggedness errors from the algorithm's underlying layer.
[0029] Specifically, based on the pixel gradient and grayscale transition features of the monochrome grayscale matrix, quadratic curve interpolation is performed to obtain the set of coordinate points of the conductor contour, including: Along the horizontal and vertical directions of the monochrome grayscale matrix, the first-order partial derivatives of each coordinate point are calculated using a 3×3 Sobel difference operator. The template for the horizontal direction is [-1,0,1; -2,0,2; -1,0,1], and the template for the vertical direction is its transpose. This yields the grayscale partial derivative matrix that characterizes the intensity of the edge transition of the conductor. In the grayscale partial derivative matrix, integer points that represent local extrema of the gradient are found. Centered on the pixel of the integer extremum, the grayscale values of the three coordinate points (one integer pixel before and one after it along the gradient direction) are used for quadratic curve fitting. The vertex of the fitted parabola is used as the contour extremum coordinates with floating-point precision. These coordinates are combined to generate a set of conductor contour coordinate points. A geometric fitting weight is initialized for each coordinate point in this set to characterize its confidence in participating in subsequent circle fitting. The initial value of the geometric fitting weight is uniformly set to the full value of 1.
[0030] It should be noted that when evaluating the geometric morphology of the edge of the crimping area of the terminal block, considering that the stripping process and the intersection of the wires inevitably produce physical deformation interference such as burrs, protrusions, gaps, and depressions at the edge, most existing visual measurement algorithms lack a screening mechanism and treat all extracted edge contour coordinate points as valid data equally. This traditional logic fails to establish a screening mechanism for local micro-geometric mutations, which often causes the algorithm to be pulled off course by burr points with errors when fitting the center, resulting in center drift. This leads to the system's inability to accurately calculate the deviation of the wiring coordinates. To solve this deformation interference problem, this invention proposes a curvature variation rate evaluation mechanism based on curve differential features. By analyzing the tangential direction change between adjacent points in the set of wire contour coordinate points within the local evaluation window, the physical burr morphology at the micro level is transformed into an objective numerical representation of the curve smoothness. This method digitally marks irregular geometric mutations at the initial contour feature level to expose various edge defects caused by tool aging or insulation tearing. The vertex of the parabola obtained by fitting corresponds to the sub-pixel position along the gradient direction. Based on the offset of this position relative to the center pixel, it is converted into two-dimensional sub-pixel horizontal and vertical coordinates of the image plane by combining the gradient direction angle.
[0031] It should be noted that the edge bending rate characterizes the degree of uncontrolled bending of the conductor sheath cross section within a small neighborhood, directly reflecting the physical reality of whether there is obstruction by intersecting conductors or the presence of stripping burrs. The local evaluation window, during the actual sinking process, is implemented using a fixed set of coordinate sequences of adjacent points. The difference in tangential angle is calculated by differentiating the coordinates of the points within the sequence. The window size of the local evaluation window is set to a range of 5-15 points, preferably 10 points. When operating within this range, if the value is less than 5 points, it becomes overly sensitive to minute image noise, causing normal arcs to be misjudged as burrs, and insufficient samples are retained in subsequent fitting. If the value is greater than 15 points, the smoothing is excessive, causing the algorithm to over-ignore real small collapses and produce false negatives. Therefore, the optimal value of 10 points achieves a numerical balance between identifying physical anomalies and preserving the normal insulation sheath arc characteristics. The local evaluation window slides point by point along the contour trajectory, with each slide step being a coordinate point. The edge curvature value calculated for each window is assigned to the center coordinate point of that window. The positions at the beginning and end of the contour that are not covered by the window are not included in the subsequent abrupt change determination.
[0032] Preferably, based on the local coordinate distribution of the set of coordinate points of the conductor profile, a differential forward tangential difference operation is performed to obtain the edge curvature, including: A local evaluation window is established along the contour coordinate trajectory of the set of contour coordinate points of the conductor. Within the local evaluation window, the angular fluctuation difference between the lines connecting two adjacent sub-pixel coordinate points is calculated to obtain the tangential angular difference value. The absolute values of all tangential angular differences within the local evaluation window are summed and divided by the contour arc length spanned by the window to obtain the directional change per unit arc length, which is used as the edge curvature rate representing the abrupt change in local curvature.
[0033] It should be noted that after the local curvature assessment of the wiring contour is established, the technical challenge of removing interference and retaining the true arc in edge data containing insulating burrs is addressed. Considering that traditional fitting algorithms generally lack a classification and removal strategy based on physical morphology during data preprocessing, and are prone to causing outliers to participate in global calculations and dragging the true geometric center by the residual weight of burrs, the smoothness classification and removal algorithm adopted in this invention abandons the conventional method of indiscriminate adoption and implements a scoring and elimination strategy based on adaptive thresholds in the visual data screening pipeline. By calculating the mean curvature change rate to generate the bending mutation threshold, and performing conditional branch judgment on the edge bending change rate, a hierarchical mechanism of zero-weight elimination and full-trust retention is established. This data cleaning mechanism ensures the purity of the contour data participating in subsequent simultaneous calculations, so as to avoid weight pollution caused by deformation interference terms in solving geometric analytical equations.
[0034] It should be noted that the pure conductor point set is a set of geometric conductor contour coordinates that have been excluded from physical interference such as wire stripping burrs and overlapping occlusions. Furthermore, the smoothness classification and elimination algorithm is implemented using basic numerical comparison and conditional branching logic during the actual sinking execution.
[0035] Preferably, based on the edge curvature variation and the global average condition, a feature data recombination operation is performed to generate a pure set of conductor points, including: The global arithmetic mean of all edge curvature is calculated to generate a curvature abrupt change threshold. The edge curvature of each coordinate point is then compared with this threshold. If the edge curvature is greater than the threshold, the segment is considered to have abrupt change interference. The geometric fitting weight associated with the coordinate point is set to 0 from its initial value, and its coordinate data is removed. If the edge curvature is less than or equal to the threshold, the segment is considered to be a true insulating arc. The geometric fitting weight of the coordinate point is kept at its full value of 1. All high-confidence coordinates with a geometric fitting weight of 1 are summarized, and a pure conductor point set is extracted.
[0036] It should be noted that the geometric fitting weights here are only used to mark whether a coordinate point participates in the subsequent circle center fitting calculation. A value of zero indicates that the point is excluded from the calculation, while a value of one indicates that the point is valid data and participates in the calculation. This is a binary filtering and marking mechanism, not the weight coefficients used in weighted least squares fitting. The subsequent circle center fitting uses ordinary least squares, performing equal-weighted fitting only on all valid points after filtering. The arc length of the contour spanned by the window is approximated by successively accumulating the straight-line distances between adjacent sub-pixel coordinate points within the local evaluation window.
[0037] S3: Generate wiring space deviation.
[0038] It should be noted that when crossing the boundaries of discrete edge coordinates and macroscopic wiring hole positions, the system needs to solve the analytical calculation problem of high-precision conversion of the residual effective arc to the standard geometric center. Since traditional measurement models often use the midpoint of the rectangular bounding box or the arithmetic mean centroid calculation method to perform a rough hole position deduction, although it can output results quickly, its calculation link is sensitive to edge symmetry and lacks strict quadratic algebraic equation support, which makes it impossible for automated quality inspection systems to track micron-level deviations and face low measurement confidence in the rigorous metrology box inspection environment. In order to improve the anti-interference capability of conductor center positioning, this invention introduces a quadratic circle fitting model based on least squares residual analysis. The system adopts analytical logic of constructing the minimum value of partial derivatives and solving the matrix to replace the centroid calculation method that is easily affected by contour incompleteness, so as to eliminate the geometric offset caused by the asymmetry of the cut and give the measurement results algebraic interpretation capability.
[0039] It should be noted that the actual center of the conductor represents the two-dimensional coordinates of the conductor's geometric center, which is mathematically perfect after excluding the obstructed area and insulation burrs. Furthermore, the quadratic circle fitting model is implemented by constructing the sum of squared errors of the geometric distance from the point to the center and using matrix operations to solve for the unknown parameters of the horizontal and vertical center point variables during the actual sinking process.
[0040] Specifically, based on the pure conductor point set, least squares circle fitting is performed to extract the actual center of the conductor circle, including: Substitute the coordinates of each point in the pure conductor point set (i.e., the coordinate data retained from the previous step with a geometric fitting weight of 1) into the quadratic term expression of the quadratic circle fitting model to construct the sum of squared errors from all data points to the theoretical circle boundary. Based on the sum of squared errors function, using the least squares method, calculate the first-order partial derivatives with respect to the horizontal and vertical coordinates of the circle center and set them equal to zero to solve the corresponding residual partial derivative extreme value equations. Analyze the system parameters of the equations through matrix inversion operations and reverse-engineer to extract the actual circle center of the conductor at the conductor crimping point.
[0041] It should be noted that the specific calculation process of least squares circle fitting is as follows: First, establish the general geometric relationship of the circle, that is, the square of the distance from any coordinate point to the center of the circle is equal to the square of the radius. Based on this, write the error expression corresponding to each coordinate point; Squash the errors of all valid coordinate points and sum them to obtain the total error sum of squares function; Set the partial derivatives of the total error sum of squares with respect to the x-coordinate of the center, the y-coordinate of the center, and the square of the radius to zero respectively to obtain a system of linear equations containing three equations; After arranging the system of equations into standard matrix form, solve the three unknowns by matrix inversion, and extract the x-coordinate and y-coordinate values of the center of the circle to obtain the actual center of the conductor. The coordinate points involved in the fitting only include the valid coordinate points retained after the previous screening. The burrs and occlusion anomalies that were marked and removed are not included in the calculation.
[0042] It should be noted that when evaluating whether the quality of the wiring positions inside the metering box meets the factory acceptance standards, simply obtaining the coordinates of the center of the isolated wire lacks practical engineering significance and cannot guide the assembly quality closed loop. Considering that traditional vision systems are usually accustomed to manually marking static baselines on the screen as visual alignment references, in continuous assembly line systems, static manual marking ignores multiple constraints such as camera installation tolerances and tooling fixture offsets, which can easily lead to uncontrollable detection baseline drift. In response to the physical defects of unstable baselines, this invention uses a theoretical model data retrieval mechanism to reshape the measurement and evaluation system. The system avoids using absolute screen coordinates that deviate from drawing specifications, and instead extracts terminal baseline coordinates that include computer-aided design dimensions, and uses them as the standard comparison base point for subsequent relative vector geometric difference derivation.
[0043] Preferably, parsing the data stored inside the metering box to obtain the terminal reference coordinates as the reference anchor point includes: The computer-aided design document of the metering box engineering assembly standard is retrieved, and the geometric reference parameters stored in the file are parsed through the data communication interface. From the parsed geometric reference parameters, the two-dimensional space horizontal and vertical coordinate sequence of the reference insertion hole of the terminal block is located and obtained, and it is output as the terminal reference coordinate.
[0044] It should be noted that the terminal reference coordinates represent the ideal absolute center position of the electrical terminal hole where the wires must be precisely inserted, as specified in the factory design drawings. Furthermore, the drawing parsing and extraction operation, during actual execution, employs standard graphic data exchange format reading and feature tag retrieval logic. The computer-aided design document uses the DXF universal exchange format. During parsing, all circular elements in the specified layer of the terminal block are read, and the center coordinates of each circle are extracted one by one, numbered according to the physical arrangement order of the terminal block to form a coordinate sequence. During the inspection process, the phase sequence number corresponding to the wire color is matched one-to-one with the terminal hole position number, and the reference coordinates of the corresponding position are retrieved to participate in the spatial deviation calculation.
[0045] It should be noted that this invention utilizes a two-dimensional vector space differential calculation mechanism to upgrade the coordinate data between two points into a composite deviation structure containing direction and magnitude. This algorithm employs the vector subtraction rule and the Euclidean distance formula to calculate the absolute difference in horizontal and vertical distances and the straight-line spacing, respectively, to comprehensively evaluate the accuracy of wire intrusion into terminal holes. In the overall data flow, this invention uses the actual center of the wire obtained from the pre-calculation to retrieve the pre-analyzed terminal reference coordinates imported into the system to calculate the relative spatial offset. The final synthesized wiring space deviation characterizes the algebraic difference between the physical assembly position and the engineering design requirements, thus providing driving data for subsequent product tolerance grading verification and early warning signal output.
[0046] Preferably, spatial calculations are performed based on the actual center of the conductor and the reference coordinates of the terminal to generate wiring space deviations, including: Based on the principles of plane analytical geometry, the difference between the projected coordinates of the actual center of the conductor and the reference coordinates of the terminal in the X and Y axes is calculated to generate the axial absolute difference. Using the Euclidean distance formula, the sum of squares of the projected coordinate differences in the horizontal and vertical axes is calculated and the square root is taken to output the center line distance between the two points. The axial absolute difference and the center line distance are combined and packaged together to generate the wiring space deviation.
[0047] It should be noted that the wiring space deviation calculation explicitly measures the relative direction and displacement of the current physical wiring position of the conductor from the hole required by the standard engineering drawing. Furthermore, the vector difference and distance calculation are implemented using basic mathematical addition and subtraction operations and the square root rule during the actual sinking process to calculate an objective algebraic result encompassing multi-directional contact states. The process of determining the degree of offset overcomes the limitations of two-dimensional visual assessment and deeply analyzes spatial geometric parameters. Working under this vector assessment system, the system avoids errors in single-dimensional judgments, thus achieving accurate error tracing even under complex conductor crimping conditions. The wiring space deviation calculated above is initially in pixel units and needs to be converted to physical millimeter units using pre-calibrated pixel equivalent parameters before participating in subsequent tolerance boundary determination. The pixel equivalent is obtained through standard calibration board data acquisition and calculation, representing the actual physical size corresponding to a single pixel, in millimeters per pixel.
[0048] S4: Output warning commands and save records.
[0049] It should be noted that the present invention uses the obtained wiring space deviation as the basis for adjudication, and classifies the specific wiring defect type based on the calculated upper and lower tolerance limits. This classification data breaks through the blockage state of manual re-inspection and provides a definite state benchmark for subsequent drive warning display and quality inspection record retention.
[0050] Specifically, tolerance boundary classification is performed based on wiring space deviation to extract wiring defect types, including: Based on the nominal diameter of the insertion hole corresponding to the terminal reference coordinates, the parameters are scaled according to preset qualified and loose ratio coefficients to generate two levels of boundaries: the qualified upper limit and the loose upper limit. These boundaries are arranged from smallest to largest to form a multi-level process tolerance boundary. The center straight distance contained in the wiring space deviation is extracted, and this center straight distance is compared with the qualified upper limit and the loose upper limit in turn to determine its assembly error range. If the center straight distance is greater than the loose upper limit, it is in the extreme over-limit range that exceeds all tolerance boundaries, and is mapped as a missing or incorrect connection defect. If the center straight distance is greater than the qualified upper limit and less than or equal to the loose upper limit, it is in the critical floating range between the two boundaries, and is mapped as a wiring loose defect. If the center straight distance is less than or equal to the qualified upper limit, it is in the qualified range, and is mapped as assembly qualified. The digital wiring defect type is output according to the above assembly error range mapping rule.
[0051] It should be noted that the wiring defect type represents a structured classification identifier indicating whether a specific wire inside the current electricity metering box has serious missing connections, misaligned positions, or loose connections. Furthermore, the tolerance boundary grading judgment algorithm, when executed, uses standard upper and lower threshold comparisons and multi-path conditional branching logic. The pass / fail ratio coefficient is 0.15 because when the offset of the wire center relative to the socket center does not exceed 15% of the socket diameter, the wire is still reliably centered and crimped with sufficient contact area, thus being considered pass / fail. The looseness ratio coefficient is 0.4 because when the offset is between 15% and 40% of the socket diameter, although the wire is inserted into the socket, it is clearly biased against the socket wall, and the crimping force is insufficient, posing a risk of loosening. Once the offset exceeds 40% of the socket diameter, the wire center has exceeded the effective contact range of the socket, considered a missing connection or incorrect insertion into an adjacent socket. Therefore, the two ratio coefficients of 0.15 and 0.4 are used to classify the three states: pass / fail, loose, and missing / incorrect connections. For example, the nominal diameter of the terminal socket of a certain type of electricity metering box is 4.5 mm. Based on a pass / fail ratio of 0.15, the upper limit for pass / fail is 0.675 mm; based on a looseness ratio of 0.4, the upper limit for looseness is 1.8 mm. If the measured linear offset distance between the center of a conductor and the center of the corresponding terminal hole is 0.5 mm, it is less than the upper limit for pass / fail and is considered acceptable. If the offset distance is 1.2 mm, it is between the upper limit for pass / fail and the upper limit for looseness and is considered a loose wiring defect. If the offset distance is 2.1 mm, it is greater than the upper limit for looseness and is considered a missing or incorrect connection defect.
[0052] It should be noted that this invention introduces a human-computer interaction communication driving algorithm as an isolation and conversion module between the vision host and the workstation Kanban. The system performs data encapsulation and conversion based on the underlying communication protocol, translating abstract defect types into readable display instructions, and uses a database inventory mechanism to permanently solidify the inspection status. In the output stage, this invention extracts the wiring defect types generated in the preceding stage, and generates interface warning instructions containing physical prompts and assembly quality inspection ledgers recording assembly attributes through communication parsing. This action connects the control closed loop from feature perception to workshop Kanban alarms, and ultimately completes the non-contact fully automatic measurement, control, and archiving of the metering box assembly quality.
[0053] It should be noted that the assembly quality inspection log and the visual alarm commands constitute the final result of the visual inspection algorithm's external interaction. When the human-computer interaction communication-driven algorithm is executed, it uses object-oriented protocol encapsulation and conversion, as well as standard relational database insertion statements to write data to disk. The execution of visual alarms and quality inspection archiving establishes the transfer of digital diagnostics to physical workshop management. The system's output of this type of terminal data signifies a complete break from the reliance on offline manual recording, achieving a fully automated digital control closed loop from color space decoupled perception to online early warning and interception of assembly hazards inside the metering box, thus completing high-quality factory quality control for smart grid supporting equipment.
[0054] Preferably, closed-loop data mapping is performed based on the wiring defect type, and early warning instructions are output and records are saved, including: The wiring defect type is parsed and converted into a bright alarm character message that can be recognized by the workshop control screen. Combined with the device address, a low-level warning message is generated and sent out as a visual alarm command. The hardware serial number of the current metering box under test is obtained through an industrial barcode scanner. It is merged and packaged with the complete set of wiring defect types into a record entity with a timestamp, generating an assembly quality inspection ledger and storing it in the system's low-level database.
[0055] This completes a visual inspection of the internal wiring assembly quality of an electricity metering box.
[0056] It should be noted that, Figure 2This diagram illustrates the principle of sub-pixel edge extraction for conductors. The left side shows the pixel grid of the gray-level partial derivative matrix, with squares indicating integer extreme pixels, circles indicating adjacent pixels along the gradient direction, and arrows indicating the gray-level gradient direction, demonstrating the pixel-level localization basis of edge features. The right side shows the result of quadratic curve fitting along the gradient direction, with three circles representing sampled integer pixel gray-level points and diamonds representing the fitted sub-pixel edge extreme points. This diagram visually presents the core logic of this invention, which achieves sub-pixel-level conductor contour extraction through quadratic curve interpolation. By locating integer gradient extreme points in the gray-level partial derivative matrix and performing quadratic curve fitting on the gray-level values of three adjacent pixels along the gradient direction, the floating-point precision edge extreme coordinates are obtained. This overcomes the limitations of hardware pixel resolution and provides a high-precision contour data foundation for subsequent edge curvature rate calculation and the generation of clean conductor point sets.
[0057] While various embodiments of the invention have been shown and described in this specification, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Many modifications, alterations, and alternatives will occur to those skilled in the art without departing from the spirit and essence of the invention.
Claims
1. A visual inspection method for the internal wiring assembly quality of an electricity metering box, characterized in that, include: S1: Obtain a monochrome grayscale matrix by executing an industrial camera pixel data acquisition and color space conversion algorithm; S2: Based on the pixel gradient and grayscale transition features of the monochrome grayscale matrix, perform quadratic curve interpolation calculation to obtain the set of conductor contour coordinate points; according to the local coordinate distribution of the conductor contour coordinate point set, perform differential forward tangential difference operation to obtain the edge curvature; based on the edge curvature and the global average condition, perform feature data recombination operation to generate a clean conductor point set; S3: Perform least-squares circle fitting calculation based on the pure conductor point set to extract the actual center of the conductor circle; parse the data stored inside the metering box to obtain the terminal reference coordinates as the reference anchor point; Spatial calculations are performed based on the actual center of the conductor and the reference coordinates of the terminal to generate wiring space deviation; S4: Perform tolerance boundary classification judgment based on wiring space deviation and extract wiring defect types; perform closed-loop data mapping based on wiring defect types, output early warning instructions and save records.
2. The visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The process of obtaining the monochrome grayscale matrix includes: The system controls an industrial camera to collect two-dimensional color pixel data of the wiring area inside the metering box online, generating a box wiring image containing the contact features of the wire harness and terminals; the box wiring image is converted from RGB color space to HSV color space, and the image is separated and decoupled into independent monochrome grayscale matrices using preset national standard line color threshold parameters.
3. The visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The set of coordinate points for obtaining the conductor contour includes: Along the horizontal and vertical directions of the monochrome grayscale matrix, obtain the grayscale partial derivative matrix representing the intensity of the edge jump of the conductor. Find the integer point of the local extreme value of the gradient in the grayscale partial derivative matrix. Taking the pixel of the integer extreme value as the center, take the grayscale values of the three coordinate points that are immediately before and after it along the gradient direction. Perform quadratic curve fitting on the grayscale values of these three coordinate points to generate a set of coordinate points of the conductor contour. For each coordinate point in this set, initialize a geometric fitting weight to represent the confidence of its participation in the subsequent circle fitting. The initial value of the geometric fitting weight is uniformly set to the full value of 1.
4. The visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The process of obtaining the edge bending coefficient includes: A local evaluation window is established along the contour coordinate trajectory of the set of contour coordinate points of the conductor. Within the local evaluation window, the angular fluctuation difference between the lines connecting two adjacent sub-pixel coordinate points is calculated to obtain the tangential angular difference value. The absolute values of all tangential angular differences within the local evaluation window are summed and divided by the contour arc length spanned by the window to obtain the directional change per unit arc length, which is used as the edge curvature rate representing the abrupt change in local curvature.
5. A visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The generation of a pure set of wire points includes: The global arithmetic mean of all edge curvature is calculated to generate a curvature abrupt change threshold. The edge curvature of each coordinate point is then compared with this threshold. If the edge curvature is greater than the threshold, the segment is considered to have abrupt change interference. The geometric fitting weight associated with the coordinate point is set to 0 from its initial value, and its coordinate data is removed. If the edge curvature is less than or equal to the threshold, the segment is considered to be a true insulating arc. The geometric fitting weight of the coordinate point is kept at its full value of 1. All high-confidence coordinates with a geometric fitting weight of 1 are summarized, and a pure conductor point set is extracted.
6. A visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The extraction of the actual center of the conductor includes: Substitute the coordinates of each point in the pure conductor point set (i.e., the coordinate data retained from the previous step with a geometric fitting weight of 1) into the quadratic term expression of the quadratic circle fitting model to construct the sum of squared errors from all data points to the theoretical circle boundary. Based on the sum of squared errors function, using the least squares method, calculate the first-order partial derivatives with respect to the horizontal and vertical coordinates of the circle center and set them equal to zero to solve the corresponding residual partial derivative extreme value equations. Analyze the system parameters of the equations through matrix inversion operations and reverse-engineer to extract the actual circle center of the conductor at the conductor crimping point.
7. A visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The process of obtaining the terminal reference coordinates, which serve as the reference anchor point, includes: The computer-aided design document of the metering box engineering assembly standard is retrieved, and the geometric reference parameters stored in the file are parsed through the data communication interface. From the parsed geometric reference parameters, the two-dimensional space horizontal and vertical coordinate sequence of the reference insertion hole of the terminal block is located and obtained, and it is output as the terminal reference coordinate.
8. A visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The generated wiring space deviation includes: Based on the principles of plane analytical geometry, the difference between the projected coordinates of the actual center of the conductor and the reference coordinates of the terminal in the X and Y axes is calculated to generate the axial absolute difference. Using the Euclidean distance formula, the sum of squares of the projected coordinate differences in the horizontal and vertical axes is calculated and the square root is taken to output the center line distance between the two points. The axial absolute difference and the center line distance are combined and packaged together to generate the wiring space deviation.
9. A visual inspection method for the internal wiring assembly quality of an electricity metering box according to claim 1, characterized in that, The types of wiring defects extracted include: Based on the nominal diameter of the insertion hole corresponding to the terminal reference coordinate, a multi-level process tolerance boundary is constructed. The center straight distance contained in the wiring space deviation is extracted, and the center straight distance is compared with the upper limit of acceptance and the upper limit of looseness in turn to determine the assembly error range to which it belongs. If the center straight distance is greater than the upper limit of looseness, it is mapped as a missing or incorrect connection defect. If the center straight distance is greater than the upper limit of acceptance and less than or equal to the upper limit of looseness, it is mapped as a loose wiring defect. If the center straight distance is less than or equal to the upper limit of acceptance, it is mapped as an acceptable assembly. The digital wiring defect type is output according to the above assembly error range mapping rule.
10. A visual inspection method for the internal wiring assembly quality of an energy metering box according to claim 1, characterized in that, The output warning command and saved record include: The wiring defect type is parsed and converted into a bright alarm character message that can be recognized by the workshop control screen. Combined with the device address, a low-level pre-alarm message is generated and sent out as a visual alarm command. The hardware serial number of the current metering box under test is obtained by an industrial barcode scanner. It is merged and packaged with the complete set of wiring defect types into a record entity with a timestamp, generating an assembly quality inspection ledger and storing it in the system's low-level database.
Citation Information
Patent Citations
Bus bar welding detection method and system, electronic device, and medium
CN120746968B
