AI-based medicine bottle color point detection method and detection device
By introducing multispectral imaging and AI algorithms into the drug bottle detection system, the problems of low detection efficiency, high missed detection rate and strong subjectivity in the prior art are solved, and more efficient and accurate drug bottle color point detection is achieved.
Patent Information
- Application Number
- CN202411840428.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-03-28
AI Technical Summary
The existing pharmaceutical bottle color point detection technology is low, has high missed detection rate and has strong subjectivity.
Using the automatic detection method of color point of the medicine bottle based on multispectral imaging and intelligent algorithms, a multispectral dome light source and high-resolution imaging system are set up on the medicine bottle conveying device, and the AI algorithm is used to extract and classify the bottle images under different detected lights, and a corresponding relationship database of various defects and optimal detected light is constructed to realize automated detection.
It improves the reliability and accuracy of the detection, reduces the missed detection rate and false detection rate, realizes the rapid and accurate identification of color point defects of the medicine bottle, and improves the detection efficiency of the production line.
Smart Images

Figure CN119715540A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of medicine bottle packaging detection, and more specifically, to an AI-based medicine bottle color point detection method and detection device. Background Art
[0002] With the continuous development of glass container production technology, the production technology of my country's pharmaceutical glass industry has become more mature, and the gap with international advanced technology has been narrowing. However, with the continuous development of production technology and the higher requirements for safe use, the market now has higher and higher quality requirements for pharmaceutical molded bottle glass containers. At present, the main detection method in the pharmaceutical glass container industry is based on traditional machine vision and a single image acquisition light source system to perform various processing technologies, including monochromatic light source, Blob analysis, morphological processing, and feature matching.
[0003] In the patents "CN113887668A A visual detection system for neck crack defects in glass container manufacturing", "CN201710205089 A visual detection method and system for carbonization of bottle heads of glass bottles and ampoules" and "CN113701588A A color point detection device and detection method for medicinal ampoule glass bottles", traditional visual detection is used for processing. In these processing methods, the light source used in the shooting process is single, and it is impossible to clearly distinguish the defects on the bottle and other interfering targets. In actual detection, traditional color point detection mainly relies on manual visual inspection. The operator inspects the surface and interior of the glass bottle with the naked eye or a magnifying glass to identify uneven color, impurities or other defects. Although this method is intuitive, it has the problems of strong subjectivity, low efficiency and high misjudgment rate. Summary of the invention
[0004] The purpose of this application is to provide a method and device for automatic detection of color points on medicine bottles based on multispectral imaging and intelligent algorithms, so as to solve the problems of low detection efficiency, high missed detection rate and strong subjectivity in the prior art.
[0005] The technical solution of this application is to provide an AI-based medicine bottle color point detection method, which includes:
[0006] Step 1, selecting a shooting area on a medicine bottle conveyor, setting the shooting area in a cavity with a white background, setting a multi-spectral dome light source at the top of the shooting area, setting a front-view camera and a top-view camera around the shooting area, aiming the front-view camera at the body of the medicine bottle, and aiming the top-view camera at the mouth of the medicine bottle, wherein the multi-spectral dome light source is used to generate a variety of detection lights, including a single light with a wavelength within a preset range or a combined light formed by superimposing different single lights;
[0007] Step 2: Use multiple detection lights generated by a multi-spectral dome light source to sequentially illuminate the pre-inspected medicine bottles, obtain images of the pre-inspected medicine bottles under different detection lights, classify and count the defects of the medicine bottles under the same detection light, and build a database of corresponding relationships between various defects and optimal detection light based on the statistical results;
[0008] Step 3: Sampling and testing a single batch of target medicine bottles to be tested, obtaining the proportion of each defect type, and taking the defect type whose proportion value exceeds a preset threshold as the target defect type;
[0009] Step 4: Set the target medicine bottles on the conveyor, determine the optimal detection light for each target defect type corresponding to the current batch of medicine bottles based on the database, use the multi-spectral dome light source to generate different optimal detection lights in sequence, and illuminate the target medicine bottles entering the shooting area;
[0010] Step 5, using a camera to sequentially capture images of the target medicine bottle under different detection lights, grouping and numbering the images corresponding to a single medicine bottle, and inputting each group of images into an image processing unit in turn;
[0011] Step 6, using the target detection model in the image processing unit to extract features from the medicine bottle image, splicing the extracted features with the position coding features of the image, encoding and decoding the spliced features in sequence, outputting prediction results based on the decoded features, and obtaining the color point defects and defect locations corresponding to the single medicine bottle;
[0012] Step 7, classifying the defects corresponding to the individual medicine bottles according to the preset defect levels, calculating the defect scores corresponding to the individual medicine bottles based on the classification results, and determining the defective medicine bottles according to the defect scores;
[0013] Step 8, the detection results of the defective medicine bottles are fed back to the control unit in real time, and the control unit controls the subsequent waste rejection device to reject the defective medicine bottles.
[0014] Furthermore, step 2 specifically includes: extracting a part of the medicine bottles to be tested as pre-inspection medicine bottles, transporting the medicine bottles to the shooting area through a transfer device, using a multi-spectral dome light source to sequentially generate a variety of detection lights to illuminate the pre-inspection medicine bottles, the multiple detection lights include at least blue light, white light and combined light, using a camera to capture the pre-inspection medicine bottle image under each detection light, for the pre-inspection medicine bottle image under a single detection light, finding all defects, classifying the defects, and counting the number of defects of each type to obtain the number of defects of each type under different detection lights, for each type of defect, using the detection light used when the largest number of defects are detected as the optimal detection light, and establishing a database of corresponding relationships between various types of defects and optimal detection lights.
[0015] Furthermore, in step 1, frontal cameras and overhead cameras are set around the shooting area, specifically including: four groups of frontal cameras distributed in a planar rectangular shape and four groups of overhead cameras distributed in a planar rectangular shape are set around the shooting area, the height of the plane where the four groups of frontal cameras are located is the same as the height of the medicine bottle body on the conveying device, and the height of the plane where the four groups of overhead cameras are located is higher than the height of the medicine bottle mouth, wherein the positions of the four groups of overhead cameras correspond to the positions of the four groups of frontal cameras.
[0016] Furthermore, in step 1, the lens of the front-facing camera is aimed at the position of the body of the medicine bottle, and the lens of the overhead camera is aimed at the position of the mouth of the medicine bottle, which specifically includes: setting a first shooting position and a second shooting position in sequence along the conveying direction of the medicine bottle in the shooting area, the first shooting position is located at the end of the medicine bottle in the cavity, and the second shooting position is located at the end of the medicine bottle in the cavity, adjusting the lenses of each group of cameras, and pointing the lenses of the two groups of front-facing cameras near the medicine bottle outlet end toward the position of the medicine bottle body at the first shooting position, and pointing the lenses of the two groups of front-facing cameras near the medicine bottle entry end toward the position of the medicine bottle body at the second shooting position, and pointing the lenses of the two groups of overhead cameras near the medicine bottle exit end toward the position of the medicine bottle mouth at the first shooting position, and pointing the lenses of the two groups of overhead cameras near the medicine bottle entry end toward the position of the medicine bottle mouth at the second shooting position.
[0017] Furthermore, in step 5, a camera is used to capture images of the medicine bottle under different detection lights, specifically including: using a frontal camera and a bird's-eye view camera to respectively capture images of the medicine bottle body and the medicine bottle mouth under different detection lights; after completing the shooting under the current detection light, controlling the multi-spectral dome light source to switch to the next detection light for shooting; for each detection light, when the medicine bottle reaches the first shooting position, two groups of frontal cameras near the outlet end of the medicine bottle are used to capture images of the medicine bottle body from two predetermined frontal directions on the front side of the medicine bottle; at the same time, two groups of bird's-eye view cameras near the outlet end of the medicine bottle are used to capture images of the medicine bottle mouth from two predetermined bird's-eye directions on the front side of the medicine bottle; when the medicine bottle reaches the second shooting position in the shooting area, two groups of frontal cameras near the inlet end of the medicine bottle are used to capture the medicine bottle body from two predetermined frontal directions on the rear side of the medicine bottle; at the same time, two groups of bird's-eye view cameras near the inlet end of the medicine bottle are used to capture images of the medicine bottle from two predetermined bird's-eye directions on the rear side of the medicine bottle.
[0018] Furthermore, in step 5, the image groups corresponding to the images of the single medicine bottle are grouped and group numbers are set, and each group of images is input into the image processing unit in turn, specifically including: taking the images of the single medicine bottle captured under different detection lights as a group of image groups, a single image group includes the bottle body image on the front side of the medicine bottle, the bottle body image on the back side of the medicine bottle, the bottle mouth image on the front side of the medicine bottle, and the bottle mouth image on the back side of the medicine bottle, the image groups corresponding to the devices are numbered according to the order of each medicine bottle, and the image groups are input into the image processing unit in order according to the numbering order.
[0019] Furthermore, step 6 specifically includes: step 6.1, using the ResNet network in the target detection model to extract features and reduce the size of the medicine bottle image to obtain multiple output feature maps, and splicing each feature vector contained in a single feature map with the corresponding positional encoding feature through the positional encoding mechanism to obtain a spliced feature vector; step 6.2, inputting the spliced feature vector into the encoder of the Transformer network for feature encoding; step 6.3, presetting M target detection frames, and inputting the M target detection frames into the Transformer network. In the decoder of nsformer, the decoder is used to decode features, and the decoding results are mapped to M target detection frames to obtain M decoded detection frame features, where M is a positive integer; in step 6.4, the M detection frame features are input into the FFN layer, and the FFN layer is used to predict and classify the M detection frame features to obtain M detection frames, each of which includes width, height, center coordinates, target category and confidence; in step 6.5, the target detection model is used to output the information of the detection frames whose target categories are not background in all detection frames, and the color point defects of a single medicine bottle and the corresponding positions of each color point defect are obtained.
[0020] Furthermore, step 6.3 specifically includes: using the preset M target detection boxes and the global features output by the encoder as input features of the decoder, processing the input features using multiple stacked basic decoding units in the decoder, passing the position and category information in the global features to the target detection box, and obtaining M decoded target detection box features.
[0021] Furthermore, step 7 specifically includes: presetting a specific number of defect levels, setting a corresponding defect score according to the degree of harmful effect of each level of defect on the quality of the medicine bottle, classifying the color point defects contained in a single medicine bottle, obtaining the number of color points corresponding to each defect level, and calculating the total defect score corresponding to the single medicine bottle according to the number of color points corresponding to each defect level and the defect score:
[0022] Q sum =q1x1+q2x2+q3x3+…+q n x n
[0023] In the formula, Q sum is the total defect score corresponding to a single medicine bottle, the subscript sum represents the total, q is the number of color points corresponding to each defect level, x is the defect score corresponding to each defect level, and n is the number of defect levels; a defect threshold is preset, and the total defect score of a single medicine bottle is compared with the defect threshold. When the total defect score of a single medicine bottle is greater than the defect threshold, the medicine bottle is judged to be a defective medicine bottle. When the total defect score of a single medicine bottle is less than or equal to the defect threshold, the medicine bottle is judged to be a qualified medicine bottle.
[0024] The technical solution of the present application also provides an AI-based medicine bottle color point detection device, which includes: a multi-spectral dome light source, a high-resolution camera system, a box with a white cavity, a rack, an image processing unit, and a control unit;
[0025] The box with the white cavity is installed on the conveyor belt for transporting medicine bottles. The white cavity is located around the conveyor belt, and the internal space of the white cavity is used for taking images of the medicine bottles.
[0026] The multi-spectral dome light source is arranged at the top of the inner side of the white cavity, and is used to generate a single detection light with a wavelength within a preset range, or a combined detection light formed by superposition of different single lights, and illuminate the medicine bottle;
[0027] The rack is used to mount the high-resolution camera system;
[0028] The high-resolution camera system is installed in the white cavity through a rack, including four groups of front-facing cameras and four groups of overhead cameras. The four groups of front-facing cameras are located around the white cavity, and the lenses of the four groups of front-facing cameras are aimed at the body of the medicine bottle. The four groups of overhead cameras are located around the white cavity and above the four groups of front-facing cameras, and the lenses of the four groups of overhead cameras are aimed at the mouth of the medicine bottle.
[0029] The beneficial effects of this application are:
[0030] First, the technical solution in the present application sets the shooting area in a cavity with a white background, uses light of different wavelengths or combined light to illuminate the medicine bottle from the top, and obtains the surface image of the medicine bottle under different spectra, wherein the cavity with a white background and the top lighting method can reduce the brightness of the light, making the light irradiated on the medicine bottle more uniform, reducing the current situation where defects in the image cannot be identified due to low grayscale values. By illuminating the medicine bottle with light of different spectra, different defects and other interference targets other than defects can be clearly reflected. Compared with the existing detection method using a single light source and side lighting, the technical solution in the present application optimizes the detection light source to reduce the impact of uneven light reflection. At the same time, through the fusion analysis of multi-spectral images, it effectively improves the recognition of some tiny defects that are difficult to detect under a single wavelength or defects with unclear color changes, and can obtain richer surface information of the medicine bottle, thereby reducing the missed detection rate and improving the reliability and accuracy of detection.
[0031] Second, the technical solution in the present application utilizes an AI algorithm to identify defects in an image, and is capable of extracting and classifying detailed features on the surface of medicine bottles, distinguishing minute differences between different types of defects, and subsequently classifying defects according to preset defect levels, thereby more accurately finding defective medicine bottles, and avoiding the elimination of qualified products during subsequent waste removal, thereby reducing production costs. Compared with the existing method of requiring manual on-site inspection to find defective medicine bottles, the technical solution in the present application is more generalizable, and is capable of handling various types of defects. It is suitable for medicinal glass bottles of different shapes, sizes, and materials, further improving the accuracy and speed of detection, and avoiding the adverse effects of subjective judgment on the detection results during manual intervention. The detection results are more accurate, and automated and efficient defect recognition is achieved. It has extremely high computing efficiency, shortens the detection time, and improves the detection efficiency of the production line.
[0032] Third, the technical solution in this application can monitor the production line of medicine bottles in real time, and the detection results can be fed back to the MES system in real time, ensuring that production personnel can deal with production problems in a timely manner and facilitate quality management in the production process. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The advantages of the above and / or additional aspects of the present application will become apparent and easily understood in the description of the embodiments in conjunction with the following drawings, in which:
[0034] Figure 1 is a schematic flow chart of an AI-based medicine bottle color point detection method according to an embodiment of the present application;
[0035] Figure 2 is a structural schematic diagram of an AI-based medicine bottle color point detection device according to an embodiment of the present application;
[0036] Figure 3 is a schematic diagram of a high-resolution camera system and a shooting area according to an embodiment of the present application;
[0037] Figure 4 is a flow chart of recognizing a medicine bottle image according to a target detection model of an embodiment of the present application;
[0038] Figure 5 is a structural diagram of a target detection model according to an embodiment of the present application;
[0039] Figure 6 is a structural diagram of an encoder according to an embodiment of the present application;
[0040] Figure 7 is a structural diagram of a decoder according to an embodiment of the present application;
[0041] Figure 8This is a real-object image of a color point defect at the bottom edge of the bottle mouth taken using the method of the present application under a blue light spectrum;
[0042] Fig. 9 This is a real-object image of a color point defect at the bottle mouth taken using the method of the present application under the white light color spectrum;
[0043] Fig.10 This is a physical image of the color point defect of the bottle mouth taken by the combined light color spectrum method of the present application;
[0044] Fig.11 is a color point defect image taken using the method of the present application;
[0045] Fig.12 It is a bubble defect image taken by the method of the present application;
[0046] Fig.13 This is a color spot defect image of the bottom edge of the bottle mouth taken using the traditional method;
[0047] Fig.14 This is a frost spot defect image of the bottle body taken using the traditional method. DETAILED DESCRIPTION
[0048] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0049] In the following description, many specific details are elaborated to facilitate a full understanding of the present application. However, the present application may also be implemented in other ways different from those described herein. Therefore, the protection scope of the present application is not limited to the specific embodiments disclosed below.
[0050] like Figure 1 to Figure 2 As shown, this embodiment provides an AI-based medicine bottle color point detection device, which is arranged on a conveyor belt for transporting medicine bottles and is used to perform color point detection on medicine bottles moving on the conveyor belt. The AI-based medicine bottle color point detection device includes a multi-spectral dome light source, a high-resolution camera system, a box with a white cavity, a frame, an image processing unit and a control unit.
[0051] The box with a white cavity is installed on a conveyor belt for transporting medicine bottles. The white cavity is located around the conveyor belt. The internal space of the white cavity is used for capturing images of the medicine bottles. In this embodiment, the medicine bottle color point detection device uses a white cavity background to make the lighting more uniform.
[0052] The multi-spectral dome light source is arranged at the top of the inner side of the white cavity. The multi-spectral dome light source is used to generate a single detection light with a wavelength within a preset range, or a combined detection light formed by superimposing different single lights, and irradiate the medicine bottle.
[0053] The racks are symmetrically arranged around the inner side of the white cavity, and the racks are used to install a high-resolution camera system.
[0054] A high-resolution camera system is installed in the white cavity through a rack. The high-resolution camera system includes four groups of front-facing cameras and four groups of overhead cameras. The four groups of front-facing cameras are symmetrically installed around the white cavity through a rack. The lenses of the four groups of front-facing cameras are aimed at the body of the medicine bottle. The four groups of overhead cameras are symmetrically installed around the white cavity through a rack and are located above the four groups of front-facing cameras. The lenses of the four groups of overhead cameras are aimed at the mouth of the medicine bottle.
[0055] like Figure 1 As shown, this embodiment provides an AI-based medicine bottle color point detection method, the method comprising:
[0056] Step 1, select a shooting area on the medicine bottle conveying device, set the shooting area in a cavity with a white background, set a multi-spectral dome light source at the top of the shooting area, set a front-view camera and a bird's-eye view camera around the shooting area, aim the lens of the front-view camera at the position of the medicine bottle body, and aim the lens of the bird's-eye view camera at the position of the medicine bottle mouth; wherein the multi-spectral dome light source is used to generate a variety of detection lights, and the multiple detection lights include a single light with a wavelength within a preset range or a combination light formed by superimposing different single lights.
[0057] A predetermined position on a medicine bottle conveying device is used as a shooting area, and a box with a cavity with a white background is arranged. The shooting area is set in the cavity with a white background, and a multi-spectral dome light source is arranged directly above the shooting area so that the light generated by the multi-spectral dome light source can be evenly irradiated downward to the shooting area and the medicine bottles being photographed. Four groups of front-facing cameras distributed in a planar rectangular shape and four groups of overhead cameras distributed in a planar rectangular shape are arranged around the shooting area, and the height of the plane where the four groups of front-facing cameras are located is the same as the height of the medicine bottle body on the conveying device, and the height of the plane where the four groups of overhead cameras are located is higher than the height of the medicine bottle mouth, wherein the four groups of overhead cameras are located directly above the four groups of front-facing cameras, and the positions of the four groups of overhead cameras correspond to the positions of the four groups of front-facing cameras.
[0058] In the shooting area, a first shooting position and a second shooting position are sequentially arranged along the conveying direction of the medicine bottle, the first shooting position is located at one end of the medicine bottle in the cavity, and the second shooting position is located at one end of the medicine bottle in the cavity. The lenses of each group of cameras are adjusted, and the lenses of the two groups of front-facing cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle body at the first shooting position, and the lenses of the two groups of front-facing cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle body at the second shooting position, and the lenses of the two groups of overhead cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle mouth at the first shooting position, and the lenses of the two groups of overhead cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle mouth at the second shooting position.
[0059] The multiple detection lights generated by the multi-spectral dome light source include at least blue light, white light and combined light. The various defects and other interference targets on the medicine bottle are imaged differently under different spectral detection lights. When detecting, different detection lights are used to illuminate the medicine bottle from the top downward, so that multiple images of the medicine bottle surface taken from the same direction with different effects of highlighting various defects can be obtained, so that various defects and interference targets can be distinguished more clearly and false detection can be reduced. In this embodiment, the multi-spectral dome light source can use existing multi-spectral lamps and other equipment.
[0060] It should be noted that in order to improve the accuracy of color point detection of medicine bottles, it is necessary to obtain images of the medicine bottles in all directions. The four groups of front-facing cameras arranged around the transmission device are used to obtain all-round images of the position of the medicine bottle body from four directions. Among them, when the medicine bottle is in the first shooting position, the two groups of front-facing cameras at the medicine bottle output end can obtain images of the bottle body from two directions on the front side of the medicine bottle (the side of the medicine bottle in the forward direction is the front side, and the other side is the rear side). When the medicine bottle is in the second shooting position, the two groups of front-facing cameras at the medicine bottle input end can obtain images of the bottle body from two directions on the rear side of the medicine bottle. Similarly, four groups of overhead cameras are used to obtain all-round images of the position of the medicine bottle mouth from four directions. The overhead cameras are positioned higher than the medicine bottles and can capture the outer and inner edges of the medicine bottle mouth.
[0061] Step 2: Place the pre-inspection medicine bottles on the conveying device, illuminate the pre-inspection medicine bottles respectively with multiple detection lights generated by the multi-spectral dome light source, use a camera to capture images of the pre-inspection medicine bottles under different detection lights, classify and count the defects of the medicine bottles under the same detection light, and construct a database of the corresponding relationship between various defects and the optimal detection light based on the statistical results.
[0062] In this embodiment, before inspecting the target medicine bottle, it is first necessary to construct a database of the correspondence between various defects and optimal detection light, and set the corresponding optimal detection light for each specific defect type of the target medicine bottle.
[0063] A portion of the medicine bottles to be inspected are randomly selected from the medicine bottles to be inspected as pre-inspection medicine bottles (i.e., sample medicine bottles for pre-inspection, and these pre-inspection medicine bottles may be a portion of medicine bottles randomly selected from target medicine bottles to be inspected produced in multiple batches), the pre-inspection medicine bottles are set on a conveying device, the medicine bottles are transported to a shooting area by a transfer device, a multi-spectral dome light source is used to sequentially generate a variety of detection lights, and the pre-inspection medicine bottles are irradiated, and a camera is used to capture images of the pre-inspection medicine bottles under each detection light. For the pre-inspection medicine bottle images under a single detection light, all defects are found, the defects are classified, and the number of defects of each type is counted to obtain the number of defects of each type under different detection lights. For each type of defect, the detection light used when the largest number of defects is detected is used as the optimal detection light, and a database of corresponding relationships between various types of defects and optimal detection lights is established.
[0064] For example: the number of Class A defects detected under blue light is 3, the number of Class B defects is 4, and the number of Class C defects is 5; the number of Class A defects detected under white light is 4, the number of Class B defects is 1, and the number of Class C defects is 3; the number of Class A defects detected under combined light is 2, the number of Class B defects is 3, and the number of Class C defects is 6. Then, the optimal detection light for Class A defects is white light, the optimal detection light for Class B defects is blue light, and the optimal detection light for Class C defects is combined light.
[0065] In this embodiment, in step 2, all defects are found out for the pre-inspected medicine bottle image under a single detection light, and a manual search method can be used.
[0066] Step 3: Perform sampling inspection on a single batch of target medicine bottles to be inspected, obtain the proportion of each defect type, and take the defect type whose proportion value exceeds a preset threshold as the target defect type.
[0067] Randomly select some sample medicine bottles from a single batch of target medicine bottles to be inspected, set these sample medicine bottles on a conveying device, transport the medicine bottles to the shooting area by using the transfer device, use a multi-spectral dome light source to generate multiple detection lights in sequence, and irradiate the pre-inspection medicine bottles, use a camera to capture images of sample medicine bottles under each detection light, for the pre-inspection medicine bottle images under a single detection light, find out all defects, classify the defects, and count the number of defects of each type to obtain the number of defects of each type under different detection lights, for each type of defect, take the maximum number counted as the number of defects of this type, determine the proportion of each defect type (i.e. the proportion of each defect type in the total number of defects) according to the number of each defect type and the total number of defects (the total number of defects is the sum of the number of each defect type), and take the defect type with a proportion value exceeding a preset threshold as the target defect type.
[0068] Step 4: Place a single batch of target medicine bottles to be inspected on a conveyor, determine the optimal detection light for each target defect type corresponding to the current batch of medicine bottles based on the database, use a multi-spectral dome light source to generate different optimal detection lights in sequence, and illuminate the target medicine bottles entering the shooting area.
[0069] The multi-spectral dome light source is communicatively connected with the control unit, and a single batch of target medicine bottles to be inspected are set on the conveying device. After the inspection starts, the medicine bottles follow the conveying device and move at a constant speed and enter the shooting area. The control unit calls the information in the database and controls the multi-spectral dome light source to generate corresponding optimal detection light in sequence according to the target defect types corresponding to the current batch of medicine bottles, and uses different optimal detection lights to illuminate the shooting area and the medicine bottles entering the shooting area.
[0070] In this embodiment, before performing color point detection on the medicine bottle, it is necessary to pre-generate a database so that when performing the detection, the controller can use the data set in the database to automatically select the most suitable light source conditions according to the specific defect type of the object to be detected, so as to improve the accuracy and efficiency of defect detection.
[0071] In this embodiment, when determining the specific defect type to be detected, the control unit can obtain the defect type to be detected according to the external input instruction, and the external input instruction can be obtained by manual input or by input from an external system after being preset.
[0072] Step 5, using a camera to sequentially capture images of the target medicine bottle under different detection lights, grouping and numbering the images corresponding to a single medicine bottle, and inputting each group of images into an image processing unit in turn;
[0073] Four groups of frontal cameras and four groups of overhead cameras are connected to the control unit respectively. After the detection starts, the medicine bottle moves at a constant speed following the transfer device. The frontal camera and overhead camera are used to respectively capture the image of the medicine bottle body and the image of the medicine bottle mouth under different detection light. After completing the shooting under the current detection light, the control unit controls the multi-spectral dome light source to switch to the next detection light.
[0074] Specifically, for each detection light, when the medicine bottle reaches the first shooting position of the shooting area, the control unit is used to control the two groups of frontal cameras near the outlet end of the medicine bottle to respectively shoot the body of the medicine bottle from two predetermined frontal directions on the front side of the medicine bottle, so as to obtain two images of the bottle body on the front side of the medicine bottle. At the same time, the two groups of overhead cameras near the outlet end of the medicine bottle are controlled to respectively shoot the mouth of the medicine bottle from two predetermined overhead directions on the front side of the medicine bottle, so as to obtain two images of the mouth of the medicine bottle on the front side of the medicine bottle. When the medicine bottle reaches the second shooting position of the shooting area, the control unit is used to control the two groups of frontal cameras near the inlet end of the medicine bottle to respectively shoot the body of the medicine bottle from two predetermined frontal directions on the back side of the medicine bottle, so as to obtain two images of the body on the back side of the medicine bottle. At the same time, the two groups of overhead cameras near the inlet end of the medicine bottle are controlled to respectively shoot the mouth of the medicine bottle from two predetermined overhead directions on the back side of the medicine bottle, so as to obtain two images of the mouth of the medicine bottle on the back side of the medicine bottle.
[0075] The images of a single medicine bottle taken under different detection lights are taken as a group of image groups, and a single image group includes the bottle body image on the front side of the medicine bottle, the bottle body image on the back side of the medicine bottle, the bottle mouth image on the front side of the medicine bottle, and the bottle mouth image on the back side of the medicine bottle. The image groups corresponding to the device are numbered according to the order of each medicine bottle. The numbers are used to distinguish different medicine bottles. The image groups are input into the image processing unit in sequence according to the numbering order for subsequent image processing operations.
[0076] In this embodiment, the eight images corresponding to a single medicine bottle may be grouped together, and a different number may be set for each group of images. The medicine bottles may be distinguished by the number so that defective medicine bottles can be subsequently eliminated based on the corresponding number.
[0077] Step 6, using the target detection model in the image processing unit to extract features from the medicine bottle image, splicing the extracted features with the position coding features of the image, encoding and decoding the spliced features in sequence, outputting prediction results based on the decoded features, and obtaining the color point defects and defect locations corresponding to the single medicine bottle;
[0078] like Figures 5 to 7 As shown, in this embodiment, the target detection model includes a ResNet network, a Transformer network and an FFN layer (feed forward layer). The ResNet network is used to extract features and reduce the size of the medicine bottle image. The Transformer network includes an encoder and a decoder for encoding and decoding the input features. The FFN layer is the prediction head of the target detection model, which is used to generate prediction results based on the decoded features. After the medicine bottle image is input into the target detection model, it is processed by the ResNet network, encoder, decoder and prediction head in sequence, and finally the prediction head outputs the prediction result.
[0079] like Figure 4As shown, the target detection model in the image processing unit is used to identify the medicine bottle image and finally output the prediction result, which specifically includes the following steps:
[0080] Step 6.1, use the ResNet network in the target detection model to extract features and reduce the size of the medicine bottle image to obtain multiple output feature maps, and concatenate each feature vector contained in a single feature map with the corresponding positional encoding feature through the positional encoding mechanism to obtain the concatenated feature vector;
[0081] The ResNet network is used to extract features and reduce the size of the medicine bottle image to obtain multiple feature maps. A global average pooling operation is performed on a single feature map to obtain multiple feature vectors. The plane where each pixel in the medicine bottle image is located is taken as the x, y plane. The positional encoding mechanism is used to extract the corresponding position features of each feature vector in the medicine bottle image. Each feature vector is added and spliced with the corresponding position features in the x, y direction to obtain the spliced feature vector.
[0082] In this embodiment, the ResNet network can perform convolution and pooling operations on the medicine bottle image through its front-end input layer to complete preliminary feature extraction and size reduction, and then continuously extract deeper features through multiple residual blocks (the jump connections within the residual blocks enable the model to better learn multi-level features), while continuing to reduce the size in some of the layers, and finally obtaining multiple output feature maps, which are converted into feature vectors through a global average pooling operation, wherein a single feature map contains multiple channels (such as pixels), and each channel is converted into a corresponding feature vector; the positional encoding mechanism Positional Encoding is used to add position information to each input feature vector (i.e., adding position information by adding features), so that the Transformer can perceive the positional relationship of the features to make up for the defect that the Transformer cannot process the order of input data. The Transformer processes each feature independently under the self-attention mechanism, regardless of the position of the feature.
[0083] In this embodiment, the ResNet (Residual Network) network is an architecture based on CNN (Convolutional Neural Network), which improves the traditional CNN by introducing residual connections and belongs to a special type of CNN; Backbone is the part of the DETR (detection transformer) target detection model responsible for extracting features from the original image data, and the ResNet network can be used as Backbone to extract image features, that is, the ResNet network is only an option for Backbone, and Backbone can also use other architectures.
[0084] Step 6.2, input the concatenated feature vector into the encoder of the Transformer network for feature encoding;
[0085] like Figure 6 The figure shows the basic encoding unit of the encoder, which is composed of multiple such basic encoding units stacked together. The basic encoding unit includes a multi-head self-attention layer (Multi-Head Self-Attention, used to help the model capture the relationship between each feature in the feature map, so that the representation of each position not only depends on its own input, but also takes into account the influence of other positions), a residual connection and normalization layer (Add&Norm, the residual connection Add represents the addition of vector content, which can help prevent the network from having gradient vanishing problems during training, and the normalization layer Norm helps improve the stability of training and accelerate convergence), and a feed-forward neural network layer FFN (Feed-Forward Network, used to independently transform the features of each position to enhance the nonlinear representation ability of the model).
[0086] The encoder processes the concatenated feature vector using multiple stacked basic coding units to obtain the encoded global features. Specifically, for a single basic coding unit, the encoder first extracts global features from the concatenated feature vector through a multi-head self-attention mechanism to obtain a feature vector with context information (context information refers to the relationship between the features of each position and the features of other positions) to obtain richer global feature information. The feature vector with context information and the input concatenated feature vector are used as input features of the previous residual connection and normalization layer, and residual connection (Add) and normalization (Norm) are performed in sequence (i.e., the features are standardized). The output features of the previous residual connection and normalization layer are then nonlinearly transformed through the FFN layer to enhance the expression ability of the model. The nonlinearly transformed features and the output features of the previous residual connection and normalization layer are used as input features of the next residual connection and normalization layer, and residual connection and normalization are performed in sequence to finally obtain the encoded feature vector.
[0087] As shown in the figure, the encoder in Transformer is composed of multiple separate basic encoding units. Each unit takes the feature extraction result and position encoding information of the previous unit as input for further feature extraction.
[0088] Step 6.3, preset M target detection boxes, input the M target detection boxes into the decoder of Transformer, use the decoder to decode the features, and map the decoding results to the M target detection boxes to obtain M decoded detection box features, where M is a positive integer;
[0089] like Figure 7 The figure shows the basic decoding unit of the decoder, which is composed of multiple such basic decoding units stacked together. The basic decoding unit includes a multi-head self-attention layer (Multi-Head Self-Attention), a residual connection and normalization layer (Add&Norm), and a feed-forward neural network layer FFN (Feed-Forward Network).
[0090] The preset M target detection frames and the global features output by the encoder are used as the input features of the decoder, and the input features are processed by multiple stacked basic decoding units in the decoder, and the position and category information in the global features are passed to the target detection frame to obtain M decoded target detection frame features; specifically, for a single basic decoding unit, the preset M target detection frames are first used as the first input feature, and the multi-head self-attention mechanism of the previous stage is used to process it, and the processed features and the first input features are used as the input of the previous residual connection and normalization layer, and residual connection and normalization are performed in sequence, and then the output of the previous residual connection and the normalization layer, the encoded feature vector, the M target detection frames and The position encoding feature is used as the second input feature, and is processed by the multi-head self-attention mechanism of the later stage. The processed feature, M target detection frames and the output of the previous residual connection and normalization layer are used as the input of the intermediate residual connection and normalization layer, and residual connection and normalization are performed in sequence. The output features of the intermediate residual connection and normalization layer are then nonlinearly transformed through the FFN layer to enhance the expression ability of the model. The nonlinearly transformed features and the output features of the intermediate residual connection and normalization layer are used as the input of the later residual connection and normalization layer, and residual connection and normalization are performed in sequence. Finally, the position and category information in the global feature is passed to the target detection frame to obtain M decoded detection frame features.
[0091] In this embodiment, 100 target detection frames can be preset, that is, M=100. After the encoded feature vector is input into the encoder, 100 decoded detection frame features can be obtained after the attention structure and mapping.
[0092] Step 6.4, input the M detection box features into the FFN layer, use the FFN layer to predict and classify the M detection box features, and obtain M detection boxes, each of which includes width, height, center coordinates, target category label and confidence (indicating the possibility that the target in the box is the target category, usually a value between 0 and 1);
[0093] In this embodiment, the decoded detection box features contain position and category information. The FFN layer calculates the decoded detection box features by three linear layers with a ReLU activation function and a hidden layer. FFN can output the standardized center coordinates, height and width of the detection box, and use the softmax function to obtain the target category label and confidence.
[0094] Step 6.5, use the target detection model to output the information of all detection frames whose target categories are not background, and obtain the color point defects of a single medicine bottle and the corresponding positions of each color point defect.
[0095] In this embodiment, in step 4.5, only the information of the detection boxes of target categories other than the background is output.
[0096] Step 7, classifying the defects corresponding to the individual medicine bottles according to the preset defect levels, calculating the defect scores corresponding to the individual medicine bottles based on the classification results, and determining the defective medicine bottles according to the defect scores;
[0097] A specific number of defect levels are preset, and the corresponding defect scores are set according to the degree of harmful effects of defects of each level on the quality of the medicine bottle. According to the preset defect levels, the color point defects contained in a single medicine bottle are classified to obtain the number of color points corresponding to each defect level. The total defect score corresponding to a single medicine bottle is calculated based on the number of color points and defect scores corresponding to each defect level:
[0098] Q sum =q1x1+q2x2+q3x3+…+q n x n
[0099] In the formula, Q sum is the total defect score corresponding to a single medicine bottle, the subscript sum represents the total, q is the number of color points corresponding to each defect level, x is the defect score corresponding to each defect level, and n is the number of defect levels.
[0100] A defect threshold is preset, and the total defect score of a single medicine bottle is compared with the defect threshold. When the total defect score of a single medicine bottle is greater than the defect threshold, the medicine bottle is determined to be a defective medicine bottle and needs to be rejected. When the total defect score of a single medicine bottle is less than or equal to the defect threshold, the medicine bottle is determined to be a qualified medicine bottle and does not need to be rejected.
[0101] It should be noted that the defect level can be set according to existing experience or manually preset standards, such as setting level I and level II. Level I defects are color points with a diameter less than a first diameter threshold and an average brightness greater than a first brightness threshold, and level II defects are color points with a diameter greater than or equal to a second diameter threshold and an average brightness less than or equal to a second brightness threshold. The defect scores corresponding to level I are set to x1, and the defect scores corresponding to level II are set to x2. When a single medicine bottle contains one level I defect and two level II defects, its corresponding defect score is x1+2*x2. When the value of x1+2*x2 is greater than the predetermined defect threshold, the medicine bottle needs to be rejected, otherwise it will not be rejected.
[0102] Step 8, feeding back the detection results of the defective medicine bottles to the control unit in real time, and the control unit controls the subsequent waste rejection device to reject the defective medicine bottles.
[0103] In this embodiment, the inspection results of the medicine bottles on the conveyor device can be fed back to the MES system (Manufacturing Execution System, which is used to monitor the production process in real time to ensure efficient and smooth production operations) in real time, and timely feedback on problems on the production line can be provided, ensuring that production personnel can deal with production problems in a timely manner, adjust the process to complete the closed loop of production and inspection, and facilitate quality management in the production process.
[0104] The method of the present invention is compared with the traditional method. In the traditional method, the light source is a single light source, and when photographing the medicine bottle, the light source illuminates from the side of the medicine bottle. Since the medicine bottle is a transparent glass bottle, when illuminated from the side, the light is too strong for the camera, and the grayscale value of the captured color point defects is very low. In the subsequent image processing, it will be impossible to identify due to the low grayscale value, resulting in a large number of false detections. The method of the present invention uses a multi-spectral surface light source to illuminate from the top of the medicine bottle, and the medicine bottle is placed in a white cavity for photographing, and the white cavity background is used to generate diffuse reflection, so that the lighting is more uniform. For the camera, there will be no excessive light, and the captured color point defects are clearly visible, avoiding the situation that they cannot be identified due to the low grayscale value in the subsequent image processing, and reducing the false detection rate.
[0105] like Figure 11 to Figure 12 As shown in the figure, in the glass medicine bottle, the color of the bubble defect is close to the color of the bottle body, and the shape is relatively regular, the color is black and yellow, and the shape is irregular; if the light is shone from the side of the medicine bottle, the brightness is too high for the camera, and the bubble cannot be photographed or the bubble color is too light to be identified. If the light is shone from the top of the medicine bottle, the brightness is uniform for the camera, and the upper half of the bubble photographed is bright, and the lower half is dark, as shown in the figure. Fig.12 As shown, the method of the present invention uses a high-resolution color camera to capture color dots and bubbles with a diameter greater than or equal to 0.3 mm.
[0106] In actual testing, medicine bottles may be frosted, and frost spots will form when the frost is uneven. The traditional method uses a single light source, and the imaging of frost spots and color spots during testing is extremely similar, such as Figure 13 to Figure 14 For images taken using traditional methods, Fig.13 The red frame in the middle is the color point location. Fig.14 The red box in the middle is the frost point location, and it is difficult to distinguish between color points and frost points. Therefore, when using traditional methods for detection, due to the influence of frost points, trying to detect color points will inevitably lead to false detection, resulting in the elimination of qualified products in the subsequent rejection, increasing production costs.
[0107] The method of the present invention uses a multi-spectral light source to illuminate the medicine bottle. The multi-spectral light source can generate a single light with a wavelength within a preset range and a combined light formed by superposition of different single lights, such as white light, blue light and combined light. During detection, the surface image of the medicine bottle under detection lights of different spectra can be obtained. Since different defects on the medicine bottle and other interfering targets are imaged differently under detection lights of different spectra, the characteristics of detection lights of different spectra can be used to better distinguish different defects and other targets on the surface of the medicine bottle that are not defects, such as frost spots, to reduce false detections, thereby reducing waste of production costs. The method of the present invention can more effectively capture the characteristic information of color points, especially hidden color points that are difficult to detect with the naked eye, by combining light sources of different wavelengths; for example:
[0108] The orange-red spot at the mouth of the bottle can be clearly photographed by combining light (white ring light and coaxial light) and shooting with a color camera. Fig.10 As shown in the figure, the blue spots on the bottle can be clearly photographed by irradiating with blue light and shooting with a color camera, as shown in the figure. Figure 8 and Fig. 9 As shown; the black stone spots on the bottom of the bottle can be clearly photographed by irradiating with red light and shooting with a color camera.
[0109] In actual production, even if a multi-spectral system is used to capture color dots, the color dots are slight and their positions are not fixed, so they cannot be effectively extracted using traditional detection methods. Traditional detection methods usually use manual on-site detection to find defective medicine bottles, especially at the bottom edge of the bottle mouth. The shaking of the bottle position and the instability of the bottle imaging lead to many false alarms. However, the detection of color dots is a type of defect that must be strictly detected in actual inspections. In response to this situation, the present invention uses AI algorithms to process medicine bottle images in real time and detect defective products, so that the entire solution can achieve a higher detection rate and a lower false detection rate.
[0110] The present invention is used to conduct on-site testing, and after the test is completed, the accuracy of the present invention and the detection situation are statistically analyzed. In this embodiment, the detection results within 11 days are mainly statistically analyzed; the statistical results and accuracy analysis are shown in the following table:
[0111] Days Number of detections Detect defects Kick Rate Missed detection Day 1 50124 4100 8.17% 0 Day 2 49388 4356 8.81% 2 Day 3 47652 4214 8.84% 3 Day 4 51225 4685 9.12% 4 Day 5 52435 4132 7.88% 2 Day 6 50256 5234 10.41% 3 Day 7 48568 4156 8.51% 0 Day 8 49658 4658 9.32% 3 Day 9 53201 5214 9.88% 4 Day 10 51035 4963 9.72% 2 Day 11 54694 5241 9.58% 5
[0112] It can be clearly seen from the above table that the reliability of the method of the present invention is relatively high; the total number of bottles tested per day is stable at around 50,000. Although the positions of the detected color points are complex and the colors vary in size, the overall scrap rate remains at around 8%, and the number of missed bottles is guaranteed to be in the single digit. The scrap rate of the traditional method remains above 20%, and the speed of manual detection is very slow. Compared with the traditional method, the method of the present invention has greatly improved the accuracy of on-site detection.
[0113] The steps in this application can be adjusted in order, combined, and deleted according to actual needs.
[0114] The units in the device of the present application can be combined, divided and deleted according to actual needs.
[0115] Although the present application is disclosed in detail with reference to the accompanying drawings, it should be understood that these descriptions are merely exemplary and are not intended to limit the application of the present application. The scope of protection of the present application is defined by the appended claims and may include various modifications, alterations and equivalents made to the invention without departing from the scope and spirit of the present application.
Claims
1. A method for detecting color points of medicine bottles based on AI, characterized in that: The AI-based medicine bottle color point detection method includes: Step 1, selecting a shooting area on a medicine bottle conveyor, setting the shooting area in a cavity with a white background, setting a multi-spectral dome light source at the top of the shooting area, setting a front-view camera and a top-view camera around the shooting area, aiming the front-view camera at the body of the medicine bottle, and aiming the top-view camera at the mouth of the medicine bottle, wherein the multi-spectral dome light source is used to generate a variety of detection lights, including a single light with a wavelength within a preset range or a combined light formed by superimposing different single lights; Step 2: Use multiple detection lights generated by a multi-spectral dome light source to sequentially illuminate the pre-inspected medicine bottles, obtain images of the pre-inspected medicine bottles under different detection lights, classify and count the defects of the medicine bottles under the same detection light, and build a database of corresponding relationships between various defects and optimal detection light based on the statistical results; Step 3: Sampling and testing a single batch of target medicine bottles to be tested, obtaining the proportion of each defect type, and taking the defect type whose proportion value exceeds a preset threshold as the target defect type; Step 4: Set the target medicine bottles on the conveyor, determine the optimal detection light for each target defect type corresponding to the current batch of medicine bottles based on the database, use the multi-spectral dome light source to generate different optimal detection lights in sequence, and illuminate the target medicine bottles entering the shooting area; Step 5, using a camera to sequentially capture images of the target medicine bottle under different detection lights, grouping and numbering the images corresponding to a single medicine bottle, and inputting each group of images into an image processing unit in turn; Step 6, using the target detection model in the image processing unit to extract features from the medicine bottle image, splicing the extracted features with the position coding features of the image, encoding and decoding the spliced features in sequence, outputting prediction results based on the decoded features, and obtaining the color point defects and defect locations corresponding to the single medicine bottle; Step 7, classifying the defects corresponding to the individual medicine bottles according to the preset defect levels, calculating the defect scores corresponding to the individual medicine bottles based on the classification results, and determining the defective medicine bottles according to the defect scores; Step 8, the detection results of the defective medicine bottles are fed back to the control unit in real time, and the control unit controls the subsequent waste rejection device to reject the defective medicine bottles.
2. The AI-based medicine bottle color point detection method according to claim 1, characterized in that: The step 2 specifically includes: A portion of the medicine bottles to be tested are extracted as pre-inspection medicine bottles, which are transported to the shooting area by a transfer device, and a multi-spectral dome light source is used to sequentially generate multiple detection lights to illuminate the pre-inspection medicine bottles, wherein the multiple detection lights include at least blue light, white light and combined light. A camera is used to capture images of the pre-inspection medicine bottles under each detection light. For the pre-inspection medicine bottle images under a single detection light, all defects are found, the defects are classified, and the number of defects of each type is counted to obtain the number of defects of each type under different detection lights. For each type of defect, the detection light used when the largest number of defects is detected is used as the optimal detection light, and a database of corresponding relationships between various types of defects and optimal detection lights is established.
3. The AI-based medicine bottle color point detection method according to claim 1, characterized in that: In step 1, a front-view camera and a top-view camera are arranged around the shooting area, which specifically includes: Four groups of front-facing cameras and four groups of overhead cameras are arranged in a rectangular planar distribution around the shooting area, so that the height of the plane where the four groups of front-facing cameras are located is the same as the height of the medicine bottle body on the conveying device, and the height of the plane where the four groups of overhead cameras are located is higher than the height of the medicine bottle mouth, wherein the positions of the four groups of overhead cameras correspond to the positions of the four groups of front-facing cameras.
4. The AI-based medicine bottle color point detection method according to claim 3, characterized in that: In step 1, the lens of the front-view camera is directed to the position of the body of the medicine bottle, and the lens of the overhead camera is directed to the position of the mouth of the medicine bottle, which specifically includes: In the shooting area, a first shooting position and a second shooting position are sequentially arranged along the conveying direction of the medicine bottle, the first shooting position is located at one end of the medicine bottle in the cavity, and the second shooting position is located at one end of the medicine bottle in the cavity. The lenses of each group of cameras are adjusted, and the lenses of the two groups of front-facing cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle body at the first shooting position, and the lenses of the two groups of front-facing cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle body at the second shooting position, and the lenses of the two groups of overhead cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle mouth at the first shooting position, and the lenses of the two groups of overhead cameras near the medicine bottle outlet end are directed toward the position of the medicine bottle mouth at the second shooting position.
5. The AI-based medicine bottle color point detection method according to claim 4, characterized in that: In step 5, using a camera to capture images of the medicine bottle under different detection lights specifically includes: A front-facing camera and an overhead camera are used to respectively capture images of the body and mouth of the medicine bottle under different detection lights. After completing the shooting under the current detection light, the multi-spectral dome light source is controlled to switch to the next detection light for shooting. For each detection light, when the medicine bottle reaches the first shooting position, two groups of front-facing cameras near the outlet end of the medicine bottle are used to capture images of the body of the medicine bottle from two predetermined front-facing directions on the front side of the medicine bottle. At the same time, two groups of overhead cameras near the outlet end of the medicine bottle are used to capture images of the mouth of the medicine bottle from two predetermined overhead directions on the front side of the medicine bottle. When the medicine bottle reaches the second shooting position in the shooting area, two groups of front-facing cameras near the inlet end of the medicine bottle are used to capture the body of the medicine bottle from two predetermined front-facing directions on the rear side of the medicine bottle. At the same time, two groups of overhead cameras near the inlet end of the medicine bottle are used to capture images of the medicine bottle from two predetermined overhead directions on the rear side of the medicine bottle.
6. The AI-based medicine bottle color point detection method according to claim 5, characterized in that: In step 5, the image corresponding to a single medicine bottle is used as a unit image group to divide and set a group number, and each group of images is input into the image processing unit in turn, specifically including: The images of a single medicine bottle taken under different detection lights are taken as a group of image groups, and a single image group includes the bottle body image on the front side of the medicine bottle, the bottle body image on the back side of the medicine bottle, the bottle mouth image on the front side of the medicine bottle, and the bottle mouth image on the back side of the medicine bottle. The image groups corresponding to the device are numbered according to the order of each medicine bottle, and the image groups are input into the image processing unit in sequence according to the numbering order.
7. The AI-based medicine bottle color point detection method according to claim 1, characterized in that: The step 6 specifically includes: Step 6.1, use the ResNet network in the target detection model to extract features and reduce the size of the medicine bottle image to obtain multiple output feature maps, and concatenate each feature vector contained in a single feature map with the corresponding positional encoding feature through the positional encoding mechanism to obtain the concatenated feature vector; Step 6.2, input the concatenated feature vector into the encoder of the Transformer network for feature encoding; Step 6.3, preset M target detection boxes, input the M target detection boxes into the decoder of Transformer, use the decoder to decode the features, and map the decoding results to the M target detection boxes to obtain M decoded detection box features, where M is a positive integer; Step 6.4, input the M detection box features into the FFN layer, use the FFN layer to predict and classify the M detection box features, and obtain M detection boxes, each of which includes width, height, center coordinates, target category and confidence; Step 6.5, use the target detection model to output the information of all detection frames whose target categories are not background, and obtain the color point defects of a single medicine bottle and the corresponding positions of each color point defect.
8. The AI-based medicine bottle color point detection method according to claim 1, characterized in that: The step 6.3 specifically includes: The preset M target detection boxes and the global features output by the encoder are used as the input features of the decoder. The input features are processed using multiple stacked basic decoding units in the decoder, and the position and category information in the global features are passed to the target detection box to obtain M decoded target detection box features.
9. The AI-based medicine bottle color point detection method according to claim 1, characterized in that: The step 7 specifically includes: A specific number of defect levels are preset, and the corresponding defect scores are set according to the degree of harmful effects of defects of each level on the quality of the medicine bottle. The color point defects contained in a single medicine bottle are classified to obtain the number of color points corresponding to each defect level. The total defect score corresponding to a single medicine bottle is calculated based on the number of color points and defect scores corresponding to each defect level: Q sum =q1x1+q2x2+q3x3+…+q n x n In the formula, Q sum is the total defect score corresponding to a single medicine bottle, the subscript sum represents the total, q is the number of color points corresponding to each defect level, x is the defect score corresponding to each defect level, and n is the number of defect levels; A defect threshold is preset, and the total defect score of a single medicine bottle is compared with the defect threshold. When the total defect score of a single medicine bottle is greater than the defect threshold, the medicine bottle is judged to be a defective medicine bottle. When the total defect score of a single medicine bottle is less than or equal to the defect threshold, the medicine bottle is judged to be a qualified medicine bottle.
10. A detection device for executing the AI-based medicine bottle color point detection method according to any one of claims 1 to 9, characterized in that: The detection device includes a multi-spectral dome light source, a high-resolution camera system, a box with a white cavity, a rack, an image processing unit and a control unit; The box with the white cavity is installed on the conveyor belt for transporting medicine bottles. The white cavity is located around the conveyor belt, and the internal space of the white cavity is used for taking images of the medicine bottles. The multi-spectral dome light source is arranged at the top of the inner side of the white cavity, and is used to generate a single detection light with a wavelength within a preset range, or a combined detection light formed by superposition of different single lights, and illuminate the medicine bottle; The rack is used to mount the high-resolution camera system; The high-resolution camera system is installed in the white cavity through a rack, including four groups of front-facing cameras and four groups of overhead cameras. The four groups of front-facing cameras are located around the white cavity, and the lenses of the four groups of front-facing cameras are aimed at the body of the medicine bottle. The four groups of overhead cameras are located around the white cavity and above the four groups of front-facing cameras, and the lenses of the four groups of overhead cameras are aimed at the mouth of the medicine bottle.
Citation Information
Patent Citations
Visual detection method and system for bottleneck carbonization of glass bottle ampoule
CN108665438A
Medicinal ampoule glass bottle color point detection device and method
CN113701588A
Container flaw detection method and system based on improved YOLOv4
CN113887668A
Cited By
Medicine bottle counting method for full-automatic medicine bottle counting equipment of intravenous administration center
CN120411014A
Intelligent sensing detection method and system for TAC membrane filtration process
CN121207988A