### 因为手里的项目原因,需要使用到人脸的68个关键点定位,Dlib对关键点的定位可以说很准确的,写下这篇博客记录配置流程
首先要下载Cmake和Dlib以及VS2019
VS2019的下载和OpenCV的安装可以看我的这篇博客博客链接
cmake下载地址
Dlib下载地址
解压Dlib-19.18到文件夹dlibrelease(什么名字都行)
新建下图中的install和build两个文件夹
源码选择刚才解压的文件夹的位置
将源码编译的位置选择刚才新建的build文件夹
点击configure产生以下界面
产生这个界面,
第一个选择你已经安装好的VS的版本
第二个选择 X64
等一会后产生以下界面
将CMAKE_INSTALL_RREFIX的value选择为刚才建立的文件夹的install文件夹
然后点击Generate
完成后点击 Open Project
在打开的VS工程中将图中的选择为Release X64
右键点击ALL_BUILD进行生成,然后等待完成。
右键点击INSTALL进行生成,然后等待完成。
然后新建一个VS项目
在项目上邮件,选择属性
配置include和lib(具体步骤可以参考这篇博客博客链接)
写入附加依赖项
在刚才的install文件夹下的lib文件夹中有一个文件,文件名即为附加依赖项的名字,复制粘贴即可
点击确认
写入测试代码(测试代码来自于dlib官网)
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*
This is an example illustrating the use of the perspective_window tool
in the dlib C++ Library. It is a simple tool for displaying 3D point
clouds on the screen.
*/
#include <dlib/gui_widgets.h>
#include <dlib/image_transforms.h>
#include <cmath>
using namespace dlib;
using namespace std;
// ----------------------------------------------------------------------------------------
int main()
{
// Let's make a point cloud that looks like a 3D spiral.
std::vector<perspective_window::overlay_dot> points;
dlib::rand rnd;
for (double i = 0; i < 20; i+=0.001)
{
// Get a point on a spiral
dlib::vector<double> val(sin(i),cos(i),i/4);
// Now add some random noise to it
dlib::vector<double> temp(rnd.get_random_gaussian(),
rnd.get_random_gaussian(),
rnd.get_random_gaussian());
val += temp/20;
// Pick a color based on how far we are along the spiral
rgb_pixel color = colormap_jet(i,0,20);
// And add the point to the list of points we will display
points.push_back(perspective_window::overlay_dot(val, color));
}
// Now finally display the point cloud.
perspective_window win;
win.set_title("perspective_window 3D point cloud");
win.add_overlay(points);
win.wait_until_closed();
}
// ----------------------------------------------------------------------------
结果如下即表明运行成功(鼠标拖动图案有小惊喜)