关闭页面特效

2020/4/3

1|0今日学习


  • 搭好dlib c++的环境
  • 三节课
  • 写完作业

2|0今日杂碎记录


2|1dlib 的编译


官网教程,稳得一批

2|2CMakeLists.txt 的编写


project(dlib_test) # 工程名字 find_package(OpenCV REQUIRED) # 使用opencv , 注意括号中的大小写 cmake_minimum_required(VERSION 2.8.12) # cmake 版本 # cmake needs is the dlib source code folder and it will take care of everything. add_subdirectory(../dlib dlib_build) # 需要编译的添加子目录 include_directories( ${OpenCV_INCLUDE_DIRS} ) add_executable(dlib_test main.cpp) # 要编译的文件, 这里的dlib_test 是生成的可执行文件的名字 target_link_libraries( dlib_test ${OpenCV_LIBS} ) # dlib_test 是生成的可执行文件的名字 # Finally, you need to tell CMake that this program, assignment_learning_ex, # depends on dlib. You do that with this statement: target_link_libraries(dlib_test dlib::dlib) # dlib_test 是生成的可执行文件的名字

dlib的CMakeLists.txt编写详细规则
opencv的CMakeLists.txt编写详细规则
更多关于CMakeLists.txt 的编写

2|3C++中的rectangle API


void rectangle(Mat& img, Point pt1,Point pt2,const Scalar& color, int thickness=1, int lineType=8, int shift=0)  void rectangle(Mat& img, Rect rec, const Scalar& color, int thickness=1, int lineType=8, int shift=0 )

2|4dlib C++ 检测特征点


#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 { cv::VideoCapture cap(0); if (!cap.isOpened()) { cerr << "Unable to connect to camera" << endl; return 1; } //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 (cv::waitKey(30) != 27) { // Grab a frame cv::Mat temp; cap >> temp; cv_image<bgr_pixel> cimg(temp); //这一行一定不能少, dlib和opencv中的img格式保存不一样 // 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 i = 0; i < 68; i++) { circle(temp, 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特征点", temp); } } 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; } }

如果标了数字会是这样的。

dlib 的demo1
dlib 的demo2

2|5明天再使用的方法


FaceDetection
python 与 C++ dlib人脸检测结果对比

刷剧时间长了哇,后悔一秒。


__EOF__

作  者Hichens
出  处https://www.cnblogs.com/hichens/p/12626286.html
关于博主:莫得感情的浅度学习机器人
版权声明:@Hichens
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!

posted @   hichens  阅读(186)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· winform 绘制太阳,地球,月球 运作规律
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
点击右上角即可分享
微信分享提示