1342710 九、發明說明: 【發明所屬之技術領域】 本發明涉及一種相機自動對焦系統及方法。 【先前技術】 在拍攝照片時,人物通常是畫面的主體,因此所有的 對焦、測光都應該基於人物臉部進行。對於普通相機,這 需要曝光鎖定的焦點鎖定操作,普通用戶不太容易掌握。 目前市場上,人臉對焦技術已非常普及,這一技術能夠讓 相機自動識別畫面中是否有人的臉部,並自動將人臉作為 拍攝的主體。相機在對焦和曝光控制方面都將針對人臉的 狀況來調整。這樣,拍攝者就可以專注於構圖和拍攝時機 的把握,不會再被煩瑣的操作分散精力。 但是,當開啟連續對焦功能拍攝在移動中的人的照片 時,人的位置不停改變,則需要隨時改變對焦範圍,這時 對焦馬達不能判斷人的移動方向執跡,需要不斷前後掃描 對焦和改變對焦範圍,直到掃描到人臉,浪費很多時間, 不能及時並且清晰地捕捉移動中的人的暫態清晰照片。 【發明内容】 鑒於以上内容,有必要提供一種相機自動對焦系統及 方法,利用人臉相對於整個晝面的大小變化和位置判斷連 續對焦的方向和軌跡,來減少對焦的時間。 一種相機自動對焦系統,用於拍攝移動的人體照片時 進行自動對焦,該系統包括自動連續對焦程式及運行該自 動連續對焦程式的數位信號處理系統,該數位信號處理系 13427101342710 IX. Description of the Invention: [Technical Field of the Invention] The present invention relates to a camera autofocus system and method. [Prior Art] When taking a picture, the person is usually the subject of the picture, 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. Face-focusing technology is now very popular on the market. This technology allows the camera to automatically recognize the face of someone in the picture 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 movement of the person, and it is necessary to continuously scan the focus and change. The focus range is not wasted until the face is scanned, and it is not possible 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 autofocusing when photographing a moving human body, 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 1342710
統存儲有第一晝面和第二晝面, 被拍攝者移動時連續抓去的兩張 旦面和第二晝面分別用矩形框框住人臉,該自動連續對焦 程式包括:偵測模組,用於偵測人臉在第一畫面中的相^ 位置’取該晝面中的矩形框的—條對角線,得到該對角綠The first and second sides of the system are stored, and the two faces and the second side that are continuously captured by the photographer are respectively framed by a rectangular frame, and the automatic continuous focus program includes: a detection module. For detecting the position of the face in the first picture, 'take the diagonal of the rectangle in the face, and get the diagonal green
晝面和第二當而合另,丨用拓极柄/士,ηΛν _ . 五a,— ^對角綠,得到該對角線的 兩個頂點的錢;料計算漁,用於根制述第二畫面 中的對角線兩個頂點的座標,計算該矩形框的面積s2;判 斷模組’用於判斷第二畫面中的矩形框的面積52是否大於 第-畫面中的矩形框的面積S1 ;及對焦模組,用於當幻大 於si時,控制相機朝著近攝方向對焦掃描;當§2小於Μ 時,控制相機朝著無限遠處對焦掃描。 # —種相機自動對焦方法,用於拍攝移財的人體昭片昼 和 和 和 和 和 和 和 和 和 和 和 和 和 和 和 和 Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ Λ The coordinates of the two vertices of the diagonal line in the second picture are calculated, and the area s2 of the rectangular frame is calculated; the determining module 'is used to determine whether the area 52 of the rectangular frame in the second picture is larger than the rectangular frame in the first picture Area S1; and focus module, used to control the camera to focus scan in the close-up direction when the illusion is greater than si; control the camera to focus on the infinity scan when § 2 is less than Μ. #—A kind of camera autofocus method, used to shoot the human body
時進行自動對焦,該方法包括如下步驟:偵測人臉在第一 畫面中的相對位置,取該畫面中的矩形框的一條對角線, 得到該對角線的兩個頂點的座標;根據所述第-畫面中對 角線的兩個頂點的座標計算第一畫面中矩形框的面積 1,谓測人臉在第二畫面中的相對位置,取該畫面中矩形 王的條對角線,得到該對角線的兩個頂點的座標;根據 所述第一畫面中的對角線兩個頂點的座標計算該矩形拒的 1342710 晝面中的矩形框的面積S1 ;若52大於S1,則判斷被拍攝者 朝著近攝方向移動控制相機朝著近攝方向對焦掃描;當幻 小於S1時,控制相機朝著無限遠處對焦掃描。 相較於習知技術’本發明利用人臉相對於整個畫面的 大小變化和位置判斷連續對焦的方向和軌跡,來減少自動 對焦的時間。 【實施方式】 如圖1所示’是本發明相機自動對焦系統的硬體架構 圖。該系統包括:自動連續對焦程式10,該自動連續對焦 程式10運行於一數位信號處理系統(Digital Signal Process,簡稱DSP) 12,該DSP系統12存儲有所拍攝移動 中的人的連續動作的畫面。 如圖2所示’是本發明相機自動對焦方法較佳實施例 的示意圖。所示第一畫面1(以下簡稱畫面1)和第二畫面2 (以下簡稱晝面2)為兩張人臉對焦晝面,且該人臉對焦畫 面為被拍攝者的連續動作的畫面,每一畫面中分別用一矩 形框框住人臉。 如圖3所示’是圖1中自動連續對焦程式1〇的功能模組 圖。該自動連續對焦程式包括:偵測模組20、計算模組22、 判斷模組24、對焦楔組26。 偵測模組20 ’用於偵測人臉在晝面1中的相對位置, 所述矩形框框住人臉,取該矩形對焦框的其中一條對角 線’得到該對角線的兩個頂點的座標,如點Μ,點N,如 圖2所示。 1342710 计算核組22,用於根據所要拍攝的物體的大小將晝面 :平均劃分成若干個小方格,本實施例中,以劃分十六個小 方格為例進行說明。 所述計算模組22,還用於計算畫面1中矩形框的面積 S1,並計算該框的中心點〇的座標,該矩形框的中心點〇 即為人臉的中心點,點A在一小方格ABCD内,計算該方格 的四個頂點:點A、點B、點c及點D的座標,如圖2所示, 當前對焦區域為方格ABCD所在的區域。 # 所述偵測模組20,還用於偵測人臉在畫面2中的相對 位置,矩形框框住該晝面2中的人臉,取該矩形的—條對角 線’得到該對角線的兩個頂點的座標,如點M、,、,如 圖2所示。 所述計算模組22,還用於計算畫面2中的該矩形框的 面積S2,並計鼻該矩形框的中心點〇、的座標,點〇、在—小 方格A、B、C、D、内’計算該方格的四個頂點:點a、、點B、、 點C'及點D的座標’如圖2所示。 • 判斷模組24,用於判斷點A、點B、點C及點D的座標 與點A、點B、點C及點D的座標是否分別對應相等;^ 不相等,則判斷所拍攝的人已經離開對焦範圍,需要重新 對焦。 對焦模組26,用於當所述判斷模組24判斷人已經離開 對焦範圍時’則將對焦區域設為方格A、B、C、D、所在的區 域。 所述判斷模組24,還用於判斷S2是否大於S1。 11 1342710 所述對焦模組26,還用於當S2大於S1時,朝著macr〇 (近攝)方向對焦掃描,當S2小於S1時,朝著無限遠處對 焦掃描。 如圖4所示’是本發明相機自動對焦方法的較佳實施 例的流程圖。 首先’步驟S30 ’計算模組22根據被拍攝者的大小將 第一畫面和第二晝面平均劃分成多個方格,偵測模組2〇做 人臉偵測找出人臉在畫面1中的相對位置,所述矩形框框住 人臉,取該矩形對焦框的其中一條對角線,得到該對角線 的兩個頂點的座標,如點Μ,點N,如圖2所示。 步驟S32 ’計算模組22計算畫面1中矩形框的面積$ 1, 並計算該框的中心點Ο的座標,該矩形框的中心點〇即為人 臉的中心點’點Α在一小方格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、點C及點D的 12 1342710 座標與點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 1342710 數位信號處理系統 12 偵測模組 20 計算模組 22 判斷模組 24 對焦模組 26Performing autofocusing, the method includes the following steps: detecting a relative position of a human face in the first picture, taking a diagonal line of the rectangular frame in the picture, and obtaining coordinates of two vertices of the diagonal line; The coordinates of the two vertices of the diagonal line in the first picture calculate the area 1 of the rectangular frame in the first picture, and the relative position of the human face in the second picture is measured, and the diagonal line of the rectangular king in the picture is taken. Obtaining coordinates of two vertices of the diagonal line; calculating an area S1 of the rectangular frame in the 1342710 昼 plane of the rectangle according to the coordinates of the two vertices of the diagonal line in the first picture; if 52 is greater than S1, Then, it is judged that the subject moves toward the close-up direction to control the camera to focus scan toward the close-up direction; when the illusion is smaller than S1, the camera is controlled to focus on the infinity scan. Compared with the prior art, the present invention uses the face size and position of the face relative to the entire picture to determine the direction and trajectory of continuous focus to reduce the time of autofocus. [Embodiment] As shown in Fig. 1, the hardware architecture of the camera autofocus system of the present invention is shown. The system includes an automatic continuous focus program 10 that operates on a Digital Signal Process (DSP) 12 that stores a picture of a continuous motion of a person moving in motion. . Figure 2 is a schematic view of a preferred embodiment of the camera autofocus method of the present invention. The first screen 1 (hereinafter referred to as screen 1) and the second screen 2 (hereinafter referred to as the surface 2) are two face-focusing faces, and the face-focused image is a continuous motion of the photographer. A rectangular frame is used to frame the face in a picture. As shown in Fig. 3, it is a functional module diagram of the automatic continuous focus program 1〇 in Fig. 1. The automatic continuous focus program includes a detection module 20, a calculation module 22, a determination module 24, and a focus wedge group 26. The detecting module 20 ′ is configured to detect a relative position of the face in the face 1 , the rectangular frame framing the face, and taking one diagonal of the rectangular focus frame to obtain the two vertices of the diagonal Coordinates, such as point, point N, as shown in Figure 2. 1342710 The calculation core group 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 an area S1 of a rectangular frame in the screen 1, and calculate a coordinate of a center point 该 of the frame, where a center point of the rectangular frame is a center point of the face, and the point A is in a In the small square ABCD, the coordinates of the four vertices of the square are calculated: point A, point B, point c, and point D. As shown in Fig. 2, the current focus area is the area where the square ABCD is located. The detecting module 20 is further configured to detect a relative position of the face in the screen 2, and the rectangular frame frames the face in the face 2, and the diagonal of the rectangle is taken to obtain the diagonal The coordinates of the two vertices of the line, such as points M, ,, are shown in Figure 2. The calculation module 22 is further configured to calculate the area S2 of the rectangular frame in the screen 2, and calculate the coordinates of the center point of the rectangular frame, the point 〇, the small squares A, B, C, D. Inside 'calculates the four vertices of the square: the coordinates of point a, point B, point C' and point D are as shown in Fig. 2. • The judging module 24 is configured to determine whether the coordinates of the points A, B, C, and D are equal to the coordinates of the points A, B, C, and D; ^ if they are not equal, the photographed The person has left the focus range and needs to refocus. The focusing module 26 is configured to set the focus area to the area where the squares A, B, C, D are located when the determining module 24 determines that the person has left the focus range. The determining module 24 is further configured to determine whether S2 is greater than S1. 11 1342710 The focus module 26 is further configured to focus scan toward the macr〇 (close-up) direction when S2 is greater than S1, and to focus at infinity when S2 is less than S1. Figure 4 is a flow chart of a preferred embodiment of the camera autofocus method of the present invention. First, the 'step S30' calculation module 22 divides the first picture and the second picture into a plurality of squares according to the size of the subject, and the detection module 2 performs face detection to find the face in the picture 1. The relative position, the rectangular frame frames the face, takes one of the diagonal lines of the rectangular focus frame, and obtains the coordinates of the two vertices of the diagonal line, such as point Μ, point N, as shown in FIG. 2 . Step S32 'The calculation module 22 calculates the area $1 of the rectangular frame in the screen 1, and calculates the coordinates of the center point 该 of the frame, and the center point of the rectangular frame is the center point of the face' point in a small square Within the ABCD, calculate the coordinates of the four vertices of the square: point A, point B, point C, and point D. As shown in Figure 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 frames the face in the picture 2 to take a diagonal line of the rectangle to obtain the two vertices of the diagonal line. The coordinates, such as point M, point N, are shown in Figure 2. Step S36, the calculation module 22 calculates the area S2 of the rectangular frame in the facet 2, and calculates the coordinate 'point 中心 of the center point of the rectangular frame, in a small square A, B, C, D, 'Calculating the four vertices of the square: point A, point B, point C, and point D, as shown in Figure 2. Step S38 'The determination module 24 determines whether the coordinates of the 12 1342710 coordinates of the points A, B, C, and D are equal to the coordinates of the points A, B, C, and D, respectively. If they are not equal, Then it is judged that the person who has taken the photo has left the focus range and needs to refocus. In step S40, the determination module 24 determines whether the area S2 of the rectangular frame in the facet 2 is larger than the area S1 of the rectangular frame in the picture 1. In step S42', if S2 is larger than S1', the focus module 26 scans the focus in the macro direction. 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 1342710 Digital signal processing system 12 Detection module 20 Calculation module 22 Judgment module 24 Focus module 26
1414