基于人脸68特征点识别的美颜算法(一) 大眼算法 C++

1、加载一张原图,并识别人脸的68个特征点

	cv::Mat img = cv::imread("5.jpg");
    // 人脸68特征点的识别函数
	vector<Point2f> points_vec = dectectFace68(img);
    // 大眼效果函数
	Mat dst0 = on_BigEye(800, img, points_vec);

请添加图片描述
2、函数

vector<Point2f> dectectFace68(Mat src)
{
   
   
	vector<Point2f> points_vec;
	
	int* pResults = NULL;
	//在检测函数中使用了pBuffer。  
	//如果你调用多个线程中的函数,请为每个线程创建一个缓冲区!  
	unsigned char* pBuffer = (unsigned char*)malloc(DETECT_BUFFER_SIZE);
	if (!pBuffer)
	{
   
   
		fprintf(stderr, "Can not alloc buffer.\n");
		//return 100;
	}
	Mat gray;
	cvtColor(src, gray, CV_BGR2GRAY);
	int doLandmark = 1;// do landmark detection  
	pResults = facedetect_multiview_reinforce(pBuffer, (unsigned char*)(gray.ptr(0)), gray.cols, gray.rows, (int)gray.step,
		1.2f, 2, 48, 0, doLandmark);

	int cxa = *pResults;

	ofstream file("facedata.txt", ios::out);
	//打印检测结果 



	if (0 == cxa)
	{
   
   
	}
	else
	{
   
   
		
		for (int i = 0; i < (pResults ? *pResults : 0); i++)
		{
   
   
			
			short* p = ((short*)(pResults + 1)) + 142 * i;
			//rectangle(src, Rect(p[0], p[1], p[2], p[3]), Scalar(0, 255, 0), 2);
			if (doLandmark)
			{
   
   
				for (int j = 0; j < 68; j++)
				{
   
   
					char c[8];
					_itoa(j, c, 10);
					
					

					Point2f ff(p[
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

向日葵xyz

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

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

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

打赏作者

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

抵扣说明:

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

余额充值