A visual inspection method for screening the width of a cinnamon stick
By using industrial cameras and image processing technology, the width of cinnamon sticks can be automatically detected to ensure it meets specifications, solving the problem of high manual intervention costs in cinnamon stick specification classification and achieving fast and accurate automatic screening.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU UNIVERSITY
- Filing Date
- 2023-03-28
- Publication Date
- 2026-04-17
AI Technical Summary
The current technology for classifying cinnamon sticks by specifications requires a lot of manual intervention, resulting in high labor costs and low efficiency, and making it impossible to achieve automated, fast and accurate screening.
The system uses an industrial camera to acquire images, performs grayscale conversion and threshold segmentation, combines region filling and closing operations to remove noise, extracts the cinnamon stick region using the minimum bounding rectangle, and determines whether the width meets the specifications by using the minimum grayscale value point, thus achieving automatic detection.
The system automates the detection of cinnamon stick width, improving detection speed and accuracy, reducing labor costs, and meeting the requirements of high-end customers for standardized packaging.
Smart Images

Figure CN116542905B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of visual inspection methods for screening the width of cinnamon sticks, specifically a visual inspection method for screening the width of cinnamon sticks. Background Technology
[0002] Currently, cinnamon sticks are used to flavor mulled wine, coffee, and milk tea, and their applications are becoming increasingly sophisticated. Therefore, users need to categorize and package cinnamon sticks according to their size. However, even with pre-sorted products, some individual sizes may be mixed in, affecting product quality. Since the size difference between each size is only two to three millimeters, manual selection would require significant manpower and time. To improve production efficiency, reduce labor costs, and lower time costs, achieving industrial automation, machine vision-based automatic inspection has emerged. Therefore, developing a fast and effective method for identifying cinnamon sticks in packaging is essential. Based on this, a width-based visual inspection method for cinnamon sticks is proposed. Summary of the Invention
[0003] The purpose of this invention is to provide a visual inspection method for screening the width of cinnamon sticks. This method addresses the issue that as high-end customers have higher requirements for the appearance and shape of cinnamon sticks, the market demands standardized packaging of cinnamon sticks according to specific sizes. Currently, manual inspection is required to verify whether the packaging conforms to these requirements, which is time-consuming and labor-intensive. Therefore, the market needs a visual inspection device to automatically inspect the packaging of cinnamon sticks. This invention can replace manual inspection and automatically check whether the width of cinnamon sticks of a certain size meets the packaging requirements of that size. Furthermore, the inspection method of this invention is simple, fast, and accurate.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a visual detection method for width screening of cinnamon sticks, the method comprising:
[0005] Images are acquired using an industrial camera, and the original images are converted to grayscale using a certain method. Threshold segmentation is then performed on the grayscale images to obtain the regions where the packaging paper and cinnamon sticks are located.
[0006] The packaging area is obtained by using area filling to fill the area where the wrapping paper and cinnamon stick are located.
[0007] The region containing the cinnamon stick is obtained by subtracting the region containing the wrapping paper and the cinnamon stick from the packaging area.
[0008] Apply region fill to the area where the cinnamon stick is located, and then use the closing operation to remove small noise.
[0009] The minimum bounding rectangle is used to obtain the coordinates, length, width, and angle of the minimum bounding rectangle. A rectangular region is obtained based on the coordinates, angle, length, and width of the minimum bounding rectangle. A measurement rectangle is then generated based on this rectangular region.
[0010] Extract the grayscale value of each integer point perpendicular to the direction of the measurement rectangle as an integer sequence;
[0011] Find the local minimum value of the grayscale value; find the distance between two local minimum values;
[0012] Determine if the distance is greater than a specific value. If it is greater than a specific value, then this package contains cinnamon sticks that do not conform to the packaging specifications of this batch.
[0013] Preferably, the cinnamon stick region is obtained by grayscale conversion and threshold segmentation of the packaging paper and cinnamon stick images, including:
[0014] The image captured by the camera is converted to grayscale, and the average value of the three channels of the color image (RGB) is taken as the grayscale value, which is divided into grayscale values of 0 to 255 for each pixel.
[0015] Pixel threshold segmentation is performed to extract pixels whose grayscale values fall within a preset grayscale range.
[0016] Preferably, the shape transformation of the region uses region filling; the region filling is to fill the empty parts within the region, making the relevant features more obvious.
[0017] Preferably, the region difference is calculated by subtracting the packaging area from the region containing the packaging paper to obtain the cinnamon stick region with less noise; a region closing operation is performed on the cinnamon stick region, and a circle is selected as the structural element to eliminate the noise region.
[0018] Preferably, the region closing operation first dilates and then erodes the region. The definitions of dilation and erosion are as follows: Dilation involves sequentially moving a structuring element within the image. After each movement, the pixel values covered by the structuring element are sorted, and the maximum pixel value replaces the pixel value at the position corresponding to the structuring element's center point. This can be used to fill holes in an image, causing the image to expand outwards. Here, B is the structuring element, and A is the image being processed. The mathematical expression is defined as:
[0019]
[0020] Erosion works by moving structuring elements sequentially across an image. After each move, the pixel values covered by the structuring element are sorted, and the pixel with the smallest value is replaced with the pixel value corresponding to the center point of the structuring element. This eliminates small noise points and causes the image to converge inwards. The mathematical expression is defined as:
[0021]
[0022] The closing operator is denoted as:
[0023] Preferably, the minimum bounding rectangle is used for the area where the noise reduction point is located to obtain the coordinates, length, width and angle of the minimum bounding rectangle, and the measurement rectangle is used to extract the straight edge perpendicular to the long side of the rectangle.
[0024] Preferably, the threshold segmentation divides the background image into a highest threshold and a lowest threshold based on the difference in grayscale values of the image, and selects the pixels at the highest and lowest thresholds to generate the corresponding background image regions.
[0025] This invention provides a visual inspection method for screening the width of cinnamon sticks. This visual inspection method for screening the width of cinnamon sticks has the following beneficial effects:
[0026] 1. The visual inspection method for screening the width of cinnamon sticks: As high-end customers have higher requirements for the appearance and shape of cinnamon sticks, the market will require cinnamon sticks to be packaged in a uniform size according to specifications. However, whether the packaging meets the requirements still needs to be checked manually, which is time-consuming and laborious. Therefore, the market needs a visual inspection device to realize the automatic inspection of cinnamon stick packaging. This invention can replace manual inspection and realize that the width of cinnamon sticks of a certain specification meets the packaging requirements of that specification. Moreover, the inspection method of this invention is simple, fast in detecting cinnamon sticks, and has a high accuracy rate.
[0027] 2. The visual inspection method for width screening of cinnamon sticks utilizes region closing operations to first dilate and then erode the region containing the cinnamon sticks. Region filling is then applied to the region containing the cinnamon sticks, followed by closing operations to remove small noise points. A minimum bounding rectangle is used to denoise the region containing the noise points, resulting in a rectangular area. A measurement rectangle is then generated based on this rectangular area. The minimum bounding rectangle is used again to obtain its coordinates, length, width, and angle. The measurement rectangle is used to extract the straight edges perpendicular to the long side of the rectangle. Gray values of each integer point perpendicular to the measurement rectangle are extracted as an integer sequence. The minimum gray value is calculated. The distance between two minimum gray values is calculated. Threshold segmentation divides the background image into a maximum and minimum threshold based on the gray value differences. Pixels at the maximum and minimum thresholds are selected to generate corresponding background image regions. The distance between these regions is checked against a specific value. If the distance is greater than a specific value, the package contains cinnamon sticks that do not conform to the batch packaging specifications.
[0028] 3. The visual inspection method for width screening of cinnamon sticks involves acquiring images using an industrial camera, converting the original images to grayscale using a specific method, performing grayscale conversion and threshold segmentation on the packaging paper and cinnamon stick images to obtain the cinnamon stick region, performing pixel threshold segmentation to extract pixels with grayscale values within a preset grayscale range, transforming the region shape using region filling, which involves filling the empty parts within the region to make the relevant features more obvious, performing threshold segmentation on the grayscale image to obtain the region where the packaging paper and cinnamon sticks are located, performing region filling on the region where the packaging paper and cinnamon sticks are located to obtain the packaging region, and calculating the difference between the region where the packaging paper and cinnamon sticks are located and the packaging region to obtain the region where the cinnamon sticks are located. Attached Figure Description
[0029] Figure 1 A flowchart of a visual inspection method for width screening of cinnamon sticks provided in an embodiment of the present invention;
[0030] Figure 2 This is a schematic diagram illustrating that the packaging provided in this embodiment of the invention does not contain other specifications;
[0031] Figure 3 The schematic diagrams provided for embodiments of the present invention include other specifications. Detailed Implementation
[0032] like Figure 1-3 As shown, the present invention provides a technical solution: a visual detection method for screening the width of cinnamon sticks, the method comprising:
[0033] Images are acquired using an industrial camera. The original images are then converted to grayscale using a specific method. Threshold segmentation is performed on the grayscale images to identify the regions containing the packaging paper and cinnamon sticks. The grayscale and threshold segmentation of the packaging paper and cinnamon stick images yields the cinnamon stick region, which includes:
[0034] The image captured by the camera is converted to grayscale, and the average value of the three channels of the color image (RGB) is taken as the grayscale value, which is divided into grayscale values of 0 to 255 for each pixel.
[0035] Pixel threshold segmentation is performed to extract pixels whose grayscale values fall within a preset grayscale range;
[0036] The packaging area is obtained by using area filling to fill the area where the wrapping paper and cinnamon stick are located.
[0037] The region containing the cinnamon stick is obtained by subtracting the region containing the wrapping paper and the packaging area; the shape of the region is then transformed using region filling; region filling is the process of filling the empty parts within the region to make the relevant features more obvious.
[0038] The region containing the cinnamon stick is filled using a region fill operation, followed by a closing operation to remove small noise. The region difference is calculated by subtracting the packaging area from the area containing the packaging paper, resulting in the cinnamon stick region with less noise. A region closing operation is then performed on the cinnamon stick region, using a circle as the structuring element to eliminate noise areas. The region closing operation then dilates and erodes this region. Dilation and erosion are defined as follows: Dilation involves moving the structuring element sequentially within the image, sorting the pixel values covered by the structuring element after each move, and replacing the pixel value at the position corresponding to the structuring element's center point with the maximum value. This can be used to fill holes in an image, causing the image to expand outwards. Here, B is the structuring element, A is the image being processed, and the mathematical expression is defined as:
[0039]
[0040] Erosion works by moving structuring elements sequentially across an image. After each move, the pixel values covered by the structuring element are sorted, and the pixel with the smallest value is replaced with the pixel value corresponding to the center point of the structuring element. This eliminates small noise points and causes the image to converge inwards. The mathematical expression is defined as:
[0041]
[0042] The closing operator is denoted as:
[0043] The minimum bounding rectangle is used to obtain the coordinates, length, width, and angle of the minimum bounding rectangle. A rectangular region is obtained based on the coordinates, angle, length, and width of the minimum bounding rectangle. A measurement rectangle is generated based on this rectangular region. The minimum bounding rectangle is used to obtain the coordinates, length, width, and angle of the minimum bounding rectangle. The measurement rectangle is used to extract the straight edge perpendicular to the long side of the rectangle.
[0044] Extract the grayscale value of each integer point perpendicular to the direction of the measurement rectangle as an integer sequence;
[0045] Find the minimum gray value; find the distance between two minimum values; threshold segmentation divides the background image into the highest and lowest thresholds based on the difference in gray values of the image, and selects the pixels at the highest and lowest thresholds to generate the corresponding background image regions.
[0046] Determine if the distance is greater than a specific value. If it is greater than a specific value, then this package contains cinnamon sticks that do not conform to the packaging specifications of this batch.
[0047] The visual inspection method for width screening of cinnamon sticks involves acquiring images using an industrial camera, converting the original images to grayscale using a specific method, and performing grayscale conversion and threshold segmentation on the packaging paper and cinnamon stick images to obtain the cinnamon stick region. This includes: grayscale conversion of the camera-acquired image, taking the average of the RGB channels of the color image as the grayscale value, and dividing each pixel into grayscale values from 0 to 255; pixel threshold segmentation, extracting pixels with grayscale values within a preset grayscale range; region transformation using region filling; and region filling, which involves filling in the empty areas within the region to make relevant features more prominent. The optimized image undergoes thresholding segmentation to obtain the region containing the wrapper and cinnamon stick. Region filling is then applied to this region to obtain the packaging area. Subtraction between the wrapper / cinnamon stick region and the packaging area yields the region containing the cinnamon stick. A region closing operation is then applied to this region, first dilating and then eroding. Dilation and erosion are defined as follows: Dilation involves sequentially moving a structuring element within the image. After each movement, the pixel values covered by the structuring element are sorted, and the maximum pixel value replaces the pixel value corresponding to the center point of the image and the structuring element. This can be used to fill holes in the image, expanding it outwards. Here, B is the structuring element, A is the image being processed, and the mathematical expression is defined as:
[0048]
[0049] Erosion works by moving a structuring element sequentially across an image. After each move, the pixel values covered by the structuring element are sorted, and the pixel with the smallest value replaces the pixel value at the position corresponding to the center point of the structuring element. This can eliminate small noise points and cause the image to converge inwards. The mathematical expression is defined as:
[0050]
[0051] The closing operator is denoted as: The process involves: filling the area containing the cinnamon sticks with region fill and then using a closing operation to remove small noise points; applying a minimum bounding rectangle to the area after noise reduction to obtain the coordinates, length, width, and angle of the minimum bounding rectangle; using the coordinates, angle, length, and width of the minimum bounding rectangle to obtain a rectangular area, and generating a measurement rectangle based on this rectangular area; applying the minimum bounding rectangle to the area after noise reduction to obtain the coordinates, length, width, and angle of the minimum bounding rectangle, and using the measurement rectangle to extract the straight edges perpendicular to the long side of the rectangle; extracting the grayscale value of each integer point perpendicular to the direction of the measurement rectangle as an integer sequence; finding the minimum grayscale value; calculating the distance between two minimum grayscale values; threshold segmentation based on the difference in grayscale values in the image, dividing the background image into a highest threshold and a lowest threshold according to a set grayscale threshold, selecting the pixels at the highest and lowest thresholds to generate the corresponding background image areas; determining whether the distance is greater than a specific value, if it is greater than a specific value, then this package contains cinnamon sticks that do not conform to the packaging specifications of this batch.
Claims
1. A visual inspection method for width screening of cinnamon sticks, characterized in that: The method includes: S101: Use an industrial camera to acquire images, convert the acquired raw images to grayscale using a certain method; perform threshold segmentation on the grayscale images, and use the threshold segmentation method to obtain the regions where the packaging paper and cinnamon sticks are located; S102: Use area filling to obtain the packaging area for the area where the wrapping paper and cinnamon stick are located; S103: Calculate the difference between the area containing the wrapping paper and the cinnamon stick and the packaging area to obtain the area containing the cinnamon stick; S104: Use region fill on the area where the cinnamon stick is located, and then use closing operation to remove small noise. S105: Apply the minimum bounding rectangle to the area where the noise reduction point is located to obtain the coordinates, length, width, and angle of the minimum bounding rectangle; use the coordinates, angle, length, and width of the minimum bounding rectangle to obtain a rectangular area, and generate a measurement rectangle based on this rectangular area. S106: Extract the grayscale value of each integer point perpendicular to the direction of the measurement rectangle as an integer column; S107: Find the minimum value of grayscale; find the distance between two minimum values; S108: Determine if the distance is greater than a specific value. If it is greater than a specific value, then this package contains cinnamon sticks that do not conform to the packaging specifications of this batch.
2. The visual inspection method for width screening of cinnamon sticks according to claim 1, characterized in that: In step S101, the cinnamon stick region is obtained by grayscale conversion and threshold segmentation of the packaging paper and cinnamon stick images, including: The image captured by the camera is converted to grayscale, and the average value of the three RGB channels of the color image is taken as the grayscale value. Pixel threshold segmentation is performed to extract pixels with grayscale values within the preset grayscale range.
3. The visual inspection method for width screening of cinnamon sticks according to claim 1, characterized in that: In step S102, the shape of the transformed region is filled using region filling; The area filling refers to filling the empty parts within the area, making the relevant features more obvious.
4. The visual inspection method for width screening of cinnamon sticks according to claim 1, characterized in that: In step S103, the region difference is calculated by subtracting the packaging area from the region containing the packaging paper to obtain the cinnamon stick region with less noise; a region closing operation is performed on the cinnamon stick region, and a circle is selected as the structural element to eliminate the noise region.
5. The visual inspection method for width screening of cinnamon sticks according to claim 1, characterized in that: In S104, the region closing operation first expands and then erodes the region.
6. The visual inspection method for width screening of cinnamon sticks according to claim 1, characterized in that: In step S105, the minimum bounding rectangle is used to obtain the coordinates, length, width, and angle of the minimum bounding rectangle for the region after noise reduction. The measurement rectangle is used to extract the straight edge perpendicular to the long side of the rectangle.
7. The visual inspection method for width screening of cinnamon sticks according to claim 2, characterized in that: The threshold segmentation divides the background image into a maximum threshold and a minimum threshold based on the difference in grayscale values. Pixels at the maximum and minimum thresholds are selected to generate corresponding background image regions.
Citation Information
Patent Citations
Monocular vision-based reconstituted cut stem width detection method
CN112862815A
KR20200029778A