Dlib在Visual Studio 2017上的编译和配置
此教程根据官网整理。
工具:
CMake + Visual Studio 2017 + Win 10
编译
1.以管理员身份打开命令行;
2.Lz路径:F:\GitHub\dlib-19.16,命令行输入:
>F:
>cd GitHub\dlib-19.16\examples
>mkdir build
>cd build
>cmake ..
>cmake --build . --config Release
3.默认编译32位,编译64位参考:https://blog.csdn.net/xingchenbingbuyu/article/details/53236541
4.等待编译结束即可;
配置
1.新建文件夹lib,将编译后的dlib19.16.0_release_32bit_msvc1914.lib(F:\GitHub\dlib-19.16\examples\build\dlib_build\Release)复制到lib(F:\GitHub\dlib-19.16\lib)下;
2.新建Win32控制台程序;
3.配置环境变量,打开属性页:
1.配置属性\VC++ 目录\库目录:F:\GitHub\dlib-19.16\lib;
2.配置属性\C/C++\常规\附加包含目录:F:\GitHub\dlib-19.16;
3.配置属性\链接器\输入\附加依赖项:dlib19.16.0_release_32bit_msvc1914.lib
4.运行以下程序:
#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();
}
5.运行结果: