Automatic counting and subpackaging control system based on machine vision
By designing an automatic counting subcontract control system based on machine vision including image acquisition, processing, segmentation, analysis and subcontract control units, the existing system has solved the problems of noise interference, inaccurate edge detection, low accuracy of material type identification and inflexible subcontract control, and achieved high-precision material counting and subcontract control, meeting the efficient and accurate needs of modern industrial production.
Patent Information
- Application Number
- CN202510592773.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-06-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing machine vision-based material counting and subcontracting system has problems such as noise interference, inaccurate edge detection, low accuracy of material type identification and inflexible subcontracting control in the image acquisition, processing and segmentation process, which is difficult to meet the efficient and accurate needs of modern industrial production.
An automatic counting subcontracting control system based on machine vision is designed, including image acquisition, processing, segmentation, analysis and subcontracting control units. By converting the color image into a grayscale image, and using the median or mean filtering algorithm to remove noise, using the Canny edge detection algorithm for image segmentation, extracting material shape features and identifying material type through feature matching algorithm, and finally quantities statistics and subcontracting control are performed based on material type and shape features.
It realizes high-precision image acquisition and processing, accurate material edge detection and shape feature extraction, improves the accuracy of material type identification and flexibility of subcontract control, and meets the efficient and accurate requirements of modern industrial production for material counting and subcontracting.
Smart Images

Figure CN120191584A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of subcontracting control, and particularly to an automatic counting and subcontracting control system based on machine vision. Background Art
[0002] In the modern industrial production process, the counting and subcontracting links of materials are crucial, and their efficiency and accuracy directly affect the production efficiency and product quality of enterprises. Traditional material counting and subcontracting work mainly rely on manual operation. However, manual operation has many drawbacks. On the one hand, long-term repetitive labor is extremely likely to cause fatigue of the staff, which in turn leads to problems such as counting errors and inaccurate subcontracting ratios, reducing the precision and reliability of production. On the other hand, the speed of manual operation is limited, making it difficult to meet the large-scale and high-efficiency production requirements, resulting in an extended production cycle and increased enterprise costs.
[0003] With the continuous progress of technology, machine vision technology has gradually been applied to the industrial production field. Some existing material counting and subcontracting systems based on machine vision still expose many problems in practical applications. In the image acquisition link of some systems, affected by factors such as environmental light and material surface characteristics, the quality of the collected images is poor, and there is a serious problem of noise interference, which directly affects the subsequent image analysis and processing results. In image processing, common image conversion and denoising algorithms cannot effectively remove the noise under complex backgrounds, resulting in the loss of image information and affecting the extraction of material features. In the image segmentation stage, existing edge detection algorithms cannot accurately determine the edges of materials, resulting in inaccurate extraction of material shape features and affecting the recognition of material types. In addition, existing systems lack effective feature matching algorithms in the material classification and recognition link, and the recognition accuracy is low, making it difficult to quickly and accurately recognize various types of materials. In the subcontracting control link, due to the lack of comprehensive analysis of material types and shape features, it is impossible to flexibly perform accurate packaging allocation according to the preset subcontracting rules.
[0004] Therefore, developing a control system that can overcome the above problems, achieve high-precision image acquisition and processing, accurately identify material types, and efficiently complete automatic counting and subcontracting of materials according to preset rules has become an urgent technical problem in this field. Summary of the Invention
[0005] The purpose of the present invention is to provide an automatic counting and subcontracting control system based on machine vision, which solves the technical problems proposed in the background art.
[0006] The purpose of the present invention can be achieved through the following technical solutions:
[0007] An automatic counting and subcontracting control system based on machine vision includes:
[0008] The image acquisition unit obtains the sub-packaging material image of the material to be sub-packaged through an industrial camera;
[0009] The image processing unit is used to convert the acquired color sub-packaging material image into a grayscale image, and at the same time uses a median filtering algorithm or an average filtering algorithm to remove the noise in the grayscale image;
[0010] The image segmentation unit uses the Canny edge detection algorithm to calculate the Sobel gradient after smoothing the image through Gaussian filtering, determines the edge pixels through non-maximum suppression and double-threshold processing, and then optimizes the edge connectivity through dilation and erosion operations to finally generate an edge image;
[0011] The image analysis unit is used to process the edge detection result output by the image segmentation unit, first extract the shape features of the material, and then classify and identify the material type based on the feature matching algorithm;
[0012] The sub-packaging control unit performs quantity statistics based on the material type and shape features of the material to be sub-packaged, and completes the packaging allocation according to the preset sub-packaging rules; among them, the sub-packaging rules refer to the allocation standards for material packaging, and specifically stipulate the different types of materials and their corresponding quantity ratios included in each packaging unit.
[0013] As a further solution of the present invention: The method of the image processing unit is as follows:
[0014] Obtain the RGB values of the color sub-packaging material image;
[0015] Then through: H = 0.299×R + 0.587×G + 0.114×B
[0016] Calculate the grayscale value H of the corresponding grayscale image of the sub-packaging material image;
[0017] In the formula, R, G, and B are the values of the red, green, and blue channels in the color sub-packaging material image respectively;
[0018] The method of using the median filtering algorithm to remove the noise in the grayscale image is as follows:
[0019] Select a pixel point, and use a specified neighborhood N×N, and obtain the grayscale values of each pixel point in the neighborhood of this pixel point;
[0020] Sort the grayscale values of each pixel point in the neighborhood from small to large, and then take the median value as the new grayscale value of this pixel point;
[0021] The method of using the average filtering algorithm to remove the noise in the grayscale image is as follows:
[0022] Select a pixel point, and use a specified neighborhood N×N, and obtain the gray values of each pixel point within the neighborhood of this pixel point;
[0023] Calculate the average value of the gray values corresponding to all pixel points within the neighborhood, and use this average value as the new gray value of this pixel point.
[0024] As a further solution of the present invention: the method of the image segmentation unit is as follows:
[0025] First, use a Gaussian filter to smooth the grayscale image, and then use the Sobel operator to calculate the gradient values of the image in the x and y directions respectively;
[0026] Then perform non-maximum suppression on the gradient magnitude, only retaining the pixels with the local gradient maximum; at the same time, for each pixel, check the two adjacent pixels in its gradient direction. When the gradient magnitude of this pixel is not the local maximum, set its gradient magnitude to 0;
[0027] Next, determine the edges according to the preset low threshold and high threshold;
[0028] When the gradient magnitude of a pixel is greater than the high threshold, this pixel is determined to be a strong edge pixel;
[0029] When the gradient magnitude of a pixel is between the low threshold and the high threshold, this pixel is determined to be a weak edge pixel;
[0030] Among them, the weak edge pixels connected to the strong edge pixels are determined to be the retained edge pixels;
[0031] Subsequently, perform dilation operation and erosion operation on the basis of selecting an M×M neighborhood according to the corresponding pixels, where M is a preset value;
[0032] Finally, determine the edge image according to all the pixels in the foreground area.
[0033] As a further solution of the present invention: the dilation operation method is as follows: expand the foreground area in the grayscale image, and then slide the neighborhood on the image. When the neighborhood overlaps with the foreground area in the image, set the pixel corresponding to the center of this neighborhood to the pixel of the foreground area; the erosion operation is opposite to the dilation operation method. It is to shrink the foreground area in the image, and then slide the neighborhood on the image. Only when the neighborhood is completely contained in the foreground area of the image, the pixel corresponding to the center of this neighborhood is set to the pixel of the foreground area.
[0034] As a further solution of the present invention: the method for extracting the shape features of the image analysis unit is as follows:
[0035] For the obtained edge image, by traversing all the pixel points on the edge image, the number of pixel points contained within the contour is counted and used as the contour area of the edge image; meanwhile, the distance between adjacent pixel points is calculated using the Euclidean distance formula, and then the distances between all adjacent pixel points are summed up, and the sum is denoted as the contour perimeter;
[0036] Then, using the circularity formula: Calculate the circularity Y of the edge image in the relevant image data;
[0037] In the formula, S is the contour area of the edge image, and C is the contour perimeter of the edge image;
[0038] Meanwhile, using the formula: Calculate the area-perimeter ratio B of the edge image in the relevant image data;
[0039] Among them, the circularity Y and the area-perimeter ratio B of the edge image are the shape features.
[0040] As a further solution of the present invention: The classification and recognition method of the image analysis unit is as follows:
[0041] Establish a material feature database based on the shape features of all known materials;
[0042] Take the shape features of each known material in the material feature database as samples and compare them one by one with the shape features of the material to be recognized;
[0043] Among them, the one-by-one comparison uses the Euclidean distance algorithm to calculate the similarity between the corresponding shape features of the material to be recognized and each shape feature in the material feature database;
[0044] The similarity calculation formula is as follows:
[0045] In the formula, W j is the similarity between the material to be sub-packaged and the jth known material in the material feature database, Y is the circularity in the corresponding shape features of the material to be sub-packaged, and Y1 j is the circularity in the corresponding shape features of the jth known material in the material feature database, and j is the serial number of the known material in the material feature database, which is a variable value;
[0046] Compare the similarity W j between the material to be sub-packaged and each known material with a preset similarity threshold Wy respectively:
[0047] Then select the material type corresponding to the known material with the smallest W j ≤Wy and W j as the material type of the material to be sub-packaged.
[0048] Advantages of the present invention:
[0049] High image quality: The image processing unit converts the color sub-packaged material image into a grayscale image and uses the median filtering algorithm or the mean filtering algorithm to remove noise. This effectively improves the image quality, reduces noise interference, makes subsequent image analysis and processing more accurate and reliable, and avoids problems such as misjudgment caused by image noise.
[0050] Accurate edge detection: The image segmentation unit uses the Canny edge detection algorithm. After a series of steps such as Gaussian filtering to smooth the image, calculating the Sobel gradient, non-maximum suppression, double-threshold processing, dilation and erosion operations, it can accurately determine the edge pixels and generate a high-quality edge image. This helps to accurately extract the shape features of the material and provides an accurate basis for subsequent material type identification and counting.
[0051] Accurate shape feature extraction: The image analysis unit traverses the edge image pixels, accurately calculates the contour area, calculates the contour perimeter, and uses relevant formulas to calculate shape features such as circularity and area perimeter ratio. This method can comprehensively and accurately describe the shape features of the material and provides rich and reliable information for the classification and identification of the material.
[0052] Reliable classification and identification: The image analysis unit establishes a material feature database based on the shape features of known materials and calculates the similarity through the Euclidean distance algorithm for classification and identification. This method can effectively compare the material to be identified with known materials, select the known material type with the similarity meeting the threshold and the smallest value as the type of the sub-packaged material, improves the accuracy and reliability of classification and identification, and reduces the identification error.
[0053] Efficient automatic counting and sub-packaging: The sub-packaging control unit conducts quantity statistics based on the material type and shape features and completes the packaging distribution according to the preset sub-packaging rules. This realizes the automatic counting and sub-packaging of materials, improves production efficiency, reduces the workload and error rate of manual operations, and at the same time ensures the accuracy of the material type and quantity ratio in each packaging unit, meeting the standardized requirements of production and packaging.
[0054] Excellent overall system performance: The units of this system cooperate with each other. From image acquisition, processing, segmentation, analysis to sub-packaging control, it forms a complete and efficient automatic counting and sub-packaging control process. The overall system can adapt to the counting and sub-packaging requirements of different types of materials, has strong versatility and practicability, and can be widely applied to related industrial production fields to improve the automation level and management efficiency of production. Brief description of the drawings
[0055] The present invention will be further described below in conjunction with the drawings.
[0056] Figure 1 It is the system block diagram of the automatic counting and subcontracting control system based on machine vision of the present invention.
[0057] Figure 2 It is the schematic flow diagram of the image segmentation unit in the automatic counting and subcontracting control system based on machine vision of the present invention.
[0058] Figure 3 It is the schematic flow diagram of the image analysis unit in the automatic counting and subcontracting control system based on machine vision of the present invention. Specific embodiments
[0059] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0060] Embodiment 1
[0061] Please refer to Figure 1 、 Figure 2 、 Figure 3 As shown, the present invention is an automatic counting and subcontracting control system based on machine vision, including:
[0062] An image acquisition unit, which acquires the subcontracting material image of the material to be subcontracted through an industrial camera;
[0063] An image processing unit, which is used to convert the acquired color subcontracting material image into a grayscale image in the following manner:
[0064] Obtain the RGB values of the color subcontracting material image;
[0065] Then through: H = 0.299×R + 0.587×G + 0.114×B
[0066] Calculate the grayscale value H of the corresponding grayscale image of the subcontracting material image;
[0067] In the formula, R, G, and B are the values of the red, green, and blue channels in the color subcontracting material image respectively;
[0068] An image segmentation unit, which is used to perform edge detection on the input grayscale image by the Canny method:
[0069] It first uses Gaussian filtering for smoothing, then uses the Sobel operator to calculate the gradients in the x and y directions, then refines the edges through non-maximum suppression, determines the edges according to the preset high and low thresholds, and finally determines the edge image through dilation and erosion operations.
[0070] The specific method of edge detection is as follows:
[0071] First, use a Gaussian filter to smooth the grayscale image, and then use the Sobel operator to calculate the gradient values of the image in the x and y directions respectively;
[0072] Then, perform non-maximum suppression on the gradient magnitude, only retaining the pixels with the local maximum gradient; at the same time, for each pixel, check the two adjacent pixels in its gradient direction. When the gradient magnitude of this pixel is not the local maximum, set its gradient magnitude to 0;
[0073] Next, determine the edges according to the preset low threshold and high threshold;
[0074] When the gradient magnitude of a pixel is greater than the high threshold, the pixel is determined to be a strong edge pixel;
[0075] When the gradient magnitude of a pixel is between the low threshold and the high threshold, the pixel is determined to be a weak edge pixel;
[0076] Among them, the weak edge pixels connected to the strong edge pixels are determined to be the retained edge pixels;
[0077] Subsequently, perform dilation operation and erosion operation on the M×M neighborhood according to the corresponding pixels;
[0078] The dilation operation method is: expand the foreground area in the grayscale image, then slide the neighborhood on the image. When the neighborhood overlaps with the foreground area in the image, set the pixel corresponding to the center of the neighborhood to the pixel of the foreground area;
[0079] In this embodiment, M takes the value of 5;
[0080] The erosion operation is opposite to the dilation operation. It is to shrink the foreground area in the image, then slide the neighborhood on the image. Only when the neighborhood is completely contained in the foreground area of the image, set the pixel corresponding to the center of the neighborhood to the pixel of the foreground area;
[0081] Among them, the Canny method is a prior art, so it will not be elaborated here;
[0082] Finally, determine the edge image according to all the pixels in the foreground area;
[0083] The image analysis unit is used to extract the shape features of the materials to be sub-packaged according to the edge image obtained by the image segmentation unit, and then classify and identify the material types of the materials to be sub-packaged according to the shape features;
[0084] The extraction method of the shape features is as follows:
[0085] For the obtained edge image, by traversing all the pixel points on the edge image, count the number of pixel points contained within the contour and use it as the contour area of the edge image; at the same time, calculate the distance between adjacent pixel points through the Euclidean distance formula, then sum up the distances between all adjacent pixel points and record the sum as the contour perimeter;
[0086] Then use the circularity formula: Calculate the circularity Y of the edge image in the relevant image data;
[0087] In the formula, S is the contour area of the edge image, and C is the contour perimeter of the edge image;
[0088] At the same time, use the formula: Calculate the area perimeter ratio B of the edge image in the relevant image data;
[0089] Among them, the circularity Y and the area perimeter ratio B of the edge image are the shape features;
[0090] The classification and recognition method of the material type is as follows:
[0091] Establish a material feature database based on the shape features of all known materials;
[0092] Take the shape features of each known material in the material feature database as samples and compare them with the shape features of the material to be recognized one by one;
[0093] Among them, the one-by-one comparison uses the Euclidean distance algorithm to calculate the similarity between the corresponding shape features of the material to be recognized and each shape feature in the material feature database;
[0094] The similarity calculation formula is as follows:
[0095] In the formula, W j is the similarity between the material to be subcontracted and the jth known material in the material feature database, Y is the circularity in the corresponding shape features of the material to be subcontracted, and Y1 j is the circularity in the corresponding shape features of the jth known material in the material feature database, and j is the serial number of the known material in the material feature database, which is a variable value;
[0096] B1 j is the area perimeter ratio in the corresponding shape features of the jth known material in the material feature database;
[0097] Compare the similarity W between the material to be subcontracted and each known material j with a preset similarity threshold Wy respectively:
[0098] Then select W from them j ≤Wy and Wj The material type corresponding to the smallest known material is used as the material type of the material to be sub-packed.
[0099] The sub-packaging control unit is used to count the quantity of the material to be sub-packed based on the material type of the material to be sub-packed and the shape characteristics of the material to be sub-packed, and then perform sub-packaging operations according to the pre-set sub-packaging rules.
[0100] Among them, the sub-packaging rule refers to the distribution standard for material packaging, which specifically stipulates the different types of materials contained in each packaging unit and their corresponding quantity ratios.
[0101] The method is as follows:
[0102] Divide the sub-packaging material image into several regions.
[0103] In each region, according to the material type and shape characteristics of the material to be sub-packed,
[0104] Count and identify the number of materials to be sub-packed corresponding to each material type.
[0105] When the count reaches the set distribution standard, trigger the action of the sub-packaging equipment to perform sub-packaging operations on the corresponding quantity of materials to be sub-packed.
[0106] For example: The material to be sub-packed this time is hardware fittings, specifically: each material package contains 8 M8 nuts, 8 M8×50 bolts, and 16 flat gaskets with an inner diameter of 10mm.
[0107] The sub-packaging control process is as follows:
[0108] Divide the collected sub-packaging material image into multiple rectangular regions, and the size of each region is reasonably set according to the material size and the conveyor belt width to ensure that the quantity of materials in each region is appropriate for counting.
[0109] Identify the material type based on the shape characteristics of the hardware fittings and count the quantity of different types of fittings in each region; taking the M8 nut as an example, the system recognizes the hexagonal contour, combines features such as its area perimeter ratio and circularity, accurately determines it as an M8 nut, and performs counting.
[0110] When the quantities of M8 nuts, M8×50 bolts, and flat gaskets with an inner diameter of 10mm in a certain region reach 8, 8, and 16 respectively, the system immediately triggers the action of the sub-packaging equipment; the sub-packaging equipment quickly grabs the hardware fittings in that region into the corresponding packaging containers to complete a sub-packaging operation.
[0111] This embodiment constructs a complete set of automatic counting and subpackaging control system based on machine vision. Through multiple functional units such as image acquisition, processing, segmentation, analysis and subpackaging control, accurate counting and classified subpackaging of materials to be subpacked are realized. The image acquisition unit ensures the acquisition of material images, and the image processing unit converts color images into grayscale images, laying the foundation for subsequent processing. The image segmentation unit uses the Canny method for edge detection and can accurately extract the edges of materials. The image analysis unit extracts shape features and identifies material types, and the subpackaging control unit performs subpackaging operations based on material types and shape features. The entire system realizes an automated process from material image acquisition to subpackaging operations, reduces manual intervention, improves the accuracy and efficiency of counting and subpackaging, and is suitable for subpackaging scenarios of various materials.
[0112] Embodiment 2
[0113] See also Figure 1 , Figure 2 , Figure 3 As shown, as the second embodiment of the present invention, when the present application is implemented, compared with the first embodiment, the technical solution of this embodiment is different from that of the first embodiment only in that, in this embodiment, according to the characteristics of the subpackaged materials, a variety of different light sources are provided at the industrial camera, specifically:
[0114] For materials to be packaged that are too small, such as granular medicines, use an LED parallel light source, where the LED parallel light source is set in a position parallel to the optical axis of the industrial camera and about 15-25 cm away from the conveyor belt or placement plane of the materials to be packaged;
[0115] Adjust the brightness according to the color and reflective properties of the material to be packaged:
[0116] When the color of the material to be subpackaged is dark, it means that it absorbs more light, so the brightness of the light source should be increased;
[0117] When the color of the material to be subpackaged is light and the reflection is strong, the brightness is reduced;
[0118] In this embodiment, the brightness can be adjusted to a suitable range through a brightness adjustment knob provided by the light source or a digital adjustment module connected to the control system, so that the captured image has rich particle details and no overexposure or underexposure phenomenon;
[0119] For stacked and stuck materials to be packaged, such as screws, a diffuse reflection light source is used. The diffuse reflection light source is set at a position with an angle of 30-60 degrees to the camera optical axis and 10-20 cm away from the screw placement plane;
[0120] In this embodiment, taking a 45-degree angle as an example, this angle can produce appropriate reflection and shadow effects on the surface of the screw, highlighting the contour and details of the screw, which is convenient for subsequent image analysis. If the angle is too small, it may not effectively reduce the reflection. If the angle is too large, it may cause the shadow to be too strong, affecting the judgment of the adhered part.
[0121] For the materials to be sub-packed that are similar in color to the background, such as transparent objects, a backlight illumination source is selected. For example, a high-brightness LED backlight board is used.
[0122] Among them, the backlight illumination source is set behind the materials to be sub-packed, which is opposite to the industrial camera.
[0123] Based on Embodiment 1, this embodiment sets multiple light sources for materials to be sub-packed with different characteristics. For materials that are too small, the LED parallel light source can clearly capture the particle details. The brightness is adjusted according to the color and reflection characteristics of the materials to avoid overexposure or underexposure of the image. For stacked and adhered materials, the diffuse reflection light source is set at a specific angle to highlight the contour and details of the materials, which is convenient for judging the adhered part. For materials that are similar in color to the background, the backlight illumination source can enhance the contrast between the materials and the background. Through these light source settings, the quality of image acquisition is improved, ensuring that the images of materials with different characteristics can meet the requirements of subsequent analysis and processing, and further improving the adaptability of the system to various materials.
[0124] Embodiment 3
[0125] Please refer to Figure 1 、 Figure 2 、 Figure 3 As shown in, as Embodiment 3 of the present invention, when the present application is specifically implemented, compared with Embodiment 1 and Embodiment 2, the technical solution of this embodiment is to combine and implement the solutions of the above Embodiment 1 and Embodiment 2. The difference between the technical solution of this embodiment and Embodiment 1 and Embodiment 2 is only that in this embodiment, the image processing unit also uses a median filtering algorithm or a mean filtering algorithm to remove noise points in the grayscale image.
[0126] The method of using the median filtering algorithm to remove noise points in the grayscale image is as follows:
[0127] Select a pixel point, and use a specified neighborhood N×N, and obtain the grayscale values of each pixel point in the neighborhood of this pixel point.
[0128] In this embodiment, N takes a value of 3.
[0129] Sort the grayscale values of each pixel point in the neighborhood in ascending order, and then take the median value as the new grayscale value of this pixel point.
[0130] The method of using the mean filtering algorithm to remove noise points in the grayscale image is as follows:
[0131] Select a pixel point, with a specified neighborhood of N×N, and obtain the gray values of each pixel point within the neighborhood of this pixel point;
[0132] Calculate the average value of the gray values corresponding to all pixel points within the neighborhood, and use this average value as the new gray value of this pixel point.
[0133] In this embodiment, based on Embodiment 1, the image processing unit uses median filtering algorithm or mean filtering algorithm to remove noise in the gray image. The median filtering algorithm can effectively suppress pulse interference such as salt-and-pepper noise by taking the median value of the gray values of neighborhood pixels and retain the edge information of the image. The mean filtering algorithm reduces the random noise in the image and makes the image smoother by calculating the average value of the gray values of neighborhood pixels. The application of these filtering algorithms improves the quality of the image, reduces the influence of noise on subsequent edge detection, shape feature extraction, and material type recognition, and improves the accuracy of the system processing results.
[0134] Embodiment 4
[0135] Please refer to Figure 1 、 Figure 2 、 Figure 3 As shown in the figures, as Embodiment 4 of the present invention, in the specific implementation of this application, compared with Embodiment 1, Embodiment 2, and Embodiment 3, the technical solution of this embodiment lies in combining the solutions of the above-mentioned Embodiment 1, Embodiment 2, and Embodiment 3 for implementation.
[0136] This embodiment comprehensively implements the technical solutions of Embodiments 1, 2, and 3. It not only has a complete automatic counting and subcontracting control function, but also can select a suitable light source according to different characteristics of materials to improve the quality of image acquisition, and can also remove image noise through filtering algorithms. This enables the system to not only accurately and efficiently count and subcontract materials, but also adapt to the processing requirements of more types and more characteristics of materials, significantly enhancing the stability, reliability, and adaptability of the system, and further optimizing the performance of the entire automatic counting and subcontracting control system based on machine vision.
[0137] The above formulas are all dimensionless and take their numerical values for calculation. The formulas are obtained by collecting a large amount of data for software simulation to obtain a formula that is closest to the actual situation. The preset parameters and threshold selection in the formulas are set by those skilled in the art according to the actual situation.
[0138] The above is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed by this application can easily think of changes or substitutions, which should all be covered within the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claimed rights.
Claims
1. Automatic counting and subpackaging control system based on machine vision, characterized in that: include: An image acquisition unit, an image processing unit, an image segmentation unit, an image analysis unit and a packet control unit, and each unit is communicatively connected with each other; First, the image acquisition unit obtains the subpackaged material image of the material to be subpackaged through an industrial camera; then the image processing unit converts the obtained color subpackaged material image into a grayscale image, and uses a median filter algorithm or a mean filter algorithm to remove noise in the grayscale image; then the image segmentation unit uses a Canny edge detection algorithm, calculates the Sobel gradient after smoothing the image through a Gaussian filter, determines the edge pixels through non-maximum suppression and double threshold processing, and then optimizes the edge connectivity through expansion and corrosion operations to finally generate an edge image; then the image analysis unit extracts the shape characteristics of the material by processing the edge detection result output by the image segmentation unit, and then realizes the classification and identification of the material type based on the feature matching algorithm; finally, the subpackage control unit performs quantity statistics based on the material type and shape characteristics of the material to be subpackaged, and completes the packaging allocation according to the preset subpackage rules; wherein the subpackage rules refer to the allocation standards for material packaging, which specifically stipulate the different types of materials contained in each packaging unit and their corresponding quantity ratios.
2. The automatic counting and sub-packaging control system based on machine vision according to claim 1 is characterized in that: The image segmentation unit is implemented as follows: First, a Gaussian filter is used to smooth the grayscale image, and then the Sobel operator is used to calculate the gradient values of the image in the x and y directions. Then, the gradient amplitude is non-maximum suppressed, and only the pixels with the local maximum gradient value are retained. At the same time, for each pixel, the two adjacent pixels in the gradient direction are checked. When the gradient amplitude of the pixel is not the local maximum, its gradient amplitude is set to 0. Then the edge is determined based on the pre-set low and high thresholds; When the gradient amplitude of a pixel is greater than a high threshold, the pixel is determined to be a strong edge pixel; when the gradient amplitude of a pixel is between a low threshold and a high threshold, the pixel is determined to be a weak edge pixel; wherein, weak edge pixels connected to strong edge pixels are determined to be retained edge pixels; Then, an M×M neighborhood is selected according to the corresponding pixel to perform dilation and erosion operations, where M is a preset value; Finally, the edge image is determined based on the pixels of all foreground areas.
3. The automatic counting and sub-packaging control system based on machine vision according to claim 1 is characterized in that: The dilation operation is as follows: the foreground area in the grayscale image is enlarged, and then the neighborhood is slid on the image. When the neighborhood overlaps with the foreground area in the image, the pixel corresponding to the center of the neighborhood is set as the pixel of the foreground area.
4. The automatic counting and sub-packaging control system based on machine vision according to claim 1 is characterized in that: The erosion operation is the opposite of the dilation operation. It shrinks the foreground area in the image and then slides the neighborhood on the image. Only when the neighborhood is completely contained in the foreground area of the image, the pixel corresponding to the center of the neighborhood is set as the pixel of the foreground area.
5. The automatic counting and sub-packaging control system based on machine vision according to claim 1 is characterized in that: The shape feature extraction method of the image analysis unit is as follows: For the edge image obtained, all pixels on the edge image are traversed, the number of pixels contained in the contour is counted, and the number is used as the contour area of the edge image; at the same time, the distance between adjacent pixels is calculated using the Euclidean distance formula, and then the distances between all adjacent pixels are summed up, and the sum is recorded as the contour perimeter; Then use the circularity formula: Calculate the circularity Y of the edge image in the relevant image data; Where S is the contour area of the edge image, and C is the contour perimeter of the edge image; At the same time, using the formula: The area-perimeter ratio B of the edge image in the relevant image data is calculated; wherein the circularity Y and the area-perimeter ratio B of the edge image are shape features.
6. The automatic counting and sub-packaging control system based on machine vision according to claim 1 is characterized in that: The classification and identification method of the image analysis unit is as follows: Establish a material feature database based on the shape features of all known materials; The shape features of each known material in the material feature database are used as samples to be compared with the shape features of the material to be identified one by one; Among them, the Euclidean distance algorithm is used to calculate the similarity between the corresponding shape features of the material to be identified and each shape feature in the material feature database, and it is marked as W j , j is the serial number of a known material in the material feature database, which is the variable value; The similarity W between the material to be subcontracted and each known material j Compare with a preset similarity threshold Wy respectively: Then select W from j ≤Wy and W j The material type corresponding to the smallest known material is used as the material type of the material to be subpackaged.
7. The automatic counting and sub-packaging control system based on machine vision according to claim 5 is characterized in that: The similarity calculation formula is as follows: Where W j is the similarity between the material to be subpackaged and the jth known material in the material feature database, Y is the circularity of the corresponding shape feature of the material to be subpackaged, Y1 j is the circularity of the shape feature corresponding to the jth known material in the material feature database; B1 j It is the area-to-perimeter ratio of the shape feature corresponding to the jth known material in the material feature database.
8. The automatic counting and sub-packaging control system based on machine vision according to claim 1 is characterized in that: The method of using median filtering algorithm to remove noise in grayscale images is as follows: Select a pixel point and a specified neighborhood N×N, and obtain the grayscale value of each pixel point in the neighborhood of the pixel point; Sort the grayscale values of each pixel in the neighborhood from small to large, and then take the middle value as the new grayscale value of the pixel.
9. The automatic counting and sub-packaging control system based on machine vision according to claim 1 is characterized in that: The method of using mean filtering algorithm to remove noise in grayscale images is as follows: Select a pixel point and a specified neighborhood N×N, and obtain the grayscale value of each pixel point in the neighborhood of the pixel point; Calculate the average grayscale value of all pixels in the neighborhood, and use the average grayscale value as the new grayscale value of the pixel.