A pen barrel surface defect detection system
By combining a linear array camera and a stepper motor with a parallel light source, a pen barrel surface defect detection system has been developed. This system integrates Blob analysis, line fitting, and edge smoothing operators to solve the accuracy and efficiency problems in insulin pen barrel defect detection, achieving efficient and accurate defect detection and dimensional measurement.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-26
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies are insufficient for efficiently and accurately detecting various defects in insulin pen barrels, and traditional methods suffer from large errors in dimensional measurement, resulting in low efficiency and poor stability.
By employing a linear array camera in conjunction with a stepper motor and using parallel light sources for illumination, along with an image processing module to perform Blob analysis, line fitting, and edge smoothing operators, the system enables defect detection and dimensional measurement of the pen barrel surface.
It improves the detection accuracy of pen barrel defects and dimensional measurements, saves inspection time, and enhances inspection efficiency and stability.
Smart Images

Figure CN115700374B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology, and in particular relates to a pen barrel surface defect detection system. Background Technology
[0002] As is well known, the insulin pens used by diabetic patients are medical devices, and their production requires a high degree of precision. However, no matter how well the production equipment is optimized, defective products are inevitable. Manufacturers need to discard these defective products to avoid affecting patients' use and treatment. For a long time, quality inspection of pens on industrial production lines has relied on manual inspection, which has been criticized for its low accuracy and inefficiency.
[0003] In 2017, Chen Qi from Jiangsu University researched defect detection on the working surface of sliding bearings. He used metrology_model template matching and threshold segmentation to extract defects. Based on the area, shape, and texture features of the defects, he constructed an OVR-SVM classifier to detect defects on the working surface of sliding bearings. However, the mechanical structure of the hardware was unstable, resulting in a detection efficiency of 1.5s / piece. Furthermore, the brightness of the light source decayed over time, which was also a difficult problem to solve. In 2018, Yu Wenxuan from the University of Electronic Science and Technology of China developed a machine vision-based bearing surface defect detection system. He used distortion correction, ROI extraction of defect locations, and Gaussian filtering on images captured by industrial cameras to detect defects. However, the system had limitations, including insufficient defect collection and the inability to identify all types of defects. In 2019, Peng Peng from Xi'an University of Technology researched methods for detecting defects on the smooth surface of bearing rollers. He used bilateral filtering preprocessing on images captured by industrial cameras to extract features from the smooth defect surface and achieved automatic defect detection through deep learning.
[0004] In summary, the background analysis reveals that defect detection in machine vision can be broadly categorized into two types: one is using deep learning for model training, which requires a large amount of data and extremely high hardware support; the other is analyzing defect features and utilizing feature enhancement, filtering, and threshold segmentation. However, in reality, pen pen defects have small grayscale differences, and threshold segmentation is unstable, which can lead to missed detections and false detections to some extent.
[0005] Existing technologies make it difficult to detect defects in insulin pen barrels:
[0006] First, there are many types of product defects, so ordinary methods are difficult to cover all defects.
[0007] Second, the insulin pen barrel is relatively small, and the error is large when measuring its size using ordinary methods;
[0008] Third, traditional image edge defect detection is inefficient and has poor stability. Summary of the Invention
[0009] To address the above-mentioned technical deficiencies, this invention provides a pen barrel surface defect detection system, which improves the detection accuracy of pen barrel defects and dimensional measurements, and saves detection time.
[0010] To achieve the above-mentioned technical objectives, the present invention is implemented through the following technical solution:
[0011] A pen barrel surface defect detection system, comprising:
[0012] A stepper motor is used to drive the pen barrel.
[0013] Parallel light source, used to supplement the light on the pen barrel;
[0014] The image acquisition module is used to acquire image information of the pen barrel;
[0015] The image processing module receives data from the image acquisition module and analyzes and processes the data; among which:
[0016] The image processing module includes a first detection module that obtains the pen barrel size through data analysis and a second detection module that obtains pen barrel edge defects through data analysis.
[0017] The image acquisition module interacts with the image processing module; the image acquisition module includes a first image acquisition device and a second image acquisition device, the shooting angle of the first image acquisition device is perpendicular to the direction of the parallel light source propagation, and the angle between the shooting angle of the second image acquisition device and the first image acquisition device is in the range of 5 to 45 degrees; the dimensions include the opening depth and the opening width; the edge defects include contour scratches.
[0018] Preferably, the image acquisition module is a line scan camera, which acquires images by scanning line by line during operation, and then integrates the multi-line scan images into a surface image.
[0019] Preferably, the opening depth detection process is as follows: first, Blob analysis is performed on the image to segment the area to be detected; then, the opening depth is measured by linear fitting.
[0020] Preferably, the opening width detection process is as follows: first, Blob analysis is performed on the image to segment the area to be detected; then, the opening width is measured by a straight line extension logic operation.
[0021] Preferably, the edge defect detection process is as follows: first, perform Blob analysis on the image to segment the area to be detected; then, use an edge smoothing operator to detect contour damage.
[0022] Preferably, the system further includes a support base, which includes a base plate. A portal frame and two three-dimensional motion platforms are mounted on the upper surface of the base plate. The stepper motor is mounted on the portal frame with its motor shaft pointing vertically upward. Two image acquisition devices are mounted on the two three-dimensional motion platforms.
[0023] Preferably, a vertical shaft hole is provided at the top of the portal frame, the stepper motor is located inside the frame, a bearing centering seat is provided at the upper opening of the shaft hole, and the rotating shaft of the stepper motor passes through the shaft hole from bottom to top and connects with the bearing in the bearing centering seat.
[0024] Preferably, the three-dimensional motion platform includes a two-dimensional motion platform mounted on the upper surface of the base plate, and a vertical fine-tuning bracket is provided on the upper surface of each two-dimensional motion platform.
[0025] Preferably, a camera mount is installed on the vertical fine-tuning bracket.
[0026] Preferably, the angle between the shooting angle of the second image acquisition device and the first image acquisition device is 5 degrees, 15 degrees, 25 degrees, 35 degrees, or 45 degrees.
[0027] The advantages and technical effects of this invention are as follows:
[0028] This application proposes a method for detecting defects on the surface of pen barrels, utilizing edge smoothing, line fitting, and dimensional measurement. The dimensional measurement section optimizes the algorithm logic by calculating intersection points using line fitting and line extension. For edge chipping defects, commonly used filtering and Otsu thresholding are abandoned; instead, edge smoothing is used to calculate the positional relationship between defective and normal points. This invention effectively improves the detection accuracy of pen barrel defects and dimensional measurements, saving inspection time.
[0029] (1) This application addresses the structural and surface defects of the pen barrel by designing an optical environment scheme for the pen barrel surface: a line scan camera paired with a stepper motor for image acquisition; through field and laboratory testing, a line scan camera and its paired extension tube and lens, parallel backlight, robotic arm, and stepper motor were selected, and the optical environment design was completed. A platform was built in the laboratory for evaluation, and finally applied to the project. The equipment operates stably, and the acquired images clearly show the defects on the pen barrel surface.
[0030] (2) The machine vision inspection system for pen barrel surfaces optimizes the inspection method by analyzing pen barrel images: through linear fitting, linear extension and other algorithmic logic, the size measurement is completed; finally, the edge smoothing operator is used to realize the detection of contour damage. Experimental tests show that the algorithm of this inspection system can achieve stable detection of size and edge defects. Attached Figure Description
[0031] Figure 1 This is a layout diagram of the image acquisition module in a preferred embodiment of the present invention;
[0032] Figure 2 This is an example diagram illustrating the determination of the opening location using Blob analysis in a preferred embodiment of the present invention;
[0033] Figure 3 This is a comparison diagram of the straight line before and after extension in a preferred embodiment of the present invention;
[0034] Figure 4 This is a contour scratch detection diagram in a preferred embodiment of the present invention;
[0035] Figure 5 This is a diagram of a dent defect in a preferred embodiment of the present invention;
[0036] Figure 6 This is a schematic diagram showing the distance between A and B as the opening width in a preferred embodiment of the present invention;
[0037] Figure 7 This is a schematic diagram showing the distance between C and D as the opening depth in a preferred embodiment of the present invention.
[0038] The components include: 1. Base plate; 2. Horizontal fine-tuning base; 3. Vertical fine-tuning bracket; 4. Camera mounting bracket; 5. Camera No. 1; 6. Camera No. 2; 7. Parallel light source; 8. Rotation mechanism; 9. Bearing centering seat; 10. Installation station. Detailed Implementation
[0039] To make the above-mentioned objectives, control system design, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0040] Please see Figures 1 to 7 A pen barrel surface defect detection system, comprising:
[0041] A stepper motor is used to drive the pen barrel.
[0042] Parallel light source, used to supplement the light on the pen barrel;
[0043] The image acquisition module is used to acquire image information of the pen barrel;
[0044] The image processing module receives data from the image acquisition module and analyzes and processes the data; among which:
[0045] The image processing module includes a first detection module that obtains the pen barrel size through data analysis and a second detection module that obtains pen barrel edge defects through data analysis.
[0046] The image acquisition module interacts with the image processing module; the image acquisition module includes a first image acquisition device and a second image acquisition device, the shooting angle of the first image acquisition device is perpendicular to the direction of the parallel light source propagation, and the angle between the shooting angle of the second image acquisition device and the first image acquisition device is in the range of 5 to 45 degrees; the dimensions include the opening depth and the opening width; the edge defects include contour scratches.
[0047] like Figure 1 As shown, the hardware of the above-mentioned pen barrel surface defect detection system includes a support base, which includes a base plate 1. The upper surface of the base plate 1 is horizontal. A rotating mechanism 8 and two horizontal fine-tuning bases 2 are installed on the upper surface of the base plate 1. The rotating mechanism 8 includes a gate-shaped frame with a vertical shaft hole at the top of the frame. A stepper motor is located inside the frame. A bearing centering seat 9 is provided at the upper opening of the shaft hole. The rotating shaft of the stepper motor passes through the shaft hole from bottom to top and connects to the bearing in the bearing centering seat 9. The upper end of the rotating shaft of the stepper motor is the mounting position 10 for rotating the pen barrel. The two horizontal fine-tuning bases 2 are two-dimensional motion platforms. A vertical fine-tuning bracket 3 is provided on the upper surface of each horizontal fine-tuning base 2. A camera mounting bracket 4 is installed on each vertical fine-tuning bracket 3. A first image acquisition device is installed on one camera mounting bracket, and a second image acquisition device is installed on the other camera mounting bracket. The above-mentioned two-dimensional motion platform and vertical fine-tuning bracket constitute a three-dimensional motion platform.
[0048] The above preferred embodiments mainly include the following parts:
[0049] Optical environment:
[0050] In this preferred embodiment, the first image acquisition device and the second image acquisition device are line scan cameras; wherein: the first camera 5 takes pictures of the pen barrel at an angle perpendicular to the parallel light source, mainly taking pictures of defects related to surface depth, such as: scratches of various sizes, wavy lines, non-roundness, pinch marks, pits and other defects. Because it is high-angle lighting, the smooth areas of the surface can be reflected back into the camera. The light from the uneven areas of the surface will be reflected to other places due to diffuse reflection and will not enter the camera. Therefore, the defects are displayed as black images in the picture.
[0051] The angle between camera 6 (2) and camera 5 (1) ranges from 5 to 45 degrees. It primarily captures surface coating defects and performs dimensional inspections, such as: bright marks (defects caused by incomplete coating during application), uneven coating solution, dirt, coating solution buildup (coating solution accumulating to the bottom of the sample), coating solution spots, fibers, V-groove depth, and other defects and dimensional inspections. Because the shooting angle is lower than that of camera 5 (1), it is not as clear and stable in displaying depth information, but it is more effective for "film" type defects.
[0052] A line scan camera captures only one row of images at a time, i.e., an image with a resolution of 8192*1. Many 8192*1 images are obtained through relative movement with the object, and then combined to create a complete image of the object. The camera in this paper captures images with a resolution of 7500*4500, meaning 4500 rows are captured before the image is composited. Redundant parts are removed horizontally, resulting in 7500 columns, making the image smaller in memory and faster to process. Due to the high precision and the fact that the camera can only be moved to adjust "one row," the equipment needs to have μm-level accuracy for camera calibration. The final environmental adjustments are as follows: Figure 1 As shown.
[0053] Design of the dimensional measurement approach:
[0054] Image processing is the core of the entire pen barrel detection system. The detection rate of a device is closely related to the stability of the algorithm in detecting image defects. First, the image is analyzed using blob analysis to segment the area to be detected. Then, through logical operations such as line fitting and line extension, the size is measured. Finally, edge smoothing operators are used to detect contour damage.
[0055] Blob analysis:
[0056] like Figure 2 As shown: Blob analysis involves binarizing, segmenting, performing morphological operations, and calculating feature values in an image to obtain the region to be detected. First, a region with grayscale values between 70 and 255 is selected. Then, based on the feature values (area), the position of the pen stroke on the entire image is determined, such as... Figure 2 Then fill in the image in the top left corner, as shown below. Figure 2 The image in the upper right corner, take the difference, such as... Figure 2 The image in the lower left corner shows morphological erosion, and finally, the opening location is selected, as shown below. Figure 2 The image in the bottom right corner.
[0057] The opening dimensions, including opening depth and opening width, are detected using the opening locations determined by the above Blob analysis.
[0058] Opening depth:
[0059] The approach to detecting the opening depth is to calculate the distance from a point to a line. However, if only the distance between a point and a line is calculated, after repeatability tests (taking the same pen and placing it back and forth 10 times to capture the image and comparing the difference between the minimum and maximum values), the pixel difference reaches 50-100 pixels. This level of accuracy is clearly unacceptable. Therefore, the algorithm logic needs to be optimized: extract the edges of the upper part, lower part, and opening depth of the opening, calculate all the points on the edges of the upper and lower parts, delete the 20% with the largest offset, and then refit the line. The same applies to the edge of the V-shaped opening depth. This results in two lines with very small deviations. Based on all the points on these two lines, calculate the distance from the point to the line and take the average to obtain the true opening depth.
[0060] This paper uses a linear fitting-based dimensional measurement method to test 300 random pen barrels. The results are compared with those of traditional dimensional measurement methods, as shown in Table 1. The results demonstrate that the new algorithm significantly reduces the false detection rate and time, improves detection efficiency, and saves detection costs.
[0061] Table 1 is a comparison table of opening depth detection logic.
[0062]
[0063] Opening width:
[0064] When performing opening width detection, three straight lines need to be fitted, and the upper and lower two lines are extended to calculate their intersection with the third line from the left. To extend the line, first calculate the starting row and column coordinates, ending row and column coordinates, center point row and column coordinates, line length, and angle between the line and the horizontal line, and store them in the corresponding arrays. Then, calculate the extended starting row and column coordinates and ending row and column coordinates according to formula (1), and store them in the arrays. The formula for extending the line is:
[0065]
[0066] in, P Let the row and column coordinates be the starting and ending points of the line to be extended. Pc Let the row and column coordinates be the center point of the line to be extended. Phi The angle between the straight line and the horizontal line. L For the extension factor, L The larger the value of , the longer the extended line. A comparison of the line before and after extension is shown below. Figure 3 As shown, Figure 3 The left image is the image before the extension. Figure 3 The image on the right is the extended version.
[0067] Finally, by calculating the intersection point of the extended straight line and the fitted straight line from the previous text, and repeating this process twice to obtain the upper and lower intersection points, the size of the opening width is calculated based on the column coordinates of the intersection points.
[0068] Pen barrel edge defect detection:
[0069] Detection of contour damage, such as Figure 4 As shown. First, use Blob analysis to find the contour location, then filter the points on the contour, such as... Figure 4 In the top left image, locate the coordinates of the point to be detected, then perform edge smoothing and remove interference generated during the smoothing process. The smoothed result is... Figure 4 The image in the upper right corner, followed by, as Figure 4 The bottom left image compares the distances of each point before and after smoothing, and finally finds the position with the largest distance, which is the location where the contour damage occurred. Figure 4 The image in the bottom right corner.
[0070] like Figure 5 The image shown is a dent defect image after image processing according to this application;
[0071] like Figure 6 As shown in the diagram, the distance between points A and B represents the width of the opening.
[0072] like Figure 7 As shown, the distance between parallel lines C and D is the opening depth.
[0073] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A pen barrel surface defect detection system characterized by, The application relates to a pen barrel detection device. The pen barrel detection device comprises the following parts: A stepping motor for driving the pen barrel to move; A parallel light source for supplementing light to the pen barrel; An image acquisition module for acquiring image information of the pen barrel; An image processing module for receiving data of the image acquisition module and analyzing and processing the data; wherein: The image processing module comprises a first detection module for acquiring the size of the pen barrel through data analysis and a second detection module for acquiring edge defects of the pen barrel through data analysis; The image acquisition module and the image processing module are in data interaction; the image acquisition module comprises a first image acquisition device and a second image acquisition device; the shooting angle of the first image acquisition device is perpendicular to the propagation direction of the parallel light source; the angle between the shooting angle of the second image acquisition device and the shooting angle of the first image acquisition device is 5-45 degrees; the size comprises an opening depth and an opening width; the edge defects comprise profile scratches; The detection process of the opening depth is as follows: S1, Blob analysis is conducted on the image to segment the detection area; specifically, first, the area with a gray value between 70 and 255 is selected, the position of the pen barrel on the whole image is selected according to the characteristic value, then filling, subtraction and morphological corrosion are conducted, and finally the opening position is selected again; S2, the opening size is detected by using the opening position; specifically, the edges of the upper part, the lower part and the opening depth of the opening are extracted, all the points on the edges of the upper part and the lower part are calculated, 20% of the points with large deviation are deleted, the straight lines are fitted again, two straight lines are obtained, the distance of all the points on the two straight lines to the straight lines is calculated and the average value is obtained, and the real opening depth is obtained; 2. The pen barrel surface defect detection system of claim 1, wherein: The detection process of the profile scratches is as follows: first, the profile position is found by using Blob analysis, the points on the profile are screened, the point coordinates to be detected are found, edge smoothing is conducted, the interference generated during the edge smoothing is deleted, then the distance of each point before and after the edge smoothing is compared, and finally the position with the largest distance is found, which is the position where the profile scratches occur.
3. The pen barrel surface defect detection system of claim 1, wherein: The image acquisition module is a linear array camera; during work, the linear array camera adopts a line-by-line scanning mode to acquire images, and then integrates the multiple line scanning images into a surface image.
4. The pen barrel surface defect detection system of claim 3, wherein: The pen barrel detection device further comprises a supporting base; the supporting base comprises a bottom plate, a door-shaped frame and two three-dimensional movement platforms are mounted on the upper surface of the bottom plate, the stepping motor is mounted on the door-shaped frame and the motor shaft is vertically upward, and the two image acquisition devices are mounted on the two three-dimensional movement platforms.
5. The pen barrel surface defect detection system of claim 3, wherein: A vertical shaft hole is formed in the top of the door-shaped frame; the stepping motor is located in the frame; a bearing centering seat is arranged at the upper opening position of the shaft hole; and the rotating shaft of the stepping motor penetrates the shaft hole and is connected with the bearing in the bearing centering seat from bottom to top.
6. The pen barrel surface defect detection system of claim 5, wherein: The three-dimensional movement platform comprises a two-dimensional movement platform mounted on the upper surface of the bottom plate; a vertical fine adjustment support is arranged on the upper surface of each two-dimensional movement platform.
7. The pen barrel surface defect detection system of claim 1, wherein: A camera fixing frame is mounted on the vertical fine adjustment support. The angle between the shooting angle of the second image acquisition device and the shooting angle of the first image acquisition device is 5 degrees, 15 degrees, 25 degrees, 35 degrees or 45 degrees.
Citation Information
Patent Citations
Defect detection control system and method for industrial camera
CN107945152A
FPGA-based end plug defect detection device and method
CN107966454A