Bottle blank size measuring method

文档序号:32533 发布日期:2021-09-24 浏览:23次 中文

阅读说明:本技术 一种瓶胚尺寸测量方法 (Bottle blank size measuring method ) 是由 邓杰航 郭文权 黄欣茵 陈汉杰 顾国生 于 2021-06-22 设计创作,主要内容包括:本发明公开一种瓶胚尺寸测量方法,包括以下步骤,S1:读取瓶胚图像并对瓶胚图像进行图像预处理;S2:以预处理过后的图像的中线为基准把图像划分为左右两个区域;S3:分别求出左边区域图像和右边区域图像的若干波峰值,根据波峰值最大的四个位置,对应瓶胚左右各区域的支撑环、锁环和螺纹的位置;S4:分别求出左边区域图像和右边区域图像的若干波峰上沿位置和瓶口位置;S5:根据左边区域图像和右边区域图像对应位置的坐标,计算对应位置坐标的距离即可得到瓶胚尺寸参数的检测值。该方案可以使瓶胚检测系统在保证测量精度的前提下,大大减少测量时间,简化测量流程,满足线下质检和抽检需求。(The invention discloses a bottle blank size measuring method, which comprises the following steps of S1: reading a bottle embryo image and carrying out image preprocessing on the bottle embryo image; s2: dividing the image into a left area and a right area by taking the central line of the preprocessed image as a reference; s3: respectively solving a plurality of wave peak values of the left area image and the right area image, and corresponding to the positions of a support ring, a lock ring and threads of each area on the left and right of the bottle blank according to the four positions with the maximum wave peak values; s4: respectively calculating the positions of the upper edges of a plurality of wave crests and the positions of bottle openings of the left area image and the right area image; s5: and calculating the distance of the coordinates of the corresponding positions according to the coordinates of the corresponding positions of the left area image and the right area image to obtain the detection value of the bottle blank size parameter. According to the scheme, the bottle blank detection system can greatly reduce the measurement time, simplify the measurement process and meet the requirements of offline quality inspection and spot inspection on the premise of ensuring the measurement precision.)

1. A method for measuring the size of a bottle blank is characterized by comprising the following steps:

s1: reading a bottle embryo image and carrying out image preprocessing on the bottle embryo image;

s2: dividing the image into a left area and a right area by taking the central line of the preprocessed image as a reference;

s3: respectively solving a plurality of wave peak values of the left area image and the right area image, and corresponding to the positions of a support ring, a lock ring and threads of each area on the left and right of the bottle blank according to the four positions with the maximum wave peak values;

s4: respectively calculating the positions of the upper edges of a plurality of wave crests and the positions of bottle openings of the left area image and the right area image;

s5: and calculating the distance of the coordinates of the corresponding positions according to the coordinates of the corresponding positions of the left area image and the right area image to obtain the detection value of the bottle blank size parameter.

2. The method for measuring bottle embryo size as claimed in claim 1, wherein said S1 comprises the following steps:

s11: performing gray level transformation on the read original image;

s12: carrying out image cutting on the image subjected to the gray scale conversion processing;

s13: carrying out Otsu method binaryzation on the cut image;

s14: and performing small-area region removal processing on the image subjected to the Otsu binarization processing.

3. The method for measuring bottle blank size as claimed in claim 2, wherein in the step S11, the gray scale transformation comprises the following steps:

judging the number of channels of the read original image, and if the number of the channels of the bottle blank image is R, G, B three channels, performing gray level transformation on the bottle blank image; if the number of the channels of the bottle blank image is a single channel, the bottle blank image is kept as it is.

4. The method as claimed in claim 2, wherein in step S12, the image cropping step comprises:

the distance from the bottle blank to the black edge is measured manually, the two edges of the bottle blank image are contracted by 120 pixels towards the middle, and the bottom is contracted by 480 pixels upwards.

5. The method for measuring the size of bottle embryo according to claim 4, wherein in S13, the detailed procedures of Otsu method binarization are as follows:

for an image I (x, y), a segmentation threshold value of a foreground and a background is marked as T, the proportion of the number of pixels belonging to the foreground in the whole image is marked as omega 0, and the average gray level of the pixel is marked as mu 0; the proportion of the number of background pixels in the whole image is omega 1, the average gray scale of the background pixels is mu 1, the total average gray scale of the image is mu, and the inter-class variance is g; the image size is M multiplied by N, the number of pixels with the gray value smaller than a threshold T in the image is recorded as N0, and the number of pixels with the gray value larger than the threshold T is recorded as N1; then there are:

N0+N1=M×N

ω0+ω1=1

μ=ω0×μ0+ω1×μ1

g=ω0×(μ0-μ)2+ω1×(μ1-μ)2

thus, the between-class variance is:

g=ω0×ω1(μ0-μ1)2

and obtaining a threshold value T which enables the inter-class variance g to be maximum by adopting a traversal method, setting the pixel point with the pixel value smaller than T in the image as 0 and the pixel point with the pixel value larger than T as 1 according to the threshold value T, and finishing binarization processing.

6. The method for measuring the bottle embryo size as claimed in claim 5, wherein in the step S14, the small area region removing process comprises the following specific steps:

and (4) removing the small-area interference region by using a labeling algorithm, and reserving the bottle blank region.

7. The method for measuring bottle embryo size as claimed in claim 6, wherein said step S1 further comprises the step S15: and performing inclination correction on the image after the small-area region removal processing is completed.

8. The method for measuring the bottle embryo size as claimed in claim 7, wherein the step S3 comprises the following steps:

counting the number of black pixels in each row based on the left region image; calculating a plurality of peak positions according to the number of black pixels in each row, and drawing a peak image, wherein the four positions with the maximum peak value are positions of a support ring, a lock ring and threads of the image in the left area of the bottle blank;

and performing the same operation on the right area image to obtain the positions of the support ring, the lock ring and the threads of the right area image of the bottle blank.

9. The method for measuring the bottle embryo size as claimed in claim 8, wherein the step S4 comprises the steps of:

calculating a first derivative of the left region image, corresponding to a peak image of the left region image, and taking the first two maximum value points of the first derivative image as the upper edge of the peak of the left region image; finding a first derivative minimum value point from the right side to the left side of the first derivative graph, wherein the position, close to 0, of the first derivative on the left side of the point is the bottleneck position of the left area image;

and performing the same operation on the right area image to obtain the position of the upper edge of the wave crest and the position of the bottle opening of the right area image of the bottle blank.

10. The method for measuring the bottle embryo size as claimed in claim 9, wherein the step S5 comprises the following steps:

subtracting the corresponding peak positions of the left area image and the right area image and taking an absolute value to obtain the results of the outer diameter of the support ring, the outer diameter of the locking ring and the outer diameter of the thread of the bottle blank;

calculating the distance between the bottle opening positions respectively calculated by the left area image and the right area image to obtain the outer diameter of the bottle opening of the bottle blank;

and obtaining the bottle opening height and the locking ring height of the bottle blank according to the position of the upper edge of the wave crest of the right area image, the position of the bottle opening and the position of the locking ring.

Technical Field

The invention relates to the technical field of measurement and mapping, in particular to a bottle blank size measuring method.

Background

PET plastic (Polyethylene terephthalate), with the chinese name: the polyethylene glycol terephthalate has the advantages of high strength, high sanitary safety, good transparency, light weight, difficult damage, easy production and processing and the like, and is the most main packaging scheme for beverages and edible oil at present. The production of PET bottle is by PET injection moulding manufacturing enterprise with the heating of dry PET resin granule to viscous state temperature after, form PET bottle embryo through the injection nozzle injection of injection molding machine to the mould die cavity in, PET blowing manufacturing enterprise then heats PET bottle embryo to amorphous attitude temperature again after, adopts the final output PET bottle of biaxial stretching blow molding technology. As a semi-finished product of a PET bottle, the size deviation of a bottle blank opening directly influences the matching between a bottle opening and a bottle cap, and further influences the sealing quality of a product. The method is an important link of PET bottle production, and relates to quality verification of bottle preform molds by injection molding abrasive tool production enterprises and PET injection molding production enterprises, and supply quality inspection of PET bottle preforms supplied by PET injection molding production enterprises by PET blow molding production enterprises. Conventional manual inspection requires the use of a three-coordinate measuring machine. The three-coordinate measuring instrument has high measurement precision and a plurality of measurement items, can measure all bottle blank types without changing too much in equipment standardization, and can provide quality assurance for the mold industry. Shandongming good science and technology limited company provides an online star wheel bottle embryo detection machine, items such as detectable bottle embryo mouth sealing surface, ovality, embryo body filth, wire drawing, foaming, notes embryo point overlength can reach very fast to can with injection moulding device lug connection, can realize other visual detection functions. For a PET bottle blank size detection system based on a machine vision algorithm, foreign companies have provided an offline bottle blank size measurement system, but the price is high and the technical support is not timely.

The existing bottle blank size measurement technology mainly comprises a three-coordinate measuring instrument based on manual measurement and an online detection device capable of being connected with production equipment. The three-coordinate measuring instrument has high precision and a plurality of measuring items, but has large volume, cannot move, is complex to install, needs corresponding machine operation technology for technical workers, and cannot meet the increasing requirements of offline quality inspection and spot inspection. The detection of large batch of products usually needs a great amount of high-repetition work of technical workers, and has the defects of low detection speed, complex procedures, high labor intensity and the like. The online detection equipment can be fast in detection speed, can be directly connected with injection molding equipment, can realize other visual detection functions, but is generally expensive in price and large in occupied area, the precision of the measurement size of a plurality of equipment is far less than that of a three-coordinate measuring instrument, the maintenance is complex, and some key sizes are difficult to measure. Most of the existing bottle blank size detection systems are foreign products, and have the defects of high price, untimely technical support, low measurement precision, overlong measurement time and the like. Chinese invention with patent number CN112504108A is dedicated to 2021, 3/6, and discloses a device and a method for measuring the size of a bottle mouth of a high-precision full-size plastic bottle based on an LVDT displacement sensor. However, the measuring device of the scheme is complex to operate and inconvenient. In view of this, we propose a method for measuring the dimension of bottle blank with high precision and convenient operation.

Disclosure of Invention

The invention provides a bottle blank size measuring method with high precision and convenient operation, aiming at overcoming the defects of low measuring precision, untimely technical support, overlong measuring time and the like in the prior art.

In order to solve the technical problems, the technical scheme of the invention is as follows:

a bottle blank size measuring method comprises the following steps:

s1: reading a bottle embryo image and carrying out image preprocessing on the bottle embryo image;

s2: dividing the image into a left area and a right area by taking the central line of the preprocessed image as a reference;

s3: respectively solving a plurality of wave peak values of the left area image and the right area image, and corresponding to the positions of a support ring, a lock ring and threads of each area on the left and right of the bottle blank according to the four positions with the maximum wave peak values;

s4: respectively calculating the positions of the upper edges of a plurality of wave crests and the positions of bottle openings of the left area image and the right area image;

s5: and calculating the distance of the coordinates of the corresponding positions according to the coordinates of the corresponding positions of the left area image and the right area image to obtain the detection value of the bottle blank size parameter.

Among the above-mentioned scheme, this scheme can realize for bottle embryo detecting system that economy is quick, small and exquisite convenient, measurement accuracy is high, the maintenance cost is low, the operation is simple and easy, provide advantages such as algorithm support, the dimensional parameter of detection bottle embryo that can be accurate quick, like support ring external diameter, catch external diameter, external diameter of screw thread, bottleneck height etc. for under the bottle embryo detecting system can guarantee not sacrificing measurement accuracy's the prerequisite, the greatly reduced measuring time, simplify the measurement procedure, satisfy the gradual growth of day and get quality control and selective examination demand under the line.

Preferably, the S1 includes the steps of:

s11: performing gray level transformation on the read original image;

s12: carrying out image cutting on the image subjected to the gray scale conversion processing;

s13: carrying out Otsu method binaryzation on the cut image;

s14: and performing small-area region removal processing on the image subjected to the Otsu binarization processing.

In the scheme, the image quality can be improved by performing gray level conversion on the read original image, so that the display effect of the image is clearer; then, the image subjected to the gray level conversion processing is subjected to processing of removing black edges caused by illumination, so that the black edges can be prevented from influencing the detection result; then carrying out Otsu binarization processing on the cut image, wherein the Otsu binarization can convert the gray level image into a binary image, thereby facilitating subsequent processing of the image; and finally, performing small-area region removal processing on the image after the Otsu binarization processing is completed, so that an interference region in the image can be removed, and a real image of the bottle embryo is reserved. The series of image preprocessing can normalize the bottle blank image, so that the measured dimension parameters are more accurate.

Preferably, in S11, the grayscale transformation includes the specific steps of: judging the number of channels of the read original image, and if the number of the channels of the bottle blank image is R, G, B three channels, performing gray level transformation on the bottle blank image; if the number of the channels of the bottle blank image is a single channel, the bottle blank image is kept as it is.

In the above scheme, the image quality can be improved by performing gray scale conversion on the read original image, so that the display effect of the image is clearer. The calculation formula of the gray image is as follows:

img_gray=0.299×R+0.587×G+0.114×B

wherein img _ gray represents a gray image after gray conversion, R represents a red channel, G represents a green channel, and B represents a blue channel.

Preferably, in S12, the image cropping specifically includes: the distance from the bottle blank to the black edge is measured manually, the two edges of the bottle blank image are contracted by 120 pixels towards the middle, and the bottom is contracted by 480 pixels upwards.

In the above scheme, the illumination may cause the image to generate a black edge, which may affect the detection result, and therefore, the image needs to be cropped. Because the position of the black edge area of the bottle blank image is relatively fixed, the distance from the bottle blank to the black edge is manually measured, the two sides of the bottle blank image shrink by 120 pixels towards the middle, and the bottom shrinks by 480 pixels upwards, so that the cut image can be obtained.

Preferably, in S13, the detailed procedures of the tsu method binarization include: for an image I (x, y), a segmentation threshold value of a foreground and a background is marked as T, the proportion of the number of pixels belonging to the foreground in the whole image is marked as omega 0, and the average gray level of the pixel is marked as mu 0; the proportion of the number of background pixels in the whole image is omega 1, the average gray scale is mu 1, the total average gray scale of the image is mu, and the inter-class variance is g. The image size is M × N, the number of pixels in the image having a grayscale value smaller than the threshold T is denoted as N0, and the number of pixels having a grayscale value larger than the threshold T is denoted as N1. Then there are:

N0+N1=M×N

ω0+ω1=1

μ=ω0×μ0+ω1×μ1

g=ω0×(μ0-μ)2+ω1×(μ1-μ)2

thus, the between-class variance is:

g=ω0×ω1(μ0-μ1)2

and obtaining a threshold value T which enables the inter-class variance g to be maximum by adopting a traversal method, setting the pixel point with the pixel value smaller than T in the image as 0 and the pixel point with the pixel value larger than T as 1 according to the threshold value T, and finishing binarization processing.

In the above scheme, the image binarization by the Otsu method can convert the gray level image into a binary image, which is convenient for subsequent processing of the image, so that a threshold value T which maximizes the inter-class variance g is obtained by a traversal method, and the pixel points with the pixel values smaller than T and larger than T in the image are set to 0 and 1 according to the threshold value T, thereby completing the binarization processing.

Preferably, in S14, the small-area region removing process includes: and (4) removing the small-area interference region by using a labeling algorithm, and reserving the bottle blank region.

In the above scheme, the labeling algorithm specifically comprises the following steps: and distinguishing unconnected areas according to the connected areas of the image, marking the unconnected areas, calculating the area of each connected area, sequencing the connected areas from large to small, reserving the largest connected area, and deleting the connected areas with other small areas to reserve the bottle blank object.

Preferably, the step S1 further includes the step S15: and performing inclination correction on the image after the small-area removal is completed.

In the above scheme, the bottle embryo needs to be subjected to inclination correction before the bottle embryo size parameter detection, because the bottle embryo can be inclined in the placing process.

Preferably, the specific steps of S3 are: counting the number of black pixels in each row based on the left region image; calculating a plurality of peak positions according to the number of black pixels in each row, and drawing a peak image, wherein the four positions with the maximum peak value are positions of a support ring, a lock ring and threads of the image in the left area of the bottle blank; and performing the same operation on the right area image to obtain the positions of the support ring, the lock ring and the threads of the right area image of the bottle blank.

In the scheme, based on the left region image, the black pixels are the bottle blank region, and the white pixels are the background, because the number of the black pixels at the vertex positions of the support ring, the lock ring and the threads is the maximum; then, the maximum four peak values and the corresponding positions thereof are obtained according to the distribution of the number of the black pixels, and a peak image is drawn. And then, executing the same operation on the right area image to obtain the positions of the support ring, the lock ring and the threads of the right area image of the bottle blank.

Preferably, the specific step of S4 is: calculating a first derivative of the left region image, corresponding to a peak image of the left region image, and taking the first two maximum value points of the first derivative image as the upper edge of the peak of the left region image; finding a first derivative minimum value point from the right side to the left side of the first derivative graph, wherein the position, close to 0, of the first derivative on the left side of the point is the bottleneck position of the left area image; and performing the same operation on the right area image to obtain the position of the upper edge of the wave crest and the position of the bottle opening of the right area image of the bottle blank.

In the scheme, the left region image is observed to find that the number of black pixels of the image gradually increases from bottom to top, so that a first derivative of the black pixels of the left region image is calculated, the first two peaks are found from the left to the right of a first derivative graph, and the place with the maximum black pixel change rate is used as the upper edge of the peak; and (3) under the condition that the number of black pixels is gradually reduced near the bottle opening position, finding the first derivative minimum value from the right side to the left side of the first derivative graph, and searching the position, which is the bottle opening position, of the first derivative close to 0 from the top of the image by taking the point as a starting point. And performing the same operation on the right area image to obtain the position of the upper edge of the wave crest and the position of the bottle opening of the right area image of the bottle blank.

Preferably, the specific steps of S5 are: subtracting the corresponding peak positions of the left area image and the right area image and taking an absolute value to obtain the results of the outer diameter of the support ring, the outer diameter of the locking ring and the outer diameter of the thread of the bottle blank; calculating the distance between the bottle opening positions respectively calculated by the left area image and the right area image to obtain the outer diameter of the bottle opening of the bottle blank; and obtaining the bottle opening height and the locking ring height of the bottle blank according to the position of the upper edge of the wave crest of the right area image, the position of the bottle opening and the position of the locking ring.

In the scheme, four maximum wave peak positions of the left and right regional images are found from the top to the bottom of the image respectively, and the distance between the first wave peak positions corresponding to the left and right regional images is the outer diameter of the support ring; the distance between the second peak positions corresponding to the left and right side area images is the outer diameter of the locking ring; the horizontal distance between the fourth peak position of the left area image and the third peak position of the right area image is the external diameter of the thread; according to the first derivative diagram in the step S4, finding the first derivative minimum point from the right side to the left side of the image, and searching for a position where the first derivative is close to 0 from the top of the image with the point as a starting point, where the position is a bottle mouth position, and the distance between the bottle mouth positions of the left and right side area images is the outer diameter of the bottle mouth of the bottle blank; finding the position of the upper edge of the first peak from the left to the right of the first derivative diagram, then finding the point of which the first derivative on the left of the position is 0, wherein the distance between the point and the minimum value point of the first derivative is recorded as h1, the vertical distance between the position of the bottle mouth and the position of the support ring is recorded as h2, and the average value of h1 and h2 is recorded as the height h12 of the bottle mouth; the distance between the minimum point of the first derivative and the upper edge position of the second peak is recorded as h3, the vertical distance between the bottle opening position and the locking ring position is recorded as h4, the average value of h3 and h4 is recorded as the locking ring height h34, the bottle opening height and the locking ring height of the right bottle blank region can be obtained in the same way, and then the average value of the corresponding heights of the images of the left and right regions is obtained, namely the bottle opening height and the locking ring height of the bottle blank; if the bottle blank is subjected to the inclination correction processing, the bottle opening height and the locking ring height of the left area image or the right area image can be directly taken as the bottle opening height and the locking ring height of the bottle blank.

Compared with the prior art, the technical scheme of the invention has the beneficial effects that:

the invention provides a bottle blank size measuring method, which can greatly reduce the measuring time, simplify the measuring process and meet the increasingly long off-line quality inspection and spot inspection requirements on the premise that a bottle blank detecting system can ensure that the measuring precision is not sacrificed.

Drawings

FIG. 1 is a diagram of key concepts of an algorithm;

FIG. 2 is a flow chart of bottle blank image preprocessing;

FIG. 3 is a peak diagram of the image of the left region of the bottle preform;

FIG. 4 is a first derivative of the image of the left region of the bottle embryo;

FIG. 5 is a peak diagram of an image of the right area of the preform;

FIG. 6 is a first derivative chart of the image of the right area of the bottle embryo;

FIG. 7 is a schematic view of a segmented bottle preform image;

FIG. 8 is a schematic diagram of a bottle blank after segmentation; FIG. 8(a) shows the left preform region and FIG. 8(b) shows the right preform region;

FIG. 9 is a graph of the positions of key points of preform parameters;

FIG. 10 is an algorithm flow chart;

FIG. 11 is a schematic diagram of before and after image cropping;

FIG. 12 is a schematic view before and after removal of a small area region;

FIG. 13 is a schematic diagram of tilt correction.

Detailed Description

The drawings are for illustrative purposes only and are not to be construed as limiting the patent;

for the purpose of better illustrating the embodiments, certain features of the drawings may be omitted, enlarged or reduced, and do not represent the size of an actual product; it will be understood by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.

The technical solution of the present invention is further described below with reference to the accompanying drawings and examples.

Example 1

A method for measuring the size of a bottle preform, comprising the following steps, as shown in fig. 1:

s1: reading a bottle embryo image and carrying out image preprocessing on the bottle embryo image;

s2: dividing the image into a left area and a right area by taking the central line of the preprocessed image as a reference;

s3: respectively solving a plurality of wave peak values of the left area image and the right area image, and corresponding to the positions of a support ring, a lock ring and threads of each area on the left and right of the bottle blank according to the four positions with the maximum wave peak values;

s4: respectively calculating the positions of the upper edges of a plurality of wave crests and the positions of bottle openings of the left area image and the right area image;

s5: and calculating the distance of the coordinates of the corresponding positions according to the coordinates of the corresponding positions of the left area image and the right area image to obtain the detection value of the bottle blank size parameter.

In the concrete implementation process, this scheme can realize for bottle embryo detecting system that economy is quick, small and exquisite convenient, measurement accuracy is high, the maintenance cost is low, the operation is simple and easy, provide advantages such as algorithm support, the dimensional parameter of detection bottle embryo that can be accurate quick, like support ring external diameter, catch external diameter, external diameter of screw thread, bottleneck height etc. for under the bottle embryo detecting system can guarantee not sacrificing measurement accuracy's the prerequisite, the greatly reduced measuring time, simplify the measurement procedure, satisfy the day gradually growing and get quality control and selective examination demand under the line.

Example 2

The S1 includes the following steps, as shown in fig. 2:

s11: performing gray level transformation on the read original image;

s12: carrying out image cutting on the image subjected to the gray scale conversion processing;

s13: carrying out Otsu method binaryzation on the cut image;

s14: and performing small-area region removal processing on the image subjected to the Otsu binarization processing.

In the specific implementation process, the image quality can be improved by performing gray level transformation on the read original image, so that the display effect of the image is clearer; then, the image subjected to the gray level conversion processing is subjected to processing of removing black edges caused by illumination, so that the black edges can be prevented from influencing the detection result; then carrying out Otsu binarization processing on the cut image, wherein the Otsu binarization can convert the gray level image into a binary image, thereby facilitating subsequent processing of the image; and finally, performing small-area region removal processing on the image after the Otsu binarization processing is completed, so that an interference region in the image can be removed, and a real image of the bottle embryo is reserved. The series of image preprocessing can normalize the bottle blank image, so that the measured dimension parameters are more accurate.

In S11, the grayscale conversion includes: judging the number of channels of the read original image, and if the number of the channels of the bottle blank image is R, G, B three channels, performing gray level transformation on the bottle blank image; if the number of the channels of the bottle blank image is a single channel, the bottle blank image is kept as it is.

In the specific implementation process, the image quality can be improved by performing gray level conversion on the read original image, so that the display effect of the image is clearer. The calculation formula of the gray image is as follows:

img_gray=0.299×R+0.587×G+0.114×B

wherein img _ gray represents a gray image after gray conversion, R represents a red channel, G represents a green channel, and B represents a blue channel.

In S12, the image cropping specifically includes: the distance from the bottle blank to the black edge is measured manually, the two edges of the bottle blank image are contracted by 120 pixels towards the middle, and the bottom is contracted by 480 pixels upwards.

In the implementation process, the illumination may cause the image to generate a black edge, which affects the detection result, so that image cropping needs to be performed on the image, as shown in fig. 11. Because the position of the black edge area of the bottle blank image is relatively fixed, the distance from the bottle blank to the black edge is manually measured, the two sides of the bottle blank image shrink by 120 pixels towards the middle, and the bottom shrinks by 480 pixels upwards, so that the cut image can be obtained.

In S13, the detailed procedures of the tsu method binarization include: for an image I (x, y), a segmentation threshold value of a foreground and a background is marked as T, the proportion of the number of pixels belonging to the foreground in the whole image is marked as omega 0, and the average gray level of the pixel is marked as mu 0; the proportion of the number of background pixels in the whole image is omega 1, the average gray scale is mu 1, the total average gray scale of the image is mu, and the inter-class variance is g. The image size is M × N, the number of pixels in the image having a grayscale value smaller than the threshold T is denoted as N0, and the number of pixels having a grayscale value larger than the threshold T is denoted as N1. Then there are:

N0+N1=M×N

ω0+ω1=1

μ=ω0×μ0+ω1×μ1

g=ω0×(μ0-μ)2+ω1×(μ1-μ)2

thus, the between-class variance is:

g=ω0×ω1(μ0-μ1)2

and obtaining a threshold value T which enables the inter-class variance g to be maximum by adopting a traversal method, setting the pixel point with the pixel value smaller than T in the image as 0 and the pixel point with the pixel value larger than T as 1 according to the threshold value T, and finishing binarization processing.

In the specific implementation process, the Otsu binarization can convert the gray level image into a binary image, which is convenient for subsequent processing of the image, so that a threshold value T which enables the inter-class variance g to be maximum is obtained by adopting a traversal method, a pixel point of which the pixel value is smaller than T in the image is set to be 0 according to the threshold value T, and a pixel point of which the pixel value is larger than T is set to be 1, thereby completing binarization processing.

In S14, the small-area region removal processing specifically includes: and (4) removing the small-area interference region by using a labeling algorithm, and reserving the bottle blank region.

In the specific implementation process, the labeling algorithm comprises the following specific steps: the unconnected areas are distinguished according to the connected domains of the image and marked with signs, the area of each connected domain is calculated and sorted from large to small, the largest connected domain is reserved, and the connected domains with other small areas are deleted, so that the bottle blank object can be reserved, as shown in fig. 12.

The step S1 further includes a step S15: and performing inclination correction on the image after the small-area removal is completed.

In the specific implementation process, the bottle blank needs to be subjected to inclination correction before the bottle blank size parameter detection, because the bottle blank is inclined in the placing process.

In the above-described configuration, as shown in fig. 9, point 5 in fig. 9 is taken as a reference coordinate for tilt correction, and the coordinate of point 5 on the left side is expressed as (x)1,y1) And the coordinate of the right point 5 is (x)2,y2). As shown in FIG. 13, assume y1<y2Taking the vertical center line of the image as an axis, obtaining (x)1,y1) Point of symmetry (x)1′,y1') have:

a=x1′-x1

b=y2-y1

where θ is the angle of inclination and a is (x)1,y1) And (x'1,y1') a horizontal distance, b is (x)2,y2) And (x'1,y1') vertical distance. And (4) performing inclination correction on the bottle blank object according to the calculated inclination angle.

The specific steps of S3 are as follows: counting the number of black pixels in each row based on the left region image; calculating a plurality of peak positions according to the number of black pixels in each row, and drawing a peak image, wherein the four positions with the maximum peak value are positions of a support ring, a lock ring and threads of the image in the left area of the bottle blank; and performing the same operation on the right area image to obtain the positions of the support ring, the lock ring and the threads of the right area image of the bottle blank.

In the specific implementation process, based on the left region image, the black pixels are the bottle blank region, and the white pixels are the background, because the number of the black pixels at the vertex positions of the support ring, the lock ring and the threads is the maximum; then, the maximum four peak values and the corresponding positions thereof are obtained according to the distribution of the number of the black pixels, and a peak image is drawn. And then, executing the same operation on the right area image to obtain the positions of the support ring, the lock ring and the threads of the right area image of the bottle blank.

In the above solution, based on the left region image, as shown in fig. 8(a) as an example, the number of black pixels in each line is counted, the statistical result is shown in fig. 3, the abscissa corresponds to the height of each position in units of pixels, and in fig. 3, four positions with the largest calculated peak value are calculated; based on the right area image, as shown in fig. 8(b) for example, the number of black pixels per line is counted, and as a result of the counting, the height of each position on the abscissa is calculated in units of pixels as shown in fig. 5, and four positions having the largest peak values are calculated in fig. 5.

The specific steps of S4 are as follows: calculating a first derivative of the left region image, corresponding to a peak image of the left region image, and taking the first two maximum value points of the first derivative image as the upper edge of the peak of the left region image; finding a first derivative minimum value point from the right side to the left side of the first derivative graph, wherein the position, close to 0, of the first derivative on the left side of the point is the bottleneck position of the left area image; and performing the same operation on the right area image to obtain the position of the upper edge of the wave crest and the position of the bottle opening of the right area image of the bottle blank.

In the specific implementation process, the left region image is observed to find that the number of black pixels of the image gradually increases from bottom to top, so that a first derivative of the black pixels of the left region image is calculated, as shown in fig. 4, the first two peaks are found from the left to the right of the first derivative graph, and the place with the maximum black pixel change rate is used as the upper edge of the peak; and (3) under the condition that the number of black pixels is gradually reduced near the bottle opening position, finding the first derivative minimum value from the right side to the left side of the first derivative graph, and searching the position, which is the bottle opening position, of the first derivative close to 0 from the top of the image by taking the point as a starting point. And then, the same operation is carried out on the right area image, and as shown in fig. 6, the position of the upper edge of the wave crest and the position of the bottle mouth of the right area image of the bottle blank are obtained.

The specific steps of S5 are as follows: subtracting the corresponding peak positions of the left area image and the right area image and taking an absolute value to obtain the results of the outer diameter of the support ring, the outer diameter of the locking ring and the outer diameter of the thread of the bottle blank; calculating the distance between the bottle opening positions respectively calculated by the left area image and the right area image to obtain the outer diameter of the bottle opening of the bottle blank; and obtaining the bottle opening height and the locking ring height of the bottle blank according to the position of the upper edge of the wave crest of the right area image, the position of the bottle opening and the position of the locking ring.

In the specific implementation process, four maximum wave peak positions of the left and right area images are found from the top to the bottom of the image respectively, and the distance between the first wave peak positions corresponding to the left and right area images is the outer diameter of the support ring; the distance between the second peak positions corresponding to the left and right side area images is the outer diameter of the locking ring; the horizontal distance between the fourth peak position of the left area image and the third peak position of the right area image is the external diameter of the thread; according to the first derivative diagram in the step S4, finding the first derivative minimum point from the right side to the left side of the image, and searching for a position where the first derivative is close to 0 from the top of the image with the point as a starting point, where the position is a bottle mouth position, and the distance between the bottle mouth positions of the left and right side area images is the outer diameter of the bottle mouth of the bottle blank; finding the position of the upper edge of the first peak from the left to the right of the first derivative diagram, then finding the point of which the first derivative on the left of the position is 0, wherein the distance between the point and the minimum value point of the first derivative is recorded as h1, the vertical distance between the position of the bottle mouth and the position of the support ring is recorded as h2, and the average value of h1 and h2 is recorded as the height h12 of the bottle mouth; the distance between the minimum point of the first derivative and the upper edge position of the second peak is recorded as h3, the vertical distance between the bottle opening position and the locking ring position is recorded as h4, the average value of h3 and h4 is recorded as the locking ring height h34, the bottle opening height and the locking ring height of the right bottle blank region can be obtained in the same way, and then the average value of the corresponding heights of the images of the left and right regions is obtained, namely the bottle opening height and the locking ring height of the bottle blank; if the bottle blank is subjected to the inclination correction processing, the bottle opening height and the locking ring height of the left area image or the right area image can be directly taken as the bottle opening height and the locking ring height of the bottle blank.

In the above scheme, the position of the support ring, the position of the lock ring, the position of the thread, and the position of the bottle opening, which are calculated according to the left area image and the right area image, are subtracted from each other between the positions of the key points of the corresponding dimension parameter, as shown in fig. 9, so as to obtain the distance of the dimension parameter. The support ring external diameter is the distance of point 1, and the lock ring external diameter is the distance of point 2, and the external diameter of screw thread is the horizontal distance of left side point 4 and right side point 3, and the bottleneck external diameter is the distance between point 6, and the bottleneck height is the average value of the vertical distance of right side point 5 and 9 and the vertical distance of right side point 6 and 7, and the lock ring height is the average value of the vertical distance of right side point 5 and 8 and the vertical distance of right side point 6 and 2.

In the scheme, the whole method comprises the following steps:

as shown in fig. 10, the bottle embryo is imaged by an industrial camera, the image of the bottle embryo is subjected to gray scale conversion, image clipping, salivation binarization, small area removal, tilt correction, then the image of the bottle embryo is divided into left and right sides, the size parameter coordinates of the left area image and the right area image are calculated respectively, then the calculation of the size parameter of the bottle embryo is performed based on the parameter position coordinates of the left and right sides, and the value of each parameter is output. The detection precision of the invention on the bottle blank size parameter is less than or equal to 0.02mm, the invention accords with the standard specification of the packaging industry, and the detection success rate is not less than 95%.

The terms describing positional relationships in the drawings are for illustrative purposes only and are not to be construed as limiting the patent; it should be understood that the above-described embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the claims of the present invention.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种用于视觉定位的双臂移载机构

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!