Ubuntu20.04中编译seetaFaceEngine

部署运行你感兴趣的模型镜像

SeetaFace简介

seetaface是中科院计算所山世光老师组的开源人脸识别项目
https://github.com/seetaface/SeetaFaceEngine

配置要求

Cmake:超过3.1版本

opencv:3.14.15

ubuntu:20.04

参考教程:

https://blog.youkuaiyun.com/square_zou/article/details/85855499

搭建步骤:

在分别编译三个模块的时候要先进入对应模块文件夹中

1、编译FaceDetection

mkdir build   #在FaceDetection目录中
cd build
cmake ..
make -j${npoc}
cd ..

配置完成后测试,注意imagefilePath需要自己修改成具体位置

./build/facedet_test imagefilePath ./model/seeta_fd_frontal_V1.0.bin  #imagefilePath是640*480图片的路径

2、编译FaceAlignment

mkdir build  #在FaceAlignment目录中

将FaceDetection中的/include/face_detection.h和/build/libseeta_facedet_lib.so 两个文件
拷贝到/FaceAlignment/build文件夹下

然后在FaceAlignment>src>test中face_alignment_test.cpp中进行下列修改

int main(int argc, char** argv)
{
// Initialize face detection model
seeta::FaceDetection detector("./build/seeta_fd_frontal_v1.0.bin"); //修改路径
//修改成这个路径,把seeta_fd_frontal_v1.0.bin放到build中,原版是基于windows
detector.SetMinFaceSize(40);
detector.SetScoreThresh(2.f);
detector.SetImagePyramidScaleFactor(0.8f);
detector.SetWindowStep(4, 4);

在FaceAlignment>src>test中cfan.cpp中添加

using std::isnan;

在/home/lf/SeetaFaceEngine-master/FaceAlignment/src/test/face_alignment_test.cpp中进行修改

修改原因:版本问题不匹配(16.04不需要修改)

109	  // Visualize the results
110	    //cvRectangle(img_color, cvPoint(faces[0].bbox.x, faces[0].bbox.y), cvPoint(faces[0].bbox.x + faces[0].bbox.width - 1, faces[0].bbox.y + faces[0].bbox.height - 1), CV_RGB(255, 0, 0));
111	    cv::Point(faces[0].bbox.x + faces[0].bbox.width - 1, faces[0].bbox.y + faces[0].bbox.height - 1), cv::Scalar(255, 0, 0);
112
113	  for (int i = 0; i<pts_num; i++)
114	  {
115	    //cvCircle(img_color, cvPoint(points[i].x, points[i].y), 2, CV_RGB(0, 255, 0), CV_FILLED);
116	    cv::Mat img_mat = cv::cvarrToMat(img_color);
117	    cv::circle(img_mat, cv::Point(points[i].x, points[i].y), 2, cv::Scalar(0, 255, 0), cv::FILLED);
118
119	  }
120	  cvSaveImage("result.jpg", img_color);

回到FaceAlignment文件夹下

cd build #进入到刚才创建的build文件夹
cmake ..
make

拷贝/FaceDetection/build文件夹下的seeta_fd_frontal_v1.0.bin文件到FaceAlignment的build中

cd .. #回到FaceAlignment文件夹下
./build/fa_test  #运行人脸关键点检测

结果不会显示,在当前目录会有一个result.jpg

3、编译FaceIdentification

mkdir build

将以下四个文件添加到FaceIndentification/build中

libseeta_facedet_lib.so(/FaceDetection/build)
seeta_fd_frontal_v1.0.bin(/FaceDetection/model)
libseeta_fa_lib.so(FaceAlignment/build)
seeta_fa_v1.1.bin(FaceAlignment/model)
将以下两个文件添加到FaceIndentification/include中

face_alignment.h(FaceAlignment/include)
face_detection.h(/FaceDetection/include)
打开FaceIdentification/src/test/CMakeLists.txt将文件替换成如下内容

aux_source_directory (. SRC_LIST)
link_directories(${PROJECT_BINARY_DIR})
message(${SRC_LIST})
# add external libraries
find_package(OpenCV REQUIRED)
include_directories(${seeta_facedet_lib_INCLUDE_DIRS} ${seeta_fa_lib_INCLUDE_DIRS})
list(APPEND seeta_fi_lib_required_libs ${OpenCV_LIBS} seeta_facedet_lib seeta_fa_lib)
enable_testing ()
foreach (f ${SRC_LIST})
  string(REGEX REPLACE "[.]cpp" ".bin" BIN ${f})
  add_executable(${BIN} ${f})
  #target_link_libraries(${BIN} viplnet ${OpenCV_LIBS} seeta_facede_lib seeta_fa_lib)
  target_link_libraries(${BIN} viplnet ${seeta_fi_lib_required_libs})
endforeach ()

在 FaceIdentification/src/test/test_face_recognizer.cpp文件中添加如下内容头文件

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

在 FaceIdentification/src/test/test_face_verification.cpp文件中添加如下内容头文件

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

解压 FaceIdentification/model/seeta_fr_v1.0.part1.rar

unrar x seeta_fr_v1.0.part1.rar

修改FaceIdentification/src/test/test_face_verification.cpp

需要将.bin文件的路径修改下,否则会报段错误

int main(int argc, char** argv)
{
  // Initialize face detection model
  //seeta::FaceDetection detector("../../../FaceDetection/model/seeta_fd_frontal_v1.0.bin");
  seeta::FaceDetection detector("./build/seeta_fd_frontal_v1.0.bin");
  detector.SetMinFaceSize(40);
  detector.SetScoreThresh(2.f);
  detector.SetImagePyramidScaleFactor(0.8f);
  detector.SetWindowStep(4, 4);

进入FaceIdentification\build文件夹下进行编译

cmake .. 
make  

回到FaceIdentification文件夹中进行测试

./build/src/test/test_face_recognizer.bin #3个单元测试函数
./build/src/test/test_face_verification.bin #比较两个图像相似度

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值