CN108520260B - Method for identifying visible foreign matters in bottled oral liquid - Google Patents

Method for identifying visible foreign matters in bottled oral liquid Download PDF

Info

Publication number
CN108520260B
CN108520260B CN201810322118.4A CN201810322118A CN108520260B CN 108520260 B CN108520260 B CN 108520260B CN 201810322118 A CN201810322118 A CN 201810322118A CN 108520260 B CN108520260 B CN 108520260B
Authority
CN
China
Prior art keywords
oral liquid
area
length
image
foreign matters
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810322118.4A
Other languages
Chinese (zh)
Other versions
CN108520260A (en
Inventor
刘雄飞
张竞成
张豪
蔡建国
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Jiancan Biotechnology Co ltd
Original Assignee
Central South University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Central South University filed Critical Central South University
Priority to CN201810322118.4A priority Critical patent/CN108520260B/en
Publication of CN108520260A publication Critical patent/CN108520260A/en
Application granted granted Critical
Publication of CN108520260B publication Critical patent/CN108520260B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/30Noise filtering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/24Aligning, centring, orientation detection or correction of the image
    • G06V10/245Aligning, centring, orientation detection or correction of the image by locating a pattern; Special marks for positioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/34Smoothing or thinning of the pattern; Morphological operations; Skeletonisation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/56Extraction of image or video features relating to colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image

Abstract

The invention discloses a method for identifying visible foreign matters in bottled oral liquid, which comprises the steps of firstly carrying out binarization processing on a preprocessed image, dividing the oral liquid into an upper area and a lower area, respectively setting threshold values for the imaging area S, the perimeter C and the length-width ratio N of a minimum external matrix of the upper area and the lower area, and judging whether the upper area and the lower area have the visible foreign matters or not according to the relationship between parameters and the threshold values, wherein the method has high accuracy and good stability, solves the problem that the identification of the foreign matters by single parameter is easy to cause error identification, can not only effectively detect the impurities such as plant fibers, residues, hairs and the like by partition detection, but also can correctly detect the impurities such as glass residues which have small volume, certain quality and irregular movement, and can effectively eliminate the interference of bubbles; the method for identifying the visible foreign matters in the bottled oral liquid has the advantages of low equipment cost, simple and efficient processing algorithm, rich and various detectable impurity types and capability of meeting the requirement of online production.

Description

Method for identifying visible foreign matters in bottled oral liquid
Technical Field
The invention belongs to the technical field of image processing and automation, and particularly relates to a method for identifying visible foreign matters in bottled oral liquid.
Background
In recent years, the yield and sales of Chinese medicinal oral liquid are increasing at a remarkable speed, and various brands of oral liquid are in endlessly, and competition among manufacturers is stronger. However, with the increasing variety and quantity of oral liquid, the quality requirement of the oral liquid is also increasing, because in the process of extracting the oral liquid, impurities such as glass scraps, plant fibers, residues, hair, white spots and the like are inevitably mixed. In order to ensure that the oral liquid does not damage the health of human bodies, the quality control of the oral liquid has strict production process requirements and industrial quality inspection standards all the time. In the chinese pharmacopoeia (2010) it is stated that particles with a size or length of more than 50um containing foreign matter in a liquid medicine are not qualified, so that it can be seen that the foreign matter is directed to those particles with a size of more than 50 um. At present, two methods of detecting foreign matters in bottled oral liquid mainly comprise artificial strong light detection and machine vision intelligent detection.
The artificial strong light detection method is characterized in that the oral liquid is irradiated by strong light in a dark room, and a lamp inspector performs bottle-by-bottle detection on the oral liquid bottle by naked eyes.
The machine vision system converts a target object into an image signal through a machine vision tool, transmits the image signal to a special image processing system, converts the image signal into a digital signal according to the information of pixel distribution, brightness, color and the like of the image, performs corresponding operation on the digital signal by the image processing system to extract the characteristics of the target, further judges a result according to a certain rule according to the characteristics, and finally controls the on-site equipment action according to the judgment result. The intelligent detection of the machine is to process the acquired multi-frame sequence oral liquid images to be detected by adopting a proper image processing algorithm, automatically detect whether the oral liquid contains visible foreign particles and judge whether the liquid medicine to be detected meets the production standard. However, the conventional detection research on visible foreign matters in bottled oral liquid mainly has the following problems:
(1) the visible foreign matter particles possibly existing in the oral liquid bottle are various, such as glass scraps, plant fibers, residues, hairs, soil and the like, due to the difference of physical appearance and internal structure, the needed identification parameters are different, and the current algorithm usually depends on single parameter identification, so that missing detection and wrong detection are easily caused.
(2) Scales and spots exist on the surface of the oral liquid bottle body, the background of an image after imaging is complex, noise is various, quality goods and inferior-quality goods cannot be judged quickly, detection errors often occur, and the effect is not ideal.
(3) The impurities with certain mass such as the glass slag are always deposited at the bottom in the rotating process of the oral liquid bottle, and the generated bubbles appear at the middle upper part of the bottle, so that the interference is easily generated in the identification, and the phenomena of false detection and missing detection are caused.
Disclosure of Invention
The invention aims to provide a method for identifying visible foreign matters in bottled oral liquid, which has high accuracy, good stability and strong anti-bubble interference capability and can quickly detect whether the visible foreign matters exist in the bottled oral liquid.
The invention provides a method for identifying visible foreign matters in bottled oral liquid, which comprises the following steps:
(1) acquiring a plurality of continuous images of the bottled oral liquid to be detected;
(2) preprocessing the image;
(3) carrying out binarization processing on the preprocessed image;
(4) acquiring three parameters of the imaging area S, the perimeter C and the length-width ratio N of the minimum external matrix of the foreign matter;
(5) dividing the bottled oral liquid into an upper area and a lower area, and respectively setting threshold values for the imaging area S, the perimeter C and the length-width ratio N of a minimum external matrix of the upper area and the lower area;
(6) judging whether visible foreign matters exist in the upper and lower areas according to the relation between the parameters in the step (4) and the threshold values in the step (5);
if any of the parameters S, C and N of the foreign object target is higher than the set threshold, determining that a foreign object exists;
if neither the parameter S, C of the foreign object target nor N is higher than the set threshold value, it is determined as a genuine product.
In the step (1), after the bottled oral liquid to be measured is vertically rotated and suddenly stopped, 3 pictures are continuously shot by using a CCD industrial camera and are transmitted to a host.
The pretreatment in the step (2) specifically comprises the following steps:
s1, carrying out graying processing on an image to obtain a grayed image;
s2, filtering the grayed image to remove redundant impurity points in the image;
s3, performing secondary frame difference processing on the filtered image to remove static background interference;
and S4, carrying out sharpening operation on the image after frame difference to enable the edge of the image to be clear and clear, and obtaining the preprocessed image.
And in the step S2, performing filtering processing by using GAUSSIAN.
In the step S4, the sharpening process is performed by a second order differential method, and is implemented by a Laplace operator, which is defined as follows:
Figure BDA0001625564750000031
the templates used are as follows:
Figure BDA0001625564750000032
in the step (3), a self-adaptive threshold segmentation method is adopted to carry out binarization processing on the sharpened image so as to segment the visible foreign matters from the background and eliminate the interference of the background on the visible foreign matters.
The adaptive threshold segmentation method specifically uses a void cvThreshold (const CvArr src,
CvArr × dst, double threshold, double max _ value, int threshold _ type).
The three parameters of the imaging area S, the perimeter C and the length-width ratio N of the minimum circumscribed matrix in the step (4) are obtained in the following mode:
acquiring the outline of each foreign object by converting chain codes into point sequences, wherein the boundary chain codes of the foreign object regions are a1,a2,...,anThe inverse of the chain code is:
(a1,a2,...,an)-1=a1 -1,a2 -1,...,an -1
calculating the area S expression of the foreign body area by the chain code as follows:
Figure BDA0001625564750000033
in the formula: gamma rayi=γi-1+ai2,γ0Is the ordinate of the initial point, ai0And ai2The components of the directional code length in the directions k-0 (horizontal) and k-2 (vertical), ai0And ai2The values in the eight directions of the chain code are as follows:
Figure BDA0001625564750000034
the expression for calculating the perimeter C of the foreign object region from the chain code is:
Figure BDA0001625564750000035
the even code is the chain code in the horizontal or vertical direction, the code length is 1, the odd code is the chain code in the diagonal direction, the code length is
Figure BDA0001625564750000036
In the above formula: n iseIs the even number in the chain code sequence, and n is the total number of codes in the chain code sequence.
Obtaining the vertex coordinates (x) of the outermost layer profile in four directionsi,yi) (i ═ 0,1,2,3), the minimum circumscribed matrix length and width of a foreign object can be calculated using the following equations:
d1=[(xi-xi-1)2+(yi-yi-1)2]1/2
d2=[(xi-xi+1)2+(yi-yi+1)2]1/2
its midpoint (x)i,yi) Coordinates representing the vertex in either direction, (x)i-1,yi-1) And (x)i+1,yi+1) Is shown andthe coordinates of two adjacent vertexes of the three-dimensional coordinate system are sequentially calculated to obtain d1And d2Assigning a larger value to d1Smaller value is assigned to d2The expression for the minimum circumscribed matrix aspect ratio can be obtained:
N=d1/d2
the step (5) is realized by the following steps:
a. dividing the oral liquid bottle into two upper and lower regions pDEST1 and pDEST2 along the y-axis by using a cvSetImageROI (Ipmegage, CvRect) function in OpenCV, and simultaneously defining 2 rectangular regions retzie 1 and retzie 2 by using a CvSize (const CvArr src, CvArr dst, int intervention (CV _ INTER _ LINEAR) function, wherein the two rectangular regions are the same in length, the length of the retzie 1 is 5 times that of the retzie 2, the pDEST1 is divided by the retzie 1, the pDEST2 is divided by the retzie 2, the pDEST1 is defined as an upper half region, and the pDEST2 is defined as a lower half region;
b. the perimeter C of the upper half area and the lower half area and the threshold value of the minimum external matrix length-width ratio N are the same, the threshold values of the area S are different, and the threshold values of the area, the perimeter and the minimum external matrix length-width ratio parameter of the upper half area and the minimum external matrix length-width ratio parameter are respectively set as S1、C1And N1Setting the threshold values of the length-width ratio parameters of the area, the perimeter and the minimum circumscribed matrix of the lower half area as S2、C1And N1
The oral liquid is divided into an upper area and a lower area, so that impurities in the oral liquid, such as plant fibers, residues, hairs and the like with a certain length or area, can be recognized clearly in image imaging, can float in the oral liquid bottle along with vertical rotation-sudden stop of the oral liquid bottle, and can perform approximate circular motion around the center of the bottle, and the track is found well. Small, transparent impurities such as glass cullet, the volume of which is about 0.05mm visible to the naked eye3~0.15mm3The position of the glass slag is difficult to find in imaging, but the glass slag has certain quality, is sunk at the bottom of the oral liquid bottle in the rotating-sudden stopping process of the oral liquid bottle, is different from other impurities, does not make approximate circular motion around the center of a circle when in motion, has an irretrievable and irregular motion track, but can ensure that the glass slag always moves at the bottom and does not move at the bottom when in imagingAfter the oral liquid bottle is rotated and suddenly stopped, a small amount of bubbles appear at the middle upper part of the bottle, no bubbles are generated at the bottom, and the volume of the visible micro bubbles is about 0.01mm3~0.20mm3The size of the detection device is approximately similar to that of the glass slag, interference is easy to generate in identification, and the phenomena of false detection and missing detection are caused.
The oral liquid bottle may have various visible foreign particles, such as glass scraps, plant fibers, residues, hair, mud, etc., and the identification parameters required are different due to the difference in physical appearance and internal structure. Such as residues and soil, the impurities have certain mass and area, can occupy a part of pixels in imaging, cannot generate apparent deformation due to movement in the rotating movement process, can easily find the position in a picture, and can be judged by the imaging area S; impurities such as silk and cotton wool cannot be judged by using the area S due to the characteristics of fine length and almost zero mass of the impurities, and whether the impurities are foreign matters or not is judged by using the perimeter C; in the process of vertical rotation-sudden stop of the liquid medicine bottle, part of light foreign matters can cause deformation of the external structure of the liquid medicine bottle due to movement, such as hair and debris, and the parameter of the length-width ratio N of the minimum external matrix needs to be extracted for judgment.
Compared with the prior art, the invention has the beneficial technical effects that:
the method for identifying the visible foreign matters in the bottled oral liquid divides the oral liquid into an upper area and a lower area, sets the threshold values for the imaging area S, the perimeter C and the length-width ratio N of the minimum external matrix in different areas, judges whether the visible foreign matters exist in the upper area and the lower area according to the relation between the parameters and the threshold values, can quickly distinguish and clear certified products and defective products, has high precision and good stability, solves the problem that the identification of the foreign matters by single parameter is easy to cause false identification, can effectively detect the impurities such as plant fibers, residues, hairs and the like by different areas, can correctly detect the impurities such as glass residues which are small in size, have certain quality and are irregular in movement, can effectively eliminate the interference of bubbles, and reduces the occurrence of false detection and missed detection; the method for identifying the visible foreign matters in the bottled oral liquid has the advantages of low equipment cost, simple and efficient processing algorithm, rich and various detectable impurity types and capability of meeting the requirement of online production.
Drawings
Fig. 1 is a flow chart illustrating a method for identifying a foreign object visible in a bottled oral liquid according to an embodiment of the present invention.
FIG. 2 is an image of a bottled oral liquid in accordance with one embodiment of the present invention.
FIG. 3 is a schematic diagram of the upper and lower sections of the bottled oral liquid of the present invention, wherein (a) is the upper half area and (b) is the lower half area.
Fig. 4 is a flow chart of the parameter and threshold value determination for oral liquid bottle qualification in one embodiment of the present invention.
FIG. 5 is a diagram illustrating the results of detecting a foreign object according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, rather than all embodiments, and all other embodiments obtained by those skilled in the art without any creative work based on the embodiments of the present invention belong to the protection scope of the present invention.
The invention provides a method for identifying visible foreign matters in bottled oral liquid, which comprises the following steps:
(1) acquiring a plurality of continuous images of the bottled oral liquid to be detected;
(2) preprocessing the image;
(3) carrying out binarization processing on the preprocessed image;
(4) acquiring three parameters of the imaging area S, the perimeter C and the length-width ratio N of the minimum external matrix of the foreign matter;
(5) dividing the bottled oral liquid into an upper area and a lower area, and respectively setting threshold values for the imaging area S, the perimeter C and the length-width ratio N of a minimum external matrix of the upper area and the lower area;
(6) judging whether visible foreign matters exist in the upper and lower areas according to the relation between the parameters in the step (4) and the threshold values in the step (5);
if any of the parameters S, C and N of the foreign object target is higher than the set threshold, determining that a foreign object exists;
if neither the parameter S, C of the foreign object target nor N is higher than the set threshold value, it is determined as a genuine product.
The following describes a method for identifying a visible foreign object in a bottled oral liquid according to an embodiment of the present invention, with a specific flow chart shown in fig. 1:
the method comprises the following steps that firstly, a CCD industrial camera is used for continuously shooting 3 pictures of an oral liquid bottle after vertical rotation and sudden stop, and the pictures are transmitted to a host;
the appearance color of visible foreign matters possibly existing in an oral liquid bottle is variable, an RGB color mode is commonly used in the industry to express colors, RGB is the color representing three channels of red, green and blue, the standard almost comprises all colors which can be sensed by human eyesight, the standard is one of the color systems which are most widely applied at present, if RGB is 0, black is displayed, if RGB is 255, white is displayed, theoretically, if black impurities and white impurities can be identified, all impurities with colors which can be identified by human eyes between black and white can be detected by the system, if a mode of only giving strong light to the back is adopted, the background light is too strong, the light permeability is not enough, imaging of the white impurities cannot be found in a picture, and the identification of the white impurities is influenced; if the mode of only giving strong light at the bottom is adopted, the picture is too dim, and the identification of black impurities is influenced;
the method that strong light is given to the bottom and weak light is given to the background is adopted for shooting the oral liquid bottle, the type of an adopted camera is a CCD camera of a large and constant image MER-132-43U3M, the type of a bottom light source is clamping flame LH-P20-20W, the type of a back light source is the same as that of the bottom light source, but a layer of organic glass black light-transmitting frosted OLED plate and a layer of light-transmitting paper are added in front of the light source, and the obtained image of the bottled oral liquid is shot, as shown in figure 2, the permeability of light in the oral liquid bottle is good, impurities in the bottle can be clearly displayed, and the method greatly helps subsequent identification work;
in the process of shooting pictures, color information of impurities is not involved, so that a black-and-white camera is adopted, redundant information can be removed as much as possible, the processing speed is increased, the selected CCD industrial camera is a camera with a USB3.0 interface, the theoretical maximum transmission bandwidth of USB3.0 is as high as 5Gbps and about 10 times of USB2.0, and the shot pictures can be rapidly transmitted to a host computer in speed;
step two, carrying out graying processing on the 3 images to be detected simultaneously to obtain grayed images, and specifically, realizing graying processing by using a void cvCvtColor (const CvArr src, CvArr dst, int code) function;
step three, performing GaUSSIAN filtering processing on the 3 grayed images, and filtering redundant impurity points in the images, specifically, realizing the GAUSSIAN filtering processing by using a void cvSmooth (const CvArr src, CvArr dst, int smooth type is CV _ GAUSSIAN, int param1 is 3, int param2 is 0, double param3 is 0, and double param4 is 0) function;
in the process of acquiring and transmitting the image, the noise in the image can be influenced by the interference of random signals, for example, the noise quantity in the image can be influenced by external conditions such as illumination, temperature and the like, and the noise types which can appear in the image are mainly Gaussian noise and salt-pepper noise;
step four, performing secondary frame difference processing on the filtered picture, removing static background interference, and leaving a visible foreign matter track still moving, specifically, using a void cvAbsDiff (const CvArr src1, const CvArr src2, CvArr dst) function to realize secondary frame difference processing;
step five, carrying out sharpening operation on the frame-differed picture, specifically, realizing sharpening operation by using a void cvFilter2D (const CvArr src, CvArr dst, const CvMat kernel, CvPoint anchor ═ cvPoint (-1, -1)) function;
the sharpening of the picture aims to enhance the edge and the gray level jump part of an object in the image, so that the edge of the image becomes more vivid, and the edge of the object is more favorably observed by human eyes and extracted by a computer. There are two differential sharpening methods, the first order differential method and the second order differential method. Compared with the first-order differential method, the second-order differential method has narrower generated edge and stronger correspondence to the details in the image, and when the gray value changes of the image are similar, the correspondence to the line is stronger than the correspondence to the gradient and the correspondence to the point is stronger than the correspondence to the line, and the second-order differential method has better effect than the first-order differential method on the whole;
the method is realized by adopting a Laplace operator in a second-order differential method, and the Laplace operator is defined as follows:
Figure BDA0001625564750000081
the templates used are as follows:
Figure BDA0001625564750000082
performing binarization processing on the sharpened image by using a self-adaptive threshold segmentation method to segment visible foreign matters from the background and eliminate the interference of the background on the visible foreign matters;
the self-adaptive threshold segmentation method specifically comprises the steps of processing by using a void cvThreshold (const CvArr src, CvArr dst, double threshold, double max _ value, int threshold _ type) function;
step seven, three parameters of the imaging area S, the perimeter C and the length-width ratio N of the minimum circumscribed matrix of the foreign matter are realized through the following modes:
acquiring the outline of each foreign object by converting chain codes into point sequences, wherein the boundary chain codes of the foreign object regions are a1,a2,...,anThe inverse of the chain code is:
(a1,a2,...,an)-1=a1 -1,a2 -1,...,an -1
calculating the area S expression of the foreign body area by the chain code as follows:
Figure BDA0001625564750000083
in the formula: gamma rayi=γi-1+ai2,γ0Is the ordinate of the initial point, ai0And ai2The components of the directional code length in the directions k-0 (horizontal) and k-2 (vertical), ai0And ai2The values in the eight directions of the chain code are as follows:
Figure BDA0001625564750000084
the expression for calculating the perimeter C of the foreign object region from the chain code is:
Figure BDA0001625564750000085
the even code is the chain code in the horizontal or vertical direction, the code length is 1, the odd code is the chain code in the diagonal direction, the code length is
Figure BDA0001625564750000086
In the above formula: n iseIs the even number in the chain code sequence, and n is the total number of codes in the chain code sequence;
obtaining the vertex coordinates (x) of the outermost layer profile in four directionsi,yi) (i ═ 0,1,2,3), the minimum circumscribed matrix length and width of a foreign object can be calculated using the following equations:
d1=[(xi-xi-1)2+(yi-yi-1)2]1/2
d2=[(xi-xi+1)2+(yi-yi+1)2]1/2
its midpoint (x)i,yi) Coordinates representing the vertex in either direction, (x)i-1,yi-1) And (x)i+1,yi+1) Representing the coordinates of two adjacent vertexes, and calculating d1And d2Assigning a larger value to d1Smaller value is assigned to d2The expression for the minimum circumscribed matrix aspect ratio can be obtained:
N=d1/d2
3 parameters are reasonably used for detection, so that the diversity of detected impurities and the richness of a detection system can be increased, and the probability of missed detection and false detection is greatly reduced;
step eight, dividing the oral liquid into an upper area and a lower area, and respectively setting threshold values for the imaging area S, the perimeter C and the length-width ratio N of the minimum external matrix of the upper area and the lower area;
a. dividing the oral liquid bottle into two upper and lower regions pDest1 and pDest2 along the y-axis by using cvSetImageROI (CvRect rect) function in OpenCV, and defining 2 rectangular regions retzie 1 and retzie 2 by using CvSize (const CvArr src, CvArr dst, int intervention) (CV _ INTER _ line) function, wherein the two rectangular regions are the same in length, the length of retzie 1 is 5 times higher than that of retzie 2, pDest1 is divided by retzie 1, pDest2 is divided by retzie 2, pDest1 is defined as an upper half region, and pDest2 is defined as a lower half region, as shown in fig. 3;
b. the perimeter C of the upper half area and the lower half area and the threshold value of the minimum external matrix length-width ratio N are the same, the threshold values of the area S are different, and the threshold values of the area, the perimeter and the minimum external matrix length-width ratio parameter of the upper half area and the minimum external matrix length-width ratio parameter are respectively set as S1、C1And N1Setting the threshold values of the length-width ratio parameters of the area, the perimeter and the minimum circumscribed matrix of the lower half area as S2、C1And N1
Step nine, judging whether visible foreign matters exist in the upper area and the lower area according to the relation between the parameters and the threshold, specifically:
1) extracting all imaging target foreign object blocks D1,D2,...,DnIf any one of parameters S, C and N of the foreign matter target is higher than the set threshold value, the foreign matter is determined as impurity foreign matter and is a defective product;
2) if any of the parameters S, C and N of the foreign object target is not higher than the set threshold, it is determined as a genuine product, as shown in fig. 4.
The method for identifying the visible foreign matters in the bottled oral liquid has the advantages that the detection result of the visible foreign matters in the bottled oral liquid is shown in fig. 5, the pictures (a), (b) and (c) are taken as 3 pictures to be detected, the pictures (d) and (e) are upper and lower half area detection result pictures, hair threads moving at the middle upper part of the bottle to be detected can be detected in the picture (d), glass residues moving at the bottom of the bottle to be detected can be detected in the picture (e), the bottle oral liquid containing the foreign matters is judged to be defective, the foreign matter detection speed is high, and the image processing time only takes 93.04 ms.
The above description is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above-described embodiments. Modifications and variations that may occur to those skilled in the art without departing from the spirit and scope of the invention are to be considered as within the scope of the invention.

Claims (6)

1. A method for identifying visible foreign matters in bottled oral liquid is characterized by comprising the following steps:
(1) acquiring a plurality of continuous images of the bottled oral liquid to be detected;
(2) preprocessing the image;
(3) carrying out binarization processing on the preprocessed image;
(4) acquiring three parameters of the imaging area S, the perimeter C and the length-width ratio N of the minimum external matrix of the foreign matter;
(5) dividing the bottled oral liquid into an upper area and a lower area, and respectively setting threshold values for the imaging area S, the perimeter C and the length-width ratio N of a minimum external matrix of the upper area and the lower area;
(6) judging whether visible foreign matters exist in the upper and lower areas according to the relation between the parameters in the step (4) and the threshold values in the step (5);
if any of the parameters S, C and N of the foreign object target is higher than the set threshold, determining that a foreign object exists;
judging as a genuine product if neither of the parameters S, C and N of the foreign object target is higher than the set threshold;
the pretreatment in the step (2) specifically comprises the following steps:
s1, carrying out graying processing on an image to obtain a grayed image;
s2, filtering the grayed image to obtain a filtered image;
s3, performing secondary frame difference processing on the filtered image to obtain an image with frame difference;
s4, carrying out sharpening operation on the image subjected to frame difference to obtain a preprocessed image;
in the step S4, the sharpening process is performed by a second order differential method, and is implemented by a Laplace operator, which is defined as follows:
Figure FDA0003205926340000011
the templates used are as follows:
Figure FDA0003205926340000012
the three parameters of the imaging area S, the perimeter C and the length-width ratio N of the minimum circumscribed matrix in the step (4) are obtained in the following mode:
acquiring the outline of each foreign object by converting chain codes into point sequences, wherein the boundary chain codes of the foreign object regions are a1,a2,...,anThe inverse of the chain code is:
(a1,a2,...,an)-1=a1 -1,a2 -1,...,an -1
calculating the area S expression of the foreign body area by the chain code as follows:
Figure FDA0003205926340000021
in the formula: gamma rayi=γi-1+ai2,γ0Is the ordinate of the initial point, ai0And ai2The components of the directional code length in the directions k-0 (horizontal) and k-2 (vertical), ai0And ai2The values in the eight directions of the chain code are as follows:
Figure FDA0003205926340000022
the expression for calculating the perimeter C of the foreign object region from the chain code is:
Figure FDA0003205926340000023
the even code is the chain code in the horizontal or vertical direction, the code length is 1, the odd code is the chain code in the diagonal direction, the code length is
Figure FDA0003205926340000024
In the above formula: n iseIs the even number in the chain code sequence, and n is the total number of codes in the chain code sequence;
obtaining the vertex coordinates (x) of the outermost layer profile in four directionsi,yi) (i ═ 0,1,2,3), the minimum circumscribed matrix length and width of a foreign object can be calculated using the following equations:
d1=[(xi-xi-1)2+(yi-yi-1)2]1/2
d2=[(xi-xi+1)2+(yi-yi+1)2]1/2
its midpoint (x)i,yi) Coordinates representing the vertex in either direction, (x)i-1,yi-1) And (x)i+1,yi+1) Representing the coordinates of two adjacent vertexes, and calculating d1And d2Assigning a larger value to d1Smaller value is assigned to d2The expression for the minimum circumscribed matrix aspect ratio can be obtained:
N=d1/d2
2. the method for identifying the visible foreign matters in the bottled oral liquid according to claim 1, wherein in the step (1), after the bottled oral liquid to be tested is vertically rotated and suddenly stopped, 3 pictures are continuously taken by using a CCD industrial camera and transmitted to a host.
3. The method according to claim 1, wherein the filtering process in S2 is a GAUSSIAN filtering process.
4. The method for identifying visible foreign matters in bottled oral liquid according to claim 1, wherein in the step (3), a self-adaptive threshold segmentation method is adopted to carry out binarization processing on the sharpened image.
5. The method for identifying visible foreign matters in bottled oral liquid according to claim 4, wherein the adaptive threshold segmentation method is specifically processing by using a void cvThreshold (const CvArr src, CvArr dst, double threshold, double max _ value, int threshold _ type) function.
6. The method for identifying visible foreign matter in a bottled oral liquid according to claim 1, wherein the step (5) is performed by:
a. dividing the oral liquid bottle into two upper and lower regions pDEST1 and pDEST2 along the y-axis by using a cvSetImageROI (Ipmegage, CvRect) function in OpenCV, and simultaneously defining 2 rectangular regions retzie 1 and retzie 2 by using a CvSize (const CvArr src, CvArr dst, int intervention (CV _ INTER _ LINEAR) function, wherein the two rectangular regions are the same in length, the length of the retzie 1 is 5 times that of the retzie 2, the pDEST1 is divided by the retzie 1, the pDEST2 is divided by the retzie 2, the pDEST1 is defined as an upper half region, and the pDEST2 is defined as a lower half region;
b. the perimeter C of the upper half area and the lower half area and the threshold value of the minimum external matrix length-width ratio N are the same, the threshold values of the area S are different, and the threshold values of the area, the perimeter and the minimum external matrix length-width ratio parameter of the upper half area and the minimum external matrix length-width ratio parameter are respectively set as S1、C1And N1Area of the lower half areaThe threshold values of the length-width ratio parameter of the perimeter and the minimum external matrix are respectively set as S2、C1And N1
CN201810322118.4A 2018-04-11 2018-04-11 Method for identifying visible foreign matters in bottled oral liquid Active CN108520260B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810322118.4A CN108520260B (en) 2018-04-11 2018-04-11 Method for identifying visible foreign matters in bottled oral liquid

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810322118.4A CN108520260B (en) 2018-04-11 2018-04-11 Method for identifying visible foreign matters in bottled oral liquid

Publications (2)

Publication Number Publication Date
CN108520260A CN108520260A (en) 2018-09-11
CN108520260B true CN108520260B (en) 2022-02-01

Family

ID=63432392

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810322118.4A Active CN108520260B (en) 2018-04-11 2018-04-11 Method for identifying visible foreign matters in bottled oral liquid

Country Status (1)

Country Link
CN (1) CN108520260B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109360195A (en) * 2018-09-28 2019-02-19 长沙湘计海盾科技有限公司 The visible detection method of foreign particles in a kind of bottle-packaging solution
CN109799544B (en) * 2018-12-28 2021-03-19 深圳市重投华讯太赫兹科技有限公司 Intelligent detection method and device applied to millimeter wave security check instrument and storage device
CN110070523B (en) * 2019-04-02 2021-06-22 广州大学 Foreign matter detection method for bottle bottom
CN110197478A (en) * 2019-05-16 2019-09-03 红云红河烟草(集团)有限责任公司 A kind of detection method and system of cigarette case inside casing paper joint

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101354359A (en) * 2008-09-04 2009-01-28 湖南大学 Method for detecting, tracking and recognizing movement visible exogenous impurity in medicine liquid
CN201689064U (en) * 2010-05-14 2010-12-29 山东大学 Impurity detecting device after drinks are filled
CN102175693A (en) * 2011-03-08 2011-09-07 中南大学 Machine vision detection method of visual foreign matters in medical medicament
JP2012078195A (en) * 2010-10-01 2012-04-19 Toray Ind Inc Inspection method for foreign matter in solution
CN104835166A (en) * 2015-05-13 2015-08-12 山东大学 Liquid medicine bottle foreign matter detection method based on machine visual detection platform
CN105115986A (en) * 2015-08-12 2015-12-02 中南大学 System and method for detecting visible foreign substances in traditional Chinese medicine oral liquid bottles
CN105973904A (en) * 2016-04-28 2016-09-28 南京汇川图像视觉技术有限公司 Edible oil impurity detection method based on image background probability graph

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CA2207710C (en) * 1994-12-13 2001-04-03 Kjaergaard Industri Automatic A/S A method and an apparatus for identifying foreign bodies in packaged beverages, as well as use of the apparatus
CN2258276Y (en) * 1995-07-04 1997-07-23 湖南江滨机器厂 Laser injection automatic detector
JP2006308437A (en) * 2005-04-28 2006-11-09 Sukiyan Technol:Kk Device and method for inspecting foreign matter
DE102006054099A1 (en) * 2006-11-15 2008-05-21 Khs Ag Method for inspecting or monitoring bottles or similar containers and device for inspecting bottles or similar containers
CN105869154B (en) * 2015-09-23 2018-10-16 长沙理工大学 A kind of Classification and Identification detection method of 250ml medical large transfusions visible foreign matters and bubble
CN105251707B (en) * 2015-11-26 2017-07-28 长沙理工大学 Bad part eject sorting equipment based on medical large transfusion visible foreign matters detecting system
CN105784722B (en) * 2016-04-29 2018-08-07 中南大学 On a kind of assembly line in medicinal liquid bottle visible foreign matters detection method and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101354359A (en) * 2008-09-04 2009-01-28 湖南大学 Method for detecting, tracking and recognizing movement visible exogenous impurity in medicine liquid
CN201689064U (en) * 2010-05-14 2010-12-29 山东大学 Impurity detecting device after drinks are filled
JP2012078195A (en) * 2010-10-01 2012-04-19 Toray Ind Inc Inspection method for foreign matter in solution
CN102175693A (en) * 2011-03-08 2011-09-07 中南大学 Machine vision detection method of visual foreign matters in medical medicament
CN104835166A (en) * 2015-05-13 2015-08-12 山东大学 Liquid medicine bottle foreign matter detection method based on machine visual detection platform
CN105115986A (en) * 2015-08-12 2015-12-02 中南大学 System and method for detecting visible foreign substances in traditional Chinese medicine oral liquid bottles
CN105973904A (en) * 2016-04-28 2016-09-28 南京汇川图像视觉技术有限公司 Edible oil impurity detection method based on image background probability graph

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
数字图像中基于链码的目标面积计算方法;杨万扣等;《计算机工程》;20080131;第34卷(第1期);第30-33页 *
正中灯检机介绍及优势;uaahb6;《https://www.docin.com/p-1767402907.html》;20161027;第1-17页 *

Also Published As

Publication number Publication date
CN108520260A (en) 2018-09-11

Similar Documents

Publication Publication Date Title
CN108520260B (en) Method for identifying visible foreign matters in bottled oral liquid
CN110070524A (en) A kind of intelligent terminal panel visual fault detection system
CN105453153B (en) Traffic lights detects
CN109900711A (en) Workpiece, defect detection method based on machine vision
CN110261410A (en) A kind of detection device and method of glass lens defect
CN109341527B (en) Automatic shadow compensation structured light projection three-dimensional measurement system and method
CN109001212A (en) A kind of stainless steel soup ladle defect inspection method based on machine vision
CN109540925B (en) Complex ceramic tile surface defect detection method based on difference method and local variance measurement operator
CN107358627B (en) Fruit size detection method based on Kinect camera
CN110288561A (en) Refractory brick surface scratch recognition methods based on frequency filtering enhancing
CN104680519A (en) Seven-piece puzzle identification method based on contours and colors
CN103345755A (en) Chessboard angular point sub-pixel extraction method based on Harris operator
CN105784722B (en) On a kind of assembly line in medicinal liquid bottle visible foreign matters detection method and system
CN111047655A (en) High-definition camera cloth defect detection method based on convolutional neural network
CN106780473A (en) A kind of magnet ring defect multi-vision visual detection method and system
CN112819844B (en) Image edge detection method and device
CN113658131A (en) Tour type ring spinning broken yarn detection method based on machine vision
CN114119591A (en) Display screen picture quality detection method
CN110807763A (en) Method and system for detecting ceramic tile surface bulge
CN104749801B (en) High Precision Automatic optical detecting method and system
CN101937505B (en) Target detection method and equipment and used image acquisition device thereof
CN111292228A (en) Lens defect detection method
CN113012096A (en) Display screen sub-pixel positioning and brightness extraction method, device and storage medium
CN114387269B (en) Fiber yarn defect detection method based on laser
CN104813341B (en) Image processing system and image processing method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20221227

Address after: No. 322-11, No. 3, Junya North Street, Huangpu District, Guangzhou, Guangdong 510700

Patentee after: Guangzhou Jiancan Biotechnology Co.,Ltd.

Address before: Yuelu District City, Hunan province 410083 Changsha Lushan Road No. 932

Patentee before: CENTRAL SOUTH University