Dlib机器学习库的安装和使用

Dlib是一个机器学习的C++库,包含了许多机器学习常用的算法。而且文档和例子都非常详细,以后准备深入学习。
Dlib官网地址:http://www.dlib.net/ml.html
这里写图片描述

但准备使用的时候并没在网上找到很多关于安装的资料=.=对我们小白来说很不方便。所以决定在这里记录一下安装的过程。
我使用的是VS2013。

在官网下载 dlib-18.14 之后解压到 D 盘。

然后新建一个项目,右击解决方案管理器中的该项目打开属性。在项目目录中添加 dlib- 18.14的路径(注意:是 ..\dlib- 18.14而不是..\dlib- 18.14\dlib)
这里写图片描述

项目的源码我们使用Dlib中介绍GUI的例子。
这里写图片描述
项目结构如上,我们只需要把example中的源码拷贝到ConsoleApplication6.cpp 中,注意要不要漏了头文件”stdafx.h”
代码如下:

// 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 gui api from the dlib C++ Library.


This is a pretty simple example.  It makes a window with a user
defined widget (a draggable colored box) and a button.  You can drag the
box around or click the button which increments a counter.
*/



#include "stdafx.h"
#include <dlib/gui_widgets.h>
#include <sstream>
#include <string>


using namespace std;
using namespace dlib;

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

class color_box : public draggable
{
    /*
    Here I am defining a custom drawable widget that is a colored box that
    you can drag around on the screen.  draggable is a special kind of drawable
    object that, as the name implies, is draggable by the user via the mouse.
    To make my color_box draggable all I need to do is inherit from draggable.
    */
    unsigned char red, green, blue;

public:
    color_box(
        drawable_window& w,
        rectangle area,
        unsigned char red_,
        unsigned char green_,
        unsigned char blue_
        ) :
        draggable(w),
        red(red_),
        green(green_),
        blue(blue_)
    {
        rect = area;
        set_draggable_area(rectangle(10, 10, 400, 
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值