dlib-19.16编译 “已经定义的函数或声明”,错误!以及后续编译测试效果。

1. 编译方法:

参考https://blog.csdn.net/thinkcg/article/details/79113425,从dlib网站上下载最新的dlib-19.16,采用cmake的方式进行编译。

2. vs2015打开dlib.sln进行生成。

报错: “已经定义的函数或声明”错误,发现错误出现在kalman_filter.cpp和auto.cpp两个文件编译的过程中。

改错:因为我自己可能用不到这两个函数,所以我打开CMakeLists.txt文件,将有kalman_filter.cpp和auto.cpp的这两行注释掉了。如下图所示:

set(source_files 
      base64/base64_kernel_1.cpp
      bigint/bigint_kernel_1.cpp
      bigint/bigint_kernel_2.cpp
      bit_stream/bit_stream_kernel_1.cpp
      entropy_decoder/entropy_decoder_kernel_1.cpp
      entropy_decoder/entropy_decoder_kernel_2.cpp
      entropy_encoder/entropy_encoder_kernel_1.cpp
      entropy_encoder/entropy_encoder_kernel_2.cpp
      md5/md5_kernel_1.cpp
      tokenizer/tokenizer_kernel_1.cpp
      unicode/unicode.cpp
      data_io/image_dataset_metadata.cpp
      data_io/mnist.cpp
      global_optimization/global_function_search.cpp
      #filtering/kalman_filter.cpp
      test_for_odr_violations.cpp
      #svm/auto.cpp
      )

再编译,成功。

 

补充:

1.  用自己写的人脸检测主函数调用dlib检测人脸,项目生成的时候报以下错误:

 解决办法:参考https://blog.csdn.net/guanglizI/article/details/80409657,将新生成的config.h放到dlib下替代原有的config.h即可。

2. 重新生成,又报出blas缺少错误,如图

解决方式:将.caffe自动下载的依赖库中找到libopenblas.dll.a,添加到项目属性中。首先:添加 “C:\Users\hp\.caffe\dependencies\libraries_v140_x64_py35_1.1.0\libraries\lib”到库目录中;其次,添加libopenblas.dll.a到链接器->输入->附加依赖项这里面。可以解决。也是参考https://blog.csdn.net/gaohang_hdu/article/details/80415296解决的这个问题。

3. dlib人脸及人脸关键点检测测试代码参考https://blog.csdn.net/u013078356/article/details/54999592的测试代码:

#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>
 
using namespace dlib;
using namespace std;
 
// ----------------------------------------------------------------------------------------
 
int main(int argc, char** argv)
{
	try
	{
		// 定义人脸检测器,使用它来获取一张图片中,每个人脸的边界位置
		frontal_face_detector detector = get_frontal_face_detector();
 
		//定义形状预测器,用来预测给定图片和脸边界框时候的标记点的位置。
		//这里我们从shape_predictor_68_face_landmarks.dat文件加载模型
		shape_predictor sp;
		deserialize("shape_predictor_68_face_landmarks.dat") >> sp;
 
		image_window win, win_faces;
 
		// 循环所有图片,为演示效果,只用了一张图片
		for (int i = 0; i < 1; ++i)
		{
			cout << "processing image " << "2.jpg"  << endl;
			array2d<rgb_pixel> img;
			load_image(img, "2.jpg");
 
			// 放大图片以便检测到比较小的人脸.
			pyramid_up(img);
 
			//检测人脸,获得边界框
			std::vector<rectangle> dets = detector(img);
			cout << "Number of faces detected: " << dets.size() << endl;
 
			// Now we will go ask the shape_predictor to tell us the pose of
			// each face we detected.
			//****调用shape_predictor类函数,返回每张人脸的姿势
			std::vector<full_object_detection> shapes;//注意形状变量的类型,full_object_detection
			for (unsigned long j = 0; j < dets.size(); ++j)
			{
				//预测姿势,注意输入是两个,一个是图片,另一个是从该图片检测到的边界框
				full_object_detection shape = sp(img, dets[j]);
				cout << "number of parts: " << shape.num_parts() << endl;
 
				/*打印出全部68个点*/
				/*for (int i = 0; i < 68; i++)
				{
					cout << "第 " << i+1 << " 个点的坐标: " << shape.part(i) << endl;
				}*/
				
				shapes.push_back(shape);
			}
		
			//显示结果
			win.clear_overlay();
			win.set_image(img);
			win.add_overlay(dets, rgb_pixel(255, 0, 0));
			win.add_overlay(render_face_detections(shapes));
		
			//我们也能提取每张对齐剪裁后的人脸的副本,旋转和缩放到一个标准尺寸
			dlib::array<array2d<rgb_pixel> > face_chips;
			extract_image_chips(img, get_face_chip_details(shapes), face_chips);
			win_faces.set_image(tile_images(face_chips));
 
			cout << "Hit enter to process the next image..." << endl;
			cin.get();
		}
	}
	catch (exception& e)
	{
		cout << "\nexception thrown!" << endl;
		cout << e.what() << endl;
	}
 
	return 0;
}
 
// ----------------------------------------------------------------------------------------

 4. 人脸检测效果:

    白天正常角度人脸可以检测,稍微有角度偏转,包括侧脸或低头,都检测不出来。另外,在傍晚到晚上光线不好的情况下,检测效果也很一般。

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值