CN102116607B - Method and device for measuring axial displacement characterized by one-dimensional (1D) contrast ratio - Google Patents

Method and device for measuring axial displacement characterized by one-dimensional (1D) contrast ratio Download PDF

Info

Publication number
CN102116607B
CN102116607B CN 200910251092 CN200910251092A CN102116607B CN 102116607 B CN102116607 B CN 102116607B CN 200910251092 CN200910251092 CN 200910251092 CN 200910251092 A CN200910251092 A CN 200910251092A CN 102116607 B CN102116607 B CN 102116607B
Authority
CN
China
Prior art keywords
forw
pixel
measurement
observation window
max
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.)
Expired - Fee Related
Application number
CN 200910251092
Other languages
Chinese (zh)
Other versions
CN102116607A (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.)
Chongqing Technology and Business University
Original Assignee
Chongqing Technology and Business 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 Chongqing Technology and Business University filed Critical Chongqing Technology and Business University
Priority to CN 200910251092 priority Critical patent/CN102116607B/en
Publication of CN102116607A publication Critical patent/CN102116607A/en
Application granted granted Critical
Publication of CN102116607B publication Critical patent/CN102116607B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Length Measuring Devices By Optical Means (AREA)

Abstract

以一维对比度为特征测量轴向位移的方法及装置,由一台普通的计算机通过其USB接口连接一个计算机摄像头、一台步进电机及其接口电路以及摄像头轴向位移装置组成,摄像头被安装在轴向位移装置上,由步进电机所驱动,步进电机通过步进电机接口电路连接到计算机的RS232C接口,该计算机配置有摄像头拍摄以及根据一维对比度测量轴向位移程序。本发明专利以一维对比度作为被测物体图像帧的特征,通过计算像素亮度的自关联匹配系数,自动分析并选取最佳观察区域;通过计数该观察窗区域内图像特征的数目,判断物体成像聚焦的程度,进而测量物体在摄像头光学轴方向所发生的微小位移;本测量方法新颖,能够适应某种程度的环境光照变化。

Figure 200910251092

A method and device for measuring axial displacement characterized by one-dimensional contrast is composed of an ordinary computer connected to a computer camera, a stepping motor and its interface circuit, and a camera axial displacement device through its USB interface, and the camera is installed On the axial displacement device, it is driven by a stepping motor, and the stepping motor is connected to the RS232C interface of the computer through the stepping motor interface circuit. The computer is equipped with a camera to shoot and measure the axial displacement according to the one-dimensional contrast program. The patent of the present invention uses one-dimensional contrast as the feature of the image frame of the measured object, automatically analyzes and selects the best observation area by calculating the self-correlation matching coefficient of pixel brightness; and judges the imaging of the object by counting the number of image features in the observation window area The degree of focus, and then measure the tiny displacement of the object in the direction of the optical axis of the camera; this measurement method is novel and can adapt to a certain degree of environmental light changes.

Figure 200910251092

Description

以一维对比度为特征测量轴向位移的方法及装置Method and device for measuring axial displacement characterized by one-dimensional contrast

技术领域 technical field

本发明属于数字图像测量技术领域,特别是使用计算机摄像头测量物体沿其光学轴方向发生的微小位移的方法及其装置。The invention belongs to the technical field of digital image measurement, in particular to a method and a device for measuring the tiny displacement of an object along its optical axis using a computer camera.

背景技术 Background technique

最近提交的发明专利申请“以三基色对比度为特征测量沿光轴方向的位移的方法及装置”分析了检测沿系统的光轴方向发生的位移的技术,提出了一种新颖的检测轴向位移的方法及其装置,较充分地利用了摄像头拍摄的图像帧包含的信息,不过,其分析运算量较大,影响测量速度。The recently filed invention patent application "Method and device for measuring displacement along the optical axis direction based on the contrast ratio of three primary colors" analyzes the technology for detecting the displacement occurring along the optical axis direction of the system, and proposes a novel method for detecting axial displacement The method and the device thereof make full use of the information contained in the image frame captured by the camera, however, the analysis calculation amount is relatively large, which affects the measurement speed.

发明内容 Contents of the invention

本发明提供一种以一维对比度为特征测量轴向位移的方法及装置,它利用计算机摄像头,能够在照明状况发生一定的变化的环境中,测量物体沿摄像头的光轴方向所发生的微小位移矢量。The invention provides a method and device for measuring axial displacement characterized by one-dimensional contrast. It uses a computer camera to measure the tiny displacement of an object along the optical axis of the camera in an environment where the lighting conditions change to a certain extent. vector.

本发明解决其技术问题所采用的技术方案是:一台普通的计算机配置一个计算机摄像头,该摄像头被安装在一个由高精度微位移步进电机为核心组成的轴向位移装置上,该步进电机通过步进电机接口电路连接到所述计算机的RS232C接口,所述计算机配置有摄像头拍摄以及根据一维对比度测量轴向位移程序,该程序体现了以一维对比度为图像帧的特征测量轴向位移的方法,包括:The technical solution adopted by the present invention to solve its technical problems is: an ordinary computer is equipped with a computer camera, and the camera is installed on an axial displacement device composed of a high-precision micro-displacement stepping motor as the core. The motor is connected to the RS232C interface of the computer through a stepper motor interface circuit, and the computer is equipped with a program for shooting with a camera and measuring the axial displacement according to the one-dimensional contrast ratio, which reflects the characteristic measurement axial displacement with the one-dimensional contrast ratio as the image frame. Displacement methods, including:

步骤一、以位图(M×N,M,N∈正整数)的格式,拍摄一帧被测物体的图像,作为参考帧;以该帧像素阵列左上角的第一个像素的位置为原点,以向右的方向为x轴方向,垂直向下方向为y轴方向,所取坐标系的单位为一个像素的大小;在所述像素阵列的中央区域选取一个区域,大小为m0×n0,m0,n0∈正整数,称之为观察窗,它距离所述像素阵列的水平方向和垂直方向的边缘像素各有h和v个像素,即有:m0+2h=M,n0+2v=N,h,v∈正整数;Step 1. Take a frame of an image of the measured object in the format of a bitmap (M×N, M, N∈ positive integer) as a reference frame; take the position of the first pixel in the upper left corner of the pixel array of the frame as the origin , taking the rightward direction as the x-axis direction, and the vertical downward direction as the y-axis direction, the unit of the coordinate system is the size of one pixel; select an area in the central area of the pixel array, and the size is m 0 ×n 0 , m 0 , n 0 ∈ a positive integer, called the observation window, which is h and v pixels away from the edge pixels in the horizontal direction and vertical direction of the pixel array, that is: m 0 +2h=M, n 0 +2v=N, h, v∈ positive integer;

步骤二、对于上述参考帧之像素阵列,逐像素行、逐像素列导出沿X轴方向和Y轴方向的边方向数据,并以3bit的二进制数值001,010和100分别表示其中的正边、负边以及第三类边,如此构成了对应所述参考帧像素阵列的关于X轴方向和关于Y轴方向的两帧边方向数据{referencex(x,y)}和{referencey(x,y)},其中,下标x或y分别表示所沿的坐标轴的方向,符号“{ }”表示沿其中函数下标所标示的坐标轴方向观察窗内诸像素(x,y)处的边方向数据的一个集合,保存这些数据;Step 2. For the pixel array of the above reference frame, derive the side direction data along the X-axis direction and the Y-axis direction pixel by row and pixel by column, and use 3-bit binary values 001, 010 and 100 to represent the positive side, The negative edge and the third type edge constitute two frames of edge direction data {reference x (x, y)} and {reference y (x, x, y)}, wherein, the subscript x or y respectively represent the direction of the coordinate axis along, and the symbol "{ }" represents the pixels (x, y) in the observation window along the direction of the coordinate axis indicated by the function subscript A collection of edge direction data, save these data;

步骤三、对于上述两帧边方向数据,分别计算所述参考帧里观察窗内像素阵列的自关联匹配系数:Step 3. For the above two frames of edge direction data, calculate the self-correlation matching coefficient of the pixel array in the observation window in the reference frame:

autoauto __ correlatiocorrelation nno xx (( aa ,, bb )) == ΣΣ ythe y == vv ++ 11 vv ++ 11 ++ nno 00 ΣΣ xx == hh ++ 11 hh ++ 11 ++ mm 00 [[ referencereference xx (( xx ,, ythe y )) ·· referencereference xx (( xx ++ aa ,, ythe y ++ bb )) ]]

autoauto __ correlatiocorrelation nno ythe y (( aa ,, bb )) == ΣΣ ythe y == vv ++ 11 vv ++ 11 ++ nno 00 ΣΣ xx == hh ++ 11 hh ++ 11 ++ mm 00 [[ referencereference ythe y (( xx ,, ythe y )) ·· referencereference ythe y (( xx ++ aa ,, ythe y ++ bb )) ]]

式中,运算符号·表示二进制逻辑与运算,其运算结果或为逻辑0或为逻辑1,运算符号“[ ]”表示取其中的逻辑运算函数的值所对应的数值,或为数值0,或为数值1,参数变量a,b的组合决定了关联匹配算子阵列的规模,如果取3×3关联匹配算子阵列:a=-1,0,1,b=-1,0,1,因此,沿每个坐标轴方向各自会产生9个自关联系数auto_correlationx(a,b)和auto_correlationy(a,b);In the formula, the operation symbol · represents the binary logic AND operation, and the operation result is either logic 0 or logic 1, and the operation symbol "[ ]" represents the value corresponding to the value of the logic operation function, or the value 0, or The value is 1, and the combination of parameter variables a and b determines the scale of the associative matching operator array. If a 3×3 associative matching operator array is used: a=-1, 0, 1, b=-1, 0, 1, Therefore, 9 auto-correlation coefficients auto_correlation x (a, b) and auto_correlation y (a, b) will be generated along each axis direction;

步骤四、根据上述两帧边方向数据对应的自关联匹配系数,分别搜索在目前的物体表面状况以及照明状况下可以进行匹配比较的最佳观察窗像素阵列:Step 4. According to the self-association matching coefficients corresponding to the above two frames of edge direction data, search for the best observation window pixel array that can be matched and compared under the current object surface conditions and lighting conditions:

    mx=m0±step,nx=n0±step,2h=M-mx,2v=N-nx m x = m 0 ± step, n x = n 0 ± step, 2h = Mm x , 2v = Nn x

和  my=m0±step,ny=n0±step,2h=M-my,2v=N-nyand m y = m 0 ± step, n y = n 0 ± step, 2h = Mm y , 2v = Nn y ,

式中,下标x、y分别表示其值对应着沿X轴方向和Y轴方向,step为搜索过程中的步进参数,其前面的加减号由搜索方向决定;取此两组值中大者为本测量所用观察窗阵列的规模:m×n;In the formula, the subscripts x and y indicate that their values correspond to the directions along the X-axis and the Y-axis respectively, step is the step parameter in the search process, and the plus and minus signs in front of it are determined by the search direction; take the two sets of values The larger one is the size of the observation window array used for this measurement: m×n;

步骤五、对于上述参考帧之像素阵列,根据其像素亮度,逐行导出沿X轴方向1帧边方向数据;Step 5. For the pixel array of the above-mentioned reference frame, according to the brightness of the pixels, the data along the X-axis direction of one frame edge direction is derived row by row;

根据上述边方向数据,对于其中的观察窗区域,分别使用累加器计数它们所对应的正边和负边的数目:NX轴正和NX轴负,其中,N(umber)表示数目;累加上述累加器的计数结果并保存之,表示为:N(i,j=0,forw=0,back=0),其中,i=1,2,3......表示所拍摄的参考帧的顺序计数,也是测量的计数,j=0,1,2,3,......,表示第i次测量过程中拍摄的取样帧的计数,变量forw(=0,1,2,......)和back(=0,1,2,......)分别表示第i次测量中所述步进电机发生顺时钟旋转和反时钟旋转所对应的步进脉冲计数,本次测量开始前,有:i=1,j=0,forw=0,back=0;According to the above edge direction data, for the observation window area therein, use accumulators to count the numbers of their corresponding positive and negative sides: N X-axis positive and N X-axis negative , where N (umber) represents the number; accumulate The counting result of the above-mentioned accumulator and save it, expressed as: N(i, j=0, forw=0, back=0), wherein, i=1, 2, 3... represents the taken reference The sequence count of the frame is also the count of the measurement, j=0, 1, 2, 3, ..., represents the count of the sampling frame taken during the i-th measurement process, the variable forw(=0, 1, 2 ,...) and back(=0, 1, 2,...) represent the steps corresponding to the clockwise rotation and counterclockwise rotation of the stepping motor in the i-th measurement, respectively Pulse counting, before the start of this measurement, there are: i=1, j=0, forw=0, back=0;

步骤六、测量开始:所述计算机通过其RS232C接口的一根输出控制线FORWARD输出第forw=1个数字脉冲信号到所述步进电机接口电路,控制该步进电机顺时钟旋转一步,然后,拍摄第j=1帧取样帧位图;Step 6, measurement start: the computer outputs the first forw=1 digital pulse signal to the stepper motor interface circuit through an output control line FORWARD of its RS232C interface, and controls the stepper motor to rotate one step clockwise, and then, Take the sample frame bitmap of j=1 frame;

对于上述取样帧之像素阵列,根据其像素亮度,逐行导出它沿X轴方向的1帧边方向数据;For the pixel array of the above sampling frame, according to its pixel brightness, export its side direction data of one frame along the X-axis direction line by line;

根据上述边方向数据,对于其中的观察窗区域,分别使用累加器计数它们所对应的正边和负边的数目:NX轴正和NX轴负;累加上述累加器的计数结果并保存之,表示为:N(i,j=1,forw=1,back=0);According to the above side direction data, for the observation window area, use the accumulator to count the number of their corresponding positive side and negative side: N X-axis positive and N X-axis negative ; accumulate the counting results of the above accumulator and save it , expressed as: N(i, j=1, forw=1, back=0);

步骤七、如果:N(i,j=1,forw=1,back=0)≥N(i,j=0,forw=0,back=0),所述计算机通过其RS232C接口的一根输出控制线FORWARD输出第forw(=2,3,......)个数字脉冲信号到所述步进电机接口电路,控制该步进电机顺时钟旋转进步,每次顺时钟旋转一步都拍摄并分析比较前后各取样帧中观察窗内沿X轴方向所有的正边和负边的数目之和N(i,j=forw-1,forw-1,back=0)和N(i,j=forw,forw,back=0),保存之,该过程中应当会有:N(i,j=forw,forw,back=0)≥N(i,j=forw-1,forw-1,back=0),直到满足:N(i,j=forw,forw,back=0)<N(i,j=forw-1,forw-1,back=0),这时,记录(forw)MAX=forw,同时,所述计算机通过其RS232C接口的另一根输出控制线BACKWARD输出一个数字脉冲信号(back=1)到所述步进电机接口电路,控制该步进电机反时钟旋转一步,这时,相对本次测量开始前的初始位置,本装置的摄像头即处于本次测量中的最佳物体成像聚焦位置:FocusP=(forw)MAX-back=(forw)MAX-1,其计算的结果大于或等于0,表示所述步进电机的旋转方向是顺时钟方向的,该聚焦位置对应的取样帧观察窗内沿X轴方向所有的正边和负边的数目之和为:N(i,j=(forw)MAX-1,forw=(forw)MAX-1,back=0),测量过程中拍摄的取样帧的总计数结果为:j=(forw)MAX+back=(forw)MAX+1;Step 7, if: N (i, j=1, forw=1, back=0) ≥ N (i, j=0, forw=0, back=0), described computer is through one output of its RS232C interface The control line FORWARD outputs the forw (=2, 3, ...) digital pulse signal to the stepping motor interface circuit, controls the stepping motor to rotate clockwise and advances, and takes a picture every time clockwise rotates one step And analyze and compare the sum N (i, j=forw-1, forw-1, back=0) and N (i, j =forw, forw, back=0), save it, there should be in this process: N(i, j=forw, forw, back=0)≥N(i, j=forw-1, forw-1, back =0), until satisfying: N(i, j=forw, forw, back=0)<N(i, j=forw-1, forw-1, back=0), at this moment, record (forw) MAX = Forw, at the same time, the computer outputs a digital pulse signal (back=1) to the stepper motor interface circuit through another output control line BACKWARD of its RS232C interface to control the stepper motor to rotate one step counterclockwise, at this time , relative to the initial position before the start of this measurement, the camera of this device is in the best object imaging focus position in this measurement: FocusP=(forw) MAX -back=(forw) MAX -1, the calculated result is greater than Or equal to 0, indicating that the direction of rotation of the stepper motor is clockwise, and the sum of the numbers of all positive and negative sides along the X-axis direction in the observation window of the sampling frame corresponding to the focus position is: N(i, j=(forw) MAX -1, forw=(forw) MAX -1, back=0), the total counting result of the sample frames taken during the measurement is: j=(forw) MAX +back=(forw) MAX + 1;

如果:N(i,j=1,forw=1,back=0)<N(i,j=0,forw=0,back=0),所述计算机通过其RS232C接口的一根输出控制线BACKWARD输出第back=1个数字脉冲信号到所述步进电机接口电路,控制该步进电机反时钟旋转退一步,即回到本次测量的初始位置,然后,所述计算机通过其RS232C接口的输出控制线BACKWARD继续输出第back(=2,3,......)个数字脉冲信号到所述步进电机接口电路,控制该步进电机进一步反时钟旋转,在此过程中,每次反时钟旋转一步都拍摄并分析比较前后各取样帧观察窗内沿X轴方向所有的正边和负边的数目之和N(i,j=back+1,forw=1,back)和N(i,j=back,forw=1,back=back-1),应当有:N(i,j=back+1,forw=1,back=back)≥N(i,j=back,forw=1,back=back-1),保存之,如此继续,直到满足:N(i,j=back+1,forw=1,back)<N(i,j=back,forw=1,back-1),这时,记录:(back)MAX=back,同时,所述计算机通过其RS232C接口的另一根输出控制线FORWARD输出一个数字脉冲信号(forw=2)到所述步进电机接口电路,控制该步进电机顺时钟旋转一步,这时,相对本次测量开始前的初始位置,本装置的摄像头即处于本次测量中的最佳物体成像聚焦位置:FocusP=forw-(back)MAX=2-(back)MAX,其计算的结果为负值,表示所述步进电机的旋转方向是反时钟方向的,该聚焦位置对应的取样帧观察窗内沿X轴方向所有的正边和负边的数目之和为:N(i,j=((back)MAX-1)+1=(back)MAX,forw=1,back=(back)MAX-1),测量过程中拍摄的取样帧的总计数结果为:j=forw+(back)MAX=2+(back)MAXIf: N(i, j=1, forw=1, back=0)<N(i, j=0, forw=0, back=0), said computer is through an output control line BACKWARD of its RS232C interface Output the first back=1 digital pulse signal to the stepper motor interface circuit, control the stepper motor to take a step back in counterclockwise rotation, that is, return to the initial position of this measurement, and then, the computer outputs through its RS232C interface The control line BACKWARD continues to output the back (=2, 3, ...) digital pulse signal to the stepper motor interface circuit to control the stepper motor to further counter-clockwise rotation. In the process, each time One step of anti-clockwise rotation is all taken and analyzed and compared before and after each sampling frame observation window along the X-axis direction with the sum of the numbers N(i, j=back+1, forw=1, back) and N( i, j=back, forw=1, back=back-1), there should be: N(i, j=back+1, forw=1, back=back)≥N(i, j=back, forw=1 , back=back-1), save it, and continue like this until it is satisfied: N(i, j=back+1, forw=1, back)<N(i, j=back, forw=1, back-1) , at this moment, record: (back) MAX =back, simultaneously, described computer outputs a digital pulse signal (forw=2) to described stepping motor interface circuit by another root output control line FORWARD of its RS232C interface, controls The stepper motor rotates one step clockwise. At this time, relative to the initial position before the start of this measurement, the camera of this device is at the best object imaging focus position in this measurement: FocusP=forw-(back) MAX =2 -(back) MAX , the calculation result is a negative value, indicating that the rotation direction of the stepping motor is counterclockwise, and all positive and negative sides along the X-axis direction in the observation window of the sampling frame corresponding to the focus position The sum of the numbers is: N(i, j=((back) MAX -1)+1=(back) MAX , forw=1, back=(back) MAX -1), the sampling frame taken during the measurement Total counting result is: j=forw+(back) MAX =2+(back) MAX ;

综合起来,相对本次测量开始前的初始位置,本次测量所获得的物体沿所述摄像头的光学轴方向发生的位移是:Δz(i)=forw-back,上述计算式中计数器forw和back的值均为本次测量过程中最后的计数结果,计算结果有正或负的符号,分别表示所发生的位移沿光学轴前进或后退的方向,对应于所述步进电机的旋转方向(即顺时钟方向或反时钟方向),具体由步进电机的轴向位移装置之安排确定;To sum up, relative to the initial position before the start of this measurement, the displacement of the object obtained in this measurement along the optical axis direction of the camera is: Δz(i)=forw-back, the counters forw and back in the above calculation formula The values of are all the final counting results in this measurement process, and the calculation results have positive or negative signs, which respectively represent the direction in which the displacement occurs along the optical axis to advance or retreat, corresponding to the direction of rotation of the stepping motor (ie Clockwise or counterclockwise), specifically determined by the arrangement of the axial displacement device of the stepper motor;

总的位移为:ΔZ0(i)=ΔZ0(i-1)+Δz(i)The total displacement is: ΔZ 0 (i)=ΔZ 0 (i-1)+Δz(i)

其中,ΔZ0(i-1)为本次测量之前累积的轴向位移;Among them, ΔZ 0 (i-1) is the accumulated axial displacement before this measurement;

步骤八、准备下一次测量工作:测量次数计数器i=i+1,取第i次测量确定的最佳物体成像聚焦位置处相应的物体成像帧观察窗内沿X轴方向所有的正边和负边的数目之和作为新的测量参考值:Step 8. Prepare for the next measurement: measure the number of times counter i=i+1, take all positive sides and negative sides along the X-axis direction in the corresponding object imaging frame observation window at the best object imaging focus position determined by the ith measurement The sum of the number of sides is used as the new measurement reference value:

N(i,j=0,forw=0,back=0)=N(i,j=(forw)MAX-1,forw=(forw)MAX-1,back=0),或N(i,j=0,forw=0,back=0)=N(i, j=0, forw=0, back=0)=N(i, j=(forw) MAX -1, forw=(forw) MAX -1, back=0), or N(i, j =0, forw=0, back=0)=

N(i,j=((back)MAX-1)+1=(back)MAX,forw=1,back=(back)MAX-1);N(i, j=((back) MAX -1)+1=(back) MAX , forw=1, back=(back) MAX -1);

步骤九、跳转到步骤六,继续测量;Step 9, jump to step 6, continue to measure;

实际测量过程中,通过测量定标,可以获得直接的测量结果。In the actual measurement process, direct measurement results can be obtained through measurement calibration.

上述摄像头拍摄以及根据一维对比度测量轴向位移程序之步骤中所述边方向数据的定义是:The definition of the side direction data in the above camera shooting and the step of measuring the axial displacement program according to the one-dimensional contrast ratio is:

像素阵列中,沿着X轴或者沿着Y轴方向,如果一个像素的光强值比其后面的第二个像素相应的光强值还要小一个误差容限值error,即如果In the pixel array, along the X-axis or along the Y-axis, if the light intensity value of a pixel is smaller than the corresponding light intensity value of the second pixel behind it by an error tolerance value error, that is, if

I(X,Y)<I(X+2,Y)-error或I(X,Y)<I(X,Y+2)-errorI(X,Y)<I(X+2,Y)-error or I(X,Y)<I(X,Y+2)-error

则定义这两个像素之间存在一个沿该轴方向的正边;如果一个像素的光强值比其后面的第二个像素相应的光强值还要大一个误差容限值error,即如果It is defined that there is a positive edge along the axis between these two pixels; if the light intensity value of a pixel is greater than the corresponding light intensity value of the second pixel behind it by an error tolerance value error, that is, if

I(X,Y)>I(X+2,Y)+error或I(X,Y)>I(X,Y+2)+errorI(X,Y)>I(X+2,Y)+error or I(X,Y)>I(X,Y+2)+error

则定义这两个像素之间存在一个沿该轴方向的负边;如此获得的边位于该像素之后的第一个像素的位置,也即位于参与比较的两个像素的中间位置的那个像素上;如果一个像素的某种光强值与其后面的第二个像素相应的光强值接近,其值相差不超过一个误差容限值error,即如果Then it is defined that there is a negative edge along the axis between these two pixels; the edge obtained in this way is located at the position of the first pixel after this pixel, that is, the pixel located in the middle of the two pixels involved in the comparison ; If a certain light intensity value of a pixel is close to the corresponding light intensity value of the second pixel behind it, the value difference does not exceed an error tolerance value error, that is, if

    I(X+2,Y)-error≤I(X,Y)≤I(X+2,Y)+errorI(X+2, Y)-error≤I(X, Y)≤I(X+2, Y)+error

或  I(X,Y+2)-error ≤I(X,Y)≤I(X,Y+2)+error,or I(X, Y+2)-error ≤ I(X, Y) ≤ I(X, Y+2)+error,

则认为这两个像素之间沿该轴方向不存在对应的“边”,或称之为第三类边;It is considered that there is no corresponding "edge" along the axis between the two pixels, or it is called the third type of edge;

沿着某一个坐标轴方向,对应的像素行或像素列所有的正边、负边以及第三类边组成该行或该列沿该坐标轴方向的边方向数据;上列式中的误差容限值可以根据具体的光照情况,预置为一个小的数值,例如:error=10;像素阵列中的四个边与角上的像素位置不存在边方向数据。Along a certain coordinate axis direction, all positive edges, negative edges, and third-type edges of the corresponding pixel row or pixel column form the edge direction data of the row or column along the coordinate axis direction; the error tolerance in the above formula The limit value can be preset as a small value according to the specific lighting conditions, for example: error=10; there is no edge direction data at the pixel positions on the four sides and corners in the pixel array.

上述摄像头拍摄以及根据一维对比度测量轴向位移程序之步骤中所述搜索最佳观察窗像素阵列的方法包括:The method of searching for the optimal observation window pixel array according to the steps of the camera shooting and measuring the axial displacement according to the one-dimensional contrast ratio includes:

对于所述像素阵列的观察窗以及k×k(k∈正整数)关联匹配算子阵列(a,b),沿某个坐标轴方向会产生k×k个自关联匹配系数,按下列不等式比较这些自关联匹配系数:For the observation window of the pixel array and the k×k (k ∈ positive integer) associative matching operator array (a, b), k×k self-association matching coefficients will be generated along a certain coordinate axis, and compared according to the following inequality These self-association matching coefficients:

auto_correlation(a,b)≥auto_correlation(0,0)×similarityauto_correlation(a,b)≥auto_correlation(0,0)×similarity

式中,similarity描述了观察窗与其邻近相同规模的像素阵列的相似程度,例如取similarity=60%,可以预先设置,也可以根据光照情况以及被测物表面的质地进行调试和选择;In the formula, similarity describes the similarity between the observation window and its adjacent pixel array of the same scale, for example, similarity = 60%, which can be set in advance, or can be debugged and selected according to the lighting conditions and the texture of the surface of the measured object;

如果满足上述不等式的自关联系数多于k×k×1/3个,需要扩大观察窗的范围各step行和step列:令m=m0+step,n=n0+step,重新计算新的观察窗的自关联系数,并进行上述比较,直到满足上述不等式的自关联匹配系数不多于k×k×1/3个,这时,2h=M-m,2v=N-n,其中,step为步进参数,初始值为1,每次需要扩展观察窗的规模就增加1;如果超出帧内一个预定的范围,还没有找到合适的观察窗,则认为该物体这部分反射表面的质地不适于本装置的测量工作,并给出提示警告;If there are more than k×k×1/3 self-correlation coefficients satisfying the above inequality, it is necessary to expand the scope of the observation window for each step row and step column: let m=m 0 +step, n=n 0 +step, and recalculate the new The self-correlation coefficients of the observation window, and carry out the above comparison until the self-correlation matching coefficients satisfying the above inequality are no more than k×k×1/3, at this time, 2h=Mm, 2v=Nn, where step is the step The input parameter, the initial value is 1, every time the scale of the observation window needs to be expanded, it will increase by 1; if it exceeds a predetermined range in the frame, and no suitable observation window has been found, it is considered that the texture of the reflective surface of the object is not suitable for this part. The measurement work of the device, and give prompts and warnings;

如果满足上述不等式的自关联匹配系数不多于k×k×1/3个,说明被拍摄物体的表面的结构特征足够精细,最邻近像素之间的值可以区分,可以进一步尝试缩小观察窗的范围各step行和step列,以减少计算工作量:令m=m0-step,n=n0-step,重新计算观察窗的自关联系数,并进行上述比较,递进参数step每次增加1,直到所选观察窗区域满足上述不等式的自关联系数的个数不小于k×k×1/3,这时,认为搜索到了最佳观察窗像素阵列。If there are no more than k×k×1/3 self-correlation matching coefficients satisfying the above inequality, it means that the surface structure features of the object to be photographed are fine enough, and the values between the nearest adjacent pixels can be distinguished, and further attempts can be made to reduce the size of the observation window. Range each step row and step column to reduce the calculation workload: let m=m 0 -step, n=n 0 -step, recalculate the self-correlation coefficient of the observation window, and perform the above comparison, and the progressive parameter step increases each time 1. Until the number of self-correlation coefficients satisfying the above inequality in the selected observation window area is not less than k×k×1/3, at this time, it is considered that the optimal observation window pixel array has been searched.

所述摄像头轴向位移装置包括:所述摄像头安装在一个工作台上,该工作台与一根长的螺丝纹旋转轴以螺丝纹套接,该螺丝纹旋转轴通过两根支撑架安装在一张大的工作台上,并且,它与这两根支撑架都是以转轴的方式套接,在与支撑架的套接处可以转动但不发生向前或向后的位移;所述螺丝纹旋转轴上有一个固定的齿轮,它与步进电机的转轴上面的齿轮相互咬合。所述步进电机也安装在所述大的工作台上,它通过步进电机接口电路连接到计算机系统的RS232C接口。The camera axial displacement device includes: the camera is installed on a worktable, and the workbench is connected with a long threaded rotating shaft with threaded thread, and the threaded rotating shaft is installed on a On the large workbench, and it is socketed with the two support frames in the form of a rotating shaft, and can rotate at the socket with the support frame but does not move forward or backward; the screw thread rotates There is a fixed gear on the shaft, which meshes with the gear on the shaft of the stepper motor. The stepper motor is also installed on the large workbench, and it is connected to the RS232C interface of the computer system through the stepper motor interface circuit.

本发明专利以像素亮度的一维对比度作为被测物体图像帧的特征,通过计算自关联匹配系数,自动分析并选取最佳观察区域;通过计数该观察区域内图像特征的数目,判断物体成像聚焦的程度,进而测量物体在摄像头光学轴方向所发生的微小位移;本测量方法新颖,相对“以三基色对比度为特征测量沿光轴方向的位移的方法及装置”,本发明专利的优点是,减少了分析运算量,提高了测量速度。The patent of the invention uses the one-dimensional contrast of pixel brightness as the feature of the image frame of the measured object, automatically analyzes and selects the best observation area by calculating the self-correlation matching coefficient; and judges the imaging focus of the object by counting the number of image features in the observation area degree, and then measure the tiny displacement of the object in the direction of the optical axis of the camera; this measurement method is novel, and compared with the "method and device for measuring displacement along the optical axis with the contrast of three primary colors", the advantages of the patent of the present invention are, The analysis operation load is reduced, and the measurement speed is improved.

附图说明 Description of drawings

下面结合附图进一步说明本发明专利。Further illustrate the patent of the present invention below in conjunction with accompanying drawing.

图1是本发明的计算机及其摄像头测量系统方框图。Fig. 1 is a block diagram of a computer and a camera measurement system thereof of the present invention.

图2是本发明的由高精度微位移步进电机为核心组成的摄像头轴向位移装置方框图。Fig. 2 is a block diagram of the camera axial displacement device composed of a high-precision micro-displacement stepping motor as the core of the present invention.

图3是本发明的光学成像聚焦过程示意图。Fig. 3 is a schematic diagram of the optical imaging focusing process of the present invention.

图4是光电传感器芯片进行光电转换后产生的像素阵列及其观察窗区域示意图。Fig. 4 is a schematic diagram of a pixel array and its observation window area generated after the photoelectric sensor chip undergoes photoelectric conversion.

图5是一行光信号及其数字化信号、边方向数据之示意图。Fig. 5 is a schematic diagram of a row of optical signals and their digitized signals, edge direction data.

图1中,1.计算机摄像头,2.光学透镜,3.光电传感器芯片,4.USB接口,5.计算机系统,6.USB接口,7.CPU,8.RS232C接口,9.显示卡与显示器,10.内存与硬盘,11.键盘和鼠标,12.操作系统,13.摄像头驱动程序,14.摄像头拍摄以及根据一维对比度测量轴向位移程序,15.照明设备。In Figure 1, 1. Computer camera, 2. Optical lens, 3. Photoelectric sensor chip, 4. USB interface, 5. Computer system, 6. USB interface, 7. CPU, 8. RS232C interface, 9. Display card and monitor , 10. Memory and hard disk, 11. Keyboard and mouse, 12. Operating system, 13. Camera driver, 14. Camera shooting and axial displacement measurement program based on one-dimensional contrast ratio, 15. Lighting equipment.

图2中,30.步进电机与摄像头的工作台,31.支撑架,32.支撑架,33.摄像头(1)的工作台,34.螺丝纹旋转轴,341.螺丝纹旋转轴(34)上的齿轮,40.步进电机,41.步进电机(40)的旋转轴,42.步进电机(40)的旋转轴(41)上的齿轮。Among Fig. 2, 30. the workbench of stepper motor and camera, 31. bracing frame, 32. bracing frame, 33. the workbench of camera (1), 34. thread thread rotating shaft, 341. thread thread rotating shaft (34 ), the gear on the 40. stepping motor, the rotating shaft of 41. stepping motor (40), the gear on the rotating shaft (41) of 42. stepping motor (40).

图3中,90.-96.物体(圆光斑)在光轴上不同的位置所成像之示意图,97.光学轴。In Fig. 3, 90.-96. The schematic diagram of the imaging of the object (circular spot) at different positions on the optical axis, 97. The optical axis.

图5中,21.一行光信号,22.与光信号(21)对应的数字化信号,23.与数字化信号(22)对应的边方向数据。In Fig. 5, 21. a row of optical signals, 22. digitized signals corresponding to the optical signals (21), and 23. edge direction data corresponding to the digitized signals (22).

具体实施方式 Detailed ways

本发明专利包括两个部分:图1所示的计算机及其摄像头测量系统、图2所示的由高精度微位移步进电机为核心组成的摄像头轴向位移装置。The invention patent includes two parts: the computer and its camera measurement system shown in Figure 1, and the camera axial displacement device with a high-precision micro-displacement stepping motor as the core shown in Figure 2.

在计算机系统(5)上运行配售的摄像头驱动程序(13),通过USB接口(4)和(6)连接摄像头(1)到计算机(5)。然后,让摄像头聚焦成像被测量物体。On the computer system (5), run the camera driver program (13) for distribution, and connect the camera (1) to the computer (5) through USB interfaces (4) and (6). Then, let the camera focus and image the object to be measured.

测量过程中,允许照明状况发生一定的变化,以其变化不明显地影响被测量物体所成像的明暗对比度为限度。选用照明设备(15)有助于本发明的实施。例如采用漫反射的均匀照明方式,或照明设备其强度能够强于环境杂散光的影响。被测量物体的材质最好具有较细致的表面反射特征,也可以选用此类材质做成靶标,避免或克服光滑的反射面材质。During the measurement process, certain changes in lighting conditions are allowed, as long as the changes do not significantly affect the contrast between light and dark imaged by the measured object. Selecting lighting equipment (15) is helpful to the implementation of the present invention. For example, the uniform lighting method with diffuse reflection, or the intensity of the lighting equipment can be stronger than the influence of ambient stray light. The material of the object to be measured should preferably have more detailed surface reflection characteristics, and this kind of material can also be used as a target to avoid or overcome the smooth reflective surface material.

如图2所示,摄像头(1)安装在工作台(33)上,随工作台一起移动,该工作台(33)与一根长的螺丝纹旋转轴(34)以螺丝纹套接。螺丝纹旋转轴(34)通过支撑架(31)和(32)安装在一张大的工作台(30)上,并且,螺丝纹旋转轴(34)与支撑架(31)和(32)都是以转轴的方式套接,螺丝纹旋转轴(34)在与支撑架(31)和(32)的套接处可以转动但不发生向前或向后的位移。螺丝纹旋转轴(34)上有一个固定的齿轮(341),它与步进电机(40)的转轴(41)上面的齿轮(42)相互咬合,当步进电机(40)的转轴(41)旋转的时候,齿轮(42)的旋转会带动齿轮(341)旋转,进而带动螺丝纹旋转轴(34)旋转,促使摄像头(1)及其工作台(33)一起向前或向后发生移动。步进电机(40)也安装在大的工作台(30)上。As shown in Figure 2, the camera (1) is installed on the workbench (33) and moves together with the workbench, and the workbench (33) is socketed with a long threaded rotating shaft (34) with threaded threads. Screw thread rotating shaft (34) is installed on a large workbench (30) by bracing frame (31) and (32), and, thread thread rotating shaft (34) and bracing frame (31) and (32) are all Socketed in the form of a rotating shaft, the threaded rotating shaft (34) can rotate at the socketed place with the support frames (31) and (32) but does not move forward or backward. There is a fixed gear (341) on the threaded rotating shaft (34), which meshes with the gear (42) on the rotating shaft (41) of the stepping motor (40), when the rotating shaft (41) of the stepping motor (40) ) rotates, the rotation of the gear (42) will drive the gear (341) to rotate, and then drive the screw thread rotation shaft (34) to rotate, prompting the camera (1) and its workbench (33) to move forward or backward together . Stepping motor (40) is also installed on the big workbench (30).

选取计算机系统(5)的RS232C接口(8)里的两根输出信号线,如图所示的FORWARD和BACKWARD,与一根地线GROUND一起接到一个步进电机接口电路(43),在此进行功率放大,然后,再连接到步进电机(40),控制步进电机(40)作顺时钟旋转或反时钟旋转。Select two output signal lines in the RS232C interface (8) of the computer system (5), FORWARD and BACKWARD as shown in the figure, and a ground wire GROUND are connected to a stepping motor interface circuit (43), here Carry out power amplification, then, be connected to stepper motor (40), control stepper motor (40) to make clockwise rotation or anticlockwise rotation.

步进电机(40)的性能关系到本发明专利的测量精度,应当选用步进位移精细、精度高、工作稳定的电机,The performance of the stepper motor (40) is related to the measurement accuracy of the patent of the present invention, and the motor with fine stepping displacement, high precision and stable operation should be selected for use.

运行摄像头拍摄以及根据一维对比度测量轴向位移程序(14),实时测量位移。具体步骤见“发明内容”所描述,下面就其要点说明如下。Run the camera shooting and axial displacement measurement program (14) according to the one-dimensional contrast ratio to measure the displacement in real time. The specific steps are described in the "Summary of the Invention", and the main points are described below.

本发明专利测量光学轴向微位移的原理与方法基于光学成像聚焦的清晰与否,如图3所示,其判断准则是:聚焦清晰的时候,图像帧观察窗区域具有数目最多的图像特征--边反射状况。有关光电传感器芯片进行光电转换后产生的像素阵列及其观察窗区域如图4所示。有关图像特征即边方向数据的定义及其确定如图5所示。The principle and method of measuring the optical axial micro-displacement of the patent of the present invention is based on whether the focus of optical imaging is clear or not. As shown in Figure 3, the judgment criterion is: when the focus is clear, the observation window area of the image frame has the largest number of image features- - Side reflection condition. The pixel array and its observation window area generated after the photoelectric conversion of the photosensor chip is shown in FIG. 4 . The definition and determination of image features, that is, edge direction data, are shown in Figure 5.

测量开始前,计算自关联匹配系数,以选区合适的观察窗区域,判断被测物体表面的光学反射性质是否适应本测量工作,并优化分析运算量。Before the measurement starts, calculate the self-correlation matching coefficient to select a suitable observation window area, judge whether the optical reflection properties of the surface of the measured object are suitable for the measurement work, and optimize the analysis calculation amount.

本发明专利所选用的坐标轴并不局限于X轴,Y轴与它等同。The coordinate axis selected by the patent of the present invention is not limited to the X axis, and the Y axis is equivalent to it.

本发明专利所描述的测量方法也适用于其它摄像器件。The measurement method described in the patent of the present invention is also applicable to other imaging devices.

Claims (3)

1.一种以一维对比度为特征测量轴向位移的方法,它通过一台普通的计算机、一个摄像头、摄像头轴向位移装置、一台步进电机以及步进电机接口电路测量轴向位移,该计算机通过其USB接口连接到摄像头,该摄像头被安装在一个由所述步进电机为核心组成的摄像头轴向位移装置上,该步进电机通过步进电机接口电路连接到计算机的RS232C接口,所述摄像头轴向位移装置包括:摄像头(1)安装在第一工作台(33)上,第一工作台(33)与一根长的螺丝纹旋转轴(34)以螺丝纹套接,螺丝纹旋转轴(34)通过第一支撑架(31)和第二支撑架(32)安装在一张大的第二工作台(30)上,并且,螺丝纹旋转轴(34)与第一支撑架(31)和第二支撑架(32)都是以转轴的方式套接,螺丝纹旋转轴(34)在与第一支撑架(31)和第二支撑架(32)的套接处可以转动但不发生向前或向后的位移,螺丝纹旋转轴(34)上有一个固定的齿轮(341),该齿轮(341)与步进电机(40)的转轴(41)上面的齿轮(42)相互咬合,步进电机(40)也安装在第二工作台(30)上,步进电机(40)通过步进电机接口电路(43)连接到计算机(5)的RS232C接口(8);其特征在于,该方法通过摄像头拍摄并根据一维对比度测量物体沿所述摄像头的光轴方向发生的微小位移,包括下述步骤:1. A method for measuring axial displacement characterized by one-dimensional contrast, which measures axial displacement by a common computer, a camera, camera axial displacement device, a stepper motor and a stepper motor interface circuit, The computer is connected to the camera through its USB interface, and the camera is installed on a camera axial displacement device composed of the stepping motor as the core, and the stepping motor is connected to the RS232C interface of the computer through the stepping motor interface circuit, The camera axial displacement device comprises: the camera (1) is installed on the first workbench (33), the first workbench (33) is socketed with a long screw thread rotating shaft (34) with the screw thread, and the screw The screw thread rotating shaft (34) is installed on a large second workbench (30) by the first support frame (31) and the second support frame (32), and the screw thread rotating shaft (34) and the first support frame (31) and the second support frame (32) are all socketed in the form of a rotating shaft, and the threaded rotating shaft (34) can rotate at the socket with the first support frame (31) and the second support frame (32) But forward or backward displacement does not take place, a fixed gear (341) is arranged on the screw thread rotating shaft (34), and the gear (42) on the rotating shaft (41) of this gear (341) and stepper motor (40) ) interlocking, the stepper motor (40) is also installed on the second workbench (30), and the stepper motor (40) is connected to the RS232C interface (8) of the computer (5) by the stepper motor interface circuit (43); It is characterized in that the method takes pictures with a camera and measures the tiny displacement of the object along the optical axis direction of the camera according to the one-dimensional contrast ratio, including the following steps: 步骤一、以位图M×N的格式拍摄一帧被测物体的图像,作为参考帧;以该帧像素阵列左上角的第一个像素的位置为原点,以向右的方向为X轴方向,垂直向下方向为Y轴方向,所取坐标系的单位为一个像素的大小;在所述像素阵列的中央区域选取一个区域,大小为m0×n0,称之为观察窗,它距离所述像素阵列的水平方向和垂直方向的边缘像素各有h和v个像素,即有:m0+2h=M,n0+2v=N,其中,M、N、m0、n0、h、v∈正整数;Step 1. Take a frame of the image of the measured object in the format of bitmap M×N as the reference frame; take the position of the first pixel in the upper left corner of the pixel array of the frame as the origin, and take the rightward direction as the X-axis direction , the vertical downward direction is the direction of the Y axis, and the unit of the coordinate system is the size of one pixel; a region is selected in the central region of the pixel array with a size of m 0 ×n 0 , which is called the observation window, and its distance from The horizontal and vertical edge pixels of the pixel array each have h and v pixels, namely: m 0 +2h=M, n 0 +2v=N, where M, N, m 0 , n 0 , h, v ∈ positive integer; 步骤二、对于上述参考帧之像素阵列,逐像素行、逐像素列导出沿X轴方向和Y轴方向的边方向数据,并以3bit的二进制数值001,010和100分别表示其中的正边、负边以及第三类边,如此构成了对应所述参考帧像素阵列的关于X轴方向和关于Y轴方向的两帧边方向数据{referencex(x,y)}和{referencey(x,y)},其中,下标x或y分别表示所沿的坐标轴的方向,符号“{}”表示沿其中函数下标所标示的坐标轴方向观察窗内诸像素(x,y)处的边方向数据的一个集合,保存这些数据;Step 2. For the pixel array of the above reference frame, derive the side direction data along the X-axis direction and the Y-axis direction pixel by row and pixel by column, and use 3-bit binary values 001, 010 and 100 to represent the positive side, The negative edge and the third type edge constitute two frames of edge direction data {reference x (x, y)} and {reference y (x, x, y)}, wherein, the subscript x or y respectively represent the direction of the coordinate axis along, and the symbol "{}" represents the pixels (x, y) in the observation window along the direction of the coordinate axis indicated by the function subscript A collection of edge direction data, save these data; 步骤三、对于上述两帧边方向数据,分别计算所述参考帧里观察窗内像素阵列的自关联匹配系数:Step 3. For the above two frames of edge direction data, calculate the self-correlation matching coefficient of the pixel array in the observation window in the reference frame: autoauto __ correlationcorrelation xx (( aa ,, bb )) == &Sigma;&Sigma; ythe y == vv ++ 11 vv ++ 11 ++ nno 00 &Sigma;&Sigma; xx == hh ++ 11 hh ++ 11 ++ mm 00 [[ referencereference xx (( xx ,, ythe y )) &bull;&bull; referencereference xx (( xx ++ aa ,, ythe y ++ bb )) ]] autoauto __ correlationcorrelation ythe y (( aa ,, bb )) == &Sigma;&Sigma; ythe y == vv ++ 11 vv ++ 11 ++ nno 00 &Sigma;&Sigma; xx == hh ++ 11 hh ++ 11 ++ mm 00 [[ referencereference ythe y (( xx ,, ythe y )) &bull;&bull; referencereference ythe y (( xx ++ aa ,, ythe y ++ bb )) ]] 式中,运算符号·表示二进制逻辑与运算,其运算结果或为逻辑0或为逻辑1,运算符号“[]”表示取其中的逻辑运算函数的值所对应的数值,或为数值0,或为数值1,参数变量a、b的组合决定了关联匹配算子阵列的规模,如果取3×3关联匹配算子阵列:a=-1、0、1,b=-1、0、1,因此,沿每个坐标轴方向各自会产生9个自关联匹配系数auto_correlationx(a,b)和auto_correlationy(a,b);In the formula, the operation symbol · represents the binary logic AND operation, and the operation result is either logic 0 or logic 1, and the operation symbol "[]" represents the value corresponding to the value of the logic operation function, or the value 0, or The value is 1, and the combination of parameter variables a and b determines the scale of the associative matching operator array. If a 3×3 associative matching operator array is used: a=-1, 0, 1, b=-1, 0, 1, Therefore, 9 self-correlation matching coefficients auto_correlation x (a, b) and auto_correlation y (a, b) will be generated along each coordinate axis direction; 步骤四、根据上述两帧边方向数据对应的自关联匹配系数,分别搜索在目前的物体表面状况以及照明状况下可以进行匹配比较的最佳观察窗像素阵列:Step 4. According to the self-association matching coefficients corresponding to the above two frames of edge direction data, search for the best observation window pixel array that can be matched and compared under the current object surface conditions and lighting conditions: mx=m0±step,nx=n0±step,2h=M-mx,2v=N-nxm x = m 0 ± step, n x = n 0 ± step, 2h = Mm x , 2v = Nn x , 和my=m0±step,ny=n0±step,2h=M-my,2v=N-nyand m y = m 0 ± step, n y = n 0 ± step, 2h = Mm y , 2v = Nn y , 式中,下标x、y分别表示其值对应着沿X轴方向和Y轴方向,step为搜索过程中的步进参数,其前面的加减号由搜索方向决定;取此两组值中大者为本测量所用观察窗阵列的规模:m×n;In the formula, the subscripts x and y indicate that their values correspond to the directions along the X-axis and the Y-axis respectively, step is the step parameter in the search process, and the plus and minus signs in front of it are determined by the search direction; take the two sets of values The larger one is the size of the observation window array used for this measurement: m×n; 步骤五、对于上述参考帧之像素阵列,根据其像素亮度,逐行导出沿X轴方向的1帧边方向数据;Step 5. For the pixel array of the above-mentioned reference frame, according to its pixel brightness, derive the edge direction data of one frame along the X-axis direction row by row; 根据上述边方向数据,对于其中的观察窗区域,分别使用累加器计数它们所对应的正边、负边的数目:NX轴正和NX轴负,其中,N表示数目;累加上述累加器的计数结果并保存之,表示为:N(i,j=0,forw=0,back=0),其中,i=1,2,3......,表示所拍摄的参考帧的顺序计数,也是测量的计数,j=0,1,2,3,......,表示第i次测量过程中拍摄的取样帧的计数,变量forw和back分别表示第i次测量中所述步进电机发生顺时钟旋转和反时钟旋转所对应的步进脉冲计数:forw=0,1,2,......,back=0,1,2,......,本次测量开始前,有:i=1,j=0,forw=0,back=0;According to the above-mentioned edge direction data, for the observation window area therein, use accumulators to count the numbers of their corresponding positive and negative sides: N X-axis positive and N X-axis negative , where N represents the number; accumulate the above-mentioned accumulator The counting result and save it, expressed as: N(i, j=0, forw=0, back=0), wherein, i=1, 2, 3..., represents the taken reference frame Sequential counting is also the counting of measurement, j=0, 1, 2, 3,..., represents the counting of the sampling frames taken during the i-th measurement, and the variables forw and back respectively represent the The stepping pulse count corresponding to clockwise rotation and counterclockwise rotation of the stepping motor: forw=0, 1, 2,..., back=0, 1, 2,... , before the start of this measurement, there are: i=1, j=0, forw=0, back=0; 步骤六、测量开始:所述计算机通过其RS232C接口的一根输出控制线FORWARD输出第forw=1个数字脉冲信号到所述步进电机接口电路,控制该步进电机顺时钟旋转一步,然后,拍摄第j=1帧取样帧位图;Step 6, measurement start: the computer outputs the first forw=1 digital pulse signal to the stepper motor interface circuit through an output control line FORWARD of its RS232C interface, and controls the stepper motor to rotate one step clockwise, and then, Take the sample frame bitmap of j=1 frame; 对于上述取样帧之像素阵列,根据其像素亮度,逐行导出它沿X轴方向的1帧边方向数据;For the pixel array of the above sampling frame, according to its pixel brightness, export its side direction data of one frame along the X-axis direction line by line; 根据上述边方向数据,对于其中的观察窗区域,分别使用累加器计数它们所对应的正边、负边的数目:NX轴正和NX轴负;累加上述累加器的计数结果并保存之,表示为:N(i,j=1,forw=1,back=0);According to the above side direction data, for the observation window area, use the accumulator to count the number of their corresponding positive side and negative side: N X-axis positive and N X-axis negative ; accumulate the counting results of the above accumulator and save it , expressed as: N(i, j=1, forw=1, back=0); 步骤七、如果:N(i,j=1,forw=1,back=0)≥N(i,j=0,forw=0,back=0),所述计算机通过其RS232C接口的一根输出控制线FORWARD输出第forw个数字脉冲信号到所述步进电机接口电路:forw=2,3,......,控制该步进电机顺时钟旋转进步,每次顺时钟旋转一步都拍摄并分析比较前后各取样帧中观察窗内沿X轴方向所有的正边和负边的数目之和N(i,j=forw-1,forw-1,back=0)和N(i,j=forw,forw,back=0),保存之,该过程中应当会有:N(i,j=forw,forw,back=0)≥N(i,j=forw-1,forw-1,back=0),直到满足:N(i,j=forw,forw,back=0)<N(i,j=forw-1,forw-1,back=0),这时,记录(forw)MAX=forw,同时,所述计算机通过其RS232C接口的另一根输出控制线BACKWARD输出一个数字脉冲信号到所述步进电机接口电路:back=1,控制该步进电机反时钟旋转一步,这时,相对本次测量开始前的初始位置,所述摄像头即处于本次测量中的最佳物体成像聚焦位置:FocusP=(forw)MAX-back=(forw)MAX-1,其计算的结果大于或等于0,表示所述步进电机的旋转方向总的看来是顺时钟方向的,该聚焦位置对应的取样帧观察窗内沿X轴方向所有的正边和负边的数目之和为:N(i,j=(forw)MAX-1,forw=(forw)MAX-1,back=0),测量过程中拍摄的取样帧的总计数结果为:j=(forw)MAX+back=(forw)MAX+1;Step 7, if: N (i, j=1, forw=1, back=0) ≥ N (i, j=0, forw=0, back=0), described computer is through one output of its RS232C interface The control line FORWARD outputs the forwth digital pulse signal to the stepper motor interface circuit: forw=2, 3,..., to control the stepper motor to rotate clockwise and progress, and each clockwise rotation takes a step And analyze and compare the sum N (i, j=forw-1, forw-1, back=0) and N (i, j =forw, forw, back=0), save it, there should be: N(i, j=forw, forw, back=0) ≥ N(i, j=forw-1, forw-1, back =0), until satisfying: N(i, j=forw, forw, back=0)<N(i, j=forw-1, forw-1, back=0), at this moment, record (forw) MAX = Forw, at the same time, the computer outputs a digital pulse signal to the stepper motor interface circuit through another output control line BACKWARD of its RS232C interface: back=1, controls the stepper motor to rotate one step counterclockwise, at this time, Relative to the initial position before the start of this measurement, the camera is at the best object imaging focus position in this measurement: FocusP=(forw) MAX -back=(forw) MAX -1, the calculated result is greater than or equal to 0, indicating that the direction of rotation of the stepper motor is generally clockwise, and the sum of the numbers of all positive and negative sides along the X-axis direction in the observation window of the sampling frame corresponding to the focus position is: N( i, j=(forw) MAX -1, forw=(forw) MAX -1, back=0), the total counting result of the sampling frames taken during the measurement is: j=(forw) MAX +back=(forw) MAX +1; 如果:N(i,j=1,forw=1,back=0)<N(i,j=0,forw=0,back=0),所述计算机通过其RS232C接口的一根输出控制线BACKWARD输出第back=1个数字脉冲信号到所述步进电机接口电路,控制该步进电机反时钟旋转退一步,即回到本次测量的初始位置,然后,所述计算机通过其RS232C接口的输出控制线BACKWARD继续输出第back个数字脉冲信号到所述步进电机接口电路:back=2,3,......,控制该步进电机进一步反时钟旋转,在此过程中,每次反时钟旋转一步都拍摄并分析比较前后各取样帧观察窗内沿X轴方向所有的正边和负边的数目之和N(i,j=back+1,forw=1,back)和N(i,j=back,forw=1,back=back-1),应当有:N(i,j=back+1,forw=1,back=back)≥N(i,j=back,forw=1,back=back-1),保存之,如此继续,直到满足:N(i,j=back+1,forw=1,back)<N(i,j=back,forw=1,back-1),这时,记录:(back)MAX=back,同时,所述计算机通过其RS232C接口的另一根输出控制线FORWARD输出一个数字脉冲信号到所述步进电机接口电路:forw=2,控制该步进电机顺时钟旋转一步,这时,相对本次测量开始前的初始位置,所述摄像头即处于本次测量中的最佳物体成像聚焦位置:FocusP=forw-(back)MAX=2-(back)MAX,其计算的结果为负值,表示所述步进电机的旋转方向是反时钟方向的,该聚焦位置对应的取样帧观察窗内沿X轴方向所有的正边和负边的数目之和为:N(i,j=((back)MAX-1)+1=(back)MAX,forw=1,back=(back)MAX-1),测量过程中拍摄的取样帧的总计数结果为:j=forw+(back)MAX=2+(back)MAXIf: N(i, j=1, forw=1, back=0)<N(i, j=0, forw=0, back=0), said computer is through an output control line BACKWARD of its RS232C interface Output the first back=1 digital pulse signal to the stepper motor interface circuit, control the stepper motor to take a step back in counterclockwise rotation, that is, return to the initial position of this measurement, and then, the computer outputs through its RS232C interface The control line BACKWARD continues to output the back digital pulse signal to the stepper motor interface circuit: back=2, 3,..., to control the stepper motor to further rotate counterclockwise. In the process, each time One step of anti-clockwise rotation is all taken and analyzed and compared before and after each sampling frame observation window along the X-axis direction with the sum of the numbers N(i, j=back+1, forw=1, back) and N( i, j=back, forw=1, back=back-1), there should be: N(i, j=back+1, forw=1, back=back)≥N(i, j=back, forw=1 , back=back-1), save it, and continue like this until it is satisfied: N(i, j=back+1, forw=1, back)<N(i, j=back, forw=1, back-1) , at this moment, record: (back) MAX =back, simultaneously, described computer outputs a digital pulse signal to described stepping motor interface circuit by another root output control line FORWARD of its RS232C interface: forw=2, controls this The stepper motor rotates one step clockwise. At this time, relative to the initial position before the start of this measurement, the camera is in the best object imaging focus position in this measurement: FocusP=forw-(back) MAX =2-( back) MAX , the calculation result is a negative value, indicating that the rotation direction of the stepper motor is anti-clockwise, and the number of positive and negative sides along the X-axis direction in the sampling frame observation window corresponding to the focus position The sum is: N(i, j=((back) MAX -1)+1=(back) MAX , forw=1, back=(back) MAX -1), the total count of sampled frames taken during the measurement The result is: j=forw+(back) MAX =2+(back) MAX ; 综合起来,相对本次测量开始前的初始位置,本次测量所获得的物体沿所述摄像头的光学轴方向发生的位移是:Δz(i)=forw-back,To sum up, relative to the initial position before the start of this measurement, the displacement of the object obtained in this measurement along the optical axis of the camera is: Δz(i)=forw-back, 上述计算式中计数器forw和back的值均为本次测量过程中最后的计数结果,计算结果有正或负的符号,分别表示所发生的位移沿光学轴前进或后退的方向,对应于所述步进电机的旋转方向即顺时钟方向或反时钟方向,具体由步进电机为核心组成的摄像头轴向位移装置之安排确定;The values of the counters forw and back in the above calculation formula are the final counting results in this measurement process, and the calculation results have positive or negative signs, which respectively indicate the direction of the displacement that occurs along the optical axis to advance or retreat, corresponding to the The direction of rotation of the stepper motor is clockwise or counterclockwise, which is determined by the arrangement of the camera axial displacement device composed of the stepper motor as the core; 总的位移为:ΔZ0(i)=ΔZ0(i-1)+Δz(i),The total displacement is: ΔZ 0 (i)=ΔZ 0 (i-1)+Δz(i), 其中,ΔZ0(i-1)为本次测量之前累积的轴向位移;Among them, ΔZ 0 (i-1) is the accumulated axial displacement before this measurement; 步骤八、准备下一次测量工作:测量次数计数器i加1,取第i次测量确定的最佳物体成像聚焦位置处相应的物体成像帧观察窗内沿X轴方向所有的正边和负边的数目之和作为新的测量参考值:Step 8. Prepare for the next measurement: add 1 to the counter i of the number of measurements, and take the values of all positive and negative sides along the X-axis direction in the corresponding object imaging frame observation window at the best object imaging focus position determined by the ith measurement The sum of the numbers is used as the new measurement reference value: N(i,j=0,forw=0,back=0)=N(i,j=(forw)MAX-1,forw=(forw)MAX-1,back=0),或N(i,j=0,forw=0,back=0)=N(i, j=0, forw=0, back=0)=N(i, j=(forw) MAX -1, forw=(forw) MAX -1, back=0), or N(i, j =0, forw=0, back=0)= N(i,j=((back)MAX-1)+1=(back)MAX,forw=1,back=(back)MAX-1);N(i, j=((back) MAX -1)+1=(back) MAX , forw=1, back=(back) MAX -1); 步骤九、跳转到步骤六,继续测量。Step 9, jump to step 6, continue to measure. 2.根据权利要求1所述的以一维对比度为特征测量轴向位移的方法,其特征在于,所述步骤二、步骤五与步骤六中所述边方向数据的定义是:2. the method for measuring axial displacement characterized by one-dimensional contrast according to claim 1, characterized in that, the definition of side direction data in said step 2, step 5 and step 6 is: 像素阵列中,沿着X轴或者沿着Y轴方向,如果一个像素的光强值比其后面的第二个像素相应的光强值还要小一个误差容限值error,即如果:In the pixel array, along the X-axis or along the Y-axis, if the light intensity value of a pixel is smaller than the corresponding light intensity value of the second pixel behind it by an error tolerance value error, that is, if: I(X,Y)<I(X+2,Y)-error或I(X,Y)<I(X,Y+2)-error,I(X,Y)<I(X+2,Y)-error or I(X,Y)<I(X,Y+2)-error, 则定义这两个像素之间存在一个沿该轴方向的正边;如果一个像素的光强值比其后面的第二个像素相应的光强值还要大一个误差容限值error,即如果:It is defined that there is a positive edge along the axis between these two pixels; if the light intensity value of a pixel is greater than the corresponding light intensity value of the second pixel behind it by an error tolerance value error, that is, if : I(X,Y)>I(X+2,Y)+error或I(X,Y)>I(X,Y+2)+error,I(X, Y)>I(X+2, Y)+error or I(X, Y)>I(X, Y+2)+error, 则定义这两个像素之间存在一个沿该轴方向的负边;如此获得的边位于该像素之后的第一个像素的位置,也即位于参与比较的两个像素的中间位置的那个像素上;如果一个像素的某种光强值与其后面的第二个像素相应的光强值接近,其值相差不超过一个误差容限值error,即如果:Then it is defined that there is a negative edge along the axis between these two pixels; the edge obtained in this way is located at the position of the first pixel after this pixel, that is, the pixel located in the middle of the two pixels involved in the comparison ; If a certain light intensity value of a pixel is close to the corresponding light intensity value of the second pixel behind it, the difference between the values does not exceed an error tolerance value error, that is, if: I(X+2,Y)-error≤I(X,Y)≤I(X+2,Y)+error,I(X+2,Y)-error≤I(X,Y)≤I(X+2,Y)+error, 或I(X,Y+2)-error≤I(X,Y)≤I(X,Y+2)+error,or I(X, Y+2)-error≤I(X,Y)≤I(X,Y+2)+error, 则认为这两个像素之间沿该轴方向不存在对应的“边”,或称之为第三类边;上述表示式中,自变量X与自变量Y分别表示所讨论的像素在像素阵列中关于X轴与Y轴方向的坐标;Then it is considered that there is no corresponding "edge" along the axis between the two pixels, or it is called the third type of edge; in the above expression, the independent variable X and the independent variable Y represent the pixel in question in the pixel array The coordinates in the X-axis and Y-axis directions; 沿着某一个坐标轴方向,对应的像素行或像素列所有的正边、负边以及第三类边组成该行或该列沿该坐标轴方向的边方向数据;根据具体的光照情况,预置上列式中的误差容限值error为一个小的数值;像素阵列中的四个边与角上的像素位置不存在边方向数据。Along a certain coordinate axis direction, all positive edges, negative edges, and third-type edges of the corresponding pixel row or pixel column form the edge direction data of the row or column along the direction of the coordinate axis; according to the specific lighting conditions, pre-set Set the error tolerance value error in the above formula to a small value; there is no edge direction data at the pixel positions on the four sides and corners in the pixel array. 3.根据权利要求1所述的以一维对比度为特征测量轴向位移的方法,其特征在于,所述步骤四中搜索最佳观察窗像素阵列的方法包括:3. the method for measuring axial displacement characterized by one-dimensional contrast according to claim 1, characterized in that, the method of searching for the best observation window pixel array in the step 4 comprises: 对于所述像素阵列的观察窗以及k×k关联匹配算子阵列(a,b),k∈正整数,沿某个坐标轴方向会产生k×k个自关联匹配系数,按下列不等式比较这些自关联匹配系数:For the observation window of the pixel array and the k × k associated matching operator array (a, b), k∈ positive integer, k × k self-associated matching coefficients will be generated along a certain coordinate axis direction, and these are compared according to the following inequality Self-correlation matching coefficient: auto_correlation(a,b)≥auto_correlation(0,0)×similarityauto_correlation(a,b)≥auto_correlation(0,0)×similarity 式中,similarity描述了观察窗与其邻近相同规模的像素阵列的相似程度,similarity预先被设置,根据光照情况以及被测物表面的质地进行调试和选择;In the formula, similarity describes the similarity between the observation window and its neighboring pixel arrays of the same size. The similarity is pre-set and debugged and selected according to the lighting conditions and the texture of the surface of the measured object; 如果满足上述不等式的自关联匹配系数多于k×k×1/3个,需要扩大观察窗的范围各step行和step列:令m=m0+step,n=n0+step,重新计算新的观察窗的自关联匹配系数,并进行上述比较,直到满足上述不等式的自关联匹配系数不多于k×k×1/3个,这时,2h=M-m,2v=N-n,其中,step为步进参数,初始值为1,每次需要扩展观察窗的规模就增加1;如果超出帧内一个预定的范围,还没有找到合适的观察窗,则认为该物体这部分反射表面的质地不适于测量工作,并给出提示警告;If there are more than k×k×1/3 self-correlation matching coefficients satisfying the above inequality, it is necessary to expand the scope of the observation window for each step row and step column: let m=m 0 +step, n=n 0 +step, and recalculate Newly observe the self-correlation matching coefficients of the window, and carry out the above comparison until the self-correlation matching coefficients satisfying the above inequality are no more than k×k×1/3, at this time, 2h=Mm, 2v=Nn, where, step It is a stepping parameter, the initial value is 1, and it increases by 1 every time the scale of the observation window needs to be expanded; if it exceeds a predetermined range in the frame and no suitable observation window has been found, it is considered that the texture of the reflective surface of the object is not suitable For measurement work, and give prompts and warnings; 如果满足上述不等式的自关联匹配系数不多于k×k×1/3个,说明被拍摄物体的表面的结构特征足够精细,最邻近像素之间的值可以区分,进一步尝试缩小观察窗的范围各step行和step列,以减少计算工作量:令m=m0-step,n=n0-step,重新计算观察窗的自关联匹配系数,并进行上述比较,步进参数step每次增加1,直到所选观察窗区域满足上述不等式的自关联匹配系数的个数不小于k×k×1/3,这时,认为搜索到了最佳观察窗像素阵列。If there are no more than k×k×1/3 self-association matching coefficients that satisfy the above inequality, it means that the surface structure features of the object to be photographed are fine enough, and the values between the nearest adjacent pixels can be distinguished, and further try to narrow the scope of the observation window Each step row and step column to reduce the calculation workload: set m=m 0 -step, n=n 0 -step, recalculate the self-correlation matching coefficient of the observation window, and perform the above comparison, and the step parameter step increases each time 1. Until the number of self-correlation matching coefficients satisfying the above inequality in the selected observation window area is not less than k×k×1/3, at this time, it is considered that the optimal observation window pixel array has been searched.
CN 200910251092 2009-12-30 2009-12-30 Method and device for measuring axial displacement characterized by one-dimensional (1D) contrast ratio Expired - Fee Related CN102116607B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200910251092 CN102116607B (en) 2009-12-30 2009-12-30 Method and device for measuring axial displacement characterized by one-dimensional (1D) contrast ratio

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200910251092 CN102116607B (en) 2009-12-30 2009-12-30 Method and device for measuring axial displacement characterized by one-dimensional (1D) contrast ratio

Publications (2)

Publication Number Publication Date
CN102116607A CN102116607A (en) 2011-07-06
CN102116607B true CN102116607B (en) 2013-06-12

Family

ID=44215482

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200910251092 Expired - Fee Related CN102116607B (en) 2009-12-30 2009-12-30 Method and device for measuring axial displacement characterized by one-dimensional (1D) contrast ratio

Country Status (1)

Country Link
CN (1) CN102116607B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114463434B (en) * 2021-12-27 2024-11-26 智能多维数据分析研究中心有限公司 A method for real-time measurement of dynamic camera motion parameters based on one-dimensional image information

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6549648B1 (en) * 1998-06-10 2003-04-15 Leica Microsystems Wetzlar Gmbh Method for determining a position of a structural element on a substrate
CN1818545A (en) * 2006-03-02 2006-08-16 浣石 Small-displacement measuring system in long-distance plane
EP1454290B1 (en) * 2001-12-05 2008-09-10 EM Microelectronic-Marin SA Method, sensing device and optical pointing device including a sensing device for comparing light intensity between pixels
CN102095375A (en) * 2009-11-27 2011-06-15 曾艺 Method and device for measuring displacement along optical axis direction by using contrasts of three primary colors as characteristics

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6549648B1 (en) * 1998-06-10 2003-04-15 Leica Microsystems Wetzlar Gmbh Method for determining a position of a structural element on a substrate
EP1454290B1 (en) * 2001-12-05 2008-09-10 EM Microelectronic-Marin SA Method, sensing device and optical pointing device including a sensing device for comparing light intensity between pixels
CN1818545A (en) * 2006-03-02 2006-08-16 浣石 Small-displacement measuring system in long-distance plane
CN102095375A (en) * 2009-11-27 2011-06-15 曾艺 Method and device for measuring displacement along optical axis direction by using contrasts of three primary colors as characteristics

Also Published As

Publication number Publication date
CN102116607A (en) 2011-07-06

Similar Documents

Publication Publication Date Title
CN104181685A (en) Automatic digital slide focusing device and method based on microscope
CN113589506B (en) Biological microscopic vision pre-focusing device and method based on spectrum confocal principle
CN111948784A (en) Iterative optimization auto-focusing method based on hill climbing method
CN103528953A (en) Focusing method of lens of rock core image acquisition system
CN116182786B (en) Monocular vision ranging method, camera and medium
CN108345084A (en) It is a kind of to lead the zoom automatic focusing method passively combined and system
CN101294804A (en) A Digital Aerial Photography System
CN105892003B (en) A kind of line-scan digital camera automatic focusing mechanism and method
CN102116607B (en) Method and device for measuring axial displacement characterized by one-dimensional (1D) contrast ratio
CN104123728A (en) Hough transform based round pipe detection method
CN103529544A (en) Nano membrane thickness measuring instrument capable of automatically positioning and focusing
CN114397090A (en) Method for quickly measuring parallelism of optical axis of continuous zooming camera
CN113610054A (en) A method, system, device and storage medium for depth detection of underwater structural disease
TW201520669A (en) Bevel-axial auto-focus microscopic system and method thereof
CN102116606B (en) Method and device for measuring axial displacement by taking one-dimensional three-primary-color peak valley as characteristic
CN202602795U (en) Automatic focusing system orientating to linear array charge coupled device (CCD)
CN115835016B (en) Open-loop type automatic focusing method, device, equipment and medium for radiation-resistant camera
CN102116608A (en) Method and device for measuring axial displacement by using one-dimensional peaks and valleys as characteristic
CN102095374B (en) Method and device for measuring displacement along optical axis direction by using peaks and valleys of three primary colors as characteristics
CN102116605A (en) Method and device for measuring axial displacement by taking one-dimensional contrast of three primary colors as feature
CN102102980B (en) Method and device for measuring axial displacement by using sing primary color contrast as characteristic
CN205920270U (en) A dynamic focusing mechanism for high -speed microscan
CN108875124A (en) Extract the maximum backoff algorithm of confocal axial response curve peak position
CN113028997B (en) Method, device and equipment for measuring travel allowance of lens group and storage medium
CN114727095A (en) Autofocus Error Calibration Implementation Method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20130612

Termination date: 20141230

EXPY Termination of patent right or utility model