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

2 篇文章 0 订阅
2 篇文章 1 订阅

如果要配置其他版本的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

写入输入的附加依赖项

dlib19.17.0_release_64bit_msvc1916.lib;

写入测试代码

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

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

 

#include <dlib/gui_widgets.h>
#include <dlib/image_io.h>
#include <dlib/image_transforms.h>
#include <fstream>


using namespace std;
using namespace dlib;

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

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

		// 声明图像
		array2d<rgb_pixel> img;

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

		// 高斯模糊
		array2d<unsigned char> blurred_img;
		gaussian_blur(img, blurred_img);

		// sobel边缘检测
		array2d<short> horz_gradient, vert_gradient;
		array2d<unsigned char> 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;
	}
}

 

测试成功

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值