開源人臉識別seetaface入門教程 一

2021-09-23 06:52:11 字數 4259 閱讀 3440

簡述

seetaface由中科院計算所山世光研究員帶領的人臉識別研究組研發。**基於c++實現,不依賴第三方庫。然而,目前開源的**,是在windows vs上編譯的,對於我們這幫mac/linux使用者來說,用起來還是挺麻煩的。經過這幾天的學習,對seetaface總算有了全面的了解。下面,聽我娓娓道來。

注意:本文章不涉及**邏輯和原理,只是教大家如何使用seetaface做人臉識別。

引擎

facedetection

facealignment

faceidentification

以下教程都是在macosx編譯執行通過。使用cmake和make編譯

以下的編譯方法是把facedetect測試程式也編譯了,而測試程式是依賴opencv的,所以,在這之前,確認opencv是否安裝

人臉識別教程

編譯由於**是在windows平台編譯的,所以,這地方要做些修改。

進入facedetection目錄

修改include/common.h,修改38行 

#ifdef seeta_exports 

#define seeta_api __declspec(dllexport) 

#else

#define seeta_api __declspec(dllimport) 

#endif 

#if defined _win32 

#ifdef seeta_exports 

#define seeta_api __declspec(dllexport) 

#else

#define seeta_api __declspec(dllimport) 

#endif 

#else

#define seeta_api 

#endif 

修改include/feat/surf_feature_map.**件,在前面加上#include

修改include/util/image_pyramid.**件,在前面加上#include

修改src/feat/surf_feature_map.cpp檔案,在前面加上#include

增加cmakelists.txt,內容如下:

cmake_minimum_required(version 3.3) 

project(seeta_facedet_lib) 

option(build_examples  "set to on to build examples"  on) 

option(use_openmp      "set to on to build use openmp"  on) 

set(cmake_cxx_standard 11) 

set(cmake_cxx_standard_required on) 

message(status "c++11 support has been enabled by default.") 

set(cmake_cxx_flags "$ -msse4.1") 

if (use_openmp) 

find_package(openmp quiet) 

if (openmp_found) 

message(status "use openmp") 

add_definitions(-duse_openmp) 

set(cmake_c_flags "$ $") 

set(cmake_cxx_flags "$ $") 

set(cmake_exe_linker_flags "$ $") 

endif() 

endif() 

include_directories(include) 

set(src_files 

src/util/nms.cpp 

src/util/image_pyramid.cpp 

src/io/lab_boost_model_reader.cpp 

src/io/surf_mlp_model_reader.cpp 

src/feat/lab_feature_map.cpp 

src/feat/surf_feature_map.cpp 

src/classifier/lab_boosted_classifier.cpp 

src/classifier/mlp.cpp 

src/classifier/surf_mlp.cpp 

src/face_detection.cpp 

src/fust.cpp 

) add_library(face_detect shared $) 

set(facedet_required_libs face_detect) 

if (build_examples)         

message(status "build with examples.") 

find_package(opencv) 

if (not opencv_found) 

message(warning "opencv not found. test will not be built.") 

else() 

include_directories($) 

add_executable(facedet_test src/test/facedetection_test.cpp) 

target_link_libraries(facedet_test $) 

endif() 

endif() 

建立build目錄,mkdir build 編譯,cd build && cmake .. && make 當前目錄下生成可執行檔案

執行

執行完make命令以後,當前的目錄下會生成乙個可執行檔案facedet_test

由於預設的程式讀取的是當前路徑下的test_image.jpg和seeta_fd_frontal_v1.0.bin,test_image.jpg是人臉,seeta_fd_frontal_v1.0是識別的引擎。

確保以上的兩個檔案在當前路徑下存在了,既可以./facedet_test執行了。

你可以修改位於src/test目錄下的檔案,來達到自己的目的。

使用

我們可以參考src/test/facedetection_test.cpp這個測試程式,來達到我們人臉識別的目的。

標頭檔案

#include 

"opencv2/highgui/highgui.hpp"

#include "opencv2/imgproc/imgproc.hpp"

#include "face_detection.h"

opencv標頭檔案主要用來載入影象,face_detection.h是人臉識別的主要程式。 

載入人臉識別引擎

seeta::facedetection detector(『seeta_fd_frontal_v1.0』); 

設定最小人臉大小

detector.setminfacesize(40); 

這個根據實際情況調整,中,人臉越大,這個值也越大,因為這個值越小,人臉識別速度越慢。

識別中的人臉

std::vecto***ces = detector.detect(img_data); 

在這之前,需要對進行處理,這裡略過

輸出人臉識別的結果

for

(int32_t i = 0; i 

s[i].bbox.x; faces[i].bbox.y;是人臉的左上角座標。faces[i].bbox.width;faces[i].bbox.height;是人臉的長和寬。 

結語

seetaface的確是個很好用的人臉識別庫,呼叫、編譯都很簡單,但是由於文件的缺少,所以剛開始看的時候,會比較亂,不知道如何下手。本片文章主要介紹了facedetect的使用,接下來我會講解如何識別人臉的特徵點,也就是嘴、鼻子、眼。敬請期待。

《SeetaFace開源人臉識別引擎介紹》讀書筆記

結合經典級聯結構和多層神經網路的人臉檢測方法,採用的是漏斗型級聯結構 funnel structured cascade,fust 專門針對多姿態人臉檢測設計,引入由粗到細的設計理念,兼顧了速度與精度的平衡。如下圖所示,fust級聯結構在頂部由多個針對不同姿態的快速lab級聯分類器構成,緊接著是若干...

人臉識別SeetaFace6編譯

編譯生成的結果 git clone recursive 需要先編譯三個基礎庫 openrolezoo seetaauthorize tennis。先是openrolezoo,這個庫需要修改一下源 才能成功編譯 修改 openrolezoo include orz mem pot.h,在第9行 inc...

seetaface人臉匹配(VS2015)

參考 1.seetaface學習之二 2.seetaface教程 一 在 vs 中的編譯安裝和環境配置 3.seetaface原始碼中的word文件 儘管現在大家都開始用seetaface22 以後再研究 總結下自己踩過的坑 因為自己師c 新手 針對上述 seetaface教程 一 仔細寫了修改內容...