【C++】VS2019+Dlib安装及整合详细步骤

### 因为手里的项目原因,需要使用到人脸的68个关键点定位,Dlib对关键点的定位可以说很准确的,写下这篇博客记录配置流程
首先要下载Cmake和Dlib以及VS2019
VS2019的下载和OpenCV的安装可以看我的这篇博客博客链接

cmake下载地址
cmke下载Dlib下载地址
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();
}

//  ----------------------------------------------------------------------------

结果如下即表明运行成功(鼠标拖动图案有小惊喜
在这里插入图片描述

  • 14
    点赞
  • 89
    收藏
    觉得还不错? 一键收藏
  • 26
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 26
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值