A rubber plug gap detection method, device and computer readable storage medium
By using two vertical cameras and optical components of a light source, detection images of the vial from different angles are acquired, and initial and target detection areas are constructed. This solves the problem of inaccurate detection of the gap between the stopper and the bottle neck in the existing technology, and achieves high-precision gap detection.
Patent Information
- Application Number
- CN202511406448.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-29
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-09-29
AI Technical Summary
Existing technologies have low accuracy in detecting the gap between the stopper and the bottle neck. In particular, the grating sensor and single camera methods are easily affected by the bottle height tolerance and symmetry assumptions, leading to inaccurate detection.
By employing two mutually perpendicular camera devices and optical components of the light source, detection images of the same vial from two different perspectives are acquired. Edge line detection is used to determine the overall area of the vial, constructing initial and target detection areas. Feature lines of the vial shoulder and neck are detected to accurately obtain the gap distance between the stopper and the vial mouth.
It improves the accuracy of detecting the gap between the rubber stopper and the bottle neck, enabling precise determination of the gap distance within a small range, reducing positioning errors caused by vibration, and ensuring the accuracy of detecting the gap between the rubber stopper and the bottle neck.
Smart Images

Figure CN120876500B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of quality detection, and in particular to a rubber plug gap detection method and device and a computer readable storage medium. BACKGROUND
[0002] A rubber plug is a sealing element used to seal the opening of a vial or a container. In the medical field, the rubber plug is used to seal a vial to ensure the safety of the medicine and prevent external pollution. During the packaging process of the medicine, the medicine is loaded into the vial, and the rubber plug is used to preliminarily seal and protect the medicine. Then, the rubber plug and the bottle opening are crimped, and the metal cover is used to tightly press the rubber plug and the bottle opening, thereby providing additional sealing protection for the bottled medicine.
[0003] If there is a gap between the rubber plug and the bottle opening, the rubber plug cannot provide the necessary sealing for the medicine in the bottle. On the other hand, even if the crimping is performed again to seal, the ideal sealing effect cannot be achieved. Therefore, between the crimping of the bottle opening and the rubber plug, it is necessary to detect whether there is a gap between the bottle opening and the rubber plug. In the prior art, the method of detecting the gap by indirectly calculating the gap based on the height of the rubber plug detected by the grating sensor is easily affected by the height tolerance of the bottle body, thereby reducing the detection accuracy. The method of detecting the gap by three-point height detection using a single camera relies on the assumption that the bottle opening is symmetrical, and cannot detect the gap when the rubber plug is tilted on one side, thereby reducing the detection accuracy. Therefore, how to improve the accuracy of detecting the gap between the rubber plug and the bottle opening has become a problem to be solved. SUMMARY
[0004] The embodiments of the present application provide a rubber plug gap detection method, device and computer readable storage medium to at least solve the problem of low accuracy of rubber plug gap detection in the related art.
[0005] In a first aspect, the embodiments of the present application provide a rubber plug gap detection method, which is applied to a gap detection device. The gap detection device includes an optical assembly, and the optical assembly includes two mutually perpendicular camera devices and two light sources. The light sources are arranged below the camera devices. The method includes the following steps.
[0006] Two detection images of the same vial from different perspectives are obtained by the optical assembly. According to any one of the detection images, the edge lines of the two sides of the bottle body are obtained, and the overall area of the vial is determined according to the edge lines.
[0007] It is determined whether the rubber plug exists in the overall area. If the rubber plug exists in the overall area, an initial detection area is constructed based on the edge lines. In the case that the features of the shoulder and the neck are detected in the initial detection area by moving the initial detection area in the detection image, the position of the initial detection area is taken as a reference position.
[0008] With the reference position as a starting point, the initial detection area is moved by a preset length in a direction perpendicular to the bottle bottom and upward, and a target detection area is constructed based on a geometric center of the initial detection area and a preset size;
[0009] In the target detection area, a gap distance between a bottle opening edge of the penicillin bottle and a lower edge of a profile of the rubber plug is obtained, and if the gap distance is greater than a preset distance threshold, an unqualified signal is output.
[0010] In an embodiment, in a case where the feature straight line of the bottle shoulder and the bottle neck is detected in the initial detection area, a position of the initial detection area at present is taken as a reference position, and the method comprises the following steps:
[0011] Edge points in the initial detection area are collected by a preset operator, and the edge points are subjected to straight line change to obtain at least two straight lines;
[0012] An intersection angle between any two of the straight lines is obtained, and if the intersection angle satisfies a preset angle range, the straight line is taken as the feature straight line;
[0013] When the feature straight line is detected in the initial detection area, a position of the initial detection area at present is taken as a reference position.
[0014] In an embodiment, the edge lines on both sides of the bottle body comprise the following steps:
[0015] In the detection image, a vertical edge of the bottle body is enhanced by filtering to obtain an enhanced image;
[0016] In the enhanced image, according to a relationship between pixel brightness changes between the bottle body and the background, edge lines on both sides of the bottle body are determined.
[0017] In an embodiment, the detection of whether the penicillin bottle has a rubber plug comprises the following steps:
[0018] The judgment of whether the rubber plug exists in the overall area comprises the following steps:
[0019] Pixel values of all pixel points in the overall area are obtained, if the pixel values are greater than or equal to a preset pixel value, and a number of pixel points greater than the preset pixel value satisfies a preset number, it is judged that the penicillin bottle in the detection image has a rubber plug.
[0020] In an embodiment, after it is judged that the penicillin bottle in the detection image has a rubber plug, the method further comprises the following steps:
[0021] A sliding window is constructed in the area of the rubber plug, a gray value of the rubber plug is obtained according to the sliding window, and if the gray value is greater than a preset gray threshold, a region corresponding to the gray value is determined as a light reflection region.
[0022] The pixels in the light reflection area are removed, and the profile of the rubber plug is obtained by interpolation.
[0023] In an embodiment, the gap detection device comprises a photoelectric sensor and a control component, the detection images of the same vial from two different perspectives are obtained by the optical component, comprising:
[0024] The position of the vial is determined by the photoelectric sensor, when the vial is located in the detection front position, a group of pulse signals are sent to the camera device by the control component, and each camera device receives different pulse signals;
[0025] The camera device is triggered to take the same vial by the pulse signal, and the detection images of two different perspectives are obtained.
[0026] In an embodiment, the rubber plug gap detection device further comprises a display component, and after determining that the gap between the rubber plug and the bottle mouth is unqualified when the gap distance is greater than the preset distance threshold, the display component further comprises:
[0027] In the display component, a rubber plug gap distribution map is generated according to the gap distance, and each gap distance in the rubber plug gap distribution map is displayed as a first color;
[0028] In the rubber plug gap distribution map, the gap distance greater than the preset distance threshold is displayed as a second color, and the first color and the second color are different.
[0029] In a second aspect, the embodiments of the present application provide a rubber plug gap detection device, which is applied to a gap detection device, the optical component of the gap detection device comprises two mutually perpendicular camera devices and two light sources, the light sources are arranged below the camera devices, and the device comprises:
[0030] A whole area determination module is configured to obtain detection images of the same vial from two different perspectives by the optical component, obtain edge lines of both sides of the bottle body according to any detection image, and determine a whole area of the vial according to the edge lines.
[0031] A reference position determination module is configured to determine whether there is a rubber plug in the whole area, if yes, construct an initial detection area based on the edge lines, and determine a reference position by moving the initial detection area in the detection image and detecting a characteristic straight line of a shoulder and a neck in the initial detection area.
[0032] The target detection area module is configured to, based on the geometric center of the initial detection area and a preset size, construct a target detection area after moving the initial detection area by a preset length in a direction perpendicular to the bottle bottom and upward from the reference position as a starting point.
[0033] The output module is configured to, in the target detection area, obtain a gap distance between a bottle opening edge of the penicillin bottle and a lower edge of a profile of the rubber plug, and output an unqualified signal if the gap distance is greater than a preset distance threshold.
[0034] In a third aspect, an embodiment of the present application provides a rubber plug gap detection device, applied to the rubber plug gap detection method in the first aspect, and the device comprises an optical assembly, a triggering assembly, a display assembly, and a processing terminal.
[0035] The triggering assembly comprises the photoelectric sensor and a control assembly, the photoelectric sensor is located at an inlet side of the running rail, and the detection result is transmitted to the control assembly; the control assembly is electrically connected with the photoelectric sensor; the control assembly obtains a sending time according to the detection result, and sends a triggering signal to the camera device at the sending time.
[0036] The optical assembly comprises two mutually perpendicular camera devices and two light sources; the camera devices are located above the running rail and are used for shooting images of the detection position in the running rail; the light sources are respectively located below the two camera devices; the irradiation directions of the light sources are coaxial with the shooting directions of the camera devices, and the two irradiation directions intersect with a central axis of the penicillin bottle in the detection position.
[0037] The processing terminal is communicatively connected with the camera device, and is used for receiving the detection image shot by the camera device.
[0038] The display assembly is electrically connected with the processing terminal, receives the detection result of the processing terminal, and displays a distribution diagram of the rubber plug gap and a detection signal.
[0039] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the rubber plug gap detection method in the first aspect.
[0040] The rubber plug gap detection method, device, and computer readable storage medium provided in the embodiments of the present application at least have the following technical effects.
[0041] The detection images of two different perspectives of the same vial are obtained by the optical assembly in the gap detection device, so that the contents of the two detection images include the entire case of the bottle mouth. In any one detection image, the overall area of the vial is determined by edge line detection, preventing errors caused by shaking during the subsequent gap identification process. Based on the overall area of the vial, it is detected whether the rubber plug exists, if so, the initial detection area is constructed based on the edge lines on both sides of the bottle body determined by edge detection, and the initial detection area is moved for detection, if the characteristic straight line of the shoulder and the neck is detected in the initial detection area, it is determined that the position of the initial detection area is the reference position, that is, the position of the bottle mouth is preliminarily determined by the characteristic straight line of the shoulder and the neck, providing a basis for accurately determining the gap at the bottle mouth in the subsequent process. Based on the reference position, the initial detection area is moved by a preset length in the direction perpendicular to the bottom of the bottle, and the target detection area is constructed according to the geometric center of the initial detection area and the preset size, the gap distance between the bottle mouth edge and the lower edge of the rubber plug is detected in the target detection area, if the gap distance is greater than the preset threshold, the gap between the rubber plug and the bottle mouth is unqualified, and an unqualified signal is output, so as to determine that the rubber plug gap of the current vial is unqualified, and the detection of the rubber plug gap is completed. By edge detection of the bottle body, the initial position of the vial is determined, the characteristic straight line of the shoulder and the neck is detected, the target detection area is constructed at the target position, the gap distance is detected in the target detection area, and the detection area is reduced from the area of the complete vial to the local area of the bottle mouth. Further reducing the local area from the reference position to the target detection area can accurately obtain the gap distance.
[0042] The details of one or more embodiments of the present application are presented in the following drawings and description to make other features, objects and advantages of the present application more apparent. BRIEF DESCRIPTION OF DRAWINGS
[0043] The drawings described herein are intended to provide further understanding of the present application, and constitute a part of the present application. The schematic embodiments of the present application and the description thereof are used to explain the present application, and do not constitute an improper limitation on the present application. In the drawings:
[0044] Figure 1 is a flow chart of a rubber plug gap detection method according to an exemplary embodiment;
[0045] Figure 2 is a partial schematic view of an initial detection area according to another exemplary embodiment;
[0046] Figure 3 is a partial schematic view of a reference position according to an exemplary embodiment;
[0047] Figure 4 is a partial schematic view of a target detection area according to an exemplary embodiment;
[0048] Figure 5 is a block diagram of a gap detection device for a rubber plug according to an exemplary embodiment;
[0049] Figure 6 is a block diagram of an electronic device according to an exemplary embodiment.
[0050] In the above drawings, the meaning of each reference numeral is as follows:
[0051] 11, first edge line, 12, second edge line;
[0052] 21, first initial detection area, 22, second initial detection area;
[0053] 31, first straight line, 32, second straight line, 33, third straight line, 34, fourth straight line;
[0054] 41, first geometric center, 42, second geometric center, 50, target detection area, 100, rubber plug. DETAILED DESCRIPTION
[0055] In order to make the objects, technical solutions, and advantages of the present application clearer, the following will describe and explain the present application with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. Based on the embodiments provided by the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort belong to the scope of the present application.
[0056] Obviously, the drawings in the following description are only some examples or embodiments of the present application, and for those of ordinary skill in the art, the present application can be applied to other similar scenarios without creative effort based on these drawings. In addition, it can be understood that although the efforts made in this development process can be complex and lengthy, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacture or production changes based on the technical content disclosed in the present application are only routine technical means and should not be understood as insufficient disclosure of the content disclosed in the present application.
[0057] In the present application, "embodiment" means that the specific features, structures or characteristics described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears at various places in the specification does not necessarily all refer to the same embodiment, nor is each necessarily a separate or alternative embodiment to other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in the present application can be combined with other embodiments without conflict.
[0058] Unless otherwise defined, technical terms and scientific terms used in the present application shall have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. Unless otherwise defined, the terms "one", "a", "an", "the" and like terms referring to an element will not be limited to the singular but can comprise one or more elements. The terms "comprising", "containing", "having" and "including" and their variations, are intended to cover and encompass non-exclusive inclusions; for example, processes, methods, systems, products, or apparatuses that comprise a list of steps or modules (units) are not limited to the listed steps or units, but can also comprise additional steps or units not listed, or can also comprise other steps or units inherent to such processes, methods, products, or apparatuses. The terms "connected", "coupled", and like terms are not limited to direct or physical connections, but can include electrical connections, whether direct or indirect. The term "plurality" refers to two or more. The term "and / or" describes an association between associated objects, indicating that there can be three relationships, for example, "A and / or B" can mean that A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects. The terms "first", "second", "third", and the like only distinguish similar objects, and do not represent a specific order for the objects.
[0059] In a first aspect, the embodiments of the present application provide a rubber plug gap detection method, applied to a gap detection device, the gap detection device comprising an optical assembly, the optical assembly comprising two mutually perpendicular camera devices and two light sources, the light sources being arranged below the camera devices, Figure 1 is a flow chart of a rubber plug gap detection method according to an exemplary embodiment, as Figure 1 shown, the rubber plug gap detection method comprises:
[0060] In step S101, detection images of the same vial from two different angles are obtained by the optical assembly, the edge lines of both sides of the vial body are obtained according to any of the detection images, and the overall area of the vial is determined according to the edge lines.
[0061] The light source is irradiated on the vial, and the camera device is used to shoot the vial to obtain a detection image of the entire vial imaged by light and shadow. Since the position relationship of the camera device satisfies the mutual perpendicular, the range of the camera device shooting the vial satisfies 3 / 4 of a circle of the vial. However, the detection image obtained by the camera device is based on light and shadow imaging, and features can also be displayed in the detection image for the other 1 / 4 part of the vial which is not shot.
[0062] The detection images of the same vial from two different perspectives are obtained by the camera and the light source in the optical assembly, and the detection images from the two different perspectives are obtained at the same time to ensure the accuracy of the detection. Therefore, the camera is controlled by the control assembly of the gap detection device, so that the detection images can be obtained by different cameras at the same time. Specifically, it includes:
[0063] The position of the vial is detected by the photoelectric sensor, and when the vial is located at the detection pre-position, a set of pulse signals are sent to the camera by the control assembly, wherein the pulse signals received by each camera are different.
[0064] In the track for conveying the vials, each vial is uniformly transported to the end of the guide rail at a predetermined interval. The position of the current vial is detected by the photoelectric sensor, and the position of each movement of the vial is recorded by the register of the PLC. When the vial moves to the detection pre-position, i.e. at the position before the detection position, a set of pulse signals are sent to the camera by the control assembly. Since the installation position of the camera satisfies the perpendicular relationship with each other, i.e. the position of the camera satisfies the front and back position relationship, and is not located on the same straight line. Therefore, the pulse signals sent by the control assembly are not the same.
[0065] The camera is triggered to take the same vial by the pulse signal to obtain two detection images from different perspectives.
[0066] The pulse signal bit is triggered as a trigger condition. When the camera receives the pulse signal sent by the control assembly, it starts to take the same vial. Since there is a time difference between the two different pulse signals, the time difference just satisfies the moving time of the vial between the two cameras, so that the vial can be located on the center line of the camera when each camera takes the vial. When the detection image taken by the camera is in the detection image, if the central axis of the vial is not in the preset range centered on the center line of the shooting perspective, the pulse signal sent by the control assembly is adjusted according to the vertical distance between the central axis of the vial and the center line of the shooting perspective, to realize the microsecond level adjustment of the trigger signal.
[0067] In one embodiment, the control assembly is an electronic cam, and there are two electronic cams, and the electronic cams control different cameras respectively. When the photoelectric sensor monitors the position of the vial in real time, when the vial moves to the detection pre-position, the electronic cam is started, and the TTL level pulse signal is sent to different cameras without passing through the PLC. The camera triggers shooting according to the TTL level pulse signal to obtain the detection image. And the detection image is transmitted to the PLC through the GigE Vision protocol for subsequent image processing.
[0068] Continuing to refer to step S101, according to any of the detection images, the edge lines of the two sides of the bottle body are obtained. Wherein, the step of obtaining the edge lines of the two sides of the bottle body comprises:
[0069] In the detection image, the vertical edges of the bottle body are enhanced by filtering to obtain an enhanced image.
[0070] In the detection image, the small defects such as scratches and dust in the detection image are removed by morphological processing and mean filtering. Then, the vertical edges of the bottle body in the detection image are enhanced by directional filtering to obtain an enhanced image. Through the enhanced image, the interference is removed, the edge is clearer, and the accuracy of the detection result is ensured.
[0071] In the enhanced image, the edge lines of the two sides of the bottle body are determined according to the relationship between the pixel brightness changes between the bottle body and the background.
[0072] The detection image of light and shadow imaging will have obvious changes in brightness, especially between the edge line and the background. The background is directly illuminated by the light source, so the brightness of the background is large. The ampoule bottle blocks the light source, so the brightness in the detection image is small relative to the background. Based on the difference in brightness, the edge lines of the two sides of the bottle body can be clearly determined by the brightness changes of the pixels.
[0073] According to the edge lines of the bottle body, the overall region of the ampoule bottle is determined.
[0074] The edge lines of the bottle body can preliminarily determine the overall region of the ampoule bottle, so that the subsequent detection is carried out in the overall region, avoiding the error judgment of the region for detection due to vibration, and further providing a basis for the reference position of the subsequent determination of the bottle mouth.
[0075] Step S102, judging whether the rubber plug exists in the overall region, if yes, constructing an initial detection region based on the edge lines, moving the initial detection region in the detection image, and detecting the characteristic straight line of the shoulder and the neck in the initial detection region, and taking the position of the current initial detection region as the reference position.
[0076] In the overall region, it is preliminarily detected whether the rubber plug exists. The material of the rubber plug does not have the property of light transmission. In the detection image of light and shadow imaging, the color of the rubber plug is deeper than that of other regions, for example, black in the detection image. Therefore, whether the rubber plug exists can be quickly detected by the pixel value of the pixel point, and the rubber plug is obtained. Wherein, specifically includes:
[0077] Obtaining the pixel value of all pixel points in the overall region, if the pixel value is greater than or equal to a preset pixel value, and the number of pixel points greater than the preset pixel value satisfies a preset number, it is judged that the ampoule bottle in the detection image has a rubber plug.
[0078] In the whole region, the pixel value of each pixel point is compared with the preset pixel value. When the pixel value in the preset target region is greater than or equal to the preset pixel value, and the number of pixel points greater than the preset pixel value meets the preset number, it is detected that there is a rubber plug in the image. The size of the pixel value ensures that the detected pixel points meet the feature requirements of the rubber plug in the detected image, that is, they are black. The number of pixel values that meet the condition avoids false detection.
[0079] Continuing to refer to step S102, after determining that the vial has a rubber plug, an initial detection region is constructed based on the edge line. The number of initial detection regions is 2 to determine two reference positions. In the whole region, the initial detection region is moved according to a preset step, and after each movement, straight line detection is performed in the initial detection region based on the position of each movement until the characteristic straight lines of the shoulder and the neck of the bottle are detected in the two initial detection regions. The step of straight line detection specifically includes:
[0080] The edge points in the initial detection region are collected by a preset operator, and the edge points are subjected to straight line change to obtain at least two straight lines.
[0081] Based on a preset operator, edge points of the vial are collected in the initial detection region. The collected edge points are subjected to straight line change to obtain at least two straight lines. The preset operator is an edge detection operator with extremely small calculation amount, so as to avoid complex adaptive calculation on the collected edge points and preferentially ensure the speed of obtaining the edge points.
[0082] The Hough straight line transformation is adopted for straight line change, each edge point is voted in the parameter space, threshold screening and straight line extraction are performed, and at least two straight lines are obtained.
[0083] The intersection angle between any two straight lines is obtained. If the intersection angle meets the preset angle range, the straight line is taken as a characteristic straight line.
[0084] In the obtained straight lines, the intersection angle of any two straight lines is obtained. If the intersection angle is within the preset angle range, the characteristic information of the shoulder and the neck is met. The two intersecting straight lines are taken as characteristic straight lines. For example, the preset angle range is [87, 93], and two straight lines are obtained in the initial detection region by Hough straight line transformation. The angle of intersection of the two straight lines is 90°, which meets the preset angle range, so the two straight lines are characteristic straight lines.
[0085] It should be noted that when the intersection angle of the straight lines meets the preset angle range, the straight lines are also processed by average gray processing to remove interference options.
[0086] When the characteristic straight lines are detected in the initial detection region, the position of the current initial detection region is determined as a reference position.
[0087] When the characteristic straight line is detected in the initial detection region, it indicates that the region covered by the current initial detection region is the characteristic region of the bottle mouth, that is, the edge lines of the bottle shoulder and the bottle neck are perpendicular to each other. The position of the current initial detection region is determined as the reference position.
[0088] Continuing to refer to step S102, in the case where the rubber plug is detected, the initial detection region is constructed according to the edge line of the bottle body, and the reference position of the bottle mouth is obtained through the initial detection region, so that the bottle mouth can be accurately positioned, and the gap detection is performed on the basis of the bottle mouth. From the overall region of the vial to the local region of the bottle mouth, the detection range is narrowed, and the detection accuracy is improved. On the other hand, according to the reference position of the bottle mouth, the detection region of the current vial is accurately positioned, and the deviation of the detection position caused by shaking is avoided.
[0089] Step S103, taking the reference position as the starting point, moving the initial detection region by a preset length in the direction perpendicular to the bottle bottom and upward, and constructing a target detection region based on the geometric center of the initial detection region and a preset size.
[0090] After the reference positions of the bottle shoulder and the bottle neck are determined, the geometric center of the initial detection region is obtained. The geometric center represents the reference position, and the initial detection region is moved by a preset length in the direction perpendicular to the bottle bottom and upward from the geometric center. The preset length is determined according to the distance from the bottle shoulder to the bottle opening in the physical vial.
[0091] After the initial detection region is moved by the preset length, the target detection region is constructed according to the geometric center of the initial detection region and a preset size. The target detection region is used to detect the gap between the rubber plug and the bottle mouth, and the preset size is capable of covering the junction of the rubber plug and the bottle mouth.
[0092] The target detection region is determined by the reference position, and the detection range is further narrowed to the junction of the bottle mouth and the rubber plug. In the target detection region, the gap between the rubber plug and the bottle mouth can be more accurately detected.
[0093] Step S104, in the target detection region, the gap distance between the edge of the bottle mouth and the lower edge of the rubber plug profile is obtained, and if the gap distance is greater than a preset distance threshold, an unqualified signal is output.
[0094] In the target detection region, the edge point of the bottle mouth edge and the edge point of the lower edge of the rubber plug profile are obtained, and the gap between the two edge points is calculated by a distance formula. The distance formula includes the Euclidean distance. If the calculated gap distance is greater than the preset distance threshold, it indicates that there is a too large gap between the rubber plug and the bottle mouth, which will make the air tightness of the vial unable to seal the contents in the bottle.
[0095] The gap distance between the bottle mouth edge and the lower edge of the rubber plug profile can be accurately obtained in the target detection area. By comparing the gap distance with the preset distance threshold, it can be determined whether the gap between the rubber plug and the bottle mouth is qualified. If the gap is unqualified in any detection image, an unqualified signal is output.
[0096] Two detection images are obtained by the camera device, and the gap between the rubber plug and the bottle mouth is detected in each image according to the steps of steps S102 to S104. If the detection result in any one of the detection images is unqualified, the detection result is fed back to the PLC to output an unqualified signal.
[0097] In the display component of the rubber plug gap detection device, a rubber plug gap distribution map is generated according to all the obtained gap distances. Each gap distance in the rubber plug gap distribution map is displayed in a first color. In the rubber plug gap distribution map, the gap distance greater than the preset distance threshold is displayed in a second color. For example, in the generated rubber plug gap distribution map, the gap distance of each rubber plug is blue, and the gap distance greater than the preset distance threshold is red.
[0098] According to the detection result of the rubber plug gap, an electronic record is automatically generated.
[0099] Continuing to refer to step S102, after determining that the test image contains a rubber plug, the profile of the rubber plug needs to be obtained. In the process of obtaining the profile of the rubber plug, it is also necessary to avoid the interference of the reflection. Specifically, it includes:
[0100] A sliding window is constructed in the area of the rubber plug, and the gray value of the rubber plug is obtained according to the sliding window. If the gray value is greater than a preset gray threshold, it is determined that the area corresponding to the gray value is a reflection area.
[0101] If the rubber plug in the detection image has a reflection area, the gray value of the reflection area will be different from the gray value of other areas, and the greater the gray value of the reflection area, the lighter the color of the reflection area relative to other areas. Therefore, the gray value of each pixel point of the rubber plug is obtained in the sliding window, and each gray value is compared with the preset gray threshold. If the gray value is greater than the preset gray threshold, the pixel point corresponding to the current gray value is a pixel point of the reflection area. The reflection area of the rubber plug is determined by the pixel point corresponding to the gray value greater than the preset gray threshold.
[0102] The pixel points in the reflection area are removed, and the profile of the rubber plug is obtained by interpolation method.
[0103] The pixel points in the light reflection area are removed, so that the pixel points used by the interpolation method to obtain the profile are all from the rubber plug, avoiding the influence of the light reflection area on the recognition error. The quadratic spline interpolation method is used in the sliding window to obtain the profile of the rubber plug, so as to realize the pixel-level edge positioning of the rubber plug profile.
[0104] In one embodiment, Figure 2 is a partial schematic view of an initial detection area according to another exemplary embodiment, as Figure 2 As shown in the figure, in any detection image, two edge lines of the bottle body, i.e. the first edge line 11 and the second edge line 12, are obtained by performing edge detection on the detection image. The overall area of the vial is determined based on the first edge line 11 and the second edge line 12. According to the positions of the two edge lines, a first initial detection area 21 and a second initial detection area 22 are constructed, and straight line detection is performed in the overall area through the two detection areas.
[0105] Figure 3 is a partial schematic view of a reference position according to an exemplary embodiment, straight line detection is performed in the two initial detection areas. In the first initial detection area 21, a first straight line 31 and a second straight line 32 are detected, and the intersection angle of the first straight line 31 and the second straight line 32 is 90°. In the second initial detection area 22, a third straight line 33 and a fourth straight line 34 are detected, and the intersection angle of the third straight line 33 and the fourth straight line 34 is 90°. The positions of the first initial detection area 21 and the second initial detection area 22 are the reference positions. The first straight line 31, the second straight line 32, the third straight line 33 and the fourth straight line 34 are characteristic straight lines.
[0106] Figure 4 is a partial schematic view of a target detection area according to an exemplary embodiment, as Figure 4 As shown in the figure, at the reference position, a first geometric center 41 of the first initial detection area 21 and a second geometric center 42 of the second initial detection area 22 are determined, and the first geometric center 41 and the second geometric center 42 are moved to a target position according to a preset length, and a target detection area 50 is constructed at the target position, so that the gap distance between the rubber plug 100 and the bottle mouth is detected in the target detection area 50.
[0107] In summary, the rubber plug gap detection method provided by the embodiments of the present application can eliminate the visual field blind angle of the vial shooting through the detection images formed by light and shadow imaging, and can check the rubber plug gap through the detection images, determine the initial position of the vial through the edge detection of the vial body, and reduce the positioning error caused by shaking. Then, the reference position of the vial is determined through the initial detection area, and the position of the bottle mouth is determined, so that the positioning range is reduced from a large range to a small range, and the detection efficiency is improved. After the position of the bottle mouth is determined, the target detection area between the rubber plug and the bottle mouth is constructed, the gap distance is detected in the target detection area, and whether the gap of the rubber plug is qualified is determined according to the comparison between the gap distance and the preset distance threshold. If any one of the gaps of the rubber plugs in the two detection images is unqualified, the gap of the vial is unqualified. Therefore, the precise detection of the gap between the rubber plug and the bottle mouth in the vial is realized, and the detection accuracy is improved.
[0108] In a second aspect, the embodiments of the present application provide a rubber plug gap detection device applied to a gap detection device. The system includes an optical assembly including two camera devices and two light sources. The positional relationship of the camera devices satisfies perpendicularity. The light sources are arranged below the camera devices. Figure 5 FIG. 1 is a block diagram of a rubber plug gap detection device according to an exemplary embodiment. As shown in FIG. 1, the rubber plug gap detection device includes: Figure 5
[0109] The whole area determination module 110 is configured to obtain two detection images of the same vial from different angles through the optical assembly, obtain the edge lines of the two sides of the vial body according to any one of the detection images, and determine the whole area of the vial according to the edge lines.
[0110] The reference position determination module 120 is configured to determine whether there is a rubber plug in the whole area. If yes, an initial detection area is constructed based on the edge lines. In the case that the features of the shoulder and the neck are detected in the initial detection area through the movement of the initial detection area in the detection image, the position of the current initial detection area is taken as the reference position.
[0111] The target detection area construction module 130 is configured to take the reference position as a starting point, move the initial detection area by a preset length in a direction perpendicular to the bottom of the vial, and then construct a target detection area based on the geometric center of the initial detection area and a preset size.
[0112] The output module 140 is configured to obtain the gap distance between the edge of the bottle mouth of the vial and the lower edge of the contour of the rubber plug in the target detection area. If the gap distance is greater than a preset distance threshold, an unqualified signal is output.
[0113] In summary, the rubber plug gap detection device provided by the application obtains detection images of two different perspectives of the same vial through the optical assembly in the gap detection device, so that the contents of the two detection images include the entire bottle opening. In any one detection image, the overall area of the vial is determined by edge line detection to prevent errors caused by vibration during the subsequent gap identification process. Based on the overall area of the vial, it is detected whether the rubber plug is present. If so, an initial detection area is constructed based on the edge lines on both sides of the bottle body determined by edge detection, and detection is performed within the initial detection area. If the characteristic straight line of the shoulder and the neck is detected within the initial detection area, the position of the initial detection area is determined as the reference position, that is, the position of the bottle opening is preliminarily determined by the characteristic straight line of the shoulder and the neck, which provides a basis for accurately determining the gap at the bottle opening in the subsequent process. Based on the reference position, the initial detection area is moved by a predetermined length in a direction perpendicular to the bottom of the bottle and upward, and a target detection area is constructed according to the geometric center of the initial detection area and the predetermined size. The gap distance between the bottle opening edge and the lower edge of the rubber plug is detected within the target detection area. If the gap distance is greater than the predetermined threshold, the gap between the rubber plug and the bottle opening is unqualified, and an unqualified signal is output, so as to determine that the rubber plug gap of the current vial is unqualified, and the detection of the rubber plug gap is completed. By edge detection of the bottle body, the initial position of the vial is determined, the characteristic straight line of the shoulder and the neck is detected, and the target detection area is constructed at the target position. The gap distance is detected within the target detection area. The detection area is reduced from the entire vial area to the local area of the bottle opening, and the target detection area is further reduced from the local area by the reference position, so that the gap distance can be accurately obtained. It should be noted that the rubber plug gap detection device provided in the embodiment is used to implement the above-mentioned embodiments, and the description of the device has been omitted. As used above, the terms "module", "unit", "sub-unit", etc. can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the above embodiment is preferably implemented in software, hardware, or a combination of software and hardware can also be implemented and conceived.
[0114] In a third aspect, the embodiments of the application provide a rubber plug gap detection device, the device comprising: an optical assembly, a trigger assembly, a display assembly, and a processing terminal;
[0115] The trigger assembly comprises a photoelectric sensor and a control assembly. The photoelectric sensor is located at the entrance side of the running guide rail and transmits the detection result to the control assembly. The control assembly is electrically connected with the photoelectric sensor. The control assembly obtains a sending time according to the detection result and sends a trigger signal to the camera device at the sending time.
[0116] The optical assembly comprises two mutually perpendicular camera devices and two light sources, the camera devices are located above the running track and are used for shooting images of the detection position in the running track, the light sources are respectively located below the two camera devices, the irradiation directions of the light sources are coaxial with the shooting directions of the camera devices, and the two irradiation directions intersect the central axis of the vial in the detection position;
[0117] The processing terminal is in communication connection with the camera device and is used for receiving the detection image shot by the camera device;
[0118] The display assembly is electrically connected with the processing terminal, receives the detection result of the processing terminal, and displays the distribution diagram of the rubber plug gap and the detection signal.
[0119] The trigger assembly sends a trigger signal to the projection device, the projection device shoots the vial in the detection position according to the trigger signal to obtain the detection image. The camera devices arranged perpendicularly save the installation space and eliminate the visual field blind area of obtaining the detection image. The detection image is transmitted to the industrial computer for image detection processing to detect the gap between the rubber plug and the bottle opening. The detection result is transmitted to the display assembly to display the distribution diagram of the gap for visual observation and obtain the detection result.
[0120] Figure 6 is a block diagram of an electronic device according to an example embodiment. As shown in Figure 6 the electronic device can include a processor 81 and a memory 82 storing computer program instructions.
[0121] In particular, the processor 81 can include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement one or more embodiments of the present application.
[0122] The memory 82 can include a mass storage for data or instructions. By way of example, and without limitation, the memory 82 can include a hard disk drive (HDD), a floppy disk drive, a solid-state drive (SSD), a flash memory, a compact disk read only memory (CD-ROM), a digital versatile disk (DVD), a tape drive, a USB drive, or a combination of two or more of these. Where appropriate, the memory 82 can include removable or non-removable (or fixed) media. Where appropriate, the memory 82 can be internal or external to the data processing apparatus. In certain embodiments, the memory 82 is a nonvolatile memory. In certain embodiments, the memory 82 includes a read only memory (ROM). Where appropriate, this ROM can be mask programmed ROM, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), electrically alterable ROM (EAROM), or flash memory (FLASH) or a combination of two or more of these. Where appropriate, the ROM can include a combination of these without limitation. Where appropriate, the memory 82 includes a random access memory (RAM). Where appropriate, this RAM can be static random access memory (SRAM) or dynamic random access memory (DRAM), which can be Fast Page Mode Dynamic random access memory (FPMDRAM), Extended Data Output Dynamic random access memory (EDODRAM), synchronous dynamic random access memory (SDRAM), or the like.
[0123] The memory 82 can be used to store or buffer various data files needed for processing and / or communication, and possible computer program instructions executed by the processor 81.
[0124] The processor 81 reads and executes the computer program instructions stored in the memory 82 to implement any one of the above-mentioned rubber plug gap detection methods.
[0125] In an embodiment, the rubber plug gap detection device can further include a communication interface 83 and a bus 80. As shown, the processor 81, the memory 82, and the communication interface 83 are connected through the bus 80 and complete communication with each other. Figure 6
[0126] The communication interface 83 is used to realize the communication between the modules, devices, units and / or equipment in the embodiments of the present application. The communication interface 83 can also realize data communication with other components, such as external devices, image / data acquisition devices, databases, external storage, image / data processing workstations, etc.
[0127] Bus 80 includes hardware, software, or both, to couple components of the stopper gap detection device to each other in communication. Although bus 80 is shown as a single bus that interconnects the various components of the stopper gap detection device, alternative embodiments of bus 80 can utilize multiple buses. Bus 80 can be implemented in 20 various ways including, for example, as a Data Bus, Address Bus, Control Bus, Expansion Bus, Local Bus, etc. In one embodiment, the bus 80 can include a graphics accelerator interface (AGP) or other graphics bus, an extended industry standard architecture (EISA) bus, a front side bus (FSB), a Hyper Transport (HT) interconnect, an industry standard architecture (ISA) bus, an InfiniBand interconnect, a low pin count (LPC) bus, a memory bus, a micro channel architecture (MCA) bus, a peripheral component interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a serial advanced technology attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or another suitable bus or combination of two or more of these. Where appropriate, bus 80 can include one or more buses. Although the example embodiment describes and shows a particular bus, the example embodiments contemplate any suitable bus or interconnect.
[0128] In a fourth aspect, the example embodiments provide a computer readable storage medium, having stored thereon a program, wherein the program is executed by a processor to implement the stopper gap detection method according to the first aspect.
[0129] More specifically, the computer readable storage medium can include, but is not limited to, portable discs, hard disks, random access memories, read-only memories, erasable programmable read-only memories, optical storage devices, magnetic storage devices, or any suitable combination of the above.
[0130] In possible implementation manners, the present application can also be implemented in the form of a program product, which comprises program codes for causing a terminal device to perform steps of a plug gap detection method provided by the first aspect when the program product is run on the terminal device.
[0131] The program codes for executing the present application can be written in any combination of one or more programming languages, and can be executed completely on a user device, partially on a user device, as a stand-alone software package, partially on a user device and partially on a remote device, or completely on a remote device.
[0132] The technical features of the above-described embodiments can be combined in any manner. For brevity, not all possible combinations of the technical features in the above-described embodiments are described, but it should be understood that any combination of the technical features is within the scope of the present disclosure as long as the combination does not result in contradictions.
[0133] The above-described embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be noted that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present application, and these are within the scope of protection of the present application. Therefore, the scope of protection of the patent of the present application should be subject to the appended claims.
Claims
1. A method for detecting the gap of a rubber stopper, characterized in that, The method is applied to a gap detection device, which includes an optical assembly comprising two mutually perpendicular cameras and two light sources, each light source being positioned below one of the cameras. The method includes: The optical components are used to obtain two different images of the same vial from the same angle. Based on either of the images, the edge lines on both sides of the vial are obtained, and the overall area of the vial is determined based on the edge lines. Determine whether there is a rubber stopper in the overall area. If so, construct an initial detection area based on the edge line. Move the initial detection area in the detection image. If the characteristic straight line of the bottle shoulder and neck is detected in the initial detection area, take the current position of the initial detection area as the reference position. There are two initial detection areas to determine two reference positions. Starting from the reference position, the initial detection area is moved a preset length in a direction perpendicular to the bottom of the bottle, and then the target detection area is constructed based on the geometric center and preset size of the initial detection area. Within the target detection area, the gap distance between the edge of the vial opening and the lower edge of the rubber stopper contour is obtained. If the gap distance is greater than a preset distance threshold, an unqualified signal is output. When a characteristic straight line representing the bottle shoulder and neck is detected within the initial detection area, the reference position is taken from the current position of the initial detection area, including: Edge points within the initial detection area are collected using a preset operator, and the edge points are linearly transformed to obtain at least two straight lines; Obtain the intersection angle between any two of the lines; if the intersection angle meets a preset angle range, then the line is taken as the feature line. When the feature line is detected within the initial detection area, the current position of the initial detection area is used as a reference position.
2. The method for detecting the gap of a rubber stopper according to claim 1, characterized in that, The process of obtaining the edge lines on both sides of the bottle includes: In the detected image, the vertical edges of the bottle are enhanced by filtering to obtain an enhanced image; In the enhanced image, the edge lines on both sides of the bottle are determined based on the relationship between pixel brightness changes between the bottle and the background.
3. The method for detecting rubber stopper gaps according to claim 1, characterized in that, The determination of whether a rubber plug exists within the overall area includes: Obtain the pixel values of all pixels within the entire region. If the pixel values are greater than or equal to a preset pixel value, and the number of pixels greater than the preset pixel value meets a preset quantity, then it is determined that the vial in the detection image has a rubber stopper.
4. The method for detecting rubber stopper gaps according to claim 3, characterized in that, After determining that the vial in the detected image contains a rubber stopper, the process further includes: A sliding window is constructed within the area of the rubber stopper. The gray value of the rubber stopper is obtained based on the sliding window. If the gray value is greater than a preset gray value threshold, the area corresponding to the gray value is determined to be a reflective area. Remove the pixels in the reflective area and obtain the outline of the rubber stopper by interpolation.
5. The method for detecting the gap of a rubber stopper according to claim 1, characterized in that, The gap detection device includes a photoelectric sensor and a control component. The step of obtaining detection images of the same vial from two different perspectives through the optical component includes: The position of the vial is determined by the photoelectric sensor. When the vial is in the detection pre-position, the control component sends a set of pulse signals to the camera device, wherein each camera device receives a different pulse signal. The pulse signal triggers the camera device to capture images of the same vial, obtaining two detection images from different perspectives.
6. The method for detecting rubber stopper gaps according to claim 1, characterized in that, The rubber stopper gap detection device further includes a display component, and after determining that the gap between the rubber stopper and the bottle opening is unqualified if the gap distance is greater than a preset distance threshold, it further includes: In the display component, a rubber plug gap distribution map is generated based on the gap distance, and each gap distance in the rubber plug gap distribution map is displayed in a first color; In the rubber stopper gap distribution diagram, the gap distance greater than the preset distance threshold is displayed as a second color, wherein the first color and the second color are different.
7. A rubber stopper gap detection device, characterized in that, An optical assembly is used in a gap detection device, the gap detection device including two mutually perpendicular cameras and two light sources, the light sources being respectively disposed below the cameras. The device includes: The overall region determination module is used to obtain detection images of the same vial from two different perspectives through the optical components, obtain the edge lines on both sides of the vial based on either detection image, and determine the overall region of the vial based on the edge lines. The reference position determination module is used to determine whether there is a rubber stopper in the overall area. If so, an initial detection area is constructed based on the edge line. By moving the initial detection area in the detection image, if the characteristic straight line of the bottle shoulder and neck is detected in the initial detection area, the current position of the initial detection area is used as the reference position. There are two initial detection areas to determine two reference positions. A target detection region construction module is used to construct a target detection region based on the geometric center and preset size of the initial detection region after moving the initial detection region by a preset length in a direction perpendicular to the bottom of the bottle, starting from the reference position. The output module is used to obtain the gap distance between the edge of the bottle mouth and the lower edge of the contour of the rubber stopper within the target detection area. If the gap distance is greater than a preset distance threshold, an unqualified signal is output. When a characteristic straight line representing the bottle shoulder and neck is detected within the initial detection area, the reference position is taken from the current position of the initial detection area, including: Edge points within the initial detection area are collected using a preset operator, and the edge points are linearly transformed to obtain at least two straight lines; Obtain the intersection angle between any two of the lines; if the intersection angle meets a preset angle range, then the line is taken as the feature line. When the feature line is detected within the initial detection area, the current position of the initial detection area is used as a reference position.
8. A rubber stopper gap detection device, characterized in that, The device, applicable to the rubber stopper gap detection method according to any one of claims 1 to 6, comprises: an optical component, a triggering component, a display component, and a processing terminal; The triggering component includes a photoelectric sensor and a control component. The photoelectric sensor is located on the inlet side of the running guide rail and transmits the detection result to the control component. The control component is electrically connected to the photoelectric sensor. The control component obtains the transmission time based on the detection result and sends a trigger signal to the camera device at the transmission time. The optical assembly includes two mutually perpendicular camera devices and two light sources. The camera devices are located above the running guide rail and are used to capture images of the detection position in the running guide rail. The light sources are located below the two camera devices respectively. The illumination direction of the light sources is coaxial with the shooting direction of the camera devices, and the two illumination directions intersect at the central axis of the vial in the detection position. The processing terminal is communicatively connected to the camera device and is used to receive detection images captured by the camera device; The display component is electrically connected to the processing terminal, receives the detection results from the processing terminal, and displays the distribution map of the rubber plug gap and the detection signal.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the plug gap detection method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Rubber plug quality detection device and method
CN104315977A
Method for detecting airtightness of bottle stopper
CN104483080A