【dlib】人脸68特征点检测

有部分转自:http://blog.csdn.net/zmdsjtu/article/details/53454071

VS2012 dlib库:http://download.csdn.net/detail/qq_15947787/9885919

源码如下:http://download.csdn.net/detail/qq_15947787/9888611(包含shape_predictor_68_face_landmarks.dat

运行时x64 Release速度可以接受,Debug下检测速度很慢很慢

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

using namespace dlib;  
using namespace std;  

int main()  
{  
    try  
    {  
        // Load face detection and pose estimation models.  
        frontal_face_detector detector = get_frontal_face_detector();  
        shape_predictor pose_model;  
        deserialize("shape_predictor_68_face_landmarks.dat") >> pose_model;  

        // Grab and process frames until the main window is closed by the user.  

        // Grab a frame  
        cv::Mat temp;  
        //cap >> temp;  
        temp = cv::imread("1.jpg", 1);

        cv_image<bgr_pixel> cimg(temp);  
        // Detect faces   
        std::vector<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]));  

        if (!shapes.empty()) 
        {
            for (int j = 0; j < shapes.size(); j++)
            { 
                for (int i = 0; i < 68; i++) 
                {  
                    circle(temp, cvPoint(shapes[j].part(i).x(), shapes[j].part(i).y()), 3, cv::Scalar(0, 0, 255), -1);  
                    putText(temp, to_string(i), cvPoint(shapes[j].part(i).x(), shapes[j].part(i).y()), CV_FONT_HERSHEY_PLAIN, 1, cv::Scalar(255, 0, 0),1,4);
                }  
            }
        }

        //Display it all on the screen  
        imshow("Dlib特征点", temp);  
        imwrite("Dlib特征点.jpg", temp);

        cv::waitKey(0);
    }  
    catch (serialization_error& e)  
    {  
        cout << "You need dlib's default face landmarking model file to run this example." << endl;  
        cout << "You can get it from the following URL: " << endl;  
        cout << "   http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2" << endl;  
        cout << endl << e.what() << endl;  
    }  
}  



将dlib人脸68特征点检测与caffe结合,能做出很好玩的程序,附上大神的:




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值