face alignment dlib

本文介绍了一个使用Dlib库实现的人脸关键点检测程序。该程序首先加载人脸检测与姿态估计模型,接着检测图像中的人脸,并在检测到的人脸区域上找到68个面部关键点。最后,在屏幕上展示标记了关键点的图像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

代码:

void landmark(Mat face_img)
{
	string modelfile = "C:\\WorkSpace\\SoftWare\\dlib-19.10\\models\\shape_predictor_68_face_landmarks.dat";
	// Load face detection and pose estimation models.  
	frontal_face_detector detector = get_frontal_face_detector();
	shape_predictor pose_model;
	deserialize(modelfile) >> pose_model;
	// Detect faces
	cv_image<bgr_pixel> cimg(face_img);


	std::vector<dlib::rectangle> faces = detector(cimg);


	// Find the pose of each face.  
	std::vector<full_object_detection> shapes;
	for (unsigned long i = 0; i < faces.size(); ++i)
	{
		shapes.push_back(pose_model(cimg, faces[i]));
		Rect r;
		r.x = faces[i].left();
		r.y = faces[i].top();
		r.width = faces[i].width();
		r.height = faces[i].height();
		cv::rectangle(face_img, r, Scalar(0, 0, 255));
	}


	if (!shapes.empty()) {
		for (int i = 0; i < 68; i++) {
			circle(face_img, cvPoint(shapes[0].part(i).x(), shapes[0].part(i).y()), 3, cv::Scalar(0, 0, 255), -1);
			//  shapes[0].part(i).x();//68个  
		}
	}
	//Display it all on the screen  
	imshow("Dlib特征点", face_img);
	waitKey(0);
}


效果图:



提示:

1.严重性 代码 说明 项目 文件 禁止显示状态

错误 LNK2001 无法解析的外部符号 USER_ERROR__inconsistent_build_configuration__see_dlib_faq_2 cv_example C:\WorkSpace\Visual_studio\c_design\c_practice\cv_example\main.obj 1

如果出现这种 错误  请将 dlib\all\source.cpp 添加到工程目录下。

环境配置:

1. include 包含目录


2.库文件 dlib.lib 目录 

3.设置 输入 需要的库文件


4.设置支持文件


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NineDays66

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值