A kind of auto-focusing algorithm that grating project height is rebuild

文档序号:1769765 发布日期:2019-12-03 浏览:35次 中文

阅读说明:本技术 一种光栅投影法高度重建的自动对焦算法 (A kind of auto-focusing algorithm that grating project height is rebuild ) 是由 张子倩 刘刚 于 2019-08-26 设计创作,主要内容包括:本发明公开了一种光栅投影法高度重建的自动对焦算法,其算法包括以下步骤:A、利用Sobel算子计算出图片的X方向和Y方向的梯度G<Sub>X</Sub>,G<Sub>Y</Sub>;B、利用步骤A的结果计算两个方向梯度的平方G<Sub>X</Sub><Sup>2</Sup>,G<Sub>Y</Sub><Sup>2</Sup>;C、利用步骤B的结果计算得到<Image he="89" wi="305" file="DDA0002179792480000011.GIF" imgContent="drawing" imgFormat="GIF" orientation="portrait" inline="no"></Image>的结果;D、将步骤C的结果在每个像素上进行叠加。本发明在被测物表面打光栅条纹,将光栅与物体表面自身的纹理相结合共同计算清晰度,提高了清晰度的准确性,增加了图像细节信息,便于自动调整相机与被测物之间的最佳距离,同时,在不同的高度位置对被测物表面打光栅,并由相机采集图像,最后对采集到的图像进行清晰度计算,对不同位置的清晰度进行对比,分数最高的即是对焦最佳位置。(The invention discloses the auto-focusing algorithm that a kind of grating project height is rebuild, algorithm is the following steps are included: A, calculate the X-direction of picture and the gradient G of Y-direction using Sobel operator X , G Y ;B, square G of both direction gradient is calculated using the result of step A X 2 , G Y 2 ;C, it is calculated using the result of step B Result;D, the result of step C is overlapped on each pixel.The present invention beats grating fringe on measured object surface, grating is combined to common calculating clarity with the texture of body surface itself, the accuracy for improving clarity, increases image detail information, convenient for the optimum distance between adjust automatically camera and measured object, simultaneously, position acquires image to measured object surface polishing grid, and by camera at various height, finally carries out sharpness computation to acquired image, the clarity of different location is compared, highest score is focusing optimum position.)

1. the auto-focusing algorithm that a kind of grating project height is rebuild, it is characterised in that: its algorithm the following steps are included:

A, the X-direction of picture and the gradient G of Y-direction are calculated using Sobel operatorX, GY

B, square G of both direction gradient is calculated using the result of step AX 2, GY 2

C, it is calculated using the result of step BResult;

D, the result of step C is overlapped on each pixel;

E, Z axis is preferably minimized limit, and triggers projector and beats striped and bat figure;

F, CalcClarity is called using picture and ROI as parameter, and records the return value Clarity of CalcClarity;

G, judge whether Z axis is located at minimum limit or whether current Clarity is greater than previous Clarity;

If H, Z axis is located at minimum limit or current Clarity is greater than previous Clarity, Z axis moves upwards 1mm simultaneously Repeat E;

If I, Z axis is not located at minimum limit or current Clarity is less than previous Clarity, with previous Z axis light Grid ruler position is best focusing position, and superimposed result of focusing is the clarity of the picture.

2. the auto-focusing algorithm that a kind of grating project height according to claim 1 is rebuild, it is characterised in that: described When measured object is ceramic gauge block, Z axis grating scale acquires a width figure between -35mm to -42mm, and every 1mm.

3. the auto-focusing algorithm that a kind of grating project height according to claim 1 is rebuild, it is characterised in that: described Picture is stored in central processing unit after projector bat figure, and the output end of central processing unit also with the input of PLC controller End is electrically connected, meanwhile, PLC controller is bi-directionally connected with 4G communication module, and 4G communication module includes 4G gateway and long-range shifting Dynamic terminal, remote mobile terminal are the smart phone for accessing 4G network.

Technical field

The present invention relates to three-dimensional reconstruction and height measurement technique field, specially a kind of grating project height rebuild from Dynamic focus algorithm.

Background technique

Grating project is a kind of reflective measurement structure light method, for establishing three-D profile pattern, grating project Basic principle are as follows: grating (fringe light) is projected into reference planes and measured object surface, what it is due to reference planes selection is horizontal Plane, the reference grating projected to above will not deform, and when optical grating projection is to measured object surface, grating can generate difference The deformation of degree, since projection grating receives the modulation of testee apparent height, the testee height placed is different, The phase change degree of grating is also different therewith, and two-dimensional surface deforming stripe carries the three-dimensional of body surface in phase change Topographical information, therefore, by seeking the changing value of phase, available object respective point height, to obtain three-dimensional article The chamfered shape of body, the precision that raster method rebuilds object height depends on the quality for the raster image that camera takes, then phase Machine needs to adjust the distance between measured object, so that the distance between object and camera are equal to focal length, the object taken in this way Body and grating are extractions clearest, most beneficial for elevation information, but to be likely to be a surface very smooth for measured object Plane, texture it is less, by judging whether the object that camera takes clearly relatively difficult to adjust optimum height, for this purpose, It is proposed that the auto-focusing algorithm that a kind of grating project height is rebuild.

Summary of the invention

The purpose of the present invention is to provide the auto-focusing algorithms that a kind of grating project height is rebuild, to solve above-mentioned back The problem of being proposed in scape technology.

To achieve the above object, the invention provides the following technical scheme: a kind of grating project height rebuild it is automatic right Burnt algorithm, algorithm the following steps are included:

A, the X-direction of picture and the gradient G of Y-direction are calculated using Sobel operatorX, GY

B, square G of both direction gradient is calculated using the result of step AX 2, GY 2

C, it is calculated using the result of step BResult;

D, the result of step C is overlapped on each pixel;

E, Z axis is preferably minimized limit, and triggers projector and beats striped and bat figure;

F, CalcClarity is called using picture and ROI as parameter, and records the return value of CalcClarity Clarity;

G, judge whether Z axis is located at minimum limit or whether current Clarity is greater than previous Clarity;

If H, Z axis is located at minimum limit or current Clarity is greater than previous Clarity, Z axis is moved upwards 1mm simultaneously repeats E;

If I, Z axis is not located at minimum limit or current Clarity is less than previous Clarity, with previous Z Axis grating scale position is best focusing position, and superimposed result of focusing is the clarity of the picture.

Preferably, described when measured object is ceramic gauge block, Z axis grating scale arrives between -42mm in -35mm, and every 1mm Acquire a width figure.

Preferably, picture is stored in central processing unit after the projector bat figure, and the output end of central processing unit Also it is electrically connected with the input terminal of PLC controller, meanwhile, PLC controller is bi-directionally connected with 4G communication module, and 4G communication module Including 4G gateway and remote mobile terminal, remote mobile terminal is the smart phone for accessing 4G network.

Compared with prior art, beneficial effects of the present invention are as follows:

The present invention beats grating fringe on measured object surface, and grating is combined common calculating with the texture of body surface itself Clarity improves the accuracy of clarity, increases image detail information, convenient between adjust automatically camera and measured object Optimum distance, meanwhile, position acquires image to measured object surface polishing grid, and by camera at various height, finally to acquisition The image arrived carries out sharpness computation, compares to the clarity of different location, and highest score is focusing optimum position.

Specific embodiment

Below in conjunction with the embodiment of the present invention, technical solution in the embodiment of the present invention is clearly and completely retouched It states, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Based on the present invention In embodiment, every other implementation obtained by those of ordinary skill in the art without making creative efforts Example, shall fall within the protection scope of the present invention.

The auto-focusing algorithm that a kind of grating project height is rebuild, algorithm the following steps are included:

A, the X-direction of picture and the gradient G of Y-direction are calculated using Sobel operatorX, GY

B, square G of both direction gradient is calculated using the result of step AX 2, GY 2

C, it is calculated using the result of step BResult;

D, the result of step C is overlapped on each pixel;

E, Z axis is preferably minimized limit, and triggers projector and beats striped and bat figure;

F, CalcClarity is called using picture and ROI as parameter, and records the return value of CalcClarity Clarity;

G, judge whether Z axis is located at minimum limit or whether current Clarity is greater than previous Clarity;

If H, Z axis is located at minimum limit or current Clarity is greater than previous Clarity, Z axis is moved upwards 1mm simultaneously repeats E;

If I, Z axis is not located at minimum limit or current Clarity is less than previous Clarity, with previous Z Axis grating scale position is best focusing position, and superimposed result of focusing is the clarity of the picture.

Grating fringe is beaten on measured object surface, grating is combined to common calculate clearly with the texture of body surface itself Degree, improves the accuracy of clarity, increases image detail information, convenient for best between adjust automatically camera and measured object Distance, meanwhile, position acquires image to measured object surface polishing grid, and by camera at various height, finally to collected Image carries out sharpness computation, compares to the clarity of different location, and highest score is focusing optimum position.

When measured object is ceramic gauge block, Z axis grating scale acquires a width figure between -35mm to -42mm, and every 1mm.

Picture is stored in central processing unit after projector bat figure, and the output end of central processing unit is also controlled with PLC The input terminal of device is electrically connected, meanwhile, PLC controller is bi-directionally connected with 4G communication module, and 4G communication module includes 4G gateway And remote mobile terminal, remote mobile terminal are the smart phone for accessing 4G network.

In use, beating grating fringe on measured object surface, grating is combined into common meter with the texture of body surface itself Clarity is calculated, the accuracy of clarity is improved, increases image detail information, convenient between adjust automatically camera and measured object Optimum distance, meanwhile, position acquires image to measured object surface polishing grid, and by camera at various height, finally to adopting The image collected carries out sharpness computation, compares to the clarity of different location, highest score is focusing optimum bit It sets.

It although an embodiment of the present invention has been shown and described, for the ordinary skill in the art, can be with A variety of variations, modification, replacement can be carried out to these embodiments without departing from the principles and spirit of the present invention by understanding And modification, the scope of the present invention is defined by the appended.

5页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于无线同步的扫描系统及扫描方法

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!