Object size rapid measurement method based on raspberry pie

文档序号:1648305 发布日期:2019-12-24 浏览:9次 中文

阅读说明:本技术 一种基于树莓派的物体尺寸快速测量方法 (Object size rapid measurement method based on raspberry pie ) 是由 段晓杰 李鹏辉 汪剑鸣 刘广丽 李秀艳 于 2019-09-18 设计创作,主要内容包括:本发明公开了一种基于树莓派的物体尺寸快速测量方法,该方法可以在面阵相机标定完成后,直接通过面阵相机采集待测量物体的二维图像,从而实现对其关键尺寸参数信息的快速获取,本发明属于光学测量领域,可应用于对任意物体尺寸的快速测量;其原理为利用树莓派作为图像处理核心单元,能够在已知图像中参照物体尺寸信息的条件下,自动快速识别出图像中所有待测量物体,并完成对该物体关键二维尺寸参数的计算,本发明具有速度快、实用性强、便携性好等优点,测量精度满足工业生产的需要。(The invention discloses a method for quickly measuring the size of an object based on a raspberry pie, which can be used for directly acquiring a two-dimensional image of an object to be measured through an area-array camera after the area-array camera is calibrated, so as to quickly acquire key size parameter information of the object; the method has the advantages of high speed, strong practicability, good portability and the like, and the measurement precision meets the requirements of industrial production.)

1. A method for quickly measuring the size of an object based on a raspberry pie mainly comprises the following steps:

(1) collecting and preprocessing an image of an object to be measured;

(2) extracting contour information of all objects in the image;

(3) selecting and determining a reference object through preset index information;

(4) marking all objects to be measured in the image in a scanning mode;

(5) respectively determining the frame and the vertex of the object to be measured, and calculating the central point and the connecting line of each frame;

(6) calculating Euclidean distances between corresponding central points, and marking the actual size information of the object to be measured;

in the step 1, through an area-array camera module arranged on a raspberry group platform, color images of an object to be measured and a reference object are collected and transmitted to a raspberry group processor chip, and edge gaps of all objects in the image are filled through a morphological method, so that the image is preprocessed;

in step 2, after extracting the edge information of the object to be measured and the reference object, marking the external contours of all objects in the collected color image by a contour retrieval method;

in step 3, the positions and the contour sizes of all objects in the image are counted to determine a reference object, and the measurement proportion value determined by the actual size of the reference object is pixel _ per _ metric which is pixel _ width/width, wherein pixel _ width represents the number of unit pixels and takes the pixels as units; the width is the real length of the reference object and the unit is millimeter;

step 4, after the position information of the reference object is determined, carrying out serial number annotation on the object to be measured after the contour is extracted one by one from left to right in a scanning mode;

in step 5, extracting a rotation boundary of the object to be measured according to the contour line region information, drawing an outer frame of the object to be measured, returning coordinates of a frame vertex, defining a central point calculation function midpoint, simultaneously extracting coordinates of four vertices of the boundary, wherein the vertex position of the elliptic boundary is positioned by an averaging method, and calculating two adjacent vertices (x)1,y1),(x2,y2) The calculation method comprises the following steps: midpoint (x, y) ═ x1+x2)/2,(y1+y2) /2), marking the connecting line with the corresponding center line point;

in step 6, Euclidean formula is used to calculate Euclidean distance between central points corresponding to the objects to be measured, and the key dimension information of the objects to be measured can be expressed asWherein (x)z1,yz1),(xz2,yz2) Is a coordinate value corresponding to the center point.

Technical Field

The invention discloses a raspberry pie-based object dimension rapid measurement method, which can be used for collecting a two-dimensional image of an object to be measured directly through an area-array camera after the area-array camera is calibrated, so as to rapidly acquire key dimension parameter information of the object.

Background

The traditional object size measurement means mainly comprises manual and professional instrument modes; the manual mode is mainly based on measurement of a gauge, a graduated scale and the like, and the method is simple, convenient and quick, but the precision is not high; although professional instruments such as a contourgraph and an X-ray measuring instrument have high precision, the special instruments have higher requirements on the measuring environment and have certain limitations in the field of modern industrial production; with the continuous development and updating of optical technology, signal processing and computer technology, people can acquire image information of an object in the external environment through an optical imaging method, convert the image information into a digital signal which can be processed and recognized by a machine, and finally realize the function of simulating human visual information perception by using a computer or a robot, so that the machine vision technology is formed, and a new direction is provided for the rapid measurement of the object; the general measuring system based on machine vision extracts key information through an image processing algorithm by collecting an image of an object to be measured and inputting the image into a computer, and finally obtains dimension information of the object to be measured by utilizing a camera calibration parameter; meanwhile, because a computer is used as an image processing unit, the portability needs to be improved.

The raspberry type image processing system has the advantages of high speed, strong practicability and good portability because the software algorithm is deeply optimized, and the measurement precision basically meets the requirements of industrial production.

Disclosure of Invention

The invention aims to overcome the defects of the existing method and provides a raspberry group-based object size rapid measurement method, which can realize rapid measurement of two-dimensional size information of an object to be measured by setting a reference object only after a camera is calibrated.

A method for quickly measuring the size of an object based on a raspberry pie mainly comprises the following steps:

(1) collecting and preprocessing an image of an object to be measured;

(2) extracting contour information of all objects in the image;

(3) selecting and determining a reference object through preset index information;

(4) marking all objects to be measured in the image in a scanning mode;

(5) respectively determining the frame and the vertex of the object to be measured, and calculating the central point and the connecting line of each frame;

(6) calculating Euclidean distances between corresponding central points, and marking the actual size information of the object to be measured;

in the step 1, through an area-array camera module arranged on a raspberry group platform, color images of an object to be measured and a reference object are collected and transmitted to a raspberry group processor chip, and edge gaps of all objects in the image are filled through a morphological method, so that the image is preprocessed;

in step 2, after extracting the edge information of the object to be measured and the reference object, marking the external contours of all objects in the collected color image by a contour retrieval method;

in step 3, the positions and the contour sizes of all objects in the image are counted to determine a reference object, and the measurement proportion value determined by the actual size of the reference object is pixel _ per _ metric which is pixel _ width/width, wherein pixel _ width represents the number of unit pixels and takes the pixels as units; the width is the real length of the reference object and the unit is millimeter;

step 4, after the position information of the reference object is determined, carrying out serial number annotation on the object to be measured after the contour is extracted one by one from left to right in a scanning mode;

in step 5, extracting a rotation boundary of the object to be measured according to the contour line region information, drawing an outer frame of the object to be measured, returning coordinates of a frame vertex, defining a central point calculation function midpoint, and simultaneously extracting coordinates of four vertices of the boundary, wherein the coordinates of the four vertices of the boundary are extractedThe positions of the vertexes of the elliptic boundaries are positioned by an averaging method, and two adjacent vertexes (x) are calculated1,y1),(x2,y2) The calculation method comprises the following steps: midpoint (x, y) ═ x1+x2)/2,(y1+y2) /2), marking the connecting line with the corresponding center line point;

in step 6, Euclidean formula is used to calculate Euclidean distance between central points corresponding to the objects to be measured, and the key dimension information of the objects to be measured can be expressed asWherein (x)z1,yz1),(xz2,yz2) Is a coordinate value corresponding to the center point.

Compared with the prior art, the invention has the following advantages:

1. the method has good portability, and can conveniently measure under any environment because the camera and the digital image processing unit are integrated, the method has the advantages of small volume, light weight and the like, and the method can be directly supplied by a mobile power supply,

2. the method has the advantages that the measurement speed is high, the object is quickly measured in an image acquisition mode, the object in the acquisition process can be in a motion state, and meanwhile, the parameter calibration process of a measurement system in a common method is omitted, so that the method can be applied to the fields of industrial flow line production, medical measurement research and the like.

Drawings

FIG. 1 is a flow chart of a method of the present invention;

FIG. 2 is an initial image collected by the area-array camera, wherein the left card is a reference object, and the middle oval coin and the right rectangular iron box are objects to be measured;

FIG. 3 is the result of the pre-processing of the image of FIG. 2, wherein (a) is the image after the graying process; (b) is a Gaussian filtered image; (c) the image is an image after edge detection; (d) is a morphologically processed image;

FIG. 4 is a diagram of an image after extracting all the object contours in FIG. 2, where the red border is the object contour;

FIG. 5 is the image determined by referring to the size parameter information of the object, i.e. the length and width size information of the left blue card;

fig. 6 is a frame of the object to be measured in fig. 2 and a center point labeling result image thereof, and (a) is an elliptical coin labeling result image; (b) labeling a result image for the rectangular iron box on the right side;

FIG. 7 is a result image of the calculation of the dimension information of all the objects to be measured in FIG. 2, and (a) is a result image of the calculation of the middle oval coin; (b) the resulting image is calculated for the right rectangular iron box.

Detailed Description

The flow chart of the invention is shown in figure 1, the method comprises the steps that firstly, a raspberry group reads color images of an object to be measured and a reference object, which are acquired by an area-array camera, the size information of the reference object is set through programming, then image preprocessing is carried out through closed operation in Gaussian filtering, edge detection and morphological processing, and finally contour information of all objects in an image is extracted; the reference object is determined through the pre-input index information, all objects to be measured in the image are classified and labeled in a scanning mode, then the boundary frames and the vertexes of the objects to be measured are respectively determined, the positions of the middle points of all the boundary frames of the objects to be measured are calculated, corresponding connecting lines are carried out, and the Euclidean distances corresponding to the middle points are calculated, so that the actual size information of the objects to be measured can be labeled. The following describes a specific implementation process of the technical scheme of the invention with reference to the accompanying drawings:

1. collecting and preprocessing an image of an object to be measured;

a camera-specific csi (cmos Sensor interface) interface is disposed on the raspberry pi platform, and a color image corresponding to the object to be measured and the reference object is collected right above the object to be measured and the reference object by connecting an area array module with a resolution of 1920 × 1200 and 700 ten thousand pixels and transmitted to a raspberry pi processor chip, as shown in fig. 2; because the image preprocessing mainly operates on gray pixels, the acquired image is converted into a gray image by a weighted average method, the principle of the weighted average method is to weight and average the values of the red, green and blue components according to a certain weight value, and finally a gray image is obtained, and the result is shown in fig. 3 (a); considering that image quality degradation is easily caused by environmental interference in the camera acquisition process, in order to better retain the detail characteristics of an image, the method adopts a Gaussian filter algorithm to process the acquired image, the algorithm is a process of carrying out weighted average on the whole image, a Gaussian template traverses each pixel point in the image by using a normalized Gaussian template, the central value of the template is replaced by the gray value of the weighted average to obtain a smoothed image, and the processing result is shown in fig. 3 (b); because the outlines of the object to be measured and the reference object are the outer edge parts of the object to be measured and the reference object, the object to be measured and the reference object are separated from the background image at the same time, the edge characteristics of the object in the image are extracted through an edge detection algorithm, a foundation is laid for the subsequent outline information extraction, and the extraction result is shown in fig. 3 (c); finally, the object edge null attack is eliminated through a mathematical morphology algorithm to improve the accuracy of contour extraction, and the result is shown in fig. 3 (d).

2. Extracting contour information of all objects in the image;

after the edge information of the object to be measured and the reference object is extracted, the outline of all objects in the image is extracted by a contour retrieval method, contour labeling is carried out in a color image initially acquired by an area-array camera, and the labeling result is shown in fig. 4, namely a red block diagram part.

3. Selecting and determining a reference object through preset index information;

setting the leftmost object as a reference object, and determining the first detected object as the reference object from left to right by detecting the outline arrangement of the objects; the measurement method needs to measure by referring to the position and size information of the object, for example: selecting a bus card as a reference object, and obtaining the card with the length of 85.6 mm and the width of 54.0 mm by pre-measurement, as shown in fig. 5; and (3) placing the card at the leftmost side of the image, further extracting information by sequencing the sizes of the position outlines of the objects in the image, and determining a reference object. The measured scale value determined with reference to the actual size of the object is pixel _ per _ metric.

pixel_per_metric=pixel_width/width (1)

Wherein, pixel _ width is used for expressing the number of unit pixels, and the pixel px is taken as a unit; the actual length of the object is referenced in width, in millimeters.

4. Marking all objects to be measured in the image in a scanning mode;

after the position of the reference object is determined, serial numbers are marked on the object with the extracted outline item by item from left to right in a scanning mode, so that size extraction can be performed on a single object conveniently in the subsequent processing process. The serial numbers correspond to the contours of the objects to be measured, and the smaller contour line areas are ignored, so that the contours of all the objects are labeled.

5. Respectively determining the frame and the vertex of the object to be measured, and calculating the central point and the connecting line of each frame;

if the contour region is large enough, the rotation boundary of the object is extracted, the frame of the object is drawn, and the coordinates of the vertex of the frame are returned. Defining a central point calculation function midpoint, taking out coordinates of four vertexes of the boundary, positioning the vertex position of the elliptic boundary by an averaging method, and calculating two adjacent vertexes (x)1,y1),(x2,y2) The center point coordinate is calculated as follows:

midpoint(x,y)=((x1+x2)/2,(y1+y2)/2) (2)

and marking the center points and connecting the corresponding center line points, as shown in FIG. 6, wherein FIG. 6(a) is a graph of the calculation result of the border and the center point of the oval coin to be measured, and FIG. 6(b) is a graph of the calculation result of the border and the center point of the rectangular iron box to be measured

6. Calculating Euclidean distances between corresponding middle points, and marking out actual size information of the object to be detected;

and finally, calculating the Euclidean distance between the corresponding central points by using an Euclidean formula to obtain the size rho of the object, namely:

wherein (x)z1,yz1),(xz2,yz2) Are coordinate values corresponding to the two center points. The calculation labeling result is shown in fig. 7, in which (a) is the information of the major axis and minor axis dimensions of the middle oval coin; (b) the length and width dimension information of the right rectangular iron box.

7. Summary of the invention

The invention provides a method for quickly measuring the size of an object based on a raspberry pie, which fully utilizes the digital image processing capacity of the raspberry pie, utilizes an area-array camera module installed on the raspberry pie to acquire an object to be measured and a reference object image, automatically and intelligently identifies the object to be measured in the image through preset size information of the reference object, and gives accurate size information of the object to be measured, improves the requirement that a traditional high-precision size measuring system based on machine vision still needs to calibrate the measuring system, and has better portability, so the system has wide application prospect in the field of industrial production.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种有倒角零件的视觉测量方法和装置

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!