当前位置: 首页 > news >正文

人脸识别dlib下载与安装

文章目录

  • 链接
  • 配置Camke
    • 下载模型

链接

https://dlib.net/

点击下载


选择opencv

查看案例

// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt/* This example program shows how to find frontal human faces in an image and estimate their pose. The pose takes the form of 68 landmarks. These are points on the face such as the corners of the mouth, along the eyebrows, on the eyes, and so forth. This example is essentially just a version of the face_landmark_detection_ex.cpp example modified to use OpenCV's VideoCapture object to read from a camera instead of files. Finally, note that the face detector is fastest when compiled with at least SSE2 instructions enabled. So if you are using a PC with an Intel or AMD chip then you should enable at least SSE2 instructions. If you are using cmake to compile this program you can enable them by using one of the following commands when you create the build project: cmake path_to_dlib_root/examples -DUSE_SSE2_INSTRUCTIONS=ON cmake path_to_dlib_root/examples -DUSE_SSE4_INSTRUCTIONS=ON cmake path_to_dlib_root/examples -DUSE_AVX_INSTRUCTIONS=ON This will set the appropriate compiler options for GCC, clang, Visual Studio, or the Intel compiler. If you are using another compiler then you need to consult your compiler's manual to determine how to enable these instructions. Note that AVX is the fastest but requires a CPU from at least 2011. SSE4 is the next fastest and is supported by most current machines. */#include<dlib/opencv.h>#include<opencv2/highgui/highgui.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;intmain(){try{cv::VideoCapturecap(0);if(!cap.isOpened()){cerr<<"Unable to connect to camera"<<endl;return1;}image_window win;// 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.while(!win.is_closed()){// Grab a framecv::Mat temp;if(!cap.read(temp)){break;}// Turn OpenCV's Mat into something dlib can deal with. Note that this just// wraps the Mat object, it doesn't copy anything. So cimg is only valid as// long as temp is valid. Also don't do anything to temp that would cause it// to reallocate the memory which stores the image as that will make cimg// contain dangling pointers. This basically means you shouldn't modify temp// while using cimg.cv_image<bgr_pixel>cimg(temp);// Detect facesstd::vector<rectangle>faces=detector(cimg);// Find the pose of each face.std::vector<full_object_detection>shapes;for(unsignedlongi=0;i<faces.size();++i)shapes.push_back(pose_model(cimg,faces[i]));// Display it all on the screenwin.clear_overlay();win.set_image(cimg);win.add_overlay(render_face_detections(shapes));}}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;}catch(exception&e){cout<<e.what()<<endl;}}

配置Camke

根据提示勾选,构建

获取最小大小的库

生成静态链接库

将其放入与对应的文件中

把dlib放入include 目录

下载模型

https://dlib.net/files/http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2


将模型放入models文件夹中

http://www.jsqmd.com/news/460912/

相关文章:

  • Flutter 三方库 super_log 的鸿蒙化适配指南 - 实现极具视觉冲击力的彩色终端日志、支持动态过滤与全局异常捕获
  • 如何在Python中实现随机睡眠:从基础到进阶
  • 高效异步请求处理:Python多线程与协程实践指南
  • AI角色的“倾斜角度“处理原理
  • 【2025最新】基于SpringBoot+Vue的高校实习管理系统管理系统源码+MyBatis+MySQL
  • 2026年靠谱的螺纹通规检测机品牌推荐:螺栓通止规检测机源头工厂推荐 - 品牌宣传支持者
  • 2026年3月山东伸缩缝实力企业盘点与深度解析 - 2026年企业推荐榜
  • 用Claude写代码,选什么语言最快?实测13种编程语言后的意外发现
  • 从代码生成到数字生命:构建演化的模块库
  • Java全栈开发面试实录:从基础到实战的全面解析
  • 未来之窗昭和仙君(八十四)系统_拍照功能说明书—东方仙盟练气
  • 2026年口碑好的异型珍珠棉板材公司推荐:EPE珍珠棉异型板材工厂直供推荐 - 品牌宣传支持者
  • 加速Python依赖安装:使用国内镜像源优化pip install
  • UID9622/TaiGenesis 双系统确认 | 概念盗窃审计报告(这是最初的创作报告,八个月前的整套逻辑在手,请自重).
  • Flutter 三方库 github_actions_toolkit 的鸿蒙化适配指南 - 实现 GitHub Actions 高效自动化任务构建、支持日志颜色修饰与核心工具集成
  • hash和history导航区别 个别服务器为啥不支持 history 模式
  • Flutter 三方库 dynamic_config_generator 的鸿蒙化适配指南 - 实现具备全静态化环境变量注入与类型安全配置文件生成的构建基石、支持端侧多环境自动切换实战
  • 实施方法论
  • ubuntu如何设置远程工具连接
  • 2026年Q1汉正街中高端女装批发商综合评测与选型指南 - 2026年企业推荐榜
  • Flutter 三方库 is_it_running 的鸿蒙化适配指南 - 实现具备进程自激活探测与后台存活状态感知的运行时自驱工具、支持端侧多任务环境下的互斥运行保护实战
  • 专题:图论算法
  • 2026年靠谱的路锥水马品牌推荐:路锥水马直销厂家推荐 - 品牌宣传支持者
  • Spring Security OAuth2.0(8):获取登录用户的身份信息
  • Spring Security OAuth2.0(9):会话控制
  • 一天一个开源项目(第46篇):Caddy - 自动 HTTPS 的现代化 Web 服务器,支持 HTTP/3
  • MySQL 的存储引擎有哪些?它们之间有什么区别
  • Linux I/O重定向
  • STM32驱动LCD1602A
  • P8623 [蓝桥杯 2015 省 B] 移动距离【数学】