200915851 九、發明說明: 【發明所屬之技術領域】 本發明涉及一種相機自動對焦系統及方法。 【先前技術】 在拍攝照片時,人物通常是晝面的主體,因此所有的 對焦、測光都應該基於人物臉部進行。對於普通相機,這 需要曝光鎖定的焦點鎖定操作,普通用戶不太容易掌握。 目前市場上,人臉對焦技術已非常普及,這一技術能夠讓 相機自動識別晝面中是否有人的臉部,並自動將人臉作為 拍攝的主體。相機在對焦和曝光控制方面都將針對人臉的 狀況來調整。這樣,拍攝者就可以專注於構圖和拍攝時機 的把握,不會再被煩瑣的操作分散精力。 但是,當開啟連續對焦功能拍攝在移動中的人的照片 時,人的位置不停改變,則需要隨時改變對焦範圍,這時 對焦馬達不能判斷人的移動方向軌跡,需要不斷前後掃描 對焦和改變對焦範圍,直到掃描到人臉,浪費很多時間, 不能及時並且清晰地捕捉移動中的人的暫態清晰照片。 【發明内容】 鑒於以上内容,有必要提供一種相機自動對焦系統及 方法,利用人臉相對於整個晝面的大小變化和位置判斷連 續對焦的方向和軌跡,來減少對焦的時間。 一種相機自動對焦系統,用於拍攝移動的人體照片時 進行自動對焦,該系統包括自動連續對焦程式及運行該自 動連續對焦程式的數位信號處理系統,該數位信號處理系 8 200915851 統存儲有第—晝面和第二晝面,該第一晝面和第二晝面為 =拍攝者移動時連續抓去的兩張人臉對焦晝面,所述第二 二、#第—晝面分別用矩形框框住人臉,該自動連續對焦 耘式包括:偵測模組,用於偵測人臉在第一晝面中的相對 位置,取該晝面中的矩形框的-條對角線,得到該對角綠 =個頂點的座標;計算模組,用於根據所述第—晝面中 :角:兩個項點的座標計算第一晝面中矩形框的面積 Μ ,還用於偵測人臉在__㈣ 兩個頂點的;二 對角線,得到該對角線的 =角:兩個頂點的座標’計算該矩形框“ 判斷第二晝面中的矩形框的面積s2是否大於 心矩形框的面積Sl;及對焦模組,用於當幻大 斤二相機朝著近攝方向對焦掃描;當S2小於S1 控制相機朝著無限遠處對焦掃描。 —種相機自動對焦方法, =對焦,法包 旦面中的相對位置,蚩 牡弟 得到該對自綠 δχ~的矩形框的一條對角線, 對角線的兩個頂點的座標;根據所诚笛金 角線的兩個頂料座料算第―晝面中對 化偵測人臉在第二金面中二弟旦面中矩形框的面積 框的—停對角 ^的相對位置,取該晝面令矩形 所述第T二;=對角線的兩個頂點的座標;根據 面積S2;判:第的=個頂點的座標計算該矩形框的 清第〜面中的矩形框的面積S2是否大於第一 200915851 框的面親;若32大於Sl,則判斷被拍攝者 朝者近攝方向移動控制相機朝著近攝方向對焦掃描;當82 小於S1時,控制相機朝著無限遠處對焦掃描。 純於習知技術,本發_用人臉㈣於整個晝面的 大繼和位置判斷連續對焦的方向和軌跡,來減少自動 對焦的時間。 0 ^ 【實施方式】 如圖1所示’是本發明相機自動對焦系統的硬體架構 圖。該糸統包括:自動連續對焦程式1〇,該自動連續對隹 程式K)運行於—數位信號處理系統(叫制抑㈣ § rt^DSP) 12’該DSP系統12存儲有所拍攝移動 中的人的連續動作的晝面。 _如圖2所不’是本發明相機自動對焦方法較佳實施例 的不意圖。所示第一畫則(以下簡稱晝則)和第二晝面2 (以下簡稱晝面2)為兩張人臉對焦晝面,且該人臉對焦晝 面為被拍攝者的連續動作的晝面,每一畫面中分別用一矩 形框框住人臉。 圖3所不,是圖i中自動連續對焦程式1〇的功能模组 圖。該自動連續對焦程式包括:偵測模組20、計算模組22、 判斷模組24、對焦模組26。 偵測杈組20,用於偵測人臉在晝面1中的相對位置, 所述矩形框框住人臉,取該矩形對焦框的其中—條對角 線得到該對角線的兩個頂點的座標,如點M,點N,如 圖2所示。 200915851 計算模組22’用於根據所要拍攝的物體的大小將晝面 平均劃分成若干個小方格,本實施例中,以劃分十六個小 方格為例進行說明。 所述計算模組22,還用於計算晝面丄中矩形框的面積 Sl ’亚計算該框的中心點〇的座標,該矩形框的中心點〇 即為人臉的中心點,點A在一小方格ABCD内,計算該方柊 、 頁’、、、占.點A、點B、點C及點D的座標,如圖2戶斤; 當前對_域為方格ABCD所在的區域。 所述偵測模組20,還用於偵測人臉在晝面2中的相對 矩幵/框框住該晝面2中的人臉,取該矩形的—條對角 滩彳于到該對角線的兩個頂點的座標,如點M、,點N、, 圖2所示。 所述计算模組22,還用於計算晝面2中的該矩形框的 面積S2,亚計异該矩形框的中心點〇、的座標,點〇、在一小 B C D Θ,計算該方格的四個頂點:點a、、點&、 ”、、及點D、的座標,如圖2所示。 判斷板組24 ’用於判斷點A、點B、點c及點D的座標 尤=‘點B、點C及點D、的座標是否分別對應相等;若 =等貝判斷所拍攝的人已經離開對焦範圍,需要重新 對焦。 + Ά組26 ’用於當所述判斷模組24判斷人已經離開 對焦範圍時,則將對隹F 凡 J盯τ居、^域设為方格A、BX、D、所在的區 域。 所述判斷模組24 ’還用於判斷S2是否大於S1。 11 200915851 所述對焦模組26,還用於當32大於51時,朝著macr〇 (近攝)方向對焦掃描,當S2小於51時,朝著無限遠處對 焦掃描。 如圖4所不,是本發明相機自動對焦方法的較佳實施 例的流程圖。 ' 首先,步驟S30,計算模組22根據被拍攝者的大小將 第一畫面和第二畫面平均劃分成多個方格,伯測模組纖 人臉偵測找出人臉在畫面1中的相對位置,所述矩形框框住 人臉’取該矩形對焦框的其中一條對角線,得到該對角線 的兩個頂點的座標,如點Μ,點N,如圖2所示。 步驟S32,計算模組22計算晝面1中矩形框的面積, 並計算該框的中心點〇的座標,該矩形框的中心點〇即為人 臉的中心點,點A在—小方格ABCD内,計算該方格的四個 頂點.點A、點B、點C及點D的座標,如圖2所示,當前對 焦區域為方格ABCD。 步驟S34,偵測模組20偵測人臉在畫面2中的相對位 置,矩形框框住該晝面2中的人臉,取該矩形的—條對角 線,得到該對角線的兩個頂點的座標,如點M、,點N、,如 圖2所示。 步驟S36’所述計算模組22計算晝面2中的該矩形框的 面積S2,並計算該矩形框的中心點〇、的座標,點〇、在一小 方格A B C D、内,計算該方格的四個頂點:點A、、點b、、 點C及點D的座標,如圖2所示。 步驟S38,判斷模組24判斷點a、點b、點〇及點D的 12 200915851 .座標與點A'、點B'、點C'及點D'的座標是否分別對應相 等;若不相等,則判斷所拍攝的人已經離開對焦範圍,需 要重新對焦。 步驟S40,判斷模組24分別判斷所述晝面2中的矩形框 的面積S2是否大於晝面1中的矩形框的面積S1。 步驟S42,若S2大於S1,則對焦模組26往macro方向對 焦掃描。 步驟S44,上述步驟S38中,當所述判斷模組24判斷人 已經離開對焦範圍時,則改變對焦中心位置,將對焦區 域移到方格A'B'CTD'。 步驟S46,上述步驟S40中,若S2小於S1,則所述對焦 模組26往無限遠處對焦掃描。 以上所述僅為本發明之較佳實施例而已,且已達廣泛 之使用功效,凡其他未脫離本發明所揭示之精神下所完成 之均等變化或修飾,均應包含在下述之申請專利範圍内。 【圖式簡單說明】 圖1係本發明相機自動對焦系統之硬體架構圖。 圖2係本發明相機自動對焦方法較佳實施例之示意 圖。 圖3係圖1中自動連續對焦程式之功能模組圖。 圖4係本發明相機自動對焦方法的較佳實施例之流程 圖。 . 【主要元件符號說明】 自動連續對焦程式 10 13 200915851 數位信號處理系統 12 偵測模組 20 計算模組 22 判斷模組 24 對焦模組 26 14200915851 IX. Description of the Invention: [Technical Field] The present invention relates to a camera autofocus system and method. [Prior Art] When taking a picture, the character is usually the main body of the face, so all focus and metering should be based on the face of the person. For a normal camera, this requires an exposure-locked focus lock operation that is not easily grasped by the average user. Currently, face focusing technology has become very popular on the market. This technology allows the camera to automatically recognize the face of someone in the face and automatically use the face as the subject of the shot. The camera will adjust for focus and exposure control for the condition of the face. In this way, the photographer can focus on the composition and timing of the shooting, and will not be distracted by the cumbersome operation. However, when the continuous focus function is turned on to take a picture of a person moving, the position of the person keeps changing, the focus range needs to be changed at any time. At this time, the focus motor cannot judge the direction of the person's moving direction, and it is necessary to continuously scan the focus and change the focus. The range, until scanning to the face, wasted a lot of time, unable to capture the transient clear photos of the moving person in time and clearly. SUMMARY OF THE INVENTION In view of the above, it is necessary to provide a camera autofocus system and method for reducing the focus time by using the size and position of a face relative to the entire face to determine the direction and trajectory of continuous focus. A camera autofocus system for performing autofocus when photographing a moving human body photograph, the system comprising an automatic continuous focus program and a digital signal processing system running the automatic continuous focus program, the digital signal processing system 8 200915851 is stored with the first The first side and the second side are the two face-focusing faces continuously captured by the photographer when the photographer moves, and the second and second faces are respectively rectangular The frame is arranged to face the face, and the automatic continuous focus mode includes: a detecting module, configured to detect a relative position of the face in the first face, and take a diagonal of the rectangle in the face to obtain the Diagonal green=the coordinates of the vertices; the calculation module is configured to calculate the area 矩形 of the rectangular frame in the first 根据 face according to the coordinates of the first 昼 face: angle: two points, and is also used for detecting people The face is at the two vertices of __(four); the two diagonal lines get the angle of the diagonal = the coordinates of the two vertices 'calculate the rectangular frame'. Determine whether the area s2 of the rectangular frame in the second side is larger than the heart rectangle The area of the frame S1; and the focus module, used when The camera is focused toward the close-up direction; when S2 is smaller than the S1, the camera is focused on the infinity. - The camera autofocus method, = focus, the relative position in the mask, the 蚩 弟A diagonal line from the rectangle of the green δχ~, the coordinates of the two vertices of the diagonal; according to the two ejector blocks of the celestial gold horn, the face is detected in the 昼-face In the second gold face, the relative position of the area frame of the rectangular frame in the second gold face is taken as the opposite position of the T2; = the coordinates of the two vertices of the diagonal line; Area S2; Judgment: The coordinates of the first vertex calculate whether the area S2 of the rectangular frame in the clear-face of the rectangular frame is larger than the face of the first 200915851 frame; if 32 is larger than Sl, the subject is judged to be The close-up direction moves the camera to focus the camera in close-up direction; when 82 is smaller than S1, it controls the camera to focus on the infinity scan. Purely by the conventional technique, the hair _ uses the face (four) in the entire face of the big step Position determines the direction and trajectory of continuous focus to reduce autofocus 0 ^ [Embodiment] As shown in Fig. 1 is a hardware architecture diagram of the camera autofocus system of the present invention. The system includes: an automatic continuous focus program 1〇, the automatic continuous confrontation program K) runs on — Digital signal processing system (called system (4) § rt^DSP) 12' The DSP system 12 stores the face of the continuous motion of the person who is photographing the moving. _ The first embodiment (hereinafter referred to as "昼") and the second side 2 (hereinafter referred to as "昼面2") are two face-focusing faces, and the face is focused on the face. The face of the photographer's continuous motion, each frame is framed by a rectangular frame. Figure 3 is a functional block diagram of the automatic continuous focus program in Figure i. The automatic continuous focus program includes a detection module 20, a calculation module 22, a determination module 24, and a focus module 26. The detection group 20 is configured to detect the relative position of the face in the face 1 , the rectangular frame is framed by the face, and the diagonal of the rectangle of the focus frame is obtained by the two vertices of the diagonal Coordinates, such as point M, point N, as shown in Figure 2. The calculation module 22' is configured to divide the kneading surface into a plurality of small squares according to the size of the object to be photographed. In this embodiment, a description is made by taking sixteen small squares as an example. The calculation module 22 is further configured to calculate the area of the rectangular frame in the 丄 丄 亚 亚 亚 亚 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算 计算In a small square ABCD, calculate the coordinates of the square, page ', , and the point A, point B, point C, and point D, as shown in Figure 2; the current pair _ field is the area where the square ABCD is located. . The detecting module 20 is further configured to detect a relative moment of the face in the face 2/frame to frame the face in the face 2, and take a diagonal of the rectangle to the pair The coordinates of the two vertices of the corner, such as point M, point N, are shown in Figure 2. The calculation module 22 is further configured to calculate an area S2 of the rectangular frame in the facet 2, calculate a coordinate of the center point 〇 of the rectangular frame, and click on a small BCD Θ to calculate the square The four vertices: the coordinates of point a, point &, ",, and point D, as shown in Figure 2. Judging board group 24' is used to determine the coordinates of point A, point B, point c, and point D Especially = 'Point B, point C and point D, the coordinates are correspondingly equal; if = et al. judge that the person who has taken the shot has left the focus range, need to refocus. + Ά group 26 ' is used as the judgment module When judging that the person has left the focus range, the area is set to the area where the squares A, BX, D are located, and the judgment module 24' is further used to determine whether S2 is greater than S1. 11 200915851 The focus module 26 is further configured to focus scan toward the macr〇 (close-up) direction when 32 is greater than 51, and focus scan toward infinity when S2 is less than 51. No, it is a flowchart of a preferred embodiment of the camera autofocus method of the present invention. First, in step S30, the calculation module 22 is based on the subject. The size divides the first picture and the second picture into a plurality of squares on average, and the test module detects the relative position of the face in the picture 1 by the face detection, and the rectangular frame frames the face 'takes the rectangular focus frame One of the diagonal lines obtains the coordinates of the two vertices of the diagonal line, such as point Μ, point N, as shown in Fig. 2. In step S32, the calculation module 22 calculates the area of the rectangular frame in the 昼 plane 1, and Calculate the coordinates of the center point of the frame. The center point of the rectangle is the center point of the face. The point A is in the small square ABCD, and the four vertices of the square are calculated. Point A, point B, The coordinates of the point C and the point D are as shown in Fig. 2. The current focus area is the square ABCD. In step S34, the detecting module 20 detects the relative position of the face in the screen 2, and the rectangular frame is framed in the side 2 The face of the rectangle takes the diagonal of the rectangle to obtain the coordinates of the two vertices of the diagonal, such as point M, point N, as shown in Fig. 2. The calculation module 22 of step S36' Calculate the area S2 of the rectangular frame in the facet 2, and calculate the coordinates of the center point 〇 of the rectangular frame, the point 〇, in a small square ABC D, within, calculate the four vertices of the square: the coordinates of the point A, the point b, the point C and the point D, as shown in Fig. 2. In step S38, the determining module 24 determines the point a, the point b, the point 〇 and point D 12 200915851 . Whether the coordinates of the coordinates and point A', point B', point C' and point D' are equal respectively; if they are not equal, it is judged that the person who has taken the photo has left the focus range and needs to refocus In step S40, the determining module 24 determines whether the area S2 of the rectangular frame in the facet 2 is greater than the area S1 of the rectangular frame in the facet 1. In step S42, if S2 is greater than S1, the focus module 26 goes to the macro. Direction focus scan. In step S44, in the above step S38, when the determining module 24 determines that the person has left the focus range, the focus center position is changed, and the focus area is moved to the square A'B'CTD'. In step S46, in the above step S40, if S2 is smaller than S1, the focus module 26 performs in-focus scanning at infinity. The above is only the preferred embodiment of the present invention, and has been used in a wide range of applications. Any other equivalent changes or modifications which are not departing from the spirit of the present invention should be included in the following claims. Inside. BRIEF DESCRIPTION OF THE DRAWINGS Fig. 1 is a hardware structural diagram of a camera autofocus system of the present invention. Fig. 2 is a schematic view showing a preferred embodiment of the camera autofocus method of the present invention. Figure 3 is a functional block diagram of the automatic continuous focus program of Figure 1. Fig. 4 is a flow chart showing a preferred embodiment of the camera autofocus method of the present invention. [Main component symbol description] Automatic continuous focus program 10 13 200915851 Digital signal processing system 12 Detection module 20 Calculation module 22 Judgment module 24 Focus module 26 14