TW201027157A - System and method for focusing on multiple surface of an object - Google Patents

System and method for focusing on multiple surface of an object Download PDF

Info

Publication number
TW201027157A
TW201027157A TW98100629A TW98100629A TW201027157A TW 201027157 A TW201027157 A TW 201027157A TW 98100629 A TW98100629 A TW 98100629A TW 98100629 A TW98100629 A TW 98100629A TW 201027157 A TW201027157 A TW 201027157A
Authority
TW
Taiwan
Prior art keywords
image
array
focus
ccd lens
axis
Prior art date
Application number
TW98100629A
Other languages
Chinese (zh)
Other versions
TWI459063B (en
Inventor
Chih-Kuang Chang
Xian-Yi Chen
Li Jiang
Zhong-Kui Yuan
Xiao-Guang Xue
Original Assignee
Hon Hai Prec Ind Co Ltd
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 Hon Hai Prec Ind Co Ltd filed Critical Hon Hai Prec Ind Co Ltd
Priority to TW098100629A priority Critical patent/TWI459063B/en
Publication of TW201027157A publication Critical patent/TW201027157A/en
Application granted granted Critical
Publication of TWI459063B publication Critical patent/TWI459063B/en

Links

Landscapes

  • Automatic Focus Adjustment (AREA)
  • Length Measuring Devices By Optical Means (AREA)

Abstract

The present invention provides a method for focusing on multiple surface of an object. The method includes: selecting a surface to be focused on from an image of an object to be measured, a focus position of the selected surface, and a focus area of the selected surface; searching a rough focal point; moving a CCD lens in a specified distance, obtaining the image of the object to be measured and an Z-axis coordinates of the CCD lens; calculating a definition of each obtained image at the focus area; filtering the definition of the obtained image and the Z-axis coordinates of the CCD lens; ordering the filtered Z-axis coordinates of the CCD lens, so as to obtain new Z-axis coordinates of the CCD lens and new definition of each obtained image; calculating an accurate focal point according to the selected surface to be focused, the new Z-axis coordinates and the new definitions; moving the CCD lens to the accurate focal point. A system for focusing on multiple surface of an object is also provided. The present invention can focus on a selected surface of an object to be measured.

Description

201027157 * 六、發明說明: . 【發明所屬之技術領域】 本發明涉及一種影像量測系統及方法,尤其涉及一種 多重表面對焦系統及方法。 * 【先前技術】 影像量測是目前精密量測領域中最廣泛使用的量測 方法,該方法不僅精度高,而且量測速度快。影像量測主 ❹要用於工件(零件或者部件)的尺寸誤差和形位誤差的測 罝,對保證產品品質起著重要的作用。 一般而言’影像量測方法是採用影像量測機台,如 VMS (Vision Measuring System),擷取待測工件的影像, 然後將獲取的工件影像傳送給主機,透過主機中的量測軟 體對工件影像做進一步的處理。 在測量待測工件的輪廓或表面高度前,通常需要進行 影像對焦’使得待測工件的表面到CCd (Charge Coupled ❿ Device)鏡頭的距離等於焦距。之前的影像自動對焦方法 為·在一定範圍内移動CCD鏡頭,並不斷獲取待測工件上 表面的影像’然後根據獲取的影像資料計算出CCD鏡頭的 焦點位置。但是,這種方法不能區分待測工件上表面的影 像和下表面的影像,如果待測工件為透明的薄件,則利用 &種方法自動對焦時,待測工件的上、下兩個表面的影像 都有可能被CCD鏡頭獲取,導致計算出的CCD鏡頭的焦 點位置不準確。例如,本應該將CCD鏡頭對焦到上表面, 對焦結果卻是下表面,或本應該將CCD鏡頭對焦到下表 201027157 面,對焦結果卻是上表面。 【發明内容】 鑒於以上内容,有必 方法,其可自㈣“k 多重表面對焦系統及 一定的待測工件表面進行對焦。 夕 面對焦系統’包括主機和影像量測機a 所述主機包括:選握槿細m j豕篁利機台, ^^ , 、、’ ,用於在影像量測機台截取的待 測工件的景,像中選擇對焦㈣ 政料隹μ〜m 对焦位置及對焦範圍;粗 ❹ 用於控制影像量測機台的 : 粗略的焦點位置;精確對隹 砂軔哥找 組略的隹w…: 用於控制c c D鏡頭以該 從下至上在設定的精確距離内沿z轴方向 不斷截取待測工件的影像及CCD 、 不,所述糈確對焦模組,還用於對每個所截 取的待測轉的影像,以所選對焦位置為中心,選取所述 對焦範圍大小的區域’計算出該區域的料度作為該影像 的清晰度;資㈣理模組1於根據均值過錢算法對彩 像清晰度及對應CCD鏡頭的ζ軸座標進行過濾;所述資 料處理模組,還用於對過濾後的CCD鏡頭的ζ轴座標進 行等距細化,得到新的2軸座標及新的影像清晰度;所述 精確對焦模組,還用於根據選擇的對焦表面、新的ζ軸庫 標及新的影像清晰度,計算出精確的焦點位置,將ccx> 鏡頭移到該精確的焦點位置。 一種多重表面對焦方法,該方法包括如下步驟:在影 像量測機台截取的待測工件的影像中選擇對焦表面、對焦 位置及對焦範圍;控制影像量測機台的CCD鏡頭移動尋找 5 201027157 粗略的焦點位置;控制CCD鏡頭以該教敗从a 、、冗的焦點位置為中 心,在设疋的精確距離内沿Z軸方向從卞至上進一動 卜· ^2軸座標;掛 母個所戴取的待測工件的影像,以所選 ’、 了展位置為中心, 選取所述對焦範圍大小的區域,計算出諸 為該影像的清晰度;根據均值過濾演算法對 對應CCD鏡頭的Z軸座標進行過滤;對過據後的CCD鏡 頭的Z軸座標進行等距細化,得到新的Z軸座標及新的影 像清晰度;根據選擇的對焦表面、新的Z轴座標及新的影 像清晰度,計算出精確的焦點位置;將CCD鏡頭移到精確 的焦點位置。 相較於習知技術’所述的多重表面對焦系統及方法, 其可對指定的待測工件表面進行對焦,提尚了影像對焦的 準確性。 【實施方式】201027157 * VI. Description of the Invention: [Technical Field] The present invention relates to an image measuring system and method, and more particularly to a multiple surface focusing system and method. * [Prior Art] Image measurement is currently the most widely used measurement method in the field of precision measurement. This method not only has high precision, but also has fast measurement speed. Image measurement is used to measure the dimensional error and shape error of the workpiece (part or part), which plays an important role in ensuring product quality. In general, the image measurement method uses an image measuring machine, such as VMS (Vision Measuring System), to capture the image of the workpiece to be tested, and then transmits the acquired workpiece image to the host through the measurement software pair in the host. The workpiece image is further processed. Before measuring the contour or surface height of the workpiece to be tested, it is usually necessary to perform image focusing 'the distance of the surface of the workpiece to be tested to the CCd (Charge Coupled ❿ Device) lens is equal to the focal length. The previous image autofocus method was to move the CCD lens within a certain range and continuously acquire the image of the upper surface of the workpiece to be tested, and then calculate the focus position of the CCD lens based on the acquired image data. However, this method cannot distinguish between the image of the upper surface of the workpiece to be tested and the image of the lower surface. If the workpiece to be tested is a transparent thin piece, the upper and lower surfaces of the workpiece to be tested are automatically focused by the & method. The image may be acquired by the CCD lens, resulting in an inaccurate focus position of the calculated CCD lens. For example, the CCD lens should be focused on the upper surface, but the result of the focus is the lower surface, or the CCD lens should be focused on the surface of the table below 201027157, but the result is the upper surface. SUMMARY OF THE INVENTION In view of the above, there is a method that can be focused from (4) "k multi-surface focusing system and a certain surface of the workpiece to be tested. The evening surface focusing system" includes a host computer and an image measuring machine a. The host includes: Select the fine mj profit machine, ^^ , , , ' for the scene of the workpiece to be tested taken in the image measuring machine, select the focus in the image (4) Zheng 隹μ~m focus position and focus range ; Rough ❹ Used to control the image measuring machine: Rough focus position; Accurately find the 隹w... for controlling the cc D lens: The z-axis direction continuously intercepts the image of the workpiece to be tested and the CCD, and the correct focus module is also used to select each of the captured images to be measured, centering on the selected focus position, and selecting the focus range The size of the area 'calculates the area of the area as the sharpness of the image; the capital (four) rational module 1 filters the sharpness of the color image and the axis coordinates of the corresponding CCD lens according to the mean value over money algorithm; Module, also used Performing equidistant refinement on the ζ-axis coordinates of the filtered CCD lens to obtain a new 2-axis coordinate and new image definition; the precise focus module is also used according to the selected focus surface, the new ζ axis The library mark and the new image sharpness, calculate the precise focus position, and move the ccx> lens to the precise focus position. A multi-surface focusing method, the method includes the following steps: the sample to be taken at the image measuring machine Select the focus surface, focus position and focus range in the image of the workpiece; control the CCD lens movement of the image measuring machine to find 5 201027157 rough focus position; control the CCD lens to focus on the a focus from the focus position of the CCD In the precise distance of the setting, the Z-axis coordinate is moved from the 卞 to the top in the Z-axis direction; the image of the workpiece to be tested taken by the hanging mother is selected with the selected 'and the extended position as the center. The area of the range is calculated, and the resolution of the image is calculated; the Z-axis coordinate of the corresponding CCD lens is filtered according to the mean filtering algorithm; and the Z-axis coordinate of the CCD lens after the passing is performed. Isometric refinement, new Z-axis coordinates and new image sharpness; accurate focus position based on selected focus surface, new Z-axis coordinates and new image sharpness; moving CCD lens to precise Focus position. Compared with the multi-surface focusing system and method described in the prior art, it can focus on the surface of the workpiece to be tested, and the accuracy of image focusing is improved.

參閱圖1所示,係本發明多重表面對焦系統較佳實施 方式的系統架構圖。該系統主要包括顯系設備1、主機2、 影像量測機台3和輸入設備4。所述主機2包括儲存體20 和表面對焦草元21 ° 其中,所述影像量測機台3的組成參閱圖2所示,該 影像量測機合3在X軸、Y轴和z軸方向均女裝有馬達(圖 2中未示出),其主要組成部分包括機合頂蓋31、CCD鏡 頭32、機台少作面33和機台主體34,所述機台工作面33 上放置有待剁>件35。所述CCD鏡頭32用於攝取待測工 201027157 件35的影像(包柘住 影像),並將攝取的〒ϋ件上表面的影像和/威下表面的 所述儲存體2〇 3送到主機2° 對焦資料22。所述對主機2中的硬碟等,用於儲存 清晰度及CCD鏡頭3;、的包括待測工件35的影像的 另外,在CCD鏡頭π# ^等。 元21透過控制又轴^對焦過程中,所述表面對焦單Referring to Figure 1, there is shown a system architecture diagram of a preferred embodiment of the multiple surface focusing system of the present invention. The system mainly includes a display device 1, a host 2, an image measuring machine 3 and an input device 4. The main body 2 includes a storage body 20 and a surface focusing grass unit 21 °. The composition of the image measuring machine 3 is shown in FIG. 2, and the image measuring machine is combined in the X-axis, the Y-axis, and the z-axis direction. Each of the women's wear has a motor (not shown in FIG. 2), and the main components thereof include a machined top cover 31, a CCD lens 32, a machine less face 33, and a machine main body 34, which are placed on the machine work surface 33. Pending 剁> piece 35. The CCD lens 32 is configured to take an image of the workpiece 201010157 35 (including the image), and send the image of the upper surface of the captured object and the storage body 2〇3 of the lower surface to the host. 2° Focus data 22. The hard disk or the like in the host 2 is used for storing the image of the sharpness and the CCD lens 3; and the image of the workpiece 35 to be tested, in addition to the CCD lens π#^. Element 21 through the control and the axis ^ focus process, the surface focus sheet

^i® u / y t達和Y軸馬達的移動,進而改變機 口工作面33在X軸和γ Υ轴方向即水準方向)上==(本實施方式中的χ轴和 到粗略的焦點位置。然t γ _CCD _32移動 .^ . . U 、、、灸,表面對焦單元21控制Z轴馬 % # ^的移動使得該01^鏡頭32準確對焦到待 測工件35的上表面或下表面。 』行 ^述主機2連接有顯示設備i,用於顯示影像量測機 口 ^傳送給主機2的影像等。所述輸域備4可以是鍵盤 和滑鼠等,用於進行資料登錄。 所述表面對焦單元21包括墀擇模組21〇、粗略對焦模 組211、精確對焦模組212和資料處理模組Μ%本發明所 稱的模組是完成-特定功能的電齡式段,比程式更適合 於描述軟體在電腦中的執行過程,因此在本發明以下對^ 體描述都以模組描述。 所述選擇模組210用於在影像量測機台3截取的待測 工件35的影像中選擇對焦表面、對焦位置及對焦範圍。在 本實施方式中,對焦表面包括待測工件35的上表面和下表 面,對焦範圍的長度為W、寬度為η(例如,取貿為3〇mm, 201027157 Η 為 20mm)。 …所述粗略對焦模組211用於控制ccd鏡頭& 〇 哥找粗略的焦點位置。具體而言,粗略對焦模組 咖鏡頭32以所選對焦位置為中心,在設定的粗略= 内(該粗略距離可以根據量测需求進行設定,如2離 沿Z軸方向從上至下進行移動,並不斷戴取待測工件^ 的影像及CCD鏡頭32的Z轴座標。然後,對每個 的待測工件35的影像,以所選對焦位置為t心,選取2 範圍(W*H)大小的區域,計算出該區域的清晰度作為t 影像的清晰度。最後,粗略對焦模組211選取清晰度值最 大的影像對應的Ζ軸座標作為粗略的焦點位置。其中,影 像對應的Ζ轴越是指:該影像被截取時,對應CCD鏡 頭32的Z轴座標。 參閱圖3所示’係本發明計算影像清晰度的示意圖。 假設P(i,j)代表影像中的-個圖元點,D(i,j)代表該圖元點 〇 的清晰度,則以1,j) = Abs(Gray(i+l,j) _ Grayd J·)) + AbS(Gray(i,j + l)_Gray(i,H))。其中,Abs〇表示取絕對值 函數,Gray(i,j)表不圖元點P(i,j)的灰度值。將對焦範圍 (W*H )内所有圖元點的清晰度相加得到Def au = ^^D(i, j),然後除以對焦範圍内的圖元點個數,得到一個平均值, 作為該影像的清晰度。 所述精確對焦模組212用於控制CCD鏡頭以該粗 略的焦點位置為中心,在設定的精確距離内(該精確距離 小於上述粗略距離,可以根據量測需求進行設定,如 8 201027157 10mm)沿z轴方向從下至上進行移動,並不斷截取待測 .工件35的影像及CCD鏡頭32的Z軸座標。然後,對每 個所戴取的待測工件35的影像,以選擇模組21〇選擇的對 焦位置為中心,選取對焦範圍(W*H)大小的區域,計算 出該區域的清晰度作為該影像的清晰度。其中,精確對焦 模組212將計算出的影像清晰度儲存在陣列D中(從D[〇] 開始)’ CCD鏡頭32的Z軸座標儲存在陣列z中(從z[〇] ❹開始),母個影像的清晰度和對應CCD鏡頭32的Z轴座 標在陣列D和陣列z中的索引位置相同。例如,第三個影 像的清晰度儲存於D[2]中(索引位置為2),則第三個影像 對應的CCD鏡頭32的Z轴座標儲存於z[2]中(索引位置 為2)。在本實施方式中,如果陣列〇和z的元素個數小 於7 ’則返回對焦失敗資訊。 所述資料處理模組213用於根據均值過濾演算法對精 確對焦模組212計算出的影像清晰度及對應ccd鏡頭32 ❹ 的Z軸座標進行過濾,並以過濾後的資料更新陣列D和陣 列Z。在本實施中’所述對影像清晰度及對應CCD鏡頭 32的Z軸座標進行過濾是指:對影像清晰度的數值及對應 CCD鏡頭32的z軸座標值進行過濾。參閱圖4所示,係 本發明根據均值過濾演算法對影像清晰度進行過濾的示意 圖。圖4a中陣列D儲存的是過濾前的影像清晰度,依次 為 D[0] = 10 ’ D[l] = 12 ’ D[2] = 14,D[3] = 13,D[4] = 12, D[5] = 14 ’ D[6] = 13,D[7] = 15,d[8] = 14。圖 4b 中陣 列D1儲存的是過濾後的影像清晰度。根據均值過濾演算 201027157 法,陣列D中某一元素新的大小=(該元素前η個元素的大 小+該元素的大小+該元素後η個元素的大小)/(參與計算的 元素總個數),其中,第一個元素和最後一個元素大小不變。 在本實施方式中,取π=1 ’則陣列〇中某一元素新的 大小=(該元素前一個元素的大小+該元素的大小+該元素 後一個元素的大小)/3,由此可知,di[1] = (D[0] + D[l] + D[2])/3=12,Dl[2] = (D[l] + D[2] + D[3])/3 = 13,Dl[3]= ❹(D[2] + D[3] + D[4])/3=13.·..依此類推,可以計算出 〇1[4]= 13 ’ Dl[5] = 13,Dl[6] = 14 ’ Dl[7] = 14,D1[0]和 Dl[8] 大小不變,即D1[0] =D[0],Dl[8] = D[8]。然後,以陣列 D1的資料更新陣列D的資料。同理,根據均值過濾演算 法可以對CCD鏡頭32的Z軸座標進行過濾,具體過程同 影像清晰度的過濾° 所述資料處理模組213還用於對過濾後的CCD鏡頭 32的Z軸座標進行等距細化,得到新的Z轴座標及新的影 &像清晰度’並以新的資料更新陣列D和陣列Z。 參聞圖5所示,係本發明對CCD鏡頭32的Z軸座標 進行等距細化的示意圖。在坐標系Z-D中,橫軸Z代表 CCD鐃頭32的Z轴座標,縱轴D代表影像清晰度。所述 等距細化是指:在Z轴上,從第一個座標開始,每隔一定 距離,取新的z值’即得到新的z轴座標,記為陣列Z2 ; 然後,根據新的Z軸座標計算出新的影像清晰度,記為陣 列D2 ;最後,以陣列Z2的資料更新陣列Z的資料,以陣 列D2的資料更新陣列D的資料。舉例而言,第7個新的 201027157 ‘ Z軸座標Z2[6]對應新的影像清晰度D2[6]計算過程為:先 從陣列Z中求出Z[i],使得Z[i]SZ2[6]且Z[i+l]2Z2[6],在 圖5中即為Z[7] (Z[7]<Z2[6]且Z[8]>Z2[6]);然後連接點 (Z[7],D[7])和(Z[8],D[8])得到一條直線,計算該直線與直 • 線z=Z2[6]的交點,交點的縱坐標即D2[6]的值。 ‘ 所述精確對焦模組212還用於根據選擇的對焦表面、 新的Z軸座標及新的影像清晰度,計算出精確的焦點位 ❹ 置,並將CCD鏡頭32移到精確的焦點位置。其中,計算 精確焦點位置的流程如下所述。 首先,精確對焦模組212從陣列D中選取最大值 Dmax,在本實施方式中’ Dmax大於3,如果Dmax小於 等於3,則返回對焦失敗資訊。然後,根據選擇的對焦表 面在陣列D中逆序或順序搜索一個大於Dmax/3且大於3 的局部極大值點Df,對應索引位置為lndexf。具體而言, 如果選擇的對焦表面是上表面,則在陣列D中逆序搜索一 ❿ 個大於Dmax/3且大於3的局部極大值點Df ;如果選擇的 對焦表面是下表面’則在陣列D中順序搜索一個大於 Dmax/3且大於3的局部極大值點Df。所述局部極大值點 是指:該點的數值大於等於前m個資料的值和後m個資料 的值,在本實施方式中,取m=2。 精確對焦模組212再以lndexf為中心,分別逆序/順序 搜索陣列D獲取局部極小值點DminL和DminR,對應索 引位置分別為IndexL和IndexR。所述局部極小值點是指: 該點的數值小於等於前m個資料的值和後m個資料的值, 11 201027157 在本實知方式中’取m=2。如果DminL<DminR,則以Indexf 為中心’逆序搜索陣列D直到D[i]>DminR,D[i-l]<DminR 時結束搜索’其中,IndexL=i ;如果Dmini^DminR,則以 Indexf為中心,順序搜索陣列〇直到D[i]>DminR, D[i+l]<DminR 時結束搜索,其中,IndexR=i。 接著’精確對焦模組212在Z-D坐標系中,將IndexL 與IndexR之間的點連線,點indexL與點indexR連線,形^i® u / yt and the movement of the Y-axis motor, thereby changing the machine face 33 in the X-axis and γ-axis directions, ie, the level direction) == (the χ axis and the rough focus position in this embodiment) However, t γ _CCD _32 moves .^ . . . , U., moxibustion, and the surface focusing unit 21 controls the movement of the Z-axis horse % # ^ so that the 01 lens 16 is accurately focused on the upper surface or the lower surface of the workpiece 35 to be tested. The display unit i is connected to the display device i for displaying an image of the image measuring machine port ^ transmitted to the host 2. The input area 4 can be a keyboard, a mouse, etc., for data registration. The surface focusing unit 21 includes a selection module 21〇, a coarse focusing module 211, a precision focusing module 212, and a data processing module. The module referred to in the present invention is a complete-specific function of the age-old segment. The program is more suitable for describing the execution process of the software in the computer, so the following description of the present invention is described by a module. The selection module 210 is used for the workpiece 35 to be tested taken by the image measuring machine 3. The focus surface, the focus position, and the focus range are selected in the image. In this embodiment The focusing surface includes an upper surface and a lower surface of the workpiece 35 to be tested, the length of the focusing range is W, and the width is η (for example, 3 〇mm, 201027157 Η is 20 mm). The coarse focusing module 211 is used for Control the ccd lens & 〇哥 to find a rough focus position. Specifically, the coarse focus module lens 32 is centered on the selected focus position, within the set rough = within (the rough distance can be set according to the measurement requirements, For example, 2 moves from top to bottom along the Z-axis direction, and continuously wears the image of the workpiece to be tested and the Z-axis coordinate of the CCD lens 32. Then, for each image of the workpiece 35 to be tested, the selected focus is selected. The position is t center, and the area of 2 range (W*H) is selected, and the sharpness of the area is calculated as the sharpness of the t image. Finally, the coarse focus module 211 selects the axis coordinate corresponding to the image with the largest sharpness value. As a rough focus position, the more the corresponding Ζ axis of the image refers to the Z-axis coordinate of the CCD lens 32 when the image is intercepted. Referring to Figure 3, the schematic diagram of calculating the image sharpness of the present invention is assumed. (i,j) generation - a primitive point in the image, D(i,j) represents the sharpness of the point of the primitive, then 1,j) = Abs(Gray(i+l,j) _ Grayd J·)) + AbS (Gray(i, j + l)_Gray(i, H)). Among them, Abs〇 represents the absolute value function, and Gray(i,j) represents the gray value of the primitive point P(i,j). Add the sharpness of all the feature points in the focus range (W*H) to get Def au = ^^D(i, j), and then divide by the number of primitive points in the focus range to get an average value. The sharpness of the image. The precise focus module 212 is configured to control the CCD lens to be centered on the coarse focus position within a set precise distance (the precise distance is less than the rough distance, and can be set according to the measurement requirement, such as 8 201027157 10 mm) The z-axis direction is moved from bottom to top, and the image of the workpiece 35 and the Z-axis coordinate of the CCD lens 32 are continuously intercepted. Then, for each image of the workpiece 35 to be tested, with the focus position selected by the selection module 21 为 as the center, the area of the focus range (W*H) is selected, and the sharpness of the area is calculated as the image. The clarity. Wherein, the precision focusing module 212 stores the calculated image sharpness in the array D (starting from D[〇]). The Z-axis coordinate of the CCD lens 32 is stored in the array z (starting from z[〇] )). The sharpness of the parent image and the Z-axis coordinate of the corresponding CCD lens 32 are the same in the index positions of the array D and the array z. For example, if the sharpness of the third image is stored in D[2] (index position is 2), the Z-axis coordinate of the CCD lens 32 corresponding to the third image is stored in z[2] (index position is 2). . In the present embodiment, if the number of elements of the arrays z and z is less than 7 ′, the focus failure information is returned. The data processing module 213 is configured to filter the image resolution calculated by the precise focus module 212 and the Z-axis coordinate of the corresponding ccd lens 32 根据 according to the mean filtering algorithm, and update the array D and the array with the filtered data. Z. In the present embodiment, filtering the image sharpness and the Z-axis coordinate of the corresponding CCD lens 32 means filtering the value of the image sharpness and the z-axis coordinate value corresponding to the CCD lens 32. Referring to Figure 4, there is shown a schematic diagram of the present invention for filtering image sharpness based on a mean filtering algorithm. In Figure 4a, array D stores the image sharpness before filtering, which is D[0] = 10 ' D[l] = 12 ' D[2] = 14, D[3] = 13, D[4] = 12, D[5] = 14 ' D[6] = 13, D[7] = 15, d[8] = 14. Array D1 in Figure 4b stores the filtered image clarity. According to the mean filtering algorithm 201027157, the new size of an element in array D = (the size of the first n elements of the element + the size of the element + the size of the η elements after the element) / (the total number of elements participating in the calculation) ), where the first element and the last element are the same size. In the present embodiment, taking π=1 'the new size of an element in the array = = (the size of the element before the element + the size of the element + the size of the element after the element) / 3, thereby knowing ,di[1] = (D[0] + D[l] + D[2])/3=12, Dl[2] = (D[l] + D[2] + D[3])/3 = 13, Dl[3]= ❹(D[2] + D[3] + D[4])/3=13.·.. and so on, you can calculate 〇1[4]= 13 ' Dl[ 5] = 13, Dl[6] = 14 ' Dl[7] = 14, D1[0] and Dl[8] are the same size, ie D1[0] = D[0], Dl[8] = D[ 8]. Then, the data of the array D is updated with the data of the array D1. Similarly, according to the mean filtering algorithm, the Z-axis coordinate of the CCD lens 32 can be filtered, and the specific process is filtered with the image sharpness. The data processing module 213 is also used for the Z-axis coordinate of the filtered CCD lens 32. Perform equidistant refinement to get new Z-axis coordinates and new shadow & image clarity and update array D and array Z with new data. As shown in Fig. 5, the present invention is a schematic diagram of isometric refinement of the Z-axis coordinate of the CCD lens 32. In the coordinate system Z-D, the horizontal axis Z represents the Z-axis coordinate of the CCD head 32, and the vertical axis D represents image sharpness. The isometric refinement means that on the Z axis, starting from the first coordinate, taking a new z value at a certain distance, a new z-axis coordinate is obtained, which is recorded as an array Z2; then, according to the new The Z-axis coordinates calculate the new image definition, which is recorded as array D2. Finally, the data of array Z is updated with the data of array Z2, and the data of array D is updated with the data of array D2. For example, the 7th new 201027157 'Z-axis coordinate Z2[6] corresponds to the new image definition D2[6]. The calculation process is: first find Z[i] from the array Z, so that Z[i]SZ2 [6] and Z[i+l]2Z2[6], which is Z[7] (Z[7]<Z2[6] and Z[8]>Z2[6]) in Fig. 5; The connecting points (Z[7], D[7]) and (Z[8], D[8]) get a straight line, and calculate the intersection of the straight line and the straight line z=Z2[6]. The ordinate of the intersection point is The value of D2[6]. The precision focus module 212 is also used to calculate an accurate focus position based on the selected focus surface, the new Z-axis coordinate, and the new image sharpness, and to move the CCD lens 32 to the precise focus position. Among them, the process of calculating the precise focus position is as follows. First, the precision focusing module 212 selects the maximum value Dmax from the array D. In the present embodiment, 'Dmax is greater than 3, and if Dmax is less than or equal to 3, the focus failure information is returned. Then, a local maximum point Df greater than Dmax/3 and greater than 3 is searched in the array D in reverse or sequentially according to the selected focus surface, and the corresponding index position is lndexf. Specifically, if the selected focus surface is the upper surface, a series of local maximum point Df greater than Dmax/3 and greater than 3 is searched in reverse in array D; if the selected focus surface is the lower surface, then array D The middle search sequentially searches for a local maximum point Df greater than Dmax/3 and greater than 3. The local maximum point means that the value of the point is greater than or equal to the value of the first m pieces of data and the value of the last m pieces of data. In the present embodiment, m=2 is taken. The precise focus module 212 further searches the array D in reverse/sequentially with lndexf as the center to obtain the local minimum points DminL and DminR, and the corresponding index positions are IndexL and IndexR, respectively. The local minimum point means that the value of the point is less than or equal to the value of the first m pieces of data and the value of the last m pieces of data, 11 201027157 in the presently known mode, taking m=2. If DminL<DminR, then search for array D in the reverse order from Indexf until D[i]>DminR, D[il]<DminR ends searching 'where IndexL=i; if Dmini^DminR, then Indexf is Center, sequentially searches the array 〇 until D[i]>DminR, D[i+l]<DminR, and ends the search, where IndexR=i. Then the precision focusing module 212 connects the point between IndexL and IndexR in the Z-D coordinate system, and the point indexL is connected with the point indexR.

0 成閉合區域CR(參閱圖6所示),求midZ使得直線z=midZ 將閉合區域CR平分,該焦點位置midz即為精確的焦點位 置。 參閱圖7所示,係本發明計算閉合區域CR平分線 z=midZ的示意圖。其中,閉合區域cr由三角形Tril和 Tri2、梯形Tral、Tra2…Tra(n)組成,則閉合區域CR總的 面積:Area-A = Tril + Tral + Tra2 + …+Tra(n) + Tri2。 令 i=l 到 n,逐個代入公式:Area-L(i)=Tril+Tral+Tra2 ❹ + …+Tra(i) ’ 當 Area-L(i)$Area-A/2 且 Area-L(i+l)>Area-A/2 時停止代入,並令f=i,l=i-l,r=i+l。 因此,閉合區域CR在梯形Tra(f)左邊的面積: Area-L(l) = Tril + Tral + Tra2 + ... Tra(l); 且閉合區域CR在梯形Tra(f)右邊的面積:0 becomes the closed area CR (see Fig. 6), and the midZ is made such that the straight line z=midZ bisects the closed area CR, which is the precise focus position. Referring to Figure 7, the present invention calculates a schematic diagram of the closed region CR bisector z = midZ. Wherein, the closed region cr is composed of triangles Tril and Tri2, trapezoidal Tral, Tra2...Tra(n), and the total area of the closed region CR is: Area-A = Tril + Tral + Tra2 + ... + Tra(n) + Tri2. Let i=l to n and substitute the formulas one by one: Area-L(i)=Tril+Tral+Tra2 ❹ + ...+Tra(i) ' When Area-L(i)$Area-A/2 and Area-L( When i+l)>Area-A/2, the substitution is stopped, and f=i, l=il, r=i+l. Therefore, the area of the closed region CR to the left of the trapezoidal Tra(f): Area-L(l) = Tril + Tral + Tra2 + ... Tra(l); and the area of the closed region CR to the right of the trapezoid Tra(f):

Area-R(r) = Tri2 + Tra(r) + Tra(r+1) + ... + Tra(n)。 並且:Area-L(l) + Area-R(r) + Tra(f) = Area-A, Area-L(l) < Area-R(r) + Tra(f),Area-R(r) = Tri2 + Tra(r) + Tra(r+1) + ... + Tra(n). And: Area-L(l) + Area-R(r) + Tra(f) = Area-A, Area-L(l) < Area-R(r) + Tra(f),

Area-R(r) < Area-L(l) + Tra(f)。 12 201027157 平分閉合區域CR的直線z=midZ穿過梯形Tra(f),根 據點(Z[f],D[f])和點(Z[f+1],D[f+1])求得直線 y = k*x+b, 因此, (1) (2) (3) midD = k*midZ + b • 梯形Tra(f)在直線z=midZ左邊面積: ‘ AL = (midD+D[f])*(midZ-Z[f])/2 梯形Tra(f)在直線z=midZ右邊面積: AR= (midD+D[f+l])*(Z[f+l]-midZ)/2 閉合區域CR平分線左邊的面積等於右邊的面積: Area-L(l)+AL = Area-R(r) + AR ⑷ 將式(1)代入式(2)和式(3),再將(2)和(3)代入(4),得到: Area-L(l)+(k*midZ+b+D[f])* (midZ-Z[f])/2= Area-R(r) +(k*midZ+b+D[f+l])*(z[f+l]-midZ)/2,只有一個未知數 midZ,解方程即可求得midZ,使得z=midZ平分閉合區域 CR。 ❿ 參閱圖8所示,係本發明多重表面對焦方法較佳實施 方式的流程圖。首先,步驟S40,透過選擇模組21〇在影 像量測機台3截取的待測工件35的影像中選擇對焦表面、 對焦位置及對焦$2*圍。在本實施方式中,對焦表面包括待 測工件35的上表面和下表面,對焦範圍的長度為w、寬 度為Η。 步驟S41,粗略對焦模組211控制CCD鏡頭32移動 尋找粗略的焦點位置,具體過程如前所述。 步驟S42 ’精確對焦模組212控制CCD鏡頭32以該 13 201027157 粗略的焦點位置為中心’在設定的精確距離内沿z軸方向 從下至上進行移動,並不斷截取待測工件35的影像及CCD 鏡頭32的Z軸座標。Area-R(r) < Area-L(l) + Tra(f). 12 201027157 The straight line z=midZ that divides the closed region CR passes through the trapezoidal Tra(f), according to the point (Z[f], D[f]) and the point (Z[f+1], D[f+1]) The straight line y = k*x+b, therefore, (1) (2) (3) midD = k*midZ + b • The trapezoidal Tra(f) is on the left side of the line z=midZ Area: ' AL = (midD+D[ f])*(midZ-Z[f])/2 Trapezoidal Tra(f) on the straight line z=midZ right area: AR= (midD+D[f+l])*(Z[f+l]-midZ) /2 Closed area The area to the left of the CR bisector is equal to the area on the right: Area-L(l)+AL = Area-R(r) + AR (4) Substituting equation (1) into equations (2) and (3), Substituting (2) and (3) into (4) yields: Area-L(l)+(k*midZ+b+D[f])* (midZ-Z[f])/2= Area-R( r) +(k*midZ+b+D[f+l])*(z[f+l]-midZ)/2, only one unknown midZ, solve the equation to find midZ, so that z=midZ is evenly closed Area CR. Referring to Figure 8, there is shown a flow chart of a preferred embodiment of the multi-surface focusing method of the present invention. First, in step S40, the focus surface, the focus position, and the focus $2* are selected by the selection module 21 〇 in the image of the workpiece 35 to be tested taken by the image measuring machine 3. In the present embodiment, the in-focus surface includes the upper surface and the lower surface of the workpiece 35 to be tested, and the focusing range has a length w and a width of Η. In step S41, the coarse focus module 211 controls the CCD lens 32 to move to find a rough focus position, as described above. Step S42 'The precise focus module 212 controls the CCD lens 32 to move from bottom to top in the z-axis direction within the set precise distance centering on the rough focus position of the 13 201027157, and continuously intercepts the image and CCD of the workpiece 35 to be tested. The Z-axis coordinate of the lens 32.

步驟S43,精確對焦模組211對每個所戴取的待測工 件35的影像,以選擇模組21〇選擇的對焦位置為中心,選 取對焦範圍(W*H)大小的區域,計算出該區域的清晰度 作為該影像的清晰度。其中,精確對焦模組212將計算出 的t/像清晰度儲存在陣列D中(從D[〇]開始),CCD鏡頭 2的Z軸座標儲存在陣列z中(從z[〇]開始),每個影像 的肴晰度和對應CCD鏡頭32的z轴座標在陣列D和陣列 Z中的索引位置相同。在本實施方式中’如果陣列D和z 的元素個數小於7,則返回對焦失敗資訊。 步驟S44 ’資料處理模組213根據均值過濾演算法對 =確對焦模組212計算出的影像清晰度及對應cCD鏡頭 32的Z轴座標進行過濾,並以過濾後的資料更新陣列〇 和陣列Z。具體過程參見圖4的描述。 步驟S45 ’資料處理模組213對過濾後的CCD鏡頭 32= z轴座標進行等距細化,得到新的z轴座標及新的影 像β晰度’並以新的資料更新陣列D和陣列z。具體過程 參見圖5的描述。 步驟S46 ’精確對焦模組212根據選擇的對焦表面、 新的Z轴座標及新的影像清晰度,計算出精確的焦點位 置。其中,計算精確焦點位置的流程如圖9所示。 步驟S47 ’精確對焦模組212將CCD鏡頭32移到精 201027157 確的焦點位置。 . 參閱圖9所示,係本發明中步驟S46中計算精確焦點 位置的具體流程圖。步驟S50,精確對焦模組212從陣列 D中選取最大值Dmax’在本實施方式中,如果Dmax小於 夢 3 ’則直接返回對焦失敗資訊。 步驟S51,根據選擇的對焦表面在陣列D中逆序或順 序搜索一個大於Dmax/3且大於3的局部極大值點Df,對 ❹應索引位置為Indexf。具體而言,如果選擇的對焦表面是 上表面,則在陣列D中逆序搜索一個大於Dmax/3且大於 3的局部極大值點Df;如果選擇的對焦表面是下表面,則 在陣列D中順序搜索一個大於Dmax/3且大於3的局部極 大值點Df。所述局部極大值點是指:該點的數值大於等於 前m個資料的值和後瓜個資料的值在本實施方式中,取 m=2。 步驟S52,精確對焦模組212以Indexf為中心,分別 ❹逆序/順序搜索陣列D獲取局部極小值點DminL和 DminR,對應索引位置分別為IndexL和IndexR。所述局部 極小值點是指:該點的數值小於等於前m個資料的值 m個資料的值,在本實施方式中,取m=2。 步驟S53,精確對焦模組212判斷DminL是否小於 DmmR。如果DminL小於DminR,執行步驟S54,如果In step S43, the precise focus module 211 selects the image of the workpiece 35 to be tested for each of the images to be measured, selects the focus position selected by the module 21, and selects the area of the focus range (W*H) to calculate the area. The sharpness is used as the sharpness of the image. Wherein, the precision focusing module 212 stores the calculated t/image resolution in the array D (starting from D[〇]), and the Z-axis coordinate of the CCD lens 2 is stored in the array z (starting from z[〇]) The resolution of each image and the z-axis coordinate of the corresponding CCD lens 32 are the same in the index positions of the array D and the array Z. In the present embodiment, 'if the number of elements of the arrays D and z is less than 7, the focus failure information is returned. Step S44' The data processing module 213 filters the image resolution calculated by the correct focus module 212 and the Z-axis coordinate of the corresponding cCD lens 32 according to the mean filtering algorithm, and updates the array 阵列 and the array Z with the filtered data. . See the description of Figure 4 for the specific process. Step S45' The data processing module 213 performs equidistant refinement on the filtered CCD lens 32=z-axis coordinates to obtain a new z-axis coordinate and a new image β-degree 'and update the array D and the array with new data. . The specific process is described in the description of FIG. Step S46' precision focus module 212 calculates an accurate focus position based on the selected focus surface, the new Z-axis coordinate, and the new image sharpness. Among them, the process of calculating the precise focus position is shown in FIG. 9. Step S47' The precision focus module 212 moves the CCD lens 32 to the precise focus position of 201027157. Referring to Fig. 9, there is shown a specific flow chart for calculating the precise focus position in step S46 of the present invention. In step S50, the precision focusing module 212 selects the maximum value Dmax' from the array D. In the present embodiment, if the Dmax is smaller than the dream 3', the focus failure information is directly returned. Step S51, searching for a local maximum value point Df greater than Dmax/3 and greater than 3 in reverse or sequential order in the array D according to the selected focusing surface, and the index position of the corresponding index is Indexf. Specifically, if the selected focus surface is the upper surface, a local maximum value point Df greater than Dmax/3 and greater than 3 is reversely searched in the array D; if the selected focus surface is the lower surface, the order is in the array D Search for a local maximum point Df greater than Dmax/3 and greater than 3. The local maximum point means that the value of the point is greater than or equal to the value of the first m pieces of data and the value of the last piece of data. In the present embodiment, m=2. In step S52, the precise focus module 212 takes the indexf as the center, and searches the array D for the local minimum value points DminL and DminR respectively, and the corresponding index positions are IndexL and IndexR, respectively. The local minimum point means that the value of the point is less than or equal to the value of the first m pieces of data, and in the present embodiment, m=2. In step S53, the precision focusing module 212 determines whether DminL is less than DmmR. If DminL is less than DminR, step S54 is performed, if

DminL大於等於DminR,執行步驟S55。 步驟S54,精確對焦模組212以Indexf為中心,逆序 搜索陣列D直到D[i]>DminR、D[M]<DminR時結束搜索, 15 201027157 其中,IndexL=i,然後執行步驟S56。 步驟S55,精確對焦模組212以Indexf為中心,順序 搜索陣列D直到D[i]>DminR、D[i+l]<DminR時結束搜 索’其中,IndexR=i,然後執行步驟S56。 步驟S56,精確對焦模組212在如圖6所示的Z-D坐 標系中’將IndexL與IndexR之間的點連線,點IndexL與 點IndexR連線,形成閉合區域CR,求midZ使得直線 A z=midZ將閉合區域CR平分。其中,計算閉合區域CR平 〇 分線的不意圖參見圖7中的描述,在此不再費述。 步驟S57,精確對焦模組212以該焦點位置midZ作為 精確的焦點位置。 最後應說明的是,以上實施方式僅用以說明本發明的 技術方案而非限制,儘管參照較佳實施方式對本發明進行 了詳細說明,本領域的普通技術人員應當理解,可以對本 發明的技術方案進行修改或等同替換,而不脫離本發明技 ❹ 術方案的精神和範圍。例如,將此方法應用於在清晰的邊 界線上尋找邊界點。 【圖式簡單說明】 圖1係本發明多重表面對焦系統較佳實施方式的系統 架構圖。 圖2係影像量測機台的結構示意圖。 圖3係本發明計算影像清晰度的示意圖。 圖4係本發明根據均值過濾演算法對影像清晰度進行 過遽的示意圖。 16 201027157 圖5係本發明對CCD鏡頭的Z軸座標進行等距細化 的示意圖。 圖6係本發明閉合區域CR的示意圖。 圖7係本發明計算閉合區域CR平分線的示意圖。 圖8係本發明多重表面對焦方法較佳實施方式的流程 圖。 圖9係圖8中步驟計算精確焦點位置的具體流程圖。DminL is greater than or equal to DminR, and step S55 is performed. In step S54, the precision focusing module 212 centers on the indexf, searches the array D in reverse order until D[i]>DminR, D[M]<DminR, and ends the search, 15 201027157, where IndexL=i, and then performs step S56. In step S55, the precision focusing module 212 searches for the array D until D[i]>DminR, D[i+l]<DminR, and searches for the index 'R in the order of Indexf, and then performs step S56. In step S56, the precision focusing module 212 connects the point between IndexL and IndexR in the ZD coordinate system as shown in FIG. 6, and connects the point IndexL and the point IndexR to form a closed region CR, and finds the midZ such that the line Az =midZ divides the closed area CR equally. The calculation of the closed area CR flat line is not described with reference to the description in Fig. 7, and will not be described here. In step S57, the precise focus module 212 uses the focus position midZ as the precise focus position. It should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, and the present invention is not limited thereto. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that Modifications or equivalent substitutions are made without departing from the spirit and scope of the invention. For example, apply this method to find boundary points on a clear boundary line. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a system architecture diagram of a preferred embodiment of a multiple surface focusing system of the present invention. Fig. 2 is a schematic structural view of an image measuring machine. Figure 3 is a schematic illustration of the calculation of image sharpness in accordance with the present invention. Fig. 4 is a schematic diagram showing the image clarity of the image according to the mean filtering algorithm of the present invention. 16 201027157 FIG. 5 is a schematic diagram showing the equidistance refinement of the Z-axis coordinate of the CCD lens according to the present invention. Figure 6 is a schematic illustration of the closed region CR of the present invention. Figure 7 is a schematic illustration of the calculation of the closed region CR bisector in accordance with the present invention. Figure 8 is a flow diagram of a preferred embodiment of the multiple surface focusing method of the present invention. Figure 9 is a detailed flow chart for calculating the precise focus position in the step of Figure 8.

【主要元件符號說明】 顯示設備 1 主機 2 影像量測機台 3 輸入設備 4 儲存體 20 表面對焦單元 21 對焦資料 22 選擇模組 210 粗略對焦模組 211 精確對焦模組 212 資料處理模組 213 選擇對焦表面、對焦位置及對焦範圍 S40 控制CCD鏡頭移動尋找粗略的焦點位置 S41 在設定的距離内移動CCD鏡頭,並不斷截取待測工件 的影像及CCD鏡頭的Z軸座標 S42 S43 在對焦範圍内計算每個影像的清晰度 17 201027157[Main component symbol description] Display device 1 Host 2 Image measuring machine 3 Input device 4 Storage body 20 Surface focusing unit 21 Focus data 22 Selection module 210 Rough focus module 211 Precision focusing module 212 Data processing module 213 Selection Focus surface, focus position and focus range S40 Control CCD lens movement to find rough focus position S41 Move the CCD lens within the set distance and continuously capture the image of the workpiece to be tested and the Z-axis coordinate S42 S43 of the CCD lens in the focus range Sharpness of each image 17 201027157

對影像清晰度及CCD鏡頭的Z軸座標進行過濾S44 對CCD鏡頭的Z軸座標進行等距細化,得到新的Z « 軸座標及新的影像清晰度 S45 根據選擇的對焦表面、新的Z轴座標及新的影像清晰 " 度計算出精確的焦點位置 S46 ' 將CCD鏡頭移到精確的焦點位置 S47Filter the image sharpness and the Z-axis coordinate of the CCD lens. S44 Perform the equidistant refinement of the Z-axis coordinate of the CCD lens to obtain a new Z « axis coordinate and new image sharpness S45. According to the selected focus surface, the new Z Axis coordinates and new image clarity " Degrees calculate the exact focus position S46 ' Move the CCD lens to the precise focus position S47

〇 18〇 18

Claims (1)

201027157 七、申請專利範匿 1 ·一種多重表面對焦方法,該方法包括如下步驟: 在影像量測機台截取的待測工件的影像中選擇對焦表 * 面、對焦位置及對焦範圍; ' 控制影像量測機台的CCD鏡頭移動尋找粗略的焦點位 、 置; 控制CCD鏡頭以該粗略的焦點位置為中心,在設定的精 確距離内沿Z軸方向從下至上進行移動,並不斷截取待 測工件的影像及CCD鏡頭的Z軸座標; 對每個所截取的待測工件的影像,以所選對焦位置為中 心,選取所述對焦範圍大小的區域,計算出該區域的清晰 度作為該影像的清晰度; 根據均值過濾演算法對影像清晰度及對應CCD鏡頭的Z 軸座標進行過濾; 對過濾後的CCD鏡頭的Z軸座標進行等距細化,得到新 〇 的Z軸座標及新的影像清晰度; 根據選擇的對焦表面、新的Z軸座標及新的影像清晰度, 計算出精確的焦點位置;及 將CCD鏡頭移到精確的焦點位置。 2·如申請專利範圍第1項所述之多重表面對焦方法,其 中,所述對焦表面包括待測工件的上表面和下表面。 3 ·如申請專利範圍第1項所述之多重表面對焦方法,其 中,所述待測工件的影像及對應CCD鏡頭的Z軸座標分 別儲存於陣列D和陣列Z中,每個影像的清晰度和對應 19 201027157 CCD鏡頭的Z轴座標在陣列D和陣列Z中的索引位置相 同。 ‘巾/專利範第3項所述之多重表面對焦方法,其 --斤述句值過濾演算法是指:陣列D或陣列Z中某— 兀素新的大小=(該元素冑η個元素的大小+該元素的大小 +該%素後11個元素的大仰(參與計算的元♦總個數),其 中’第-個元素和最後一個元素大小不變。 ❹5 *巾1專利_第3項所述之多重表面對焦方法,其 中,所^等距細化是指:以陣列Ζ和陣列D建立坐標系 Z D 軸Ζ代表CCD鏡頭的ζ軸座標,縱轴d代表影 像清晰度,在Ζ軸上,從第一個座標開始,每隔一定距 離取新的Ζ值,即得到新的2轴座標。 如_請專利範圍第5項所述之多重表面對焦方法其 中,所述步驟計算精確焦點位置包括: 、 從陣列D中選取最大值Dmax,且D_大於3 ; ❹根據選擇的對焦表面在陣列D中逆序或順序搜索一個大 於Dmax/3且大於3的局部極大值點以,對應索引位置為 Indexf ; 以Indexf為中心,分別逆序/順序搜余陣列D獲取局部極 小值點DminL和DminR ’對應索引位置分別為IndexL和 IndexR ; 如果DminL<DminR,則以indexf為中心,逆序搜索陣列 D,直到D[i]>DminR,D[i-l]<DminR時結束搜索,其中, IndexL=i,如果 Dminl^DminR,則以 Ifldexf 為中心,順 20 201027157 序搜索陣列D,直到D[i]>DminR,D[i+l]<DminR時結束 搜索’其中,IndexR=i ;及 在Z-D坐標系中,將IndexL與IndexR之間的點連線,點 IndexL與點in(jexR連線,形成閉合區域cr,求midZ使 得直線z=midZ將閉合區域CR平分,該焦點位置midZ ‘ 即為精確的焦點位置。 7 ·如申請專利範圍第ό項所述之多重表面對焦方法,其 ❹ 中,所述根據選擇的對焦表面在陣列D中逆序或順序搜 索一個大於Dmax/3且大於3的局部極大值點Df的步驟 包括如下步驟: 如果選擇的對焦表面是上表面,則在陣列D中逆序搜索 一個大於Dmax/3且大於3的局部極大值點Df ;及 如果選擇的對焦表面是下表面,則在陣列D中順序搜索 —個大於Dmax/3且大於3的局部極大值點Df。 種多重表面對焦系統,包括主機和影像量測機台, ® 其中,所述主機包括: 選擇模組’用於在影像量測機台截取的待測工件的影像中 選擇對焦表面、對焦位置及對焦範圍; 杈略對焦模組,用於控制影像量測機台的CCD鏡頭移動 尋找粗略的焦點位置; 精確對焦模組,用於控制CCD鏡頭以該粗略的焦點位置 為中心,在設定的精確距離内沿z軸方向從下至上進行 移動,並不斷截取待測工件的影像及cCD鏡頭的z軸座 標; 21 201027157201027157 VII. Patent Application 1 · A multi-surface focusing method, the method includes the following steps: selecting a focus table*, a focus position, and a focus range in an image of a workpiece to be tested captured by the image measuring machine; The CCD lens of the measuring machine moves to find the rough focus position, and the control CCD lens is centered on the rough focus position, moves from bottom to top along the Z-axis direction within the set precise distance, and continuously intercepts the workpiece to be tested. The image and the Z-axis coordinate of the CCD lens; for each image of the workpiece to be measured, centering on the selected focus position, selecting the area of the focus range, and calculating the sharpness of the area as the image clarity Degree; according to the mean filtering algorithm, the image sharpness and the Z-axis coordinate of the corresponding CCD lens are filtered; the Z-axis coordinates of the filtered CCD lens are equidistantly refined to obtain the new Z-axis coordinate and the new image clarity. Degree; calculate the exact focus position based on the selected focus surface, the new Z-axis coordinate and the new image sharpness; and the CCD mirror Move accurate focus position. 2. The multiple surface focusing method of claim 1, wherein the focusing surface comprises an upper surface and a lower surface of the workpiece to be tested. 3. The multi-surface focusing method according to claim 1, wherein the image of the workpiece to be tested and the Z-axis coordinate of the corresponding CCD lens are stored in the array D and the array Z, respectively, and the definition of each image And the Z-axis coordinates of the corresponding 19 201027157 CCD lens are the same in the index positions of array D and array Z. The multi-surface focusing method described in item 3 of the towel/patent model, the method of filtering the sentence value refers to: array D or array Z - the new size of the alizarin = (the element 胄 n elements The size of the element + the size of the element + the back of the 11 elements of the element (the total number of elements involved in the calculation ♦), where 'the first element and the last element size are unchanged. ❹ 5 * towel 1 patent _ 3 The multi-surface focusing method described in the above, wherein the equidistant refinement means that the coordinate system ZD is established by the array Ζ and the array D, the Ζ axis coordinates of the CCD lens, and the vertical axis d represents the image sharpness. On the axis, starting from the first coordinate, taking a new threshold value at a certain distance, that is, obtaining a new 2-axis coordinate. For example, the multi-surface focusing method described in the fifth aspect of the patent scope, wherein the step is accurately calculated The focus position includes: , selecting a maximum value Dmax from the array D, and D_ is greater than 3; 搜索 searching for a local maximum value greater than Dmax/3 and greater than 3 in reverse or sequentially in the array D according to the selected focusing surface, corresponding to The index position is Indexf; with Indexf as the center, respectively /The sequential search array D obtains the local minimum value points DminL and DminR 'the corresponding index positions are IndexL and IndexR respectively; if DminL<DminR, the index D is searched in the reverse order, until D[i]>DminR,D [il]<DminR ends the search, where IndexL=i, if Dminl^DminR, then Ifldexf is centered, and Array 20 is searched for the order of D[i]>DminR, D[i+l] <DminR ends the search 'where IndexR=i; and in the ZD coordinate system, the point between IndexL and IndexR is connected, the point IndexL is connected with the point in (jexR, forming a closed region cr, and the midZ is a straight line z=midZ bisects the closed region CR, which is the precise focus position. 7 · The multiple surface focusing method according to the scope of the patent application, wherein the selected focusing surface is The step of searching for a local maximum point Df greater than Dmax/3 and greater than 3 in the array D in reverse order or sequentially includes the following steps: If the selected focus surface is the upper surface, the reverse search in array D is greater than Dmax/3 and greater than Partial maximum of 3 Value point Df; and if the selected focus surface is the lower surface, sequentially search for a local maximum point Df greater than Dmax/3 and greater than 3 in array D. Multi-surface focusing system, including host and image measuring machine Taiwan, ® wherein the host includes: a selection module 'for selecting a focus surface, a focus position, and a focus range in an image of a workpiece to be tested taken by the image measuring machine; a focusing module for controlling the image The CCD lens of the measuring machine moves to find a rough focus position; the precise focusing module is used to control the CCD lens to move from bottom to top along the z-axis direction within a set precise distance centering on the rough focus position, and Continuously intercept the image of the workpiece to be tested and the z-axis coordinate of the cCD lens; 21 201027157 所述精確對焦模組’還用於 像,j 域’计算出该區域的清晰度作為該影像的ί 資料處理模組’用於根據均值過濾演算法對景 對應CCD鏡頭的Z軸座標進行過據; 1 鏡頭的Z軸 所述資料處理模組,還用於對過滤後的 軸座標及新的影像清晰 座標進行等距細化,得到新的z軸座標及每 度;及 所述精確對焦模組,還用於根據選擇的對焦表面、新的z 轴座標及新的影像清晰度,計算出精確的焦點位置,將 CCD鏡頭移到該精確的焦點位置。 9.如申請專利範圍第8項所述之多重表面對焦系統,其 中’所述對焦表面包括待測工件的上表面和下表面。 10 ·如申請專利範圍第8項所述之多重表面對焦系統,其 中,所述待測工件的影像及對應CCD鏡頭的Ζ轴座標分 〇 別儲存於陣列D和陣列Ζ中,每個影像的清晰度和對應 CCD鏡頭的Ζ轴座標在陣列D和陣列Ζ中的索引位置相 同。 22The precise focus module 'is also used to calculate the sharpness of the area as the image data processing module' for the Z-axis coordinates of the corresponding CCD lens according to the mean filtering algorithm. 1; The data processing module of the Z-axis of the lens is also used for isometric refinement of the filtered axis coordinate and the new image clear coordinate to obtain a new z-axis coordinate and each degree; and the precise focus The module is also used to calculate the exact focus position based on the selected focus surface, the new z-axis coordinate, and the new image sharpness to move the CCD lens to the precise focus position. 9. The multiple surface focusing system of claim 8, wherein the focusing surface comprises an upper surface and a lower surface of the workpiece to be tested. The multi-surface focusing system of claim 8, wherein the image of the workpiece to be tested and the coordinate of the corresponding CCD lens are stored in the array D and the array, each of the images. The sharpness and the axis coordinates of the corresponding CCD lens are the same at the index positions in array D and array 。. twenty two
TW098100629A 2009-01-09 2009-01-09 System and method for focusing on multiple surface of an object TWI459063B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW098100629A TWI459063B (en) 2009-01-09 2009-01-09 System and method for focusing on multiple surface of an object

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW098100629A TWI459063B (en) 2009-01-09 2009-01-09 System and method for focusing on multiple surface of an object

Publications (2)

Publication Number Publication Date
TW201027157A true TW201027157A (en) 2010-07-16
TWI459063B TWI459063B (en) 2014-11-01

Family

ID=44853103

Family Applications (1)

Application Number Title Priority Date Filing Date
TW098100629A TWI459063B (en) 2009-01-09 2009-01-09 System and method for focusing on multiple surface of an object

Country Status (1)

Country Link
TW (1) TWI459063B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9091821B2 (en) 2011-04-26 2015-07-28 Hong Fu Jin Precision Industry (Shenzhen) Co., Ltd. Device and method of focusing on points of objects
CN113406764A (en) * 2021-07-13 2021-09-17 广东弘景光电科技股份有限公司 Optical lens aligning method and system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5790710A (en) * 1991-07-12 1998-08-04 Jeffrey H. Price Autofocus system for scanning microscopy
CN100357779C (en) * 2004-12-17 2007-12-26 鸿富锦精密工业(深圳)有限公司 Automatic image focusing system and method
CN101191980B (en) * 2006-11-27 2010-09-01 亚洲光学股份有限公司 Automatic focusing method

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9091821B2 (en) 2011-04-26 2015-07-28 Hong Fu Jin Precision Industry (Shenzhen) Co., Ltd. Device and method of focusing on points of objects
TWI510761B (en) * 2011-04-26 2015-12-01 Hon Hai Prec Ind Co Ltd System and method for focusing multiple measurement points on a surface of an object
CN113406764A (en) * 2021-07-13 2021-09-17 广东弘景光电科技股份有限公司 Optical lens aligning method and system
CN113406764B (en) * 2021-07-13 2022-01-28 广东弘景光电科技股份有限公司 Optical lens aligning method and system

Also Published As

Publication number Publication date
TWI459063B (en) 2014-11-01

Similar Documents

Publication Publication Date Title
CN101762232B (en) Multi-surface focusing system and method
JP6239232B2 (en) High performance edge focus tool
CN105453136B (en) The three-dimensional system for rolling correction, method and apparatus are carried out using automatic focus feedback
JP6282508B2 (en) Edge detection tool enhanced for edges on uneven surfaces
JP4979928B2 (en) Three-dimensional shape calculation device and three-dimensional shape calculation method
JP6053119B2 (en) Machine vision inspection system and determination method of position measurement result thereof
JP2016061687A (en) Contour line measurement device and robot system
JP6580761B1 (en) Depth acquisition apparatus and method using polarization stereo camera
JP6071257B2 (en) Image processing apparatus, control method therefor, and program
CN101858742A (en) Fixed-focus ranging method based on single camera
CN108981608B (en) Novel line structured light vision system and calibration method
EP3839599A1 (en) Metrology system with transparent workpiece surface mode
TWI510761B (en) System and method for focusing multiple measurement points on a surface of an object
TW201312080A (en) Non-contact method for measuring dimensions of objects
JP2015156011A (en) Image acquisition device and method for controlling the same
TW201027157A (en) System and method for focusing on multiple surface of an object
EP3825649A1 (en) Ranging camera
CN110873717A (en) Image acquisition device and method for operating image acquisition device
JP5814855B2 (en) Charged particle beam adjustment support apparatus and method
JP6746722B2 (en) Method for measuring height of curved surface of microscope slide glass and microscope
JP2015187705A (en) Image acquisition device and method for controlling the same
CN114202490A (en) Wear particle surface reconstruction method based on multi-focus image and related device
JP2014115179A (en) Measuring device, document camera and measuring method
JP2018032144A (en) Image processor, image processing method and program
JP5610579B2 (en) 3D dimension measuring device

Legal Events

Date Code Title Description
MM4A Annulment or lapse of patent due to non-payment of fees