dlib landmark+人面识别

Posted 程序之家

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了dlib landmark+人面识别相关的知识,希望对你有一定的参考价值。

#include "stdafx.h"
#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 <opencv2/opencv.hpp>

using namespace std;
using namespace cv;
using namespace dlib;


//#pragma comment(lib,"dlib.lib")

int main(int argc, char** argv)
{
	long start, end;
	
	char img_file[] = "test.bmp";
	char landmark_file[] = "68.dat";

	//
	Mat img = imread(img_file);

	//
	frontal_face_detector detector = get_frontal_face_detector();

	shape_predictor sp;
	deserialize(landmark_file) >> sp;

	array2d<rgb_pixel> arrImg;
	load_image(arrImg, img_file);
	start = clock();
	std::vector<dlib::rectangle> dets = detector(arrImg);
	

	for (unsigned long j = 0; j < dets.size(); ++j)
	{
		
		full_object_detection shape = sp(arrImg, dets[j]);
		

		for (unsigned long i = 0; i < shape.num_parts(); i++)
		{
			point pt = shape.part(i);
			int x = pt.x();
			int y = pt.y();

			line(img, Point(pt.x(), pt.y()), Point(pt.x(), pt.y()), Scalar(0, 0, 255), 2);
		}
	}
	end = clock();
	printf("%ld\n", end - start);//单位:毫秒
	//
	imshow("img", img);
	waitKey();
}

  

以上是关于dlib landmark+人面识别的主要内容,如果未能解决你的问题,请参考以下文章

dlib实现人脸landmark点检测以及一些其他的应用

dlib:无法打开 face_landmark_detection_ex 进行阅读?

运行时错误:无法打开 ./dlib_model/shape_predictor_68_face_landmarks.dat

dlib库的68特征原理人脸关键点检测原理

人脸跟踪识别脸部标识

DLIB:为 194 个地标训练 Shape_predictor(海伦数据集)