201024892 九、發明說明: 【發明所屬之技術領域】 本發明係有關於影像擷取,特別是有關於一種利用拍 攝物體之成像尺寸進行自動對焦之影像擷取裝置。 【先前技術】 拍攝影像時,準確的對焦為擷取清晰影像的要素之 一。因此,除了手動對焦之外,藉助相機所提供之自動對 • 焦功能,使用者亦可擷取色彩飽及輪廓鮮明的影像。 習知上,自動對焦可透過測距裝置測量物體與鏡頭的 距離,據以調整鏡距來完成。不過,此一方式需要額外之 硬體設計與成本。 或者,於一些習知技術中,可移動鏡頭進行掃瞄,並 擷取相關之影像,將各影像進行頻域轉換後所產生之高頻 分量作為對比度,藉以根據各影像之對比度進行分析,找 出最大對比度所對應之最佳對焦位置,以擷取最清晰之影 Φ 像。然而,反覆移動鏡頭不僅耗時,當欲拍攝物體不明確 時,重複執行之對焦動作亦將導致對焦時間過長。 【發明内容】 有鑑於此,本發明提供自動對焦方法及使用上述方法 之影像擷取裝置。 基於上述目的,本發明實施例提供一種自動對焦方 法,適用於一影像擷取裝置,該影像擷取裝置包括一鏡頭 及一影像感測單元。首先,透過該鏡頭,於該影像感測單 元上擷取一影像。分析該影像,用以決定一主要拍攝物體, 5 201024892 並取得該主要拍攝物體之〆辨識資料,其中,該辨識資料 係用以取得對應於該主要拍攝物體之一成像設定值。接 著,根據該影像計算該主要拍攝物體成像於該影像感測單 元上之一成像尺寸。根據该成像尺寸、該成像設定值之一 參考尺寸及一既定像距,角以決定一拍攝距離,其中,該 既定像距為該鏡頭及該影像感測單元之距離,而該拍攝距 離為該主要拍攝物體與該钂頭之距離。最後,根據該拍攝 Φ 距離及該成像設定值,對该主要拍攝物體進行影像擷取。 另外,本發明實施例提供一種影像擷取裴置,包括一 鏡頭、一驅動單元、一影像感測單元及一處理單元。該鏡 頭用以聚焦一影像。該驅動單元耦接於該鏡頭,用以驅動 該鏡頭。該影像感測單元遂過該鏡頭擷取該影像。該處理 單元耦接於該影像感測單元’用以決定該影像之一主要拍 攝物體、取得該主要拍攝物體之一辨識資料、根據該辨識 資料取得對應於該主要拍攝物體之一成像設定值、計算該 % 主要拍攝物體成像於該影像感測單元上之一成像尺寸、根 據該成像尺寸及該成像設定值之一參考尺寸及一既定像距 來決定一拍攝距離、以及根據該拍攝距離及該成像設定值 對該主要拍攝物體進行影像擷取。 為使本發明之上述目的、特徵和優點能更明顯易懂, 下文特舉實施例’並配合所附圖示,詳細說明如下。 【實施方式】 下文係說明本發明之較佳實施方式,配合所附圖示第 1圖及第2圖,做詳細之說明。本發明說明書提供之實施 6 201024892 例中的各-杜發明不同實施方式的技術特徵。其中,實施 :1之配置係為說明之用,並非用以限制本發 ,本發明實施例係以相機為例進行說明,但不以 影=比t何需執行對焦程序之影像擷取裝置,例如:攝 影機,自適用本發明實施例所述方法。 第1 ϋ軸雜據本發明實施例之—影㈣取装置1〇 一圖匕括.一鏡頭1 、一驅動單元1 、一影像感測 •單元106及一處理單元⑽。於本發明之實施例中,該影 像擷取裝置包括一相機或一攝影機。於—實施例中,該影 像摘取裝置包括一數位相機,、一數位攝影機或一具有影像 擷取功能的電子裝置。 參考第1圖,該鏡頭1〇2用以聚焦一影像。該驅動單 几10:耦接於該鏡頭102,用以驅動該鏡頭1〇2,而該影像 感測單7G 106則透過該鏡頭1〇2擷取該影像。於一實施例 中,該驅動單元104包括一對焦馬達(未圖示),用以控 _制該鏡帛102之移動步數,改變該鏡頭1〇2與該影像感測 單7L 106間之距離。該處理單元1〇8耦接於該影像感測單 元106,用以接收該影像感測單元1〇6所擷取之影像。於 一實施例中,該處理單元108可為一數位訊號處理器 (digital signal processing,DSP),對該影像進行儲存、 分析及計算操作,並產生相關之控制信號。進一步,於另 一實施例中,該影像感測單元1 〇6可以是電荷麵合裝置 (charge-coupled device,CCD)或互補式金屬氧化半^體 (CMOS),用以透過該鏡頭102感測該影像並對應輪出 7 201024892 影像之資料。 如第1圖所示,該處理單元108從該影像感測單元106 接收該影像後,分析該影像以決定一主要拍攝物體,藉以 取出該主要拍攝物體之一辨識資料。於操作上,該影像擷 取裝置10更包括一記憶單元110,具有一資料庫(未圖 示),係儲存複數之影像樣本。於此實施例中,該處理單 元108利用影像辨識處理該影像,從該影像中擷取出複數 之拍攝物體的特徵,做為一比對模板,再將該比對模板用 ® 以與該資料庫中的每一影像樣本進行比較或配對,從而辨 識出與該等拍攝物體相似的特徵或種類,例如:人臉或房 子。隨後,根據一既定規則,從該等辨識資料中決定該主 要拍攝物體。舉例而言,可定義一優先順序來指定該主要 拍攝物體。例如:該主要拍攝物體可以該影像之人臉為主, 若無人臉,再依次搜尋動物。於另一實施例中,亦可以該 等拍攝物體之位置決定該主要拍攝物體。舉例來講,當辨 φ 識出多張人臉,可先判斷該影像之晝面中心,再尋找鄰近 中心區域之人臉,作為該主要拍攝物體。 進一步,根據該辨識資料,該處理單元108從該資料 庫中讀取對應於該主要拍攝物體之一成像設定值,如物體 尺寸,其中該物體尺寸的定義,可以從一般情況下,每一 .種物體的平均尺寸來定義。然後,該處理單元108計算該 主要拍攝物體成像於該影像感測單元106上之一成像尺寸 B。於一實施例中,假設該主要拍攝物體成像於該影像感 測單元106上的長和寬各為N個圖元,而每一圖元大小為 8 201024892 。值得注意的是,亦可透過其它 P,則該成像尺寸5 = #χρ 方式計算該成像尺寸。201024892 IX. Description of the Invention: [Technical Field] The present invention relates to image capture, and more particularly to an image capture device that performs autofocus using an imaging size of a subject. [Prior Art] When shooting an image, accurate focus is one of the elements for capturing a clear image. Therefore, in addition to manual focusing, with the automatic focus function provided by the camera, users can also capture images with vivid colors and sharp outlines. Conventionally, autofocus can measure the distance between an object and a lens through a distance measuring device, and adjust the mirror distance accordingly. However, this approach requires additional hardware design and cost. Alternatively, in some conventional techniques, the movable lens scans and captures the relevant image, and the high frequency component generated by frequency domain conversion of each image is used as a contrast, thereby analyzing according to the contrast of each image. The best focus position corresponding to the maximum contrast is taken to capture the sharpest shadow Φ image. However, repeatedly moving the lens is not only time consuming, but when the object to be photographed is not clear, the repeated focusing operation will also cause the focusing time to be too long. SUMMARY OF THE INVENTION In view of the above, the present invention provides an autofocus method and an image capture device using the above method. Based on the above, an embodiment of the present invention provides an auto-focusing method, which is suitable for an image capturing device. The image capturing device includes a lens and an image sensing unit. First, an image is captured on the image sensing unit through the lens. The image is analyzed to determine a primary subject, 5 201024892, and the identification data of the primary subject is obtained, wherein the identification data is used to obtain an imaging setting corresponding to one of the main subjects. Then, an imaging size of the main subject imaged on the image sensing unit is calculated according to the image. Determining a shooting distance according to the imaging size, a reference size of the imaging setting value, and a predetermined image distance, wherein the predetermined image distance is a distance between the lens and the image sensing unit, and the shooting distance is the The distance between the main subject and the skull. Finally, image capture is performed on the main subject according to the shooting Φ distance and the imaging setting value. In addition, an embodiment of the present invention provides an image capture device including a lens, a driving unit, an image sensing unit, and a processing unit. The lens is used to focus an image. The driving unit is coupled to the lens for driving the lens. The image sensing unit captures the image through the lens. The processing unit is coupled to the image sensing unit for determining a primary object of the image, obtaining an identification data of the primary object, and obtaining an imaging setting value corresponding to one of the main objects according to the identification data, Calculating an imaging size of the one of the main subject images on the image sensing unit, determining a shooting distance according to the imaging size and one of the imaging setting values, and determining a shooting distance, and according to the shooting distance and the The imaging set value is used to capture the image of the main subject. The above described objects, features and advantages of the present invention will become more apparent from the description of the appended claims. [Embodiment] Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the drawings 1 and 2 of the accompanying drawings. The present invention provides the technical features of the different embodiments of each of the embodiments of the present invention. The configuration of the first embodiment is for illustrative purposes, and is not intended to limit the present invention. The embodiment of the present invention is described by taking a camera as an example, but the image capturing device that does not perform the focusing process is not required. For example: a camera, self-applying the method described in the embodiments of the present invention. The first embodiment of the present invention includes a lens 1 , a driving unit 1 , an image sensing unit 106 and a processing unit ( 10 ). In an embodiment of the invention, the image capture device comprises a camera or a camera. In an embodiment, the image pickup device comprises a digital camera, a digital camera or an electronic device having an image capture function. Referring to Figure 1, the lens 1〇2 is used to focus an image. The driver 10 is coupled to the lens 102 for driving the lens 1〇2, and the image sensing unit 7G 106 captures the image through the lens 1〇2. In an embodiment, the driving unit 104 includes a focus motor (not shown) for controlling the number of moving steps of the mirror 102, and changing the lens 1〇2 and the image sensing sheet 7L 106. distance. The processing unit 〇8 is coupled to the image sensing unit 106 for receiving images captured by the image sensing unit 1〇6. In one embodiment, the processing unit 108 can be a digital signal processing (DSP) that stores, analyzes, and calculates the image and generates associated control signals. Further, in another embodiment, the image sensing unit 1 〇6 may be a charge-coupled device (CCD) or a complementary metal oxide semiconductor (CMOS) for transmitting the lens 102. Measure the image and match the data of the 7 201024892 image. As shown in FIG. 1 , after receiving the image from the image sensing unit 106, the processing unit 108 analyzes the image to determine a main subject, thereby extracting one of the main subject objects. In operation, the image capturing device 10 further includes a memory unit 110 having a database (not shown) for storing a plurality of image samples. In this embodiment, the processing unit 108 processes the image by using image recognition, and extracts features of the plurality of captured objects from the image as a comparison template, and then uses the comparison template with the database. Each image sample in the comparison is compared or paired to identify features or categories similar to the objects, such as a face or a house. Subsequently, the main subject is determined from the identification data according to a predetermined rule. For example, a priority order can be defined to specify the primary subject. For example, the main subject may be the face of the image, and if there is no face, the animal is searched in turn. In another embodiment, the location of the objects to be photographed may also determine the primary subject. For example, when identifying a plurality of faces, the center of the face of the image may be judged first, and then the face of the adjacent center area may be searched for as the main subject. Further, according to the identification data, the processing unit 108 reads, from the database, an imaging setting value corresponding to one of the main shooting objects, such as an object size, wherein the definition of the object size can be generally from each. The average size of the object is defined. Then, the processing unit 108 calculates an imaging size B of the primary subject image formed on the image sensing unit 106. In one embodiment, it is assumed that the length and width of the main imaging object imaged on the image sensing unit 106 are N primitives, and each primitive size is 8 201024892. It is worth noting that the imaging size can also be calculated by the imaging size 5 = #χρ mode through other Ps.
之後’算出該成像尺寸後,彻該成像設定值之一參 考尺寸及二既定像距’該處理單元刚可求得—拍攝距離 L,用以表示該主要拍攝物體與該鏡頭1〇2之相對距離。夹 例來講’假設該主要拍攝物體為人臉χ,則可從該資料ς 取得對應於人臉X之平均尺寸Α,作為該參考尺寸。'進— 步,若該既定像距F為該鏡頭1()2及該影像感測單元咖 間之距離,根據該參考尺寸= 該成像尺寸B及該既定像 距F,便可計算拍攝距離万。 於一實施例中,該影像擷取裝置1〇進一步包括一光圈 m及-㈣m針對該主要拍攝物體’如人臉χ,該光 圈112根據該錄設定值所決定之—光圈值來控制該鏡頭 Γ02之入射光量,岭快門114根據該成像設定值所決定 之一快門速度來調整該影像感測單元1〇6之曝光量。其 中,可透舶建式快門紐或外接式㈣裝置來觸發該快門 114。 於一實施例中,根據該拍攝距離L,該驅動單元1〇4 取得對應之一移動步數,直接驅動該鏡頭1〇2至一對焦位 置,再根據該成像設定值,擷取該主要拍攝物體之影像。 更具體地,該驅動單元104可根據該拍攝距離L的一 對焦範圍,進行對焦掃猫之操作。舉例來說,假設該拍攝 距離L為1〇公尺,該拍攝距離L所對應的該移動步數為 100步,而該對焦範圍假設預設為20步,則該驅動單元1〇4 9 201024892 二 會在第90步到第11〇步之間,以固定間隔的每一移動步 數’移動鏡頭至每-第二對焦位置處,並且進行影像綠取, 丁對焦掃描之操作’其中朗焦範圍取決於使用者之 疋該主要拍攝物體之特徵或鏡頭之規格。於每一個 對焦位置操取出相關影像後,該處理單元⑽ 於每一個第二對焦位置之影像對比度,以決定-最佳對Ϊ 位置。亦即,在該對焦範_取得對應於最大對比度之 焦位置。如此-來,可實現較高之對焦精確度。 值得注意的是’該影像擷取裝置1〇更進一步包括一 光燈116,於進行影像娜時,用以致能— ς 影像感測單it 106之曝光量。 第2圖係顯示依據本發明實施例之一 流程圖。該自動_法20適用於, 1圖之影像擷取裝置10),其中,該影像擷取 鏡頭及一影像感測單元。 展置具有一 參考第2圖,首先,透過該鏡頭,於該 … 士擷取一影像(步驟酬。其次,分析該影像攻用】= 疋一主要拍攝物體,同時取得該主要拍攝物 、 料(步驟^ 瑕之一辨識資 驟S204)。於一實施例中,自該影像 拍攝物體後,再利用—資料庫中所建立之=取複數之 等拍攝物體進行辨識,用以產生複數之辨識羨本,對該 識資料產生後,隨即根據-既定關,從;^料。該等辨 決疋該主要拍攝物體,此—部份已詳述於^辨識資料中 實施例中,於此不加贅述。 、1圖及其相關 201024892 隨後,根據該辨識資料,從該資料庫令讀取對應於該 主要拍攝物體之一成像設定值(步驟S2〇6)。於〆實施例 中’該成像設定值包括一參考尺寸、一既定像距、一光圈 值及一快門速度。該參考尺寸用以表示該主要拍攝物體之 平均尺寸。該既定像距用以表示該鏡頭及該影像感測單元 之相對距離。該光圈值用來控制該鏡頭之入射光量。該快 門逮度則用來控制該影像感測單元之曝光量。 進一步,根據該影像,取得該主要拍攝物體成像於該 影像感測單元上之一成像尺寸(步驟S2〇8)。透過該成像 2寸及該成像設定值,便可衫—簡轉,即該主要拍 $物體與該辆之距離(㈣S21G)。計算該拍攝距離之 方式已配合第i圖之實施例說明如上,在此省略其說明。 一在決定該拍攝距離後’可直接以該拍攝距離所對應之 步數驅動該鏡駐-對焦位置,同時根據該成像設 鲁擷取(步驟奶2)。 /主要拍攝物體進行影像 相對於上述之快速對焦方式’亦可根據一對 整該拍攝距離進行-精確對焦(步驟S214) I圍調 =據該雜所對應之軸步數,將移^也’ 焦位置,進行擷取影像之操作。娜= 号找具有最大對比度之影像及其 景/像中,再 此提高對焦精確度。 、、〜之最佳對焦位置,藉 相較於習知技術,本發明所 用該方法之影像擷取裝置,可 之自動對焦方法及使 不同之拍攝物體選擇成 201024892 像設定值,直接計算出最適合之對焦位置,從而縮短對焦 所需之時間。除此之外,亦可利用在對焦位置的一對焦範 圍進行小範圍之對焦掃描,藉由分析每一取樣點所擷取影 像之對比度,進而獲得一最佳對焦位置來進行影像擷取, 同時達到快速且準確對焦之目的。 雖然本發明已以較佳實施例揭露如上,然其並非用以 限定本發明,任何熟悉此項技藝者,在不脫離本發明之精 • 神和範圍内,當可做些許更動與潤飾,因此本發明之保護 範圍當視後附之申請專利範圍所界定者為準。 ❿ 12 201024892 【圖式簡單說明】 第1圖係顯示依據本發明實施例之一影像擷取裝置方 塊圖;及 第2圖係顯示依據本發明實施例之一自動對焦方法流 程圖。 【主要元件符號說明】 10〜影像擷取裝置; 102〜鏡頭; 104〜驅動單元; 106〜影像感測單元; 108〜處理單元; 110〜記憶單元; 112〜光圈; 114〜快門;及 116〜閃光燈。 13After the calculation of the imaging size, the reference size of the imaging set value and the two predetermined image distances 'the processing unit can be obtained only—the shooting distance L is used to indicate that the main shooting object is opposite to the lens 1〇2. distance. For example, if the main subject is a human face, the average size 对应 corresponding to the face X can be obtained from the data 作为 as the reference size. 'In step, if the predetermined image distance F is the distance between the lens 1 () 2 and the image sensing unit, according to the reference size = the imaging size B and the predetermined image distance F, the shooting distance can be calculated. Million. In one embodiment, the image capturing device 1 further includes an aperture m and a (four) m for the main subject 'such as a human face, the aperture 112 controlling the lens according to the aperture value determined by the recorded set value. The amount of incident light of Γ02, the ridge shutter 114 adjusts the exposure amount of the image sensing unit 〇6 according to one of the shutter speeds determined by the imaging setting value. The shutter 114 can be triggered by a built-in shutter button or an external (4) device. In an embodiment, according to the shooting distance L, the driving unit 1〇4 obtains a corresponding one of the moving steps, directly drives the lens 1〇2 to a focusing position, and then captures the main shooting according to the imaging setting value. An image of an object. More specifically, the driving unit 104 can perform the operation of focusing the cat according to a focus range of the shooting distance L. For example, if the shooting distance L is 1 〇m, the moving step corresponding to the shooting distance L is 100 steps, and the focusing range is assumed to be preset to 20 steps, then the driving unit 1〇4 9 201024892 Second, between the 90th step and the 11th step, move the lens to each of the second focus positions at a fixed interval, and perform image green capture. The range depends on the characteristics of the main subject or the size of the lens. After the relevant image is taken at each focus position, the processing unit (10) determines the image contrast at each of the second focus positions to determine the best alignment position. That is, the focus position corresponding to the maximum contrast is obtained at the focus mode. In this way, higher focus accuracy can be achieved. It should be noted that the image capturing device 1 further includes a light 116 for enabling the image to sense the exposure of the image unit it 106. Figure 2 is a flow chart showing one of the embodiments of the present invention. The automatic method 20 is applicable to the image capturing device 10) of FIG. 1 , wherein the image capturing lens and an image sensing unit are used. The display has a reference to the second picture. First, through the lens, the image is taken by the judge (step reward. Secondly, the image is analyzed) = 主要 a main subject, and the main subject and material are obtained at the same time. (Step 瑕 辨识 辨识 辨识 S 204 204 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。 。羡 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , </ RTI> 1 and its related 201024892 Subsequently, according to the identification data, an imaging setting value corresponding to one of the main shooting objects is read from the database order (step S2 〇 6). In the embodiment, the image is formed The set value includes a reference size, a predetermined image distance, an aperture value, and a shutter speed. The reference size is used to indicate an average size of the main subject. The predetermined image distance is used to indicate the lens and the image sensing unit. phase The aperture value is used to control the amount of incident light of the lens. The shutter capture is used to control the exposure amount of the image sensing unit. Further, according to the image, the main subject is imaged by the image sensing unit. One of the upper imaging dimensions (step S2〇8). Through the imaging 2 inch and the imaging set value, the shirt-simplified turn, that is, the distance between the main object and the vehicle ((4) S21G) is calculated. The method has been described above with reference to the embodiment of the first embodiment, and the description thereof is omitted here. After determining the shooting distance, the mirror standing-focus position can be directly driven by the number of steps corresponding to the shooting distance, and according to the imaging setting.撷 撷 (step milk 2). / The main subject to perform image relative to the above-mentioned fast focus mode 'can also be based on a pair of the entire shooting distance - precise focus (step S214) I hedge = according to the miscellaneous The number of axis steps will be moved to the 'focus position' to capture the image. Na = No. Find the image with the largest contrast and its scene/image, and then improve the focus accuracy. Compared with the prior art, the image capturing device of the method used in the present invention can automatically reduce the focus position by directly selecting the most suitable focus position by selecting an image of the 201024892 image by using an auto-focusing method and selecting a different image capturing object. The time required for focusing. In addition, a small range of focus scanning can be performed using a focus range at the focus position. By analyzing the contrast of the image captured by each sample point, an optimal focus position is obtained. The image capture is performed while achieving fast and accurate focus. Although the present invention has been disclosed in the above preferred embodiments, it is not intended to limit the present invention, and any one skilled in the art can not deviate from the essence of the present invention. In the context of God and the scope, the scope of protection of the present invention is defined by the scope of the appended claims. ❿ 12 201024892 BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a block diagram showing an image capturing device according to an embodiment of the present invention; and FIG. 2 is a flow chart showing an autofocus method according to an embodiment of the present invention. [Main component symbol description] 10~image capturing device; 102~lens; 104~drive unit; 106~image sensing unit; 108~processing unit; 110~memory unit; 112~aperture; 114~shutter; and 116~ flash. 13