Medical glass bottle defect detection method and device based on machine vision
Through the defect detection method and device of medical glass bottles based on machine vision, the problems of low real-time detection, poor stability, easy missed and missed detection in the prior art are solved, and efficient and accurate medical glass bottle quality detection is achieved.
Patent Information
- Application Number
- CN202411441982.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-13
- Publication Date
- 2025-04-04
AI Technical Summary
The existing medical glass bottle detection technology is limited in real environments, and the detection is not very real-time, poor stability, and easy to miss and miss the inspection.
Using machine vision-based medical glass bottle defect detection methods and devices, the side images of glass bottles are taken through industrial cameras, combined with the improved DeeplabV3+ network and Canny edge detection algorithm, the three-dimensional point cloud profile reconstruction of glass bottles is realized, and defect detection is used using the YOLOv7 algorithm.
It improves the real-time and accuracy of the detection, reduces the possibility of missed and missed detection, and ensures the accuracy and reliability of the quality inspection results of medical glass bottles.
Smart Images

Figure CN119757407A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine vision, and in particular to a method and device for detecting defects in medical glass bottles based on machine vision. Background Art
[0002] The pharmaceutical industry's strict requirements on drug quality have brought new challenges to the quality inspection of medical glass bottles. Brown medicine bottles have excellent light protection effect, which can extend the life of the medicine. They have good sealing and can extend the shelf life of the medicine. The main features of the appearance of brown sample bottles are flawless, bubble-free, and good light transmittance. There will be no phantom phenomenon when reading the text through the bottle. They are used to hold medicines, making the product give people a comfortable feeling. Brown bottles are easier to detect with cameras than transparent medicine bottles because they are colored and opaque. Figure 6 The defects of stains, air lines, cracks, etc. in the medical glass bottles shown above may lead to leakage of liquid medicine and deterioration of medicine, which not only affects the efficacy but also threatens the safety and health of the users. At the same time, tiny foreign objects in medical glass bottles are also a major hidden danger, which may cause serious medical accidents.
[0003] The production process of pharmaceutical glass bottles is a complex process with multiple factors coupled. Any abnormality in the production process will lead to product defects. Timely identification and detection of defect patterns of abnormal products is an effective way to improve product quality and production efficiency. In order to ensure the quality of pharmaceutical products, accurate defect detection of pharmaceutical glass bottles is of great research significance.
[0004] A medical glass vial is a medical glass bottle used to package small quantities of drugs and sanitary products. Medical glass vials are made of glass and are used to package liquid drugs, powders or capsules. Since the amount of medicine in a medical glass vial is important, it is crucial to ensure that the size of the medical glass vial matches the standard size. In dimensional inspection, important dimensions such as the height, outer edge and diameter of the ring are checked. In the production line, for each size of the vial, an acceptable tolerance range is defined, and products whose size is not within the predefined tolerance are detected as defective.
[0005] At present, most medical glass bottle inspections in China are done manually, which has problems such as low efficiency, poor stability, and easy omissions. Especially for some high-end pharmaceutical products, the requirements for inspection accuracy are higher, and manual inspection is no longer able to meet them. Long-term high-intensity inspections also bring health risks to operators.
[0006] Machine vision systems are increasingly favored by pharmaceutical companies due to their high efficiency and accuracy. Automated testing equipment can comprehensively and quickly test the quality of medical glass bottles, greatly improving production efficiency, while also ensuring the accuracy of test results, providing effective protection for drug quality and user safety. Compared with manual testing, machine vision systems are undoubtedly the future trend of drug quality management. Summary of the invention
[0007] In response to the above problems, the present invention provides a medical glass bottle defect detection method and device based on machine vision, which is used to solve the problems of limited application of existing medicinal glass bottle detection technology in real environments, low real-time detection, poor stability, easy missed detection and false detection, etc.
[0008] A machine vision-based medical glass bottle defect detection device comprises a No. 1 industrial camera, a No. 2 industrial camera, a No. 3 industrial camera, a camera stand and a conveyor belt; wherein the No. 1 industrial camera, the No. 2 industrial camera and the No. 3 industrial camera are connected to the camera stand through a No. 1 control unit, a No. 2 control unit and a No. 3 control unit to photograph information of medical glass products, the side of the camera stand is connected to a conveyor belt bracket, and the No. 1 industrial camera, the No. 2 industrial camera and the No. 3 industrial camera have the same mechanical structure. The camera rack includes industrial camera No. 1, industrial camera No. 2, industrial camera No. 3, control component No. 1, control component No. 2 and control component No. 3; wherein control component No. 1 and control component No. 2 have the same mechanical structure, are connected to the camera rack by a slide groove and can perform translational movement, are connected to the camera by a threaded connection and can perform rotational movement, so as to adjust the posture of industrial camera No. 1 and industrial camera No. 2; control component No. 3 is connected to the camera rack by a slide groove and can perform left and right translational movement, is connected to the camera by a slide groove and can perform up and down translational movement, so as to adjust the posture of industrial camera No. 3; the conveyor belt bracket is equipped with a timer, a medical glass bottle detection rack, a recycling box and a collection box, the timer is used to set the time so as to match the camera shooting time, the medical glass bottle detection rack is used to fix the medical glass bottles and rotate the medical glass bottles, the recycling box is used to recycle the medical glass bottles that are unqualified and defective, and the collection box is used to recycle the medical glass bottles that are qualified.
[0009] A method and device for detecting defects in medical glass bottles based on machine vision, the method is implemented according to the following steps:
[0010] Step 1: The medical glass bottle is transferred to the turntable through a mechanical transmission device and rotated at a constant angle. The industrial camera takes pictures of the side of the glass bottle at each rotation angle until the glass bottle stops when it rotates 180°.
[0011] Step 2: By capturing images at each interval angle, the cross-sectional profile images of the glass bottle at each angle can be obtained. The resulting series of cross-sectional images contain the overall three-dimensional profile information of the glass bottle.
[0012] Step 3: Perform perspective transformation on the side image of the medical glass bottle to complete image correction.
[0013] Step 4: Use the improved DeeplabV3+ network to segment the cross-sectional image of the medical glass bottle from the shooting background.
[0014] Step 5: Accurately extract the outer contour of the medical glass bottle through the improved Canny edge detection algorithm, convert the pixel contour size into the actual size according to the conversion ratio of pixel size to real size, and then reconstruct the three-dimensional point cloud contour of the medical glass bottle according to the corner and contour information of each section.
[0015] Step 6: Use the KN-4PCS algorithm to perform rough registration to achieve preliminary registration of the source point cloud and the target point cloud.
[0016] Step 7: Use the ICP point cloud registration algorithm to accurately align the collected medical glass bottle outer contour point cloud with the standard medical glass bottle 3D model point cloud.
[0017] The point cloud registration process is as follows:
[0018] 1. Select the side area of the mouth of the medical glass bottle as the point cloud registration area.
[0019] 2. Select three point clouds from the point cloud P in the area to be registered
[0020] 3. Find the point cloud with the same position as that in point cloud P in the corresponding area of target point cloud Q, and convert it using the theoretical coordinate system conversion formula of the two.
[0021] 4. Take point set p in the target point cloud P i ∈P, find the corresponding point set q in the source point cloud Q i ∈Q, such that ||q i -p i ||=min holds. Calculate the rotation matrix R and the translation matrix T to minimize the error function.
[0022] 5. For p i Use the rotation matrix R and translation matrix T obtained in the previous step to perform rotation and translation transformations to obtain the corresponding new point set p′ i = {p′ i =R×p i +T,p i ∈P}.
[0023] 6. According to the formula Calculate p′ i and the corresponding point set q i If d is less than a given threshold or greater than the preset maximum number of iterations, the iterative calculation is stopped. Otherwise, return to step 6 until the convergence condition is met.
[0024] 7. Finally, use the final rotation matrix R and translation matrix T' to complete the final overall registration.
[0025] Step 8: Calculate the contour difference points at each position of the two through the bidirectional Kd-tree point pair search algorithm, and calculate the contour deviation value to determine whether the size of the position is out of tolerance.
[0026] Step 9: While detecting the size of the medical glass bottle, use the improved YOLOv7 algorithm to detect three types of defects: stains, air lines, and cracks on the body, mouth, and bottom of the medical glass bottle.
[0027] The YOLOv7 neural network is a medical glass bottle defect recognition network, and the network structure includes:
[0028] 1. The backbone network uses CBAM modules to replace a certain number of CBL convolution modules to achieve better accuracy;
[0029] 2. The Backbone part uses PConv (PartialConvolution) to replace the convolution of this part in YOLOv7, which can reduce the redundant calculation amount of the algorithm;
[0030] 3. Introduce weighted bidirectional feature pyramid network (BiFPN) in Neck to retain more feature information of small objects;
[0031] 4. Use EIoU as the loss function to improve detection accuracy.
[0032] The training process of the YOLOv7 target detection algorithm is as follows:
[0033] 1. Collect training samples. The specific steps are as follows: obtain the target area image of each medical glass bottle, use the collected target area images as data set samples, enhance the data set by mirroring and flipping, and then divide the data set into a training set and a validation set in a ratio of 4:1. Then manually mark the defect areas and defect categories, where the defect categories include stains, air lines, and cracks, and obtain labeled data set samples;
[0034] 2. Set the loss function to EIoU loss function, input the training set, train the YOLOv7 network, and input the validation set to verify the generalization ability of the model. Set the threshold α, and when the loss value of the validation set is less than α, the training is terminated to obtain the medical glass bottle target detection model.
[0035] Step 10: further judge the defective images, judge the defective images with abnormality less than 10% as slight defects and treat them as no defects; judge the defective images with abnormality greater than 10% as defective and proceed to the next step.
[0036] Z=βZ 1 +(1-β)Z 2
[0037] Among them, Z is the degree of abnormality; Z 1 is the difference between the defective image and the standard image; Z 2 The degree of difference between the features extracted by the weighted bidirectional feature pyramid network and the standard image features.
[0038] Step 11: Medical glass bottles with defects in the body, mouth, bottom or unqualified size are rejected by the rejection mechanism. The overall defect detection of medical glass bottles is completed.
[0039] The most outstanding features and significant beneficial effects of the present invention are:
[0040] 1. This application uses the improved DeeplabV3+ network to further improve the segmentation accuracy of medical glass bottle cross-section images and shooting backgrounds. First, the lightweight model MobileNetV3-large is used as the backbone network of DeeplabV3+ to extract features in real time; second, the expansion rate of the hole convolution in the ASPP structure is increased, and the maximum pooling is used in the last layer of ASPP to effectively capture contextual information of different scales; finally, the SE attention module is introduced to perform feature weighting on the high-level features obtained by sampling and the low-level features extracted by the backbone network to distinguish the importance of different features and improve the accuracy of the fused feature information. The real-time performance of segmentation is improved, and the segmentation accuracy is relatively high.
[0041] 2. It is proposed to introduce the two-dimensional Otsu algorithm to improve the Canny algorithm. The two-dimensional Otsu algorithm is used to search all pixels in the image and find the most appropriate segmentation threshold. This solves the problem that the traditional Canny algorithm needs to manually give an edge strength threshold, thereby improving and stabilizing the edge detection accuracy. In order to improve the running speed of the algorithm and reduce the computational complexity of the algorithm, the wolf pack algorithm is introduced into the two-dimensional Otsu algorithm, and the powerful search ability of the wolf pack algorithm is used to find the optimal threshold in the image.
[0042] After the above method adaptively selects the intensity threshold of the Canny algorithm, the Canny algorithm automatically detects the edge of the image based on this intensity threshold. The improved algorithm can obtain a reliable threshold and has better accuracy and precision in edge detection.
[0043] 3. An improved YOLOv7 algorithm for detecting defects in medical glass bottles is proposed. First, the CBAM module related to the attention mechanism is introduced into the backbone network; then, the convolution of the Backbone part in YOLOv7 is replaced by PConv (PartialConvolution) to reduce the redundant calculation of the algorithm; secondly, the weighted bidirectional feature pyramid network (BiFPN) is introduced into Neck to retain more feature information of small targets; finally, EIoU is used as the loss function to improve the detection accuracy. To a certain extent, the complexity of the calculation is reduced, the real-time performance of the detection is further improved, and the detection accuracy is relatively high. The problems of the large size difference of the three defect targets of medical glass bottles, namely stains, air lines and cracks, the single detection scale and the difficulty of the original network to detect small targets such as stains are solved.
[0044] 4. A method for evaluating the degree of abnormality of medical glass bottles is proposed. This method ensures a quantitative evaluation of the degree of abnormality of defective glass bottles by performing secondary inspection on glass bottle images. First, the degree of difference between the defective image and the standard image is calculated. The features of the defective image are extracted using a weighted bidirectional feature pyramid network and compared with the features of the standard image to further analyze the subtle differences. Finally, the above-mentioned degree of difference is comprehensively calculated in a weighted manner to obtain a more accurate abnormality evaluation result. This method can effectively screen out medical glass bottles with minor and inconspicuous defects that are allowed to be used through a multi-scale weighted strategy.
[0045] 5. The present invention provides a simple structural model of a medical glass defect detection system. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 This is a schematic diagram of the main structure of the medical glass bottle defect detection device of this application
[0047] Figure 2 This is a schematic diagram of the rejection mechanism of the medical glass bottle defect detection device of this application
[0048] Figure 3 This is the flow chart of the invention method of this application
[0049] Figure 4 This is the design flow chart of the medical glass bottle defect recognition system of this application
[0050] Figure 5 This is the block diagram of the medical glass bottle detection system of this application
[0051] Figure 6 This is the defect diagram of the medical glass bottle in this application DETAILED DESCRIPTION
[0052] Specific implementation method 1: Combination Figure 1 The present embodiment is described as follows: a medical glass bottle defect detection device based on machine vision is composed of a first industrial camera 5, a second industrial camera 7, a third industrial camera 8, a camera frame 6 and a conveyor belt 10;
[0053] Industrial camera No. 1 5, industrial camera No. 2 7 and industrial camera No. 3 8 are connected to camera holder 6 via control component No. 1 15, control component No. 2 14 and control component No. 3 13 for photographing information of medical glass products. The side of camera holder 6 is connected to conveyor belt support 2, and industrial camera No. 1 5, industrial camera No. 2 7 and industrial camera No. 3 8 have the same mechanical structure.
[0054] Specific implementation method 2: Combination Figure 1 This embodiment is described. This embodiment is a further limitation of the detection device described in the specific embodiment 1. In this embodiment, a medical glass bottle defect detection device based on machine vision is described. The camera frame 4 includes a first industrial camera 5, a second industrial camera 7, a third industrial camera 8, a first control unit 15, a second control unit 14 and a third control unit 13;
[0055] The first control member 15 and the second control member 14 have the same mechanical structure. They are connected to the camera frame 4 by a slide groove to allow translational movement, and are connected to the camera by a thread to allow rotational movement, so as to adjust the posture of the first industrial camera 5 and the second industrial camera 7.
[0056] The third control member 13 is connected to the camera frame 4 by a slide groove so that it can move left and right, and is connected to the camera by a slide groove so that it can move up and down, so as to adjust the posture of the third industrial camera 8;
[0057] The rejecting mechanism structural member 18 is fixedly connected to the conveyor belt, the rejecting mechanism structural member 17 can rotate, and the rejecting mechanism structural member 16 is used to reject unqualified medical glass bottles.
[0058] Specific implementation method three: Combination Figure 1 The present embodiment is described. The present embodiment is a further limitation of the detection device described in the specific embodiment 1. The present embodiment describes a medical glass bottle defect detection device based on machine vision. The conveyor belt bracket 2 is equipped with a timer 3, a medical glass bottle detection rack 6, a recovery box 9 and a collection box 11. The timer 3 is used for timing so as to coincide with the camera shooting time. The medical glass bottle detection rack 6 is used to fix the medical glass bottles and rotate the medical glass bottles. The recovery box 9 is used to recycle the medical glass bottles that have failed the inspection and have defects, and the collection box is used for the medical glass bottles that have passed the inspection.
[0059] Specific implementation method four: Combination Figure 1 and Figure 2This embodiment is described. This embodiment is a further limitation of the detection device described in the fifth embodiment. The medical glass bottle defect detection device based on machine vision described in this embodiment has the following detection rhythm:
[0060] Medical glass bottles are conveyed from right to left by the conveyor belt, and the conveyor belt is set at a speed of 10 cm / s. Medical glass bottles are placed on the conveyor belt in turn every 7 seconds, and the timer controls the stop every 5 seconds, and each control stops for 2 seconds to facilitate camera shooting and detection. If the inspection is qualified, it will be conveyed with the conveyor belt and finally transferred to the collection box 11; if the inspection is unqualified, the medical glass bottle will be controlled by the rejection mechanism 12 to be rejected and sent to the recycling box 9.
[0061] Specific implementation method five: Combination Figure 1 This embodiment describes a method for detecting defects in medical glass bottles based on machine vision, and the specific method is as follows:
[0062] Step 1: The medical glass bottle is transferred to the turntable through a mechanical transmission device and rotated at a constant angle. The industrial camera takes pictures of the side of the glass bottle at each rotation angle until the glass bottle stops when it rotates 180°.
[0063] Step 2: By capturing images at each interval angle, the cross-sectional profile images of the glass bottle at each angle can be obtained. The resulting series of cross-sectional images contain the overall three-dimensional profile information of the glass bottle.
[0064] Step 3: Perform perspective transformation on the side image of the medical glass bottle to complete image correction.
[0065] Step 4: Use the improved DeeplabV3+ network to segment the cross-sectional image of the medical glass bottle from the shooting background.
[0066] Step 5: Accurately extract the outer contour of the medical glass bottle through the improved Canny edge detection algorithm, convert the pixel contour size into the actual size according to the conversion ratio of pixel size to real size, and then reconstruct the three-dimensional point cloud contour of the medical glass bottle according to the corner and contour information of each section.
[0067] Step 6: Use the KN-4PCS algorithm to perform rough registration to achieve preliminary registration of the source point cloud and the target point cloud.
[0068] Step 7: Use the ICP point cloud registration algorithm to accurately align the collected medical glass bottle outer contour point cloud with the standard medical glass bottle 3D model point cloud.
[0069] Step 8: Calculate the contour difference points at each position of the two through the bidirectional Kd-tree point pair search algorithm, and calculate the contour deviation value to determine whether the size of the position is out of tolerance.
[0070] Step 9: While detecting the size of the medical glass bottle, use the improved YOLOv7 algorithm to detect three types of defects: stains, air lines, and cracks on the body, mouth, and bottom of the medical glass bottle.
[0071] Step 10: further judge the defective images, judge the defective images with abnormality less than 10% as slight defects and treat them as no defects; judge the defective images with abnormality greater than 10% as defective and proceed to the next step.
[0072] Step 11: Medical glass bottles with defects in the body, mouth, bottom or unqualified size are rejected by the rejection mechanism. The overall defect detection of medical glass bottles is completed.
[0073] Specific implementation method six: Combination Figure 1 This embodiment is described. This embodiment is a further limitation of the detection method described in the fifth embodiment. In this embodiment, a method for detecting defects in medical glass bottles based on machine vision is described. The point cloud registration process in step seven is as follows:
[0074] 1. Select the side area of the mouth of the medical glass bottle as the point cloud registration area.
[0075] 2. Select three point clouds from the point cloud P in the area to be registered
[0076] 3. Find the point cloud with the same position as that in point cloud P in the corresponding area of target point cloud Q, and convert it using the theoretical coordinate system conversion formula of the two.
[0077] 4. Take point set p in the target point cloud P i ∈P, find the corresponding point set q in the source point cloud Q i ∈Q, such that ||q i -p i ||=min holds. Calculate the rotation matrix R and the translation matrix T to minimize the error function.
[0078] 5. For p i Use the rotation matrix R and translation matrix T obtained in the previous step to perform rotation and translation transformations to obtain the corresponding new point set p′ i = {p′ i =R×p i +T,p i ∈P}.
[0079] 6. According to the formula Calculate p′ i and the corresponding point set q iIf d is less than a given threshold or greater than the preset maximum number of iterations, the iterative calculation is stopped. Otherwise, return to step 6 until the convergence condition is met.
[0080] 7. Finally, use the final rotation matrix R and translation matrix T' to complete the final overall registration.
[0081] Specific implementation method seven: Combination Figure 1 This embodiment is described. This embodiment is a further limitation of the detection method described in the specific embodiment 5. This embodiment describes a method for detecting defects in medical glass bottles based on machine vision. The YOLOv7 neural network is a medical glass bottle defect recognition network. The network structure includes:
[0082] 1. The backbone network uses CBAM modules to replace a certain number of CBL convolution modules to achieve better accuracy;
[0083] 2. The Backbone part uses PConv (PartialConvolution) to replace the convolution of this part in YOLOv7, which can reduce the redundant calculation amount of the algorithm;
[0084] 3. Introduce weighted bidirectional feature pyramid network (BiFPN) in Neck to retain more feature information of small objects;
[0085] 4. Use EIoU as the loss function to improve detection accuracy.
[0086] Specific implementation method eight: Combination Figure 1 This embodiment is described. This embodiment is a further limitation of the detection method described in the specific embodiment 5. The medical glass bottle defect detection method based on machine vision described in this embodiment, the training process of the YOLOv7 target detection algorithm is as follows:
[0087] 1. Collect training samples. The specific steps are as follows: obtain the target area image of each medical glass bottle, use the collected target area images as data set samples, enhance the data set by mirroring and flipping, and then divide the data set into a training set and a validation set in a ratio of 4:1. Then manually mark the defect areas and defect categories, where the defect categories include stains, air lines, and cracks, and obtain labeled data set samples;
[0088] 2. Set the loss function to EIoU loss function, input the training set, train the YOLOv7 network, and input the validation set to verify the generalization ability of the model. Set the threshold α, and when the loss value of the validation set is less than α, the training is terminated to obtain the medical glass bottle target detection model.
[0089] Specific implementation method nine: Combination Figure 1 This embodiment is described. This embodiment is a further limitation of the detection method described in the fifth embodiment. In this embodiment, a method for detecting defects in medical glass bottles based on machine vision is described. The determination formula of step 11 is as follows:
[0090] Z=βZ 1 +(1-β)Z 2
[0091] Among them, Z is the degree of abnormality; Z 1 is the difference between the defective image and the standard image; 2 The degree of difference between the features extracted by the weighted bidirectional feature pyramid network and the standard image features.
[0092] The above description is only a preferred embodiment of the present invention and does not constitute any form of limitation to the present invention. Although the present invention has been disclosed as a preferred embodiment as above, it is not intended to limit the present invention. Any technician familiar with the profession can make some changes or modify the technical contents disclosed above into equivalent embodiments without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent replacement and improvement of the above embodiments made according to the technical essence of the present invention, within the spirit and principles of the present invention, still fall within the protection scope of the technical solution of the present invention.
Claims
1. A medical glass bottle defect detection device based on machine vision, which comprises a No. 1 industrial camera, a No. 2 industrial camera, a No. 3 industrial camera, a camera frame and a conveyor belt; wherein the No. 1 industrial camera, the No. 2 industrial camera and the No. 3 industrial camera are connected to the camera frame through a No. 1 control component, a No. 2 control component and a No. 3 control component to photograph medical glass product information, the side of the camera frame is connected to the conveyor belt bracket, and the No. 1 industrial camera, the No. 2 industrial camera and the No. 3 industrial camera have the same mechanical structure. The camera rack includes industrial camera No. 1, industrial camera No. 2, industrial camera No. 3, control component No. 1, control component No. 2 and control component No. 3; wherein control component No. 1 and control component No. 2 have the same mechanical structure, are connected to the camera rack by a slide groove and can perform translational movement, are connected to the camera by a threaded connection and can perform rotational movement, so as to adjust the posture of industrial camera No. 1 and industrial camera No. 2; control component No. 3 is connected to the camera rack by a slide groove and can perform left and right translational movement, is connected to the camera by a slide groove and can perform up and down translational movement, so as to adjust the posture of industrial camera No. 3; the conveyor belt bracket is equipped with a timer, a medical glass bottle detection rack, a recycling box and a collection box, the timer is used to set the time so as to match the camera shooting time, the medical glass bottle detection rack is used to fix the medical glass bottles and rotate the medical glass bottles, the recycling box is used to recycle the medical glass bottles that are unqualified and defective, and the collection box is used to recycle the medical glass bottles that are qualified.
2. A method and device for detecting defects in medical glass bottles based on machine vision, wherein the method is implemented according to the following steps: Step 1: The medical glass bottle is transferred to the turntable through a mechanical transmission device and rotated at a constant angle. The industrial camera takes pictures of the side of the glass bottle at each rotation angle until the glass bottle stops when it rotates 180°. Step 2: By capturing images at each interval angle, the cross-sectional profile images of the glass bottle at each angle can be obtained. The obtained series of cross-sectional images contain the overall three-dimensional profile information of the glass bottle. Step 3: Perform perspective transformation on the side image of the medical glass bottle to complete image correction. Step 4: Use the improved DeeplabV3+ network to segment the cross-sectional image of the medical glass bottle from the shooting background. Step 5: Accurately extract the outer contour of the medical glass bottle through the improved Canny edge detection algorithm, convert the pixel contour size into the actual size according to the conversion ratio of pixel size to real size, and then reconstruct the three-dimensional point cloud contour of the medical glass bottle according to the corner and contour information of each section. Step 6: Use the KN-4PCS algorithm to perform rough registration to achieve preliminary registration of the source point cloud and the target point cloud. Step 7: Use the ICP point cloud registration algorithm to accurately align the collected medical glass bottle outer contour point cloud with the standard medical glass bottle 3D model point cloud. Step 8: Calculate the contour difference points at each position of the two through the bidirectional Kd-tree point pair search algorithm, and calculate the contour deviation value to determine whether the size of the position is out of tolerance. Step 9: While detecting the size of the medical glass bottle, use the improved YOLOv7 algorithm to detect three types of defects: stains, air lines, and cracks on the body, mouth, and bottom of the medical glass bottle. Step 10: further judge the defective images, judge the defective images with abnormality less than 10% as slight defects and treat them as no defects; judge the defective images with abnormality greater than 10% as defective and proceed to the next step. Step 11: Medical glass bottles with defects in the body, mouth, bottom or unqualified size are rejected by the rejection mechanism. The overall defect detection of medical glass bottles is completed.
3. The method for detecting defects in medical glass bottles based on machine vision according to claim 2, characterized in that: The point cloud registration process in step 7 is as follows: (1) Select the side area of the mouth of the medical glass bottle as the point cloud registration area. (2) Select three point clouds from the point cloud P in the area to be registered (3) Find the point cloud with the same position as that in point cloud P in the corresponding area of target point cloud Q, and convert it using the theoretical coordinate system conversion formula of the two. (4) Select point set p from the target point cloud P i ∈P, find the corresponding point set q in the source point cloud Q i ∈Q, such that ||q i -p i ||=min holds. Calculate the rotation matrix R and the translation matrix T to minimize the error function. (5) For p i Use the rotation matrix R and translation matrix T obtained in the previous step to perform rotation and translation transformations to obtain the corresponding new point set p′ i = {p′ i =R×p i +T,p i ∈P}. (6) According to the formula Calculate p′ i and the corresponding point set q i If d is less than a given threshold or greater than the preset maximum number of iterations, the iterative calculation is stopped. Otherwise, return to step 6 until the convergence condition is met. (7) Finally, use the final rotation matrix R and translation matrix T' to complete the final overall registration.
4. The method for detecting defects in medical glass bottles based on machine vision according to claim 2, characterized in that: The improved YOLOv7 neural network in step nine is a medical glass bottle defect recognition network, and the network structure includes: (1) The backbone network uses CBAM modules to replace a certain number of CBL convolution modules to achieve better accuracy; (2) The Backbone part uses PConv (PartialConvolution) to replace the convolution of this part in YOLOv7, which can reduce the redundant calculation amount of the algorithm; (3) Introducing the weighted bidirectional feature pyramid network (BiFPN) in Neck to retain more feature information of small objects; (4). Use EIoU as the loss function to improve detection accuracy.
5. According to the improved YOLOv7 target detection algorithm described in claim 2, its training process is as follows: (1) Collect training samples. The specific steps are as follows: obtain the target area image of each medical glass bottle, use the collected target area image as the data set sample, enhance the data set by mirroring and flipping, and then divide the data set into a training set and a validation set in a ratio of 4:
1. Then manually mark the defect areas and defect categories, where the defect categories include stains, air lines, and cracks, and obtain the labeled data set samples; (2) Set the loss function to EIoU loss function, input the training set, train the YOLOv7 network, and input the validation set to verify the generalization ability of the model. Set the threshold α, and when the loss value of the validation set is less than α, the training is terminated to obtain the medical glass bottle target detection model.
6. The method for detecting defects in medical glass bottles based on machine vision according to claim 2, characterized in that: The determination method of step 11 is as follows: Z=βZ1+(1-β)Z2 Among them, Z is the degree of abnormality; Z1 is the difference between the defective image and the standard image; Z2 is the difference between the features extracted by the weighted bidirectional feature pyramid network and the features of the standard image.
Citation Information
Patent Citations
Glass oral liquid bottle defect detection system
CN113189120A
Flexible bottle unloading and transferring device and method for glass bottle making machine
CN115889231A
Glass bottle defect identification method and system
CN117351314A
Visual detection method for high-precision waste penicillin bottles
CN117635540A
Method for detecting surface defects of tablets in glass medicine bottle based on deep learning
CN118513263A
Cited By
Method and system for digitally tracing quality of light-weight glass bottle
CN120258639A