Win10 + vs2015 + dlib-19.7 + CMake-cmd

版权声明:转载需标明该文链接。 https://blog.csdn.net/zaibeijixing/article/details/80595184

文章地址:https://blog.csdn.net/zaibeijixing/article/details/80595184

文章地址:https://blog.csdn.net/zaibeijixing/article/details/80595184


Win10 + vs2015 + dlib-19.7 + CMake_cmd

(配置新电脑,把之前笔记整理发布、分享)

一:必备

1)下载并解压当前最新版本dlib-19.7。

2)下载并解压cmake-3.10.0-win64-x64,添加系统环境变量:Path——D:\tool_2\cmake310\cmake-3.10.0-win64-x64\bin

二:cmake

用命令行的形式将dlib-19.7文件生成.lib文件。详细步骤如下:

①在dlib-版本号文件夹下打开命令提示符(shift加右键),以添加make命令

②mkdir build   (作用:在当前文件夹下新建“build”文件夹)

③cd build (命令行切换到build文件夹路径)

④cmake -G “Visual Studio 14 2015 Win64” (win64版vs2015(代号14) 编译 )

⑤cmake --build . -- config Release (生成Relaese版本.lib)

【注】四行代码一行一行添加,否则④占用时间长,⑤执行不到;⑤的Release改为Debug即可生成Debug版.lib;生成的文件在新建的build\dlib文件夹内。

三:新建VS程序,项目配置属性 (使用Release_x64模式)

只需要添加库目录和附加依赖项即可。

1)添加库目录

 

2)附加依赖项

 

3)其它杂项

 

 

四:运行(Release_x64)

#include<dlib/image_processing/frontal_face_detector.h>
#include<dlib\image_processing\render_face_detections.h>
#include<dlib\image_processing.h>
#include<dlib\gui_widgets.h>
#include<dlib\image_io.h>

#include<iostream>
#include<vector>

using namespace dlib;
using namespace std;

int main(int argc, char **argv)
{
	try
	{
		frontal_face_detector detector = get_frontal_face_detector();
		image_window win;//一个显示窗口
		array2d<unsigned char> img;
		cout << "processing image" << argv[1] << endl;
		load_image(img, argv[1]);//加载一张图片
		pyramid_up(img);//对图像进行上采样,检测更小的人脸

						//开始检测,返回一系列的边界框
		std::vector<rectangle> dets = detector(img);//detector()函数检测人脸,返回一系列边界盒子
		cout << "Number of faces detected:" << dets.size() << endl;//re
																   //在原图上显示结果
		win.clear_overlay();
		win.set_image(img);
		win.add_overlay(dets, rgb_pixel(255, 0, 0));
		cout << "Hit enter to process the next image..." << endl;
		cin.get();
	}
	catch (const std::exception& e)
	{
		cout << "\nexception thrown!" << endl;
		cout << e.what() << endl;
	}
	getchar();
}

运行结果:



可以转载分享,但需在文章开头注明本文原始链接:https://blog.csdn.net/zaibeijixing/article/details/80595184


猜你喜欢

转载自blog.csdn.net/zaibeijixing/article/details/80595184