Wire harness color detection system and method
By combining a dual-camera system with a background plate, images of the wire harness from different angles are acquired, and brightness compensation and cluster analysis are performed. This solves the problems of reflection, shadow and local occlusion in wire harness color detection, and enables accurate identification of monochrome and dual-color wire harnesses, improving the real-time performance and adaptability of the detection.
Patent Information
- Application Number
- CN202611655444.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-26
- Publication Date
- 2026-11-24
AI Technical Summary
Existing wire harness color detection technologies are susceptible to reflections, shadows, and partial obstructions in complex industrial environments, resulting in a high misjudgment rate and difficulty in meeting the needs of high-speed production. In particular, the automatic identification of color layering and primary and secondary colors in two-color or multi-color wire harnesses is difficult.
A dual-camera system is used to acquire images of the wire harness at the same location from different angles. Combined with background cards of various colors and ring lighting, the region of interest is selected by Euclidean distance, and brightness compensation and cluster analysis are performed. The detection parameters are dynamically adjusted to achieve accurate identification of the wire harness color.
It significantly reduced the false positive rate, improved the real-time performance and accuracy of detection, met the needs of high-speed continuous production, shortened the product changeover cycle, and reduced the reliance on operator experience.
Smart Images

Figure CN123160690A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial visual inspection technology, specifically to a wire harness color detection system and method. Background Technology
[0002] Industrial vision inspection technology plays a crucial role in the modern wire harness manufacturing industry, where the accuracy of wire harness color directly affects the safety and reliability of electrical connections. With the increasing level of automated production, higher demands are placed on the real-time performance, accuracy, and adaptability of wire harness color inspection. This is especially true in high-speed continuous extrusion production processes, where rapid identification of the color characteristics of single-color and multi-color wire harnesses is required to ensure product compliance with specifications and effective integration with the manufacturing execution system.
[0003] Currently, wire harness color inspection on production lines mainly relies on manual visual inspection or machine vision systems based on a single camera viewpoint. Manual visual inspection is not only inefficient and labor-intensive, but also highly susceptible to subjective factors, making it difficult to guarantee consistent judgments and failing to meet the demands of high-speed production. While single-camera vision inspection solutions achieve automation, they typically acquire images from a single-angle camera and perform color comparisons using preset color thresholds or simple image processing algorithms.
[0004] However, existing single-camera inspection solutions have significant drawbacks in complex industrial environments. Because the wire harness surface is cylindrical, single-view imaging is highly susceptible to surface reflections, shadows, and partial occlusion, leading to discrepancies between the acquired color data and the actual color, and consequently, misjudgments. Furthermore, lighting conditions in production environments are often unstable. When the background color is similar to the wire harness color, existing technologies struggle to accurately segment the wire harness area, causing detection failures. For two-color or multi-color wire harnesses, traditional methods lack effective color layering and automatic primary / secondary color recognition mechanisms, easily misjudging normal two-color structures as color difference defects. Simultaneously, existing systems typically rely on repeated manual adjustments of detection thresholds and exposure parameters, resulting in long changeover cycles. Moreover, they often rely on single-frame image judgments, making them highly susceptible to false alarms due to external light interference or localized reflections, causing frequent production line downtime and severely impacting production efficiency. Summary of the Invention
[0005] In view of this, this application provides a wire harness color detection system and method, which effectively overcomes the problems of reflection, shadow and partial occlusion caused by the cylindrical surface of the wire harness during single-view shooting.
[0006] According to one aspect of the present invention, a method for detecting the color of a wire harness is provided, comprising: acquiring a first angle image and a second angle image of the same position of the wire harness at different angles, and determining a first region of interest and a second region of interest respectively according to a preset color and a color difference relationship between the color and the background card in the background board; extracting the background mean values of the first region of interest and the second region of interest respectively, and performing brightness compensation on the images according to the difference between the background mean values on both sides to offset the difference in light source or angle; separating the pixels belonging to the wire harness from the compensated first region of interest and second region of interest, and merging the extracted wire harness pixels on both sides; performing cluster analysis on the merged wire harness pixels to extract the color center, and comparing the extracted color center with a preset color standard to determine whether the wire harness color is qualified.
[0007] Optionally, the region of interest is determined based on the color difference between the preset color and the background cards in the background board, including: obtaining the Euclidean distance between the preset color and multiple background cards in the background board in the RGB space; for two-color line bundles, taking the smaller value between the Euclidean distance between the background card and the main color and the Euclidean distance between the background card and the secondary color as the effective Euclidean distance; for single-color line bundles, directly calculating the Euclidean distance between the background card and the main color; selecting the background card with the largest effective Euclidean distance or the largest Euclidean distance as the background card of interest, and determining the region of interest based on its center column coordinates and outer width.
[0008] Optionally, brightness compensation of the image includes: performing multi-point sampling in the background regions of the first region of interest and the second region of interest respectively, calculating the mean values of R, G, and B as background reference values; calculating the difference between the background reference values on both sides as an offset, and using the offset to compensate for the line bundle pixels on one or both sides, so that the two images are at the same brightness reference.
[0009] Optionally, cluster analysis is performed on the merged wire harness pixels, including: setting the number of clusters to 2 for single-color wire harnesses and setting the number of clusters to 3 for two-color wire harnesses; after clustering, sorting the pixels from largest to smallest, removing the cluster with the largest number of pixels as background or noise, and the remaining clusters are the color centers of the wire harness; for two-color wire harnesses, the minimum distance criterion is used to pair the cluster centers with the standard primary and secondary colors one by one.
[0010] Optionally, it also includes a parameter self-learning step: acquiring multiple line bundle images corresponding to multiple exposure values with a fixed step size within the exposure value search range; extracting the line bundle color in the line bundle image corresponding to each exposure value, and calculating the sum of its Euclidean distances to the standard color, selecting the exposure value with the smallest distance as the optimal exposure threshold; continuously acquiring a set number of reference image frames, performing histogram statistics on the R / G / B channel values of each frame, taking the peak position as the center and expanding a fixed fluctuation range to both sides to generate the R / G / B three-channel threshold range.
[0011] Optionally, the method further includes: adding the detection result of each frame to a status queue, dynamically determining the number of frames in the statistical window based on the harness running speed and single-frame processing time, and determining the final product status based on the proportion of unqualified frames in the statistical window. The determination of the final product status based on the proportion of unqualified frames in the statistical window includes: calculating the harness length corresponding to each frame based on the harness running speed and single-frame processing time; calculating the number of frames to be counted in the statistical window based on the harness length corresponding to the statistical window and the harness length corresponding to each frame; when the number of frames in the status queue reaches the number of frames to be counted, calculating the proportion of unqualified frames; if the proportion is greater than or equal to a set unqualified proportion threshold, the product is determined to be unqualified; otherwise, the product is determined to be qualified.
[0012] According to another aspect of the present invention, a wire harness color detection system is provided, comprising: a guiding device for guiding a wire harness to move in its extension direction; an image acquisition device including a first camera and a second camera distributed at a preset angle, the first camera and the second camera being arranged along the axial direction of the wire harness for acquiring first angle images and second angle images of the wire harness at different angles at the same position; a background plate including a first background plate matched with the first camera and a second background plate matched with the second camera, the first background plate and the second background plate each including background cards of multiple colors arranged sequentially along the extension direction of the wire harness; a supplementary lighting device configured in a ring and coaxially arranged with the wire harness for supplementary lighting around the wire harness; and a control device including a storage module. The block and processing module are configured to perform the following operations: acquire first and second angle images of the same position of the wire harness at different angles, and determine a first region of interest and a second region of interest respectively based on the color difference relationship between the preset color and the background card in the background board; extract the background mean values of the first region of interest and the second region of interest respectively, and perform brightness compensation on the image based on the difference between the background mean values on both sides to offset the difference in light source or angle; separate the pixels belonging to the wire harness from the compensated first and second regions of interest, and merge the extracted wire harness pixels on both sides; perform cluster analysis on the merged wire harness pixels to extract the color center, and compare the extracted color center with the preset color standard to determine whether the wire harness color is qualified.
[0013] Optionally, the first background board and the second background board are identical; when determining the first region of interest and the second region of interest, the processing module is specifically configured to: calculate the Euclidean distance between a preset color and multiple background cards in the background board in RGB space, select the background card with the largest Euclidean distance as the background card of interest; obtain the center column coordinates of the background card of interest, and expand outwards by a predetermined width to both sides using the center column coordinates to determine the region of interest of the rectangular area.
[0014] Optionally, when the wire harness includes a primary color and a secondary color, the processing module is specifically configured to: calculate the first RGB Euclidean distance between the background card and the primary color and the second RGB Euclidean distance with the secondary color respectively; take the smaller value between the first RGB Euclidean distance and the second RGB Euclidean distance as the effective Euclidean distance of the background card; and select the background card with the largest effective Euclidean distance as the background card of interest.
[0015] Optionally, when performing brightness compensation, the processing module is specifically configured to: perform multi-point sampling in the background areas of the first region of interest and the second region of interest respectively, calculate the average R, G, and B values of the sampling points as the first background reference value and the second background reference value; calculate the difference between the first background reference value and the second background reference value as the offset; and perform channel-by-channel brightness compensation on the pixels in the first region of interest or the second region of interest according to the offset, so that the brightness reference of the two images is consistent.
[0016] Optionally, when separating pixels belonging to a line bundle, the processing module is specifically configured to: within the first region of interest, calculate the Euclidean distance between the current pixel and the first background reference value pixel by pixel; if the distance is greater than a dynamic threshold, determine that the pixel belongs to the line bundle and retain its original RGB value; otherwise, determine that it is the background; within the second region of interest, calculate the Euclidean distance between the current pixel and the second background reference value pixel by pixel; if the distance is greater than a dynamic threshold, determine that the pixel belongs to the line bundle and retain its original RGB value; otherwise, determine that it is the background.
[0017] Optionally, when identifying the color of the wire harness, the processing module is specifically configured to: merge the wire harness pixels in the extracted first and second regions of interest into an image matrix; call the K-Means algorithm to cluster the image matrix, wherein the number of clusters is set to 2 for monochrome wire harnesses and 3 for two-color wire harnesses; count the number of pixels in each cluster and remove the cluster with the largest number of pixels, and take the color center corresponding to the remaining cluster as the color center of the wire harness.
[0018] Optionally, for two-color wire harnesses, the processing module is further configured to automatically pair the primary and secondary colors using a minimum distance criterion: calculating the Euclidean distance between the cluster center and the primary and secondary colors corresponding to the product type; if the sum of the distance from the first cluster center to the primary color and the distance from the second cluster center to the secondary color is less than the sum of the distance from the first cluster center to the secondary color and the distance from the second cluster center to the primary color, then the first cluster center is assigned as the primary color and the second cluster center as the secondary color; otherwise, the pairings are swapped.
[0019] Optionally, the storage module stores the product model and the corresponding first camera exposure value, second camera exposure value, R / G / B three-channel threshold range of the primary color, and the R / G / B three-channel threshold range of the secondary color for the two-color product; the control device is also configured to trigger a learning step when the new product is first produced to determine the exposure value and the threshold range.
[0020] This invention constructs a complete wire harness color detection system by setting up a guiding device, an image acquisition device, a background plate, a supplementary lighting device, and a control device. The image acquisition device includes a first camera and a second camera distributed at preset angles, capable of being arranged along the axial direction of the wire harness and acquiring images of the same position of the wire harness from different angles. Combined with the ring-shaped supplementary lighting device, it provides real-time omnidirectional supplementary lighting around the wire harness, effectively overcoming the problems of reflection, shadows, and partial occlusion caused by the cylindrical surface of the wire harness during single-view shooting. It obtains more realistic surface color information of the wire harness from multiple perspectives, significantly reducing the false judgment rate.
[0021] Meanwhile, the background board contains background cards of various colors, which are matched with the product models and corresponding exposure values and color threshold ranges stored in the control device. This enables the system to automatically match the optimal detection environment according to the color characteristics of the wire harness, achieving accurate identification and judgment of single-color and dual-color wire harness colors, improving the real-time performance and accuracy of detection, and meeting the needs of high-speed continuous extrusion production.
[0022] Furthermore, by setting multiple colored background cards arranged sequentially along the extension direction of the wire harness in the first and second background boards, and selecting the background card with the largest contrast based on the Euclidean distance between the preset color and the background card color during the detection process as the location basis for the region of interest, a strong color contrast is formed between the wire harness image and the background image. This background selection mechanism based on the principle of maximum color difference solves the technical problem of accurately segmenting the wire harness region when the lighting in the production site is unstable or the background color is similar to that of the wire harness, improving the stability and robustness of the region of interest extraction, and providing a high-quality data foundation for subsequent color clustering analysis.
[0023] Based on this, the processing module in the control device extracts the background from the first and second angle images and compensates for the brightness of the images according to the difference in the average background values on both sides, eliminating brightness deviations caused by inconsistent light source intensity or shooting angle differences between the left and right cameras. By unifying the color data of the two images to the same brightness benchmark, color recognition errors caused by differences in hardware environment are avoided, ensuring the consistency of dual-view image data during merging processing, thereby improving the accuracy of the K-Means clustering algorithm in extracting line bundle pixels.
[0024] Furthermore, a dynamic threshold separation method is employed to separate wire harness pixels, combined with the K-Means clustering algorithm to extract color centers from the merged wire harness pixels. Different clustering numbers are set for single-color and two-color wire harnesses, and automatic pairing of primary and secondary colors is achieved through minimum distance and other criteria. This method eliminates the need for manually pre-setting complex color segmentation rules, adaptively identifies the primary and secondary color structure of wire harnesses, effectively distinguishes normal two-color structures from color difference defects, and solves the problem of traditional methods lacking effective color layering and automatic primary and secondary color recognition mechanisms, thus improving the adaptability to the detection of complex wire harness products.
[0025] Furthermore, by triggering an automatic learning step during the first production run of a new product, multiple wire harness images corresponding to different exposure values are acquired at fixed step sizes within a set exposure search range. The Euclidean distance between the wire harness color and the standard color is calculated to determine the optimal exposure threshold. Simultaneously, the threshold ranges for the R / G / B three channels are generated based on the histogram of continuously acquired reference images. This automated parameter learning mechanism replaces the traditional method that relies on repeated manual adjustments, significantly shortening the product changeover cycle, enabling rapid adaptive adjustment of detection parameters, improving production efficiency, and reducing reliance on operator experience.
[0026] Finally, by adding the detection results of each frame to the status queue and dynamically calculating the number of frames within the statistical window based on the harness running speed and the processing time of a single frame, the final judgment is made based on the proportion of defective frames. A product is only deemed defective when the proportion of defective frames exceeds a set threshold. This sliding window-based statistical judgment mechanism effectively filters out false alarms in a single frame caused by occasional factors such as external light interference and localized reflections, avoiding frequent production line downtime. While ensuring detection accuracy, it significantly improves the continuous operation efficiency of the production line and achieves effective linkage with the manufacturing execution system. Attached Figure Description
[0027] The above and other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which: Figure 1 A perspective view of a wire harness 200 color detection system provided according to an embodiment of this application is shown; Figure 2 A top view of the wire harness 200 color detection system provided in an embodiment of this application is shown; Figure 3 A flowchart of a method for detecting wire harness color according to an embodiment of this application is shown; Figure 4 A schematic diagram of an image 300 acquired by a first camera 121 and a second camera 122 is shown in one embodiment. Detailed Implementation
[0028] The present application will now be described in more detail with reference to the accompanying drawings. In the various drawings, the same elements are indicated by similar reference numerals. For clarity, the various parts in the drawings are not drawn to scale. Furthermore, some well-known parts may not be shown.
[0029] Many specific details of this application, such as the structure, materials, dimensions, processing techniques, and methods of the devices, are described below to provide a clearer understanding of the application. However, as those skilled in the art will understand, this application may be implemented without adhering to these specific details.
[0030] Furthermore, certain terms are used in this patent specification and claims to refer to specific components. Those skilled in the art will understand that hardware manufacturers may use different names to refer to the same component. This patent specification and claims do not distinguish components based on differences in name, but rather on differences in function.
[0031] Furthermore, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0032] This application may be presented in various forms, some of which will be described below.
[0033] Figure 1 A perspective view of a wire harness 200 color detection system provided according to an embodiment of this application is shown. Figure 2 A top view of the wire harness 200 color detection system provided in an embodiment of this application is shown, as follows: Figure 1 and Figure 2 As shown, the detection system 100 includes a guiding device 110, an image acquisition device 120, a background plate 130, a supplementary lighting device 150, and a control device (not shown in the figure).
[0034] The guide device 110 is used to guide the wire harness 200 to move at a predetermined speed in its extension direction.
[0035] The image acquisition device 120 includes a first camera 121 and a second camera 122 distributed at a preset angle. The first camera 121 and the second camera 122 are arranged along the axial direction of the wire harness 200, so that the first camera 121 and the second camera 122 acquire images of the wire harness 200 at different angles from the same position. The first camera 121 is used to acquire a first angle image of the wire harness 200, and the second camera 122 is used to acquire a second angle image of the wire harness 200. The preset angle is, for example, 90° to 270°. In one embodiment, the preset angle is 135°.
[0036] Background panel 130 includes a first background panel 131 matched with a first camera 121 and a second background panel 132 matched with a second camera 122. The lens of the first camera 121 faces the cable harness 200 and the first background panel 131, such that the first angle image includes both the cable harness 200 and the first background panel 131. The first background panel 131 includes background cards 130a of various colors arranged sequentially along the extension direction of the cable harness 200, and the first angle image includes all of the background cards 130a of the first background panel 131. Correspondingly, the lens of the second camera 122 faces the cable harness 200 and the second background panel 132, such that the first angle image includes both the cable harness 200 and the second background panel 132. The second background panel 132 includes background cards 130a of various colors arranged sequentially along the extension direction of the cable harness 200, and the second angle image includes all of the background cards 130a of the second background panel 132. It is worth noting that the first background panel 131 and the second background panel 132 are identical. In one embodiment, the first background board 131 and the second background board 132 respectively include background cards 130a in black, white, blue, green and red.
[0037] The supplementary lighting device 150 includes a first supplementary lighting device 151 disposed on a first side of the image acquisition device 120 and a second supplementary lighting device 152 disposed on a second side of the image acquisition device 120. The first supplementary lighting device 151 and the second supplementary lighting device 152 are arranged in a ring, and the ring-shaped first supplementary lighting device 151 and the second supplementary lighting device 152 are coaxially arranged with the wire harness 200. In other words, the wire harness 200 passes through the ring-shaped first supplementary lighting device 151 and the second supplementary lighting device 152 in sequence, so that the first supplementary lighting device 151 and the second supplementary lighting device 152 can provide real-time all-round supplementary lighting around the wire harness 200.
[0038] The control device includes a storage module and a processing module. For monochrome products, the storage module stores the product model and the corresponding exposure values of the first camera 121, the second camera 122, and the R / G / B three-channel threshold range of the primary color. For two-color products, the storage module stores the product model and the corresponding exposure values of the first camera 121, the second camera 122, the R / G / B three-channel threshold range of the primary color, and the R / G / B three-channel threshold range of the secondary color.
[0039] The threshold ranges for the primary color's R / G / B three channels and the secondary color's R / G / B three channels (for two-color products only) are set according to product requirements. The exposure values for the first camera (121) and the second camera (122), as well as the threshold ranges for the primary color's R / G / B three channels and the secondary color's R / G / B three channels (for two-color products only), for each product model are obtained through learning.
[0040] Specifically, the learning process for the first production run of a new product is either automatically or manually triggered to obtain the exposure thresholds for the first camera 121 and the second camera 122 corresponding to that product model. The exposure value learning process includes: S001: Acquire multiple line harness images corresponding to multiple exposure values within the exposure value search range with a fixed step size; S002: Extract the color of the wire bundle in the wire bundle image corresponding to each exposure value, calculate the sum of its Euclidean distances to the standard color, and select the exposure value with the smallest distance as the optimal exposure threshold. S003: Continuously acquire a set number of reference image frames, perform histogram statistics on the R / G / B channel values of each frame, take the peak position as the center and expand a fixed fluctuation range to both sides to generate the R / G / B three-channel threshold range.
[0041] In step S001, the exposure search range [expmin, expmax] is estimated based on the Euclidean distance between the color of the new product's wiring harness 200 and a preset color (e.g., black). Specifically, the brighter the color of the wiring harness 200, the closer the determined lower exposure limit is to the minimum value of the exposure parameter; conversely, the darker the color of the wiring harness 200, the closer the determined upper exposure limit is to the maximum value of the exposure parameter.
[0042] Within the exposure value search range [expmin, expmax], multiple exposure values are acquired with a fixed step size. These multiple exposure values include, for example, exp1, exp2, ..., expn. The supplementary lighting device 150 is adjusted sequentially according to these multiple exposure values, and an image of the line bundle 200 corresponding to each exposure value is acquired. For example, the exposure value of the supplementary lighting device 150 is first set to exp1, and the first image of the line bundle 200 is captured; then, the exposure value of the supplementary lighting device 150 is set to exp2, and the second image of the line bundle 200 is captured; the above steps are repeated until the exposure value of the supplementary lighting device 150 is set to expn, and the image of the nth line bundle 200 is captured.
[0043] In step S002, the colors of the wire harness 200 in the first wire harness 200 image, the colors of the wire harness 200 in the second wire harness 200 image, ..., the colors of the wire harness 200 in the nth wire harness 200 image are extracted sequentially. In one embodiment, color clustering is performed on multiple wire harness 200 images to extract the colors of the wire harness 200 in the multiple wire harness 200 images.
[0044] In step S003, the sum of the Euclidean distances between the colors of the line harnesses 200 and the standard primary / secondary colors in multiple line harness 200 images is calculated, and the exposure value corresponding to the line harness 200 image with the smallest distance is the exposure threshold BestEXP. Both the first camera 121 and the second camera 122 perform the above steps to obtain the exposure threshold BestEXP1 corresponding to the first camera 121 and the exposure threshold BestEXP2 corresponding to the second camera 122.
[0045] The color threshold learning steps include: continuously acquiring a set number of frames of the reference image, performing histogram statistics on the R / G / B channel values of each frame, taking the peak position as the center, and expanding a fixed fluctuation range DValue to both sides to form the R / G / B three-channel threshold range of the main color and the R / G / B three-channel threshold range of the secondary color (for two-color products only). For example, the R / G / B three-channel threshold range of the main color is [MinThreshold1, MaxThreshold1], and the R / G / B three-channel threshold range of the secondary color (for two-color products only) is [MinThreshold2, MaxThreshold2].
[0046] During the inspection of the wire harness 200, the appropriate exposure threshold is selected according to the model of the wire harness 200, the guide device 110 guides the wire harness 200 to move at a predetermined speed in its extension direction, and the first camera acquires the first angle image and the second angle image of the cable.
[0047] Figure 3 A flowchart of a method for detecting wire harness color according to an embodiment of this application is shown, as follows: Figure 3As shown, the processing module is configured to perform the following steps to complete the color detection of wire harness 200: S110: Acquire first and second angle images of the same position of the wire harness at different angles, and determine the first and second regions of interest respectively based on the color difference relationship between the preset color and the background card in the background board; S120: Extract the background mean values of the first region of interest and the second region of interest respectively, and perform brightness compensation on the image based on the difference between the background mean values on both sides to offset the difference in light source or angle. S130: Separate the pixels belonging to the line bundle from the compensated first and second regions of interest, and merge the line bundle pixels extracted from both sides; S140: Perform cluster analysis on the merged wire harness pixels to extract the color center, and compare the extracted color center with the preset color standard to determine whether the wire harness color is qualified.
[0048] The processing module is configured to perform the following steps to acquire the regions of interest in the first angle image and the second angle image, respectively.
[0049] S111: Obtain the Euclidean distance in RGB space between the preset color and multiple background cards 130a in the background board 130; for a two-color line bundle, take the smaller value between the Euclidean distance between the background card and the main color and the Euclidean distance between the background card and the auxiliary color as the effective Euclidean distance; for a single-color line bundle, directly calculate the Euclidean distance between the background card and the main color. S112: Select the background card with the largest effective Euclidean distance or the largest Euclidean distance as the background card of interest, and determine the region of interest by its center column coordinates and outer width.
[0050] The first angle image and the second angle image correspond to images of the same wire harness 200 from different angles. The first camera 121 and the second camera 122 simultaneously acquire images of the same wire harness 200 from different angles, which can obtain surface color information of the wire harness 200 from different perspectives and effectively reduce misjudgments caused by single-view reflection, shadows and occlusion.
[0051] Figure 4 A schematic diagram of an image 300 acquired by a first camera 121 and a second camera 122 is shown in one embodiment, as follows: Figure 3 As shown, the first angle image and the second angle image respectively include a rear background plate 130 image and a front wire harness 200 image. The background plate 130 image includes multiple background cards 130a images arranged in sequence. The wire harness 200 image extends in the arrangement direction of the multiple background cards 130a to form a color contrast with the multiple background cards 130a.
[0052] Step S111, which involves obtaining the Euclidean distances in RGB space between the preset colors and the multiple background cards 130a in the background board 130, includes: The Euclidean distances in RGB space between the preset colors and multiple background cards 130a in the background board 130 are obtained respectively. The background card 130a with the largest Euclidean distance is selected as the background card 130a of interest, so that the line harness 200 and the background card 130a of interest form the maximum contrast.
[0053] The wire harness 200 can include one color, i.e., the primary color; or it can include two colors, i.e., a primary color and a secondary color. When including one color, all background cards 130a in the background panel 130 are traversed, and the Euclidean distances between multiple background cards 130a and the primary color of the wire harness 200 in RGB space are calculated. The background card 130a with the largest Euclidean distance is selected as the background card of interest 130a-1. When including both a primary and secondary color, the first RGB Euclidean distance between one of the background cards 130a in the background panel 130 and the primary color is calculated first, and then the second RGB Euclidean distance between that background card 130a and the secondary color is calculated. The smaller of the first RGB Euclidean distance and the second RGB Euclidean distance is taken as the effective Euclidean distance MinColorDist of that background card 130a. The effective Euclidean distance MinColorDist of multiple background cards 130a in the background board 130 is obtained in sequence. Then, it is determined which background card 130a has the largest effective Euclidean distance MinColorDist, indicating that the contrast is relatively large. The background card 130a with the largest effective Euclidean distance MinColorDist is used as the background card of interest 130a-1.
[0054] For background card 130a-1 of interest, its center column coordinate y0 is obtained. Then, its center column coordinate y0 is expanded outward by a predetermined width to the left and right to determine the region of interest, which is a rectangular region. The region of interest in the first angle image is designated as the first region of interest, and the region of interest in the second angle image is designated as the second region of interest.
[0055] It is worth noting that the preset color is determined based on the model of the wire harness.
[0056] In step S120, the background mean values of the first region of interest and the second region of interest are extracted respectively, and brightness compensation is performed on the image based on the difference between the background mean values on both sides to offset the difference in light source or angle. Specifically, this includes: S121: Perform multi-point sampling in the background regions of the first region of interest and the second region of interest respectively, and calculate the mean values of R, G and B as background reference values; S122: Calculate the difference between the background reference values on both sides as the offset, and use the offset to compensate the line bundle pixels on one or both sides so that the two images are at the same brightness reference.
[0057] In step S121, to obtain a stable first background reference value for the first region of interest and a stable second background reference value for the second region of interest, multi-point sampling is performed in the background area of the first region of interest, and the average R, G, and B values of multiple sampling points are calculated as the first background reference value. Similarly, multi-point sampling is performed in the background area of the second region of interest, and the average R, G, and B values of multiple sampling points are calculated as the second background reference value. In one embodiment, for example, multi-point sampling is performed at the top 7 rows and bottom 7 rows of the region of interest, for example, setting 14 sampling points, and calculating the average R, G, and B values of the 14 sampling points as the background reference value for that side.
[0058] In step S122, the difference between the first background mean of the first region of interest and the second background mean of the second region of interest is calculated. This difference is then used as an offset to perform brightness compensation on one or both of the first and second regions of interest. For example, if the background of the first region of interest is darker (mean value 80) and the background of the second region of interest is brighter (mean value 100), then the difference off = 100 - 80 = 20. Each pixel in the second region of interest is then subtracted by 20 to make the brightness of the second region of interest consistent with the average brightness of the second region of interest.
[0059] This application embodiment includes a brightness compensation step, which uses the difference in the RGB mean values of the same background board 130 in the left and right images as the offset to perform channel-by-channel compensation on the line bundle 200 pixels on one or both sides, so that the colors captured by the first camera 121 and the second camera 122 are on the same brightness reference, avoiding the influence of the difference in light source or angle on both sides on the subsequent K-Means clustering and color determination.
[0060] In step S130, pixels belonging to the line bundle are separated from the compensated first and second regions of interest, and the extracted line bundle pixels from both sides are merged.
[0061] In this step, the Euclidean distance between the current pixel and the first background reference value is calculated pixel by pixel within the first region of interest. If the distance is greater than the dynamic threshold v_distarg, the pixel is determined to belong to beam 200 and its original RGB value is retained; otherwise, it is determined to be background and filled with a background color that contrasts significantly with the beam 200 color. Similarly, the Euclidean distance between the current pixel and the second background reference value is calculated pixel by pixel within the second region of interest. If the distance is greater than the dynamic threshold v_distarg, the pixel is determined to belong to beam 200 and its original RGB value is retained; otherwise, it is determined to be background and filled with a background color that contrasts significantly with the beam 200 color. Afterward, the beam 200 pixels extracted from the first region of interest and the beam 200 pixels extracted from the second region of interest are merged into an image matrix.
[0062] In step S140, the color of the wire harness 200 is identified and color matching is performed.
[0063] In this step, OpenCV's K-Means algorithm is used for clustering. For a single-color line bundle of 200, the cluster number k=2; for a two-color line bundle of 200, k=3. After clustering, the number of pixels in each cluster is counted and sorted from largest to smallest. The cluster with the largest number of pixels is considered background / noise and removed. The remaining clusters are the color centers for the 200 line bundles. The cluster centers are returned in Vec3b format for subsequent primary / secondary color pairing.
[0064] For the single-color wire harness 200, the first color of the clustering result is directly taken as the detection result. For the two-color wire harness 200, the Euclidean distance between the cluster center and the primary and secondary colors corresponding to the product type is compared, and the minimum distance criterion is used to complete the one-to-one correspondence: if (distance from cluster center 1 to primary color + distance from cluster center 2 to secondary color) is less than (distance from cluster center 1 to secondary color + distance from cluster center 2 to primary color), then cluster center 1 is assigned as the primary color and cluster center 2 as the secondary color; otherwise, the pairings are swapped.
[0065] The R, G, and B channel values of the paired primary (and secondary) colors are compared with the threshold ranges of the R / G / B channels of the primary (and secondary) colors, respectively. The frame is considered acceptable only when all channel values fall within the corresponding threshold range.
[0066] Furthermore, the detection results of each frame are added to the status queue, and the number of frames in the statistical window is dynamically determined based on the harness running speed and the processing time per frame. The final product status is determined based on the proportion of unqualified frames in the statistical window, specifically including: S151: Calculate the length of the wire harness corresponding to each frame based on the wire harness running speed and the processing time of a single frame; S152: Calculate the number of frames to be counted within the statistical window based on the wire bundle length corresponding to the statistical window and the wire bundle length corresponding to each frame; S153: When the number of frames in the status queue reaches the number of frames to be counted, calculate the percentage of unqualified frames. If the percentage is greater than or equal to the set unqualified percentage threshold, the product is determined to be unqualified; otherwise, the product is determined to be qualified.
[0067] In one embodiment, the detection result (pass or fail) of each frame is added to a state queue. When there are enough frames in the state queue, the percentage of fail frames (NGPercentage) within the window is calculated. If the percentage of fail frames (NGPercentage) is greater than or equal to the set fail percentage threshold (MinNGPer), then ProductState is ultimately determined to be fail; otherwise, it is determined to be pass.
[0068] The methods for obtaining the frame number in the state queue include: Based on the operating speed of harness 200 and the processing time per frame, calculate the length of harness 200 for each frame: in, For a wiring harness operating at a speed of 200, The processing time per frame, Each frame corresponds to a wire bundle of length 200. Wherein, Typically measured in milliseconds, divided by 1000 for conversion of completion time units, makes... This indicates the length of the 200-unit harness corresponding to this frame.
[0069] Get the number of frames to be counted within the statistics window: in, To count the number of frames within the statistics window, For the length of the wire harness corresponding to the statistical window, The length of the wire harness corresponding to each frame is 200.
[0070] In other embodiments, a frame is considered unqualified if even a single frame is not qualified.
[0071] This invention constructs a complete color detection system for a wire harness 200 by setting up a guiding device 110, an image acquisition device 120, a background plate 130, a supplementary lighting device 150, and a control device. The image acquisition device 120 includes a first camera 121 and a second camera 122 distributed at preset angles. These cameras are arranged along the axial direction of the wire harness 200 and can acquire images of the same position of the wire harness 200 from different angles. Combined with the annular supplementary lighting device 150, real-time omnidirectional supplementary lighting is provided around the wire harness 200, effectively overcoming the problems of reflection, shadows, and partial occlusion caused by the cylindrical surface of the wire harness 200 during single-view shooting. This allows for the acquisition of more realistic surface color information of the wire harness 200 from multiple perspectives, significantly reducing the misjudgment rate.
[0072] Meanwhile, the background board 130 includes background cards 130a of various colors, which are matched with the product models and corresponding exposure values and color threshold ranges stored in the control device. This enables the system to automatically match the optimal detection environment according to the color characteristics of the wire harness 200, achieving accurate identification and judgment of the colors of single-color and dual-color wire harnesses 200, improving the real-time performance and accuracy of detection, and meeting the needs of high-speed continuous extrusion production.
[0073] Furthermore, by setting multiple colored background cards 130a arranged sequentially along the extension direction of the wire harness 200 in the first background plate 131 and the second background plate 132, and selecting the background card 130a with the largest contrast based on the Euclidean distance between the preset color and the color of the background card 130a as the location basis for the region of interest during the detection process, a strong color contrast is formed between the wire harness 200 image and the background image. This background selection mechanism based on the principle of maximum color difference solves the technical problem of difficulty in accurately segmenting the wire harness 200 region when the lighting in the production site is unstable or the background color is similar to that of the wire harness 200, improves the stability and robustness of the region of interest extraction, and provides a high-quality data foundation for subsequent color clustering analysis.
[0074] Based on this, the processing module in the control device extracts the background from the first and second angle images and compensates for the brightness of the images according to the difference in the average background values on both sides, eliminating brightness deviations caused by inconsistent light source intensity or shooting angle differences between the left and right cameras. By unifying the color data of the two images to the same brightness benchmark, color recognition errors caused by differences in hardware environment are avoided, ensuring the consistency of dual-view image data during merging processing, thereby improving the accuracy of the K-Means clustering algorithm in extracting 200 pixels of the line bundle.
[0075] Furthermore, a dynamic threshold separation method is employed to separate the 200 pixels of the wire harness, combined with the K-Means clustering algorithm to extract the color center of the merged 200 pixels. Different clustering numbers are set for single-color and two-color wire harnesses 200, and automatic pairing of primary and secondary colors is completed through minimum distance and correlation criteria. This method eliminates the need for manually pre-setting complex color segmentation rules, adaptively identifies the primary and secondary color structure of the wire harness 200, effectively distinguishes normal two-color structures from color difference defects, solves the problem of traditional methods lacking effective color layering and automatic primary and secondary color recognition mechanisms, and improves the adaptability to the detection of complex wire harness 200 products.
[0076] Furthermore, by triggering an automatic learning step during the first production run of a new product, multiple images of the wire harness 200 corresponding to different exposure values are acquired at fixed step sizes within a set exposure search range. The Euclidean distance between the wire harness 200 color and the standard color is calculated to determine the optimal exposure threshold. Simultaneously, the threshold ranges for the R / G / B three channels are generated based on the histogram of continuously acquired reference images. This automated parameter learning mechanism replaces the traditional method that relies on repeated manual adjustments, significantly shortening the product changeover cycle, enabling rapid adaptive adjustment of detection parameters, improving production efficiency, and reducing reliance on operator experience.
[0077] Finally, by adding the detection results of each frame to the status queue and dynamically calculating the number of frames in the statistical window based on the running speed of the harness 200 and the processing time of a single frame, the proportion of unqualified frames is used as the final judgment criterion. A product is only deemed unqualified when the proportion of unqualified frames exceeds a set threshold. This sliding window-based statistical judgment mechanism effectively filters out false alarms in a single frame caused by occasional factors such as external light interference and local reflections, avoiding frequent production line shutdowns. While ensuring detection accuracy, it significantly improves the continuous operation efficiency of the production line and achieves effective linkage with the manufacturing execution system. As described above, these embodiments do not exhaustively describe all details, nor do they limit this application to only the specific embodiments described. Obviously, many modifications and variations can be made based on the above description. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to make good use of this application and modifications based on it. This application is limited only by the claims and their full scope and equivalents.
Claims
1. A method for detecting the color of a wire harness, characterized in that, include: Acquire first and second angle images of the same position of the wire harness at different angles, and determine the first and second regions of interest respectively based on the color difference relationship between the preset color and the background card in the background board; The background mean values of the first region of interest and the second region of interest are extracted respectively, and the brightness of the image is compensated based on the difference between the background mean values on both sides to offset the difference in light source or angle. Pixels belonging to the line bundle are separated from the compensated first and second regions of interest, and the line bundle pixels extracted from both sides are merged. Cluster analysis is performed on the merged wire harness pixels to extract color centers, and the extracted color centers are compared with preset color standards to determine whether the wire harness color is qualified.
2. The wire harness color detection method according to claim 1, characterized in that, The region of interest is determined based on the color difference between the preset color and the background card in the background board, including: Obtain the Euclidean distances in RGB space between the preset colors and multiple background cards in the background panel; For two-color line bundles, the smaller of the Euclidean distance between the background card and the main color and the Euclidean distance between the background card and the secondary color is taken as the effective Euclidean distance; for single-color line bundles, the Euclidean distance between the background card and the main color is calculated directly. Select the background card with the largest effective Euclidean distance or the largest Euclidean distance as the background card of interest, and determine the region of interest by its center column coordinates and outer width.
3. The wire harness color detection method according to claim 1, characterized in that, Brightness compensation for the image includes: Multi-point sampling is performed in the background regions of the first region of interest and the second region of interest, and the mean values of R, G, and B are calculated as background reference values. The difference between the background reference values on both sides is calculated as the offset, and the offset is used to compensate the line bundle pixels on one or both sides so that the two images are at the same brightness reference.
4. The wire harness color detection method according to claim 1, characterized in that, Cluster analysis was performed on the merged line bundle pixels, including: The number of clusters is set to 2 for single-color wire harnesses and 3 for two-color wire harnesses. After clustering, sort the clusters by the number of pixels from largest to smallest, remove the cluster with the largest number of pixels as background or noise, and the remaining clusters are the color centers of the line bundle. For two-color wire harnesses, the minimum distance criterion is used to pair the cluster centers with the standard primary and secondary colors one by one.
5. The wire harness color detection method according to claim 1, characterized in that, It also includes parameter self-learning steps: Within the exposure value search range, acquire line bundle images corresponding to multiple exposure values with a fixed step size; Extract the color of the line bundle in the line bundle image corresponding to each exposure value, calculate the sum of its Euclidean distances to the standard color, and select the exposure value with the smallest distance as the optimal exposure threshold. A set number of reference image frames are continuously acquired. Histogram statistics are performed on the R / G / B channel values of each frame. The peak position is taken as the center and a fixed fluctuation range is extended to both sides to generate the threshold range of the R / G / B three channels.
6. The wire harness color detection method according to claim 1, characterized in that, Also includes: The detection results of each frame are added to the status queue, and the number of frames in the statistical window is dynamically determined based on the harness running speed and the processing time of a single frame. The final product status is determined based on the proportion of unqualified frames in the statistical window. The final product status is determined based on the percentage of non-compliant frames within the statistical window, including: The length of the wire harness corresponding to each frame is calculated based on the wire harness running speed and the processing time of a single frame. Calculate the number of frames to be counted within the statistical window based on the wire length corresponding to the statistical window and the wire length corresponding to each frame; When the number of frames in the status queue reaches the number of frames to be counted, the percentage of unqualified frames is calculated. If the percentage is greater than or equal to the set unqualified percentage threshold, the product is determined to be unqualified; otherwise, the product is determined to be qualified.
7. A wire harness color detection system, characterized in that, include: A guiding device for guiding the wire harness to move in its extending direction; An image acquisition device includes a first camera and a second camera distributed at a preset angle. The first camera and the second camera are arranged along the axis of the wire harness to acquire first angle images and second angle images of the wire harness at the same position at different angles. The background board includes a first background board matched with the first camera and a second background board matched with the second camera. Both the first background board and the second background board include background cards of various colors arranged sequentially along the extension direction of the wire harness. A supplemental lighting device, configured as a ring and coaxially aligned with the wire harness, is used to provide supplemental lighting around the wire harness; and The control device includes a storage module and a processing module, the processing module being configured to perform the following operations: Acquire first and second angle images of the same position of the wire harness at different angles, and determine the first and second regions of interest respectively based on the color difference relationship between the preset color and the background card in the background board; The background mean values of the first region of interest and the second region of interest are extracted respectively, and the brightness of the image is compensated based on the difference between the background mean values on both sides to offset the difference in light source or angle. Pixels belonging to the line bundle are separated from the compensated first and second regions of interest, and the line bundle pixels extracted from both sides are merged. Cluster analysis is performed on the merged wire harness pixels to extract color centers, and the extracted color centers are compared with preset color standards to determine whether the wire harness color is qualified.
8. The wire harness color detection system according to claim 7, characterized in that, The first background panel and the second background panel are identical; the processing module is specifically configured to determine the first region of interest and the second region of interest as follows: Calculate the Euclidean distance between the preset color and multiple background cards in the background board in the RGB space, and select the background card with the largest Euclidean distance as the background card of interest; Obtain the center column coordinates of the background card of interest, and expand outwards by a predetermined width to both sides using the center column coordinates to determine the rectangular region of interest.
9. The wire harness color detection system according to claim 8, characterized in that, When the line harness includes a primary color and a secondary color, the processing module is specifically configured to select the background card of interest as follows: Calculate the first RGB Euclidean distance between the background card and the primary color, and the second RGB Euclidean distance between the background card and the secondary color, respectively; The smaller value between the first RGB Euclidean distance and the second RGB Euclidean distance is taken as the effective Euclidean distance of the background card; Choose the background card with the largest effective Euclidean distance as the background card of interest.
10. The wire harness color detection system according to claim 7, characterized in that, When performing brightness compensation, the processing module is specifically configured as follows: Multi-point sampling is performed in the background regions of the first region of interest and the second region of interest, and the mean values of R, G, and B of the sampling points are calculated as the first background reference value and the second background reference value. The difference between the first background reference value and the second background reference value is calculated as the offset; Based on the offset, perform channel-by-channel brightness compensation on the pixels in the first region of interest or the second region of interest to make the brightness reference of the two images consistent.
11. The wire harness color detection system according to claim 7, characterized in that, When separating pixels belonging to a line bundle, the processing module is specifically configured as follows: Within the first region of interest, the Euclidean distance between the current pixel and the first background reference value is calculated pixel by pixel. If the distance is greater than the dynamic threshold, the pixel is determined to belong to the line bundle and its original RGB value is retained; otherwise, it is determined to be the background. Within the second region of interest, the Euclidean distance between the current pixel and the second background reference value is calculated pixel by pixel. If the distance is greater than the dynamic threshold, the pixel is determined to belong to the line bundle and its original RGB value is retained; otherwise, it is determined to be the background.
12. The wire harness color detection system according to claim 7, characterized in that, When identifying the color of the wire harness, the processing module is specifically configured as follows: The extracted line bundle pixels from the first and second regions of interest are merged into an image matrix; The K-Means algorithm is used to cluster the image matrix, where the number of clusters for monochrome line bundles is set to 2, and the number of clusters for duocolor line bundles is set to 3. Count the number of pixels in each cluster and remove the cluster with the largest number of pixels. Use the color center of the remaining cluster as the color center of the wire harness.
13. The wire harness color detection system according to claim 12, characterized in that, For two-color wire harnesses, the processing module is also configured to automatically pair the primary and secondary colors based on minimum distance and criteria: Calculate the Euclidean distance between the cluster centers and the primary and secondary colors corresponding to the product types; If the sum of the distances from the first cluster center to the primary color and the second cluster center to the secondary color is less than the sum of the distances from the first cluster center to the secondary color and the second cluster center to the primary color, then the first cluster center is assigned to the primary color and the second cluster center to the secondary color; otherwise, the pairs are swapped.
14. The wire harness color detection system according to claim 7, characterized in that, The storage module stores the product model and the corresponding exposure values of the first camera, the second camera, the R / G / B three-channel threshold range of the main color, and the R / G / B three-channel threshold range of the auxiliary color for the two-color product. The control device is also configured to trigger a learning step when a new product is first produced to determine the exposure value and the threshold range.
