為了使本技術領域的人員更好地理解本說明書中的技術方案,下面將結合本說明書實施例中的圖式,對本說明書實施例中的技術方案進行清楚、完整地描述,顯然,所描述的實施例僅是本說明書一部分實施例,而不是全部的實施例。基於本說明書中的實施例,本領域普通技術人員在沒有做出進步性勞動前提下所獲得的所有其他實施例,都應當屬於本說明書保護的範圍。
本說明書實施例提供了一種人臉識別方法及裝置。
下面首先對本說明書實施例提供的一種人臉識別方法進行介紹。
需要說明的是,本說明書實施例提供的人臉識別方法適用於電子設備,在實際應用中,該電子設備可以為伺服器,或者,該電子設備也可以為手機、平板電腦、個人數位助理等終端設備,或者,該電子設備也可以為筆記型電腦、桌上型電腦、桌面機等電腦設備,本說明書實施例對此不作限定。
圖1是本說明書的一個實施例的人臉識別方法的流程圖,如圖1所示,該方法可以包括以下步驟:步驟102、步驟104、步驟106和步驟108,其中,
在步驟102中,獲取用於人臉識別的RGB圖像和對應的深度圖像,其中,RGB圖像中包含至少一個人臉。
本說明書實施例中,用於人臉識別的RGB圖像(彩色圖)和對應的深度圖像為針對同一場景拍攝的圖像。深度圖像中每個像素點的灰度值可用於表徵拍攝場景中某一點到深度圖像採集設備的距離。用於採集深度圖像的設備稱為深度圖像採集設備,用於採集RGB彩色圖像的設備稱為RGB圖像採集設備。
在步驟104中,從RGB圖像中選擇目標人臉。
本說明書實施例中,目標人臉像為RGB圖中最有可能用於人臉識別的人臉。
本說明書實施例中,可以對RGB圖像進行人臉檢測,檢測其中包含的人臉,並從中選擇一個人臉,作為目標人臉。具體的,可以將RGB圖像中預設區域的人臉,選擇為目標人臉。
考慮到具有人臉識別意圖的使用者通常會正對圖像採集設備的拍攝焦點或處於人群的正中位置,基於這種情況,本說明書實施例中,預設區域可以包括:RGB圖像的中心區域、或者RGB圖像拍攝時的焦點區域。相應的,可以將RGB圖像中心區域內的人臉,選擇為目標人臉;或者,可以將RGB圖像拍攝時的焦點區域內的人臉,選擇為目標人臉。
在步驟106中,根據目標人臉和深度圖像,判斷RGB圖像中是否存在干擾人臉;若否,則執行步驟108;其中,干擾人臉到人臉圖像採集設備的距離與目標人臉到人臉圖像採集設備的距離的差值小於預設閾值。
本說明書實施例中,人臉圖像採集設備指的是深度圖像採集設備。干擾人臉與目標人臉到深度圖像採集設備的距離相當或相差不多。
考慮到具有人臉識別意圖的使用者通常比較靠近圖像採集設備、並且在多人場景下具有人臉識別意圖的使用者通常只有一個,基於這種情況,本說明書實施例中,通過判斷RGB圖像中是否有干擾人臉,來確定目標人臉是否為多人場景下最具人臉識別意圖的人臉;具體的,如果RGB圖像中存在干擾人臉,則表明目標人臉不是多人場景下最具人臉識別意圖的人臉;如果RGB圖像中不存在干擾人臉,則表明目標人臉時多人場景下最具人臉識別意圖的人臉。
考慮到對RGB圖像進行人臉檢測,有時會造成人臉的漏檢,例如RGB圖像的角落裡的人臉或RGB圖像中出現的半張人臉無法檢測出來,基於這種情況,本說明書實施例中,採用對RGB圖像和該RGB圖像對應的深度圖像,可以避免上述漏檢的問題。
在步驟108中,基於目標人臉進行人臉識別。
本說明書實施例中,如果RGB圖像中不存在干擾人臉,則基於RGB圖像中的目標人臉進行人臉識別;如果RGB圖像中存在干擾人臉,則輸出提示訊息,該提示訊息用於提示RGB圖像中存在干擾人臉。
為了便於理解,以“刷臉支付”場景為例對本說明書實施例的技術方案進行舉例說明。
“刷臉支付”是基於人臉識別的支付方式,已成為線下消費場景的主要支付手段之一,具有操作便捷、體驗好等特點。隨著人臉識別技術的發展,“刷臉支付”已無需使用者輸入其他身份資訊(如手機號、帳號)便可完成支付行為,即僅需使用者刷一下臉就可以直接完成支付行為。對於以上的刷臉流程而言,其具有一個風險問題:當用於刷臉的畫面中存在多個人臉時,難以確認該畫面中的哪個使用者有意願進行支付行為,此時,可能會出現誤扣錢的情況,如果發生該情況,會發生資損,對“刷臉支付”的完全性造成較大的影響。
考慮到隨著攝影鏡頭硬體的逐步發展,線下支付場景中通常都配備了深度圖像採集設備,而深度圖像採集設備所採集到的深度圖像可以表示每個物體到相機的距離,基於這種情況,本說明書實施例中,可以獲取用於“刷臉支付”的RGB圖像和對應的深度圖像,檢測RGB圖像中的人臉,選定可能的支付使用者人臉(即目標人臉);之後,根據選定的人臉和深度圖像,判斷RGB圖像中是否存在干擾人臉,如果RGB圖像中存在干擾人臉,則認為本次支付交易存在多人臉無法確認的風險,並提示使用者該風險,讓使用者再次輸入相關帳戶資訊進行確認;如果RGB圖像中不存在干擾人臉,則認為本次支付交易較為安全,基於選定的人臉進行識別,識別通過後進行支付。
由上述實施例可見,該實施例中,在對包含多個人臉的RGB圖像進行人臉識別時,可以結合該RGB圖像對應的深度圖像,來確定該RGB圖像中用於人臉識別的人臉。相對於僅僅依據RGB圖像進行人臉識別,本說明書實施例中,由於深度圖像中包含的資訊比較豐富、且深度圖像可以反映該深度圖像中的各人臉到圖像採集設備的距離、且人臉到圖像採集設備的距離可以從一定程度上反映了使用者的人臉識別意願,因此本說明書實施例可以避免RGB圖像中人臉的漏檢,以及可以比較準確地確定出RGB圖像中用於人臉識別的人臉。
圖2是本說明書的另一個實施例的人臉識別方法的流程圖,本說明書實施例中,可以首先計算目標人臉到圖像採集設備的距離,根據計算得到的距離和深度圖像,來判斷RGB圖像中是否存在干擾人臉,此時,如圖2所示,該方法可以包括以下步驟:
在步驟202中,獲取用於人臉識別的RGB圖像和對應的深度圖像,其中,RGB圖像中包含至少一個人臉。
本說明書實施例中,用於人臉識別的RGB圖像(彩色圖)和對應的深度圖像為針對同一場景拍攝的圖像。深度圖像中每個像素點的灰度值可用於表徵拍攝場景中某一點到深度圖像採集設備的距離。用於採集深度圖像的設備稱為深度圖像採集設備,用於採集RGB彩色圖像的設備稱為RGB圖像採集設備。
在步驟204中,從RGB圖像中選擇目標人臉。
本說明書實施例中,目標人臉像為RGB圖中最有可能用於人臉識別的人臉。
本說明書實施例中,可以對RGB圖像進行人臉檢測,檢測其中包含的人臉,並從中選擇一個人臉,作為目標人臉。具體的,可以將RGB圖像中預設區域的人臉,選擇為目標人臉。
考慮到具有人臉識別意圖的使用者通常會正對圖像採集設備的拍攝焦點或處於人群的正中位置,基於這種情況,本說明書實施例中,預設區域可以包括:RGB圖像的中心區域、或者RGB圖像拍攝時的焦點區域。相應的,可以將RGB圖像中心區域內的人臉,選擇為目標人臉;或者,可以將RGB圖像拍攝時的焦點區域內的人臉,選擇為目標人臉。
在步驟206中,確定目標人臉在深度圖像中對應的目標區域。
考慮到RGB圖像採集設備的攝影鏡頭和深度圖像採集設備的攝影鏡頭是預先標定好的,即兩者具有明確的空間座標變換關係,基於這種情況,本說明書實施例中,可以根據RGB圖像和其對應的深度圖像的空間座標變換關係,確定目標人臉在深度圖像上的座標(即目標區域)。
在步驟208中,根據目標區域內像素點的資訊,計算目標人臉到人臉圖像採集設備的距離D1。
由於深度圖像中每個像素都表示距離,因此本說明書實施例中,可以根據目標區域內像素點的資訊,計算目標人臉到人臉圖像採集設備的距離D1;具體的,可以計算目標區域內各像素點到人臉圖像採集設備的距離,將各像素點到人臉圖像採集設備的距離的平均值,確定為目標人臉到人臉圖像採集設備的距離D1。
在步驟210中,判斷深度圖像中是否存在距離人臉圖像採集設備為D2的人臉;若否,則執行步驟212;其中,D1與D2的差值小於預設閾值。
本說明書實施例中,如果深度圖像中存在距離人臉圖像採集設備為D2的人臉,則RGB圖像中存在干擾人臉;如果深度圖像中不存在距離人臉圖像採集設備為D2的人臉,則確定RGB圖像中不存在干擾人臉。
本說明書實施例中,人臉圖像採集設備指的是深度圖像採集設備。干擾人臉與目標人臉到深度圖像採集設備的距離相當或相差不多。
本說明書實施例中,深度圖像中距離人臉圖像採集設備為D2的人臉包括:輪廓完整清晰的人臉、或者輪廓不完整不清晰的人臉。
考慮到具有人臉識別意圖的使用者通常比較靠近圖像採集設備、並且在多人場景下具有人臉識別意圖的使用者通常只有一個,本說明書實施例中,通過判斷RGB圖像中是否有干擾人臉,來確定目標人臉是否為多人場景下最具人臉識別意圖的人臉;具體的,如果RGB圖像中存在干擾人臉,則表明目標人臉不是多人場景下最具人臉識別意圖的人臉;如果RGB圖像中不存在干擾人臉,則表明目標人臉時多人場景下最具人臉識別意圖的人臉。
考慮到對RGB圖像進行人臉檢測,有時會造成人臉的漏檢,例如RGB圖像的角落裡的人臉或RGB圖像中出現的半張人臉無法檢測出來,本說明書實施例中,採用對RGB圖像和該RGB圖像對應的深度圖像,可以避免上述漏檢的問題。
在步驟212中,基於目標人臉進行人臉識別。
本說明書實施例中,如果RGB圖像中不存在干擾人臉,則基於RGB圖像中的目標人臉進行人臉識別;如果RGB圖像中存在干擾人臉,則輸出提示訊息,該提示訊息用於提示RGB圖像中存在干擾人臉。
由上述實施例可見,該實施例中,在對包含多個人臉的RGB圖像進行人臉識別時,可以結合該RGB圖像對應的深度圖像,來確定該RGB圖像中用於人臉識別的人臉。相對於僅僅依據RGB圖像進行人臉識別,本說明書實施例中,由於深度圖像中包含的資訊比較豐富、且深度圖像可以反映該深度圖像中的各人臉到圖像採集設備的距離、且人臉到圖像採集設備的距離可以從一定程度上反映了使用者的人臉識別意願,因此本說明書實施例可以避免RGB圖像中人臉的漏檢,以及可以比較準確地確定出RGB圖像中用於人臉識別的人臉。
圖3是本說明書的一個實施例的人臉識別裝置的結構示意圖,如圖3所示,在一種軟體實施方式中,人臉識別裝置300,可以包括:獲取模組301、選擇模組302、判斷模組303和識別模組304,其中,
獲取模組301,用於獲取用於人臉識別的RGB圖像和對應的深度圖像,所述RGB圖像中包含至少一個人臉;
選擇模組302,用於從所述RGB圖像中選擇目標人臉;
判斷模組303,用於根據所述目標人臉和所述深度圖像,判斷所述RGB圖像中是否存在干擾人臉,所述干擾人臉到人臉圖像採集設備的距離與所述目標人臉到所述人臉圖像採集設備的距離的差值小於預設閾值;
識別模組304,用於在所述RGB圖像中不存在所述干擾人臉的情況下,基於所述目標人臉進行人臉識別。
由上述實施例可見,該實施例中,在對包含多個人臉的RGB圖像進行人臉識別時,可以結合該RGB圖像對應的深度圖像,來確定該RGB圖像中用於人臉識別的人臉。相對於僅僅依據RGB圖像進行人臉識別,本說明書實施例中,由於深度圖像中包含的資訊比較豐富、且深度圖像可以反映該深度圖像中的各人臉到圖像採集設備的距離、且人臉到圖像採集設備的距離可以從一定程度上反映了使用者的人臉識別意願,因此本說明書實施例可以避免RGB圖像中人臉的漏檢,以及可以比較準確地確定出RGB圖像中用於人臉識別的人臉。
可選地,作為一個實施例,所述選擇模組302,可以包括:
人臉選擇子模組,用於將所述RGB圖像中預設區域的人臉,選擇為目標人臉。
可選地,作為一個實施例,所述預設區域包括:
所述RGB圖像的中心區域、或者所述RGB圖像拍攝時的焦點區域。
可選地,作為一個實施例,所述判斷模組303,可以包括:
目標區域確定子模組,用於確定所述目標人臉在所述深度圖像中對應的目標區域;
距離計算子模組,用於根據所述目標區域內像素點的資訊,計算所述目標人臉到人臉圖像採集設備的距離D1;
判斷子模組,用於判斷所述深度圖像中是否存在距離所述人臉圖像採集設備為D2的人臉,所述D1與D2的差值小於所述預設閾值;其中,
如果所述深度圖像中存在距離所述人臉圖像採集設備為D2的人臉,則所述RGB圖像中存在干擾人臉;如果所述深度圖像中不存在距離所述人臉圖像採集設備為D2的人臉,則確定所述RGB圖像中不存在干擾人臉。
可選地,作為一個實施例,所述距離計算子模組,可以包括:
距離計算單元,用於計算所述目標區域內各像素點到人臉圖像採集設備的距離;
距離確定單元,用於將所述各像素點到人臉圖像採集設備的距離的平均值,確定為所述目標人臉到人臉圖像採集設備的距離D1。
可選地,作為一個實施例,所述人臉識別裝置300,還可以包括:
輸出模組,用於在所述RGB圖像中存在所述干擾人臉的情況下,輸出提示訊息,所述提示訊息用於提示所述RGB圖像中存在干擾人臉。
圖4是本說明書的一個實施例電子設備的結構示意圖,如圖4所示,在硬體層面,該電子設備包括處理器,可選地還包括內部匯流排、網路介面、記憶體。其中,記憶體可能包含記憶體,例如高速隨機存取記憶體(Random-Access Memory,RAM),也可能還包括非易失性記憶體(non-volatile memory),例如至少1個磁碟記憶體等。當然,該電子設備還可能包括其他業務所需要的硬體。
處理器、網路介面和記憶體可以通過內部匯流排相互連接,該內部匯流排可以是ISA(Industry Standard Architecture,工業標準架構)匯流排、PCI(Peripheral Component Interconnect,周邊組件互連標準)匯流排或EISA(Extended Industry Standard Architecture,延伸工業標準架構)匯流排等。所述匯流排可以分為位址匯流排、資料匯流排、控制匯流排等。為便於表示,圖4中僅用一個雙向箭頭表示,但並不表示僅有一根匯流排或一種類型的匯流排。
記憶體,用於存放程式。具體地,程式可以包括程式碼,所述程式碼包括電腦操作指令。記憶體可以包括記憶體和非易失性記憶體,並向處理器提供指令和資料。
處理器從非易失性記憶體中讀取對應的電腦程式到記憶體中然後運行,在邏輯層面上形成人臉識別裝置。處理器,執行記憶體所存放的程式,並具體用於執行以下操作:
獲取用於人臉識別的RGB圖像和對應的深度圖像,所述RGB圖像中包含至少一個人臉;
從所述RGB圖像中選擇目標人臉;
根據所述目標人臉和所述深度圖像,判斷所述RGB圖像中是否存在干擾人臉,所述干擾人臉到人臉圖像採集設備的距離與所述目標人臉到所述人臉圖像採集設備的距離的差值小於預設閾值;
如果所述RGB圖像中不存在所述干擾人臉,則基於所述目標人臉進行人臉識別。
本說明書實施例中,在對包含多個人臉的RGB圖像進行人臉識別時,可以結合該RGB圖像對應的深度圖像,來確定該RGB圖像中用於人臉識別的人臉。相對於僅僅依據RGB圖像進行人臉識別,本說明書實施例中,由於深度圖像中包含的資訊比較豐富、且深度圖像可以反映該深度圖像中的各人臉到圖像採集設備的距離、且人臉到圖像採集設備的距離可以從一定程度上反映了使用者的人臉識別意願,因此本說明書實施例可以避免RGB圖像中人臉的漏檢,以及可以比較準確地確定出RGB圖像中用於人臉識別的人臉。
可選地,作為一個實施例,所述從所述RGB圖像中選擇目標人臉,包括:
將所述RGB圖像中預設區域的人臉,選擇為目標人臉。
可選地,作為一個實施例,所述預設區域包括:
所述RGB圖像的中心區域、或者所述RGB圖像拍攝時的焦點區域。
可選地,作為一個實施例,所述根據所述目標人臉和所述深度圖像,判斷所述RGB圖像中是否存在干擾人臉,包括:
確定所述目標人臉在所述深度圖像中對應的目標區域;
根據所述目標區域內像素點的資訊,計算所述目標人臉到人臉圖像採集設備的距離D1;
判斷所述深度圖像中是否存在距離所述人臉圖像採集設備為D2的人臉,所述D1與D2的差值小於所述預設閾值;
如果所述深度圖像中存在距離所述人臉圖像採集設備為D2的人臉,則所述RGB圖像中存在干擾人臉;如果所述深度圖像中不存在距離所述人臉圖像採集設備為D2的人臉,則確定所述RGB圖像中不存在干擾人臉。
可選地,作為一個實施例,所述根據所述目標區域內像素點的資訊,計算所述目標人臉到人臉圖像採集設備的距離D1,包括:
計算所述目標區域內各像素點到人臉圖像採集設備的距離;
將所述各像素點到人臉圖像採集設備的距離的平均值,確定為所述目標人臉到人臉圖像採集設備的距離D1。
可選地,作為一個實施例,所述方法還包括:
如果所述RGB圖像中存在所述干擾人臉,則輸出提示訊息,所述提示訊息用於提示所述RGB圖像中存在干擾人臉。
上述如本說明書圖4所示實施例揭示的人臉識別裝置執行的方法可以應用於處理器中,或者由處理器實現。處理器可能是一種積體電路晶片,具有信號的處理能力。在實現過程中,上述方法的各步驟可以通過處理器中的硬體的集成邏輯電路或者軟體形式的指令完成。上述的處理器可以是通用處理器,包括中央處理器(Central Processing Unit,CPU)、網路處理器(Network Processor,NP)等;還可以是數位訊號處理器(Digital Signal Processor,DSP)、專用積體電路(Application Specific Integrated Circuit,ASIC)、場可程式設計閘陣列(Field-Programmable Gate Array,FPGA)或者其他可程式設計邏輯器件、分立門或者電晶體邏輯器件、分立硬體組件。可以實現或者執行本說明書實施例中的公開的各方法、步驟及邏輯方塊圖。通用處理器可以是微處理器或者該處理器也可以是任何常規的處理器等。結合本說明書實施例所公開的方法的步驟可以直接體現為硬體解碼處理器執行完成,或者用解碼處理器中的硬體及軟體模組組合執行完成。軟體模組可以位於隨機記憶體,快閃記憶體、唯讀記憶體,可程式設計唯讀記憶體或者電可讀寫可程式設計記憶體、暫存器等本領域成熟的儲存媒體中。該儲存媒體位於記憶體,處理器讀取記憶體中的資訊,結合其硬體完成上述方法的步驟。
該電子設備還可執行圖1的方法,並實現人臉識別裝置在圖1所示實施例的功能,本說明書實施例在此不再贅述。
本說明書實施例還提供了一種電腦可讀儲存媒體,該電腦可讀儲存媒體儲存一個或多個程式,該一個或多個程式包括指令,該指令當被包括多個應用程式的可擕式電子設備執行時,能夠使該可擕式電子設備執行圖1所示實施例的方法,並具體用於執行以下方法:
獲取用於人臉識別的RGB圖像和對應的深度圖像,所述RGB圖像中包含至少一個人臉;
從所述RGB圖像中選擇目標人臉;
根據所述目標人臉和所述深度圖像,判斷所述RGB圖像中是否存在干擾人臉,所述干擾人臉到人臉圖像採集設備的距離與所述目標人臉到所述人臉圖像採集設備的距離的差值小於預設閾值;
如果所述RGB圖像中不存在所述干擾人臉,則基於所述目標人臉進行人臉識別。
總之,以上所述僅為本說明書的較佳實施例而已,並非用於限定本說明書的保護範圍。凡在本說明書的精神和原則之內,所作的任何修改、等同替換、改進等,均應包含在本說明書的保護範圍之內。
上述實施例闡明的系統、裝置、模組或單元,具體可以由電腦晶片或實體實現,或者由具有某種功能的產品來實現。一種典型的實現設備為電腦。具體的,電腦例如可以為個人電腦、膝上型電腦、蜂巢式電話、相機電話、智慧型電話、個人數位助理、媒體播放機、導航設備、電子郵件設備、遊戲控制台、平板電腦、可穿戴設備或者這些設備中的任何設備的組合。
電腦可讀媒體包括永久性和非永久性、可移動和非可移動媒體可以由任何方法或技術來實現資訊儲存。資訊可以是電腦可讀指令、資料結構、程式的模組或其他資料。電腦的儲存媒體的例子包括,但不限於相變記憶體(PRAM)、靜態隨機存取記憶體(SRAM)、動態隨機存取記憶體(DRAM)、其他類型的隨機存取記憶體(RAM)、唯讀記憶體(ROM)、電可擦除可程式設計唯讀記憶體(EEPROM)、快閃記憶體或其他記憶體技術、唯讀光碟唯讀記憶體(CD-ROM)、數位多功能光碟(DVD)或其他光學儲存、磁盒式磁帶,磁帶磁片儲存或其他磁性存放裝置或任何其他非傳輸媒體,可用於儲存可以被計算設備存取的資訊。按照本文中的界定,電腦可讀媒體不包括暫存電腦可讀媒體(transitory media),如調變的資料信號和載波。
還需要說明的是,術語“包括”、“包含”或者其任何其他變體意在涵蓋非排他性的包含,從而使得包括一系列要素的過程、方法、商品或者設備不僅包括那些要素,而且還包括沒有明確列出的其他要素,或者是還包括為這種過程、方法、商品或者設備所固有的要素。在沒有更多限制的情況下,由語句“包括一個……”限定的要素,並不排除在包括所述要素的過程、方法、商品或者設備中還存在另外的相同要素。
本說明書中的各個實施例均採用遞進的方式描述,各個實施例之間相同相似的部分互相參見即可,每個實施例重點說明的都是與其他實施例的不同之處。尤其,對於系統實施例而言,由於其基本相似於方法實施例,所以描述的比較簡單,相關之處參見方法實施例的部分說明即可。In order to enable those skilled in the art to better understand the technical solutions in this specification, the following will clearly and completely describe the technical solutions in the embodiments of this specification in conjunction with the drawings in the embodiments of this specification. Obviously, the described The embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without making progressive labor should fall within the protection scope of this specification.
The embodiments of this specification provide a face recognition method and device.
The following first introduces a face recognition method provided by an embodiment of this specification.
It should be noted that the face recognition method provided in the embodiments of this specification is applicable to electronic devices. In practical applications, the electronic device can be a server, or the electronic device can also be a mobile phone, a tablet computer, a personal digital assistant, etc. The terminal device, or the electronic device may also be a computer device such as a notebook computer, a desktop computer, a desktop computer, etc., which is not limited in the embodiment of this specification.
Fig. 1 is a flowchart of a face recognition method according to an embodiment of the present specification. As shown in Fig. 1, the method may include the following steps: step 102, step 104, step 106, and step 108, where:
In step 102, an RGB image and a corresponding depth image for face recognition are acquired, where the RGB image contains at least one face.
In the embodiments of this specification, the RGB image (color map) used for face recognition and the corresponding depth image are images taken for the same scene. The gray value of each pixel in the depth image can be used to characterize the distance from a certain point in the shooting scene to the depth image acquisition device. The device used to collect the depth image is called the depth image acquisition device, and the device used to collect the RGB color image is called the RGB image acquisition device.
In step 104, the target face is selected from the RGB image.
In the embodiment of this specification, the target face image is the face most likely to be used for face recognition in the RGB image.
In the embodiment of this specification, face detection can be performed on the RGB image, the face contained therein is detected, and a face is selected as the target face. Specifically, a human face in a preset area in the RGB image can be selected as the target human face.
Considering that the user with the intention of face recognition will usually be directly facing the shooting focus of the image acquisition device or in the middle of the crowd, based on this situation, in the embodiment of this specification, the preset area may include: the center of the RGB image Area, or focus area when RGB image is taken. Correspondingly, the face in the central area of the RGB image can be selected as the target face; or, the face in the focus area when the RGB image is taken can be selected as the target face.
In step 106, judge whether there is an interfering face in the RGB image based on the target face and the depth image; if not, proceed to step 108; wherein, the distance between the interfering face and the face image acquisition device is the same as that of the target person The difference in the distance between the face and the face image acquisition device is less than the preset threshold.
In the embodiments of this specification, the face image acquisition device refers to the depth image acquisition device. The distance between the interfering face and the target face to the depth image acquisition device is equal or similar.
Considering that the user with the intention of face recognition is usually closer to the image capture device, and there is usually only one user with the intention of face recognition in a multi-person scene, based on this situation, in the embodiment of this specification, the RGB Whether there is an interfering face in the image, to determine whether the target face is the most intent of face recognition in a multi-person scene; specifically, if there is an interfering face in the RGB image, it indicates that the target face is not many The face with the most facial recognition intention in the human scene; if there is no interfering face in the RGB image, it indicates that the target face is the most intent face in the multi-person scene.
Taking into account the face detection of RGB images, sometimes it will cause missed detection of human faces. For example, the face in the corner of the RGB image or half of the face in the RGB image cannot be detected. Based on this situation In the embodiment of this specification, the RGB image and the depth image corresponding to the RGB image are used to avoid the above-mentioned problem of missed detection.
In step 108, face recognition is performed based on the target face.
In the embodiment of this specification, if there is no interfering face in the RGB image, face recognition is performed based on the target face in the RGB image; if there is an interfering face in the RGB image, a prompt message is output. It is used to indicate the presence of interfering faces in the RGB image.
In order to facilitate understanding, the technical solutions of the embodiments of the present specification are illustrated by taking the scenario of "paying by face scanning" as an example.
"Pay with face recognition" is a payment method based on face recognition. It has become one of the main payment methods in offline consumption scenarios. It has the characteristics of convenient operation and good experience. With the development of face recognition technology, "face payment" does not require users to enter other identification information (such as mobile phone number, account number) to complete the payment behavior, that is, the user only needs to swipe the face to directly complete the payment behavior. For the above face brushing process, it has a risk problem: when there are multiple faces in the screen used to brush the face, it is difficult to confirm which user in the screen is willing to make the payment. At this time, it may appear In the case of wrongful deduction of money, if this happens, capital loss will occur, which will have a greater impact on the completeness of the "face payment".
Taking into account that with the gradual development of camera lens hardware, offline payment scenes are usually equipped with depth image acquisition equipment, and the depth images collected by the depth image acquisition equipment can indicate the distance of each object to the camera. Based on this situation, in the embodiment of this specification, the RGB image and the corresponding depth image used for "face payment" can be acquired, the face in the RGB image can be detected, and the possible payment user face (ie Target face); After that, according to the selected face and depth image, determine whether there is an interfering face in the RGB image. If there is an interfering face in the RGB image, it is considered that there are multiple faces in the payment transaction that cannot be confirmed The user will be prompted to enter the relevant account information again for confirmation; if there is no interfering human face in the RGB image, the payment transaction is considered safer, and the recognition is based on the selected face. Payment is made after approval.
It can be seen from the above embodiment that in this embodiment, when performing face recognition on an RGB image containing multiple human faces, the depth image corresponding to the RGB image can be combined to determine that the RGB image is used for the face. Recognized face. Compared with the face recognition based only on RGB images, in the embodiments of this specification, since the information contained in the depth image is richer, and the depth image can reflect the information of each face in the depth image to the image acquisition device The distance and the distance from the face to the image acquisition device can reflect the user’s face recognition willingness to a certain extent. Therefore, the embodiments of this specification can avoid the missed detection of the face in the RGB image, and can be more accurately determined Output the face used for face recognition in RGB image.
Figure 2 is a flowchart of a face recognition method according to another embodiment of this specification. In this embodiment of this specification, the distance from the target face to the image acquisition device can be calculated first, and the calculated distance and depth image Determine whether there is an interference face in the RGB image. At this time, as shown in Figure 2, the method may include the following steps:
In step 202, an RGB image and a corresponding depth image for face recognition are acquired, where the RGB image contains at least one face.
In the embodiments of this specification, the RGB image (color map) used for face recognition and the corresponding depth image are images taken for the same scene. The gray value of each pixel in the depth image can be used to characterize the distance from a certain point in the shooting scene to the depth image acquisition device. The device used to collect the depth image is called the depth image acquisition device, and the device used to collect the RGB color image is called the RGB image acquisition device.
In step 204, the target face is selected from the RGB image.
In the embodiment of this specification, the target face image is the face most likely to be used for face recognition in the RGB image.
In the embodiment of this specification, face detection can be performed on the RGB image, the face contained therein is detected, and a face is selected as the target face. Specifically, a human face in a preset area in the RGB image can be selected as the target human face.
Considering that the user with the intention of face recognition will usually be directly facing the shooting focus of the image acquisition device or in the middle of the crowd, based on this situation, in the embodiment of this specification, the preset area may include: the center of the RGB image Area, or focus area when RGB image is taken. Correspondingly, the face in the central area of the RGB image can be selected as the target face; or, the face in the focus area when the RGB image is taken can be selected as the target face.
In step 206, the target area corresponding to the target face in the depth image is determined.
Considering that the photographic lens of the RGB image acquisition device and the photographic lens of the depth image acquisition device are pre-calibrated, that is, the two have a clear spatial coordinate transformation relationship. Based on this situation, in the embodiments of this specification, the RGB The spatial coordinate transformation relationship between the image and its corresponding depth image determines the coordinates of the target face on the depth image (that is, the target area).
In step 208, the distance D1 from the target face to the face image acquisition device is calculated according to the information of the pixel points in the target area.
Since each pixel in the depth image represents a distance, in the embodiment of this specification, the distance D1 from the target face to the face image acquisition device can be calculated according to the pixel information in the target area; specifically, the target can be calculated The distance from each pixel in the area to the face image acquisition device, and the average of the distance from each pixel to the face image acquisition device is determined as the distance D1 from the target face to the face image acquisition device.
In step 210, it is determined whether there is a face D2 from the face image acquisition device in the depth image; if not, step 212 is executed; wherein the difference between D1 and D2 is less than a preset threshold.
In the embodiments of this specification, if there is a face that is D2 from the face image acquisition device in the depth image, then there is an interfering face in the RGB image; if there is no face image acquisition device in the depth image, it is D2 face, it is determined that there is no interfering face in the RGB image.
In the embodiments of this specification, the face image acquisition device refers to the depth image acquisition device. The distance between the interfering face and the target face to the depth image acquisition device is equal or similar.
In the embodiment of this specification, the face whose distance is D2 from the face image acquisition device in the depth image includes: a face with a complete and clear outline, or a face with an incomplete and unclear outline.
Considering that the user with the intention of face recognition is usually closer to the image acquisition device, and there is usually only one user with the intention of face recognition in a multi-person scene, in the embodiment of this specification, it is determined whether there is Interfering face to determine whether the target face is the most intended face in a multi-person scene; specifically, if there is an interfering face in the RGB image, it indicates that the target face is not the most in a multi-person scene. Face recognition intent; if there is no interfering face in the RGB image, it indicates that the target face is the most intent to face recognition in a multi-person scene.
Considering that face detection is performed on RGB images, sometimes it may cause missed detection of human faces. For example, the face in the corner of the RGB image or half of the face in the RGB image cannot be detected. The embodiment of this specification In the RGB image and the depth image corresponding to the RGB image, the above-mentioned missed detection problem can be avoided.
In step 212, face recognition is performed based on the target face.
In the embodiment of this specification, if there is no interfering face in the RGB image, face recognition is performed based on the target face in the RGB image; if there is an interfering face in the RGB image, a prompt message is output. It is used to indicate the presence of interfering faces in the RGB image.
It can be seen from the above embodiment that in this embodiment, when performing face recognition on an RGB image containing multiple human faces, the depth image corresponding to the RGB image can be combined to determine that the RGB image is used for the face. Recognized face. Compared with the face recognition based only on RGB images, in the embodiments of this specification, since the information contained in the depth image is richer, and the depth image can reflect the information of each face in the depth image to the image acquisition device The distance and the distance from the face to the image acquisition device can reflect the user’s face recognition willingness to a certain extent. Therefore, the embodiments of this specification can avoid the missed detection of the face in the RGB image, and can be more accurately determined Output the face used for face recognition in RGB image.
FIG. 3 is a schematic structural diagram of a face recognition device according to an embodiment of this specification. As shown in FIG. 3, in a software implementation, the face recognition device 300 may include: an acquisition module 301, a selection module 302, The judgment module 303 and the identification module 304, in which,
The acquisition module 301 is configured to acquire an RGB image and a corresponding depth image for face recognition, where the RGB image contains at least one face;
The selection module 302 is used to select a target face from the RGB image;
The judging module 303 is used to judge whether there is an interfering face in the RGB image based on the target face and the depth image, and the distance between the interfering face and the face image collection device is the same as that of the The difference in the distance between the target face and the face image acquisition device is less than a preset threshold;
The recognition module 304 is configured to perform face recognition based on the target face when the interfering face does not exist in the RGB image.
It can be seen from the above embodiment that in this embodiment, when performing face recognition on an RGB image containing multiple human faces, the depth image corresponding to the RGB image can be combined to determine that the RGB image is used for the face. Recognized face. Compared with the face recognition based only on RGB images, in the embodiments of this specification, since the information contained in the depth image is richer, and the depth image can reflect the information of each face in the depth image to the image acquisition device The distance and the distance from the face to the image acquisition device can reflect the user’s face recognition willingness to a certain extent. Therefore, the embodiments of this specification can avoid the missed detection of the face in the RGB image, and can be more accurately determined Output the face used for face recognition in RGB image.
Optionally, as an embodiment, the selection module 302 may include:
The face selection submodule is used to select a face in a preset area in the RGB image as a target face.
Optionally, as an embodiment, the preset area includes:
The central area of the RGB image or the focal area when the RGB image is taken.
Optionally, as an embodiment, the judgment module 303 may include:
A target area determining sub-module, configured to determine the target area corresponding to the target face in the depth image;
The distance calculation sub-module is used to calculate the distance D1 from the target face to the face image acquisition device according to the information of the pixels in the target area;
The judging submodule is used to judge whether there is a face D2 from the face image acquisition device in the depth image, and the difference between D1 and D2 is less than the preset threshold; wherein,
If there is a face that is D2 from the face image acquisition device in the depth image, there is an interfering face in the RGB image; if there is no face image in the depth image If the image collection device is a D2 face, it is determined that there is no interfering face in the RGB image.
Optionally, as an embodiment, the distance calculation submodule may include:
A distance calculation unit, configured to calculate the distance from each pixel in the target area to the face image acquisition device;
The distance determining unit is configured to determine the average value of the distances from each pixel point to the face image acquisition device as the distance D1 from the target face to the face image acquisition device.
Optionally, as an embodiment, the face recognition apparatus 300 may further include:
The output module is configured to output a prompt message when the interfering human face exists in the RGB image, and the prompt message is used to prompt the interfering human face in the RGB image.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the specification. As shown in Fig. 4, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. Among them, the memory may include memory, such as high-speed random-access memory (Random-Access Memory, RAM), and may also include non-volatile memory, such as at least one magnetic disk memory. Wait. Of course, the electronic equipment may also include hardware required by other businesses.
The processor, network interface, and memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture) bus or a PCI (Peripheral Component Interconnect) bus Or EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of presentation, only one double-headed arrow is used to indicate in FIG. 4, but it does not mean that there is only one busbar or one type of busbar.
Memory, used to store programs. Specifically, the program may include program code, and the program code includes computer operation instructions. The memory may include memory and non-volatile memory, and provide instructions and data to the processor.
The processor reads the corresponding computer program from the non-volatile memory to the memory and then runs it to form a face recognition device on the logical level. The processor executes the programs stored in the memory and is specifically used to perform the following operations:
Acquiring an RGB image used for face recognition and a corresponding depth image, where the RGB image contains at least one face;
Selecting a target face from the RGB image;
According to the target face and the depth image, it is determined whether there is an interfering face in the RGB image, and the distance from the interfering face to the face image acquisition device is the same as the distance from the target face to the person The difference in the distance of the face image acquisition device is less than a preset threshold;
If the interfering face does not exist in the RGB image, face recognition is performed based on the target face.
In the embodiment of the present specification, when performing face recognition on an RGB image containing multiple human faces, the depth image corresponding to the RGB image can be combined to determine the human face used for face recognition in the RGB image. Compared with the face recognition based only on RGB images, in the embodiments of this specification, since the information contained in the depth image is richer, and the depth image can reflect the information of each face in the depth image to the image acquisition device The distance and the distance from the face to the image acquisition device can reflect the user’s face recognition willingness to a certain extent. Therefore, the embodiments of this specification can avoid the missed detection of the face in the RGB image, and can be more accurately determined Output the face used for face recognition in RGB image.
Optionally, as an embodiment, the selecting a target human face from the RGB image includes:
The human face in the preset area in the RGB image is selected as the target human face.
Optionally, as an embodiment, the preset area includes:
The central area of the RGB image or the focal area when the RGB image is taken.
Optionally, as an embodiment, the judging whether there is an interfering human face in the RGB image based on the target human face and the depth image includes:
Determining a target area corresponding to the target face in the depth image;
Calculate the distance D1 from the target face to the face image acquisition device according to the pixel information in the target area;
Determining whether there is a face D2 from the face image acquisition device in the depth image, and the difference between D1 and D2 is less than the preset threshold;
If there is a face that is D2 from the face image acquisition device in the depth image, there is an interfering face in the RGB image; if there is no face image in the depth image If the image collection device is a D2 face, it is determined that there is no interfering face in the RGB image.
Optionally, as an embodiment, the calculating the distance D1 from the target face to the face image acquisition device according to the pixel information in the target area includes:
Calculating the distance from each pixel in the target area to the face image acquisition device;
The average value of the distance from each pixel to the face image collection device is determined as the distance D1 from the target face to the face image collection device.
Optionally, as an embodiment, the method further includes:
If the interfering human face exists in the RGB image, a prompt message is output, and the prompt message is used to prompt the interfering human face in the RGB image.
The above-mentioned method executed by the face recognition apparatus disclosed in the embodiment shown in FIG. 4 of this specification may be applied to or implemented by the processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the above method can be completed by hardware integrated logic circuits in the processor or instructions in the form of software. The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (DSP), a dedicated Integrated circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like. The steps of the method disclosed in the embodiments of this specification can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random memory, flash memory, read-only memory, programmable read-only memory, or electrically readable, writable and programmable memory, register. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
The electronic device can also execute the method in FIG. 1 and realize the functions of the embodiment of the face recognition apparatus shown in FIG. 1, which will not be repeated in the embodiment of this specification.
The embodiment of this specification also provides a computer-readable storage medium, the computer-readable storage medium stores one or more programs, and the one or more programs include instructions. When the instructions are included in a portable electronic device that includes multiple application programs When the device is executed, the portable electronic device can be made to execute the method of the embodiment shown in FIG. 1, and is specifically used to execute the following methods:
Acquiring an RGB image used for face recognition and a corresponding depth image, where the RGB image contains at least one face;
Selecting a target face from the RGB image;
According to the target face and the depth image, it is determined whether there is an interfering face in the RGB image, and the distance from the interfering face to the face image acquisition device is the same as the distance from the target face to the person The difference in the distance of the face image acquisition device is less than a preset threshold;
If the interfering face does not exist in the RGB image, face recognition is performed based on the target face.
In short, the above descriptions are only preferred embodiments of this specification, and are not intended to limit the protection scope of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the protection scope of this specification.
The systems, devices, modules or units explained in the above embodiments may be implemented by computer chips or entities, or implemented by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, and a wearable. Device or any combination of these devices.
Computer-readable media includes permanent and non-permanent, removable and non-removable media, and information storage can be realized by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), and other types of random access memory (RAM) , Read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only CD-ROM (CD-ROM), digital multi-function Optical discs (DVD) or other optical storage, magnetic cassettes, magnetic tape storage or other magnetic storage devices, or any other non-transmission media, can be used to store information that can be accessed by computing devices. According to the definition in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
It should also be noted that the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, product or equipment including a series of elements not only includes those elements, but also includes Other elements that are not explicitly listed, or include elements inherent to this process, method, commodity, or equipment. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, commodity, or equipment that includes the element.
The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for related parts, please refer to the part of the description of the method embodiment.