Windows下VS17(x64 release)+Dlib19.17配置(简易版)

如果要配置其他版本的vs和其他版本Dlib的请看这篇

https://blog.csdn.net/wilsonass/article/details/90581787


首先下载Dlib已经编译好的内容

https://pan.baidu.com/s/1uZN2DQ59gQokgTBEYZb_uw 
提取码:hbn1 

下载完成后进行解压,解压后会有两个文件夹

这两个是编译好的VS17下Win64的Release版本

然后在VS中进行配置 include和lib

Windows下VS17(x64 release)+Dlib19.17配置(简易版)_第1张图片

写入输入的附加依赖项

dlib19.17.0_release_64bit_msvc1916.lib;

Windows下VS17(x64 release)+Dlib19.17配置(简易版)_第2张图片

Windows下VS17(x64 release)+Dlib19.17配置(简易版)_第3张图片

写入测试代码

其中的string img_path = "001.jpg";是当前目录下的图片,通过把图片重命名移动到项目的当前目录下可进行测试

当前目录为:右键项目,选择在资源管理器中打开文件夹

 

#include 
#include 
#include 
#include 


using namespace std;
using namespace dlib;

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

int main(int argc, char** argv)
{
	try
	{

		// 声明图像
		array2d img;

		string img_path = "001.jpg";
		load_image(img, img_path);

		// 高斯模糊
		array2d blurred_img;
		gaussian_blur(img, blurred_img);

		// sobel边缘检测
		array2d horz_gradient, vert_gradient;
		array2d edge_image;
		sobel_edge_detector(blurred_img, horz_gradient, vert_gradient);

		//非极大边缘抑制
		suppress_non_maximum_edges(horz_gradient, vert_gradient, edge_image);

		// 显示结果
		image_window my_window(edge_image, "Normal Edge Image");

		// We can also easily display the edge_image as a heatmap or using the jet color
		// scheme like so.
		image_window win_hot(heatmap(edge_image));
		image_window win_jet(jet(edge_image));

		// also make a window to display the original image
		image_window my_window2(img, "Original Image");

		// Sometimes you want to get input from the user about which pixels are important
		// for some task.  You can do this easily by trapping user clicks as shown below.
		// This loop executes every time the user double clicks on some image pixel and it
		// will terminate once the user closes the window.
		point p;
		while (my_window.get_next_double_click(p))
		{
			cout << "User double clicked on pixel:         " << p << endl;
			cout << "edge pixel value at this location is: " << (int)edge_image[p.y()][p.x()] << endl;
		}

		// wait until the user closes the windows before we let the program 
		// terminate.
		win_hot.wait_until_closed();
		my_window2.wait_until_closed();


		// Finally, note that you can access the elements of an image using the normal [row][column]
		// operator like so:
		cout << horz_gradient[0][3] << endl;
		cout << "number of rows in image:    " << horz_gradient.nr() << endl;
		cout << "number of columns in image: " << horz_gradient.nc() << endl;
	}
	catch (exception& e)
	{
		cout << "exception thrown: " << e.what() << endl;
	}
}

Windows下VS17(x64 release)+Dlib19.17配置(简易版)_第4张图片

 

测试成功

你可能感兴趣的:(Windows,VS,环境配置,Dlib)