资源简介
68人脸特征点Hog+SVM人脸表情识别,完整工程项目,开发工具vs2015,opencv3.3.1,Dilb库
代码片段和文件信息
//@zmdsjtu@163.com
//2016-12-15
//#pragma comment(linker “/subsystem:windows /entry:mainCRTStartup“)//去除CMD窗口
#include
#include
#include
#include
#include
#include
#include
using namespace dlib;
using namespace std;
void 写入TXT(string 名字 string 内容 bool 是否覆盖);
int main()
{
try
{
cv::VideoCapture cap(0);
//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;
std::vector faces2;
// Grab and process frames until the main window is closed by the user.
int 文件名 = 0;
// while (cv::waitKey(30) != 27)
// while (cv::waitKey(30) != 27){
// cv::VideoCapture cap(“1.avi“);
if (!cap.isOpened())
{
cerr << “Unable to connect to camera“ << endl;
return 1;
}
int 帧数 = cap.get(7);
// while (cv::waitKey(30) != 27 && --帧数 != 14)
while (cv::waitKey(30) != 27)
{
// Grab a frame
cv::Mat temp;
cap >> temp;
// temp = cv::imread(“1.bmp“);
cv_image cimg(temp);
// Detect faces
std::vector faces = detector(cimg);
if (!faces.empty())faces2 = faces;
// Find the pose of each face.
std::vectorject_detection> shapes;
if (faces.empty()) {
// for (unsigned long i = 0; i < faces2.size(); ++i)
// shapes.push_back(pose_model(cimg faces2[i]));
}
else {
for (unsigned long i = 0; i < faces.size(); ++i)
shapes.push_back(pose_model(cimg faces[i]));
}
if (!shapes.empty()) {
cv::line(temp cvPoint(faces[0].left() faces[0].top()) cvPoint(faces[0].right() faces[0].top()) cv::Scalar(255 0 0));
cv::line(temp cvPoint(faces[0].left() faces[0].top()) cvPoint(faces[0].left() faces[0].bottom()) cv::Scalar(255 0 0));
文件名++;
float 系数 = -(faces[0].top() - faces[0].bottom()) / 300.0;
cout << 系数 << endl;
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);
putText(temp to_string(i) cvPoint(shapes[0].part(i).x() shapes[0].part(i).y()) CV_FONT_HERSHEY_PLAIN 1 cv::Scalar(255 0 0) 1 4);
//--------------这部分是想用来采集训练数据的
写入TXT((to_string(文件名) + “.txt“) to_string((shapes[0].part(i).x() - faces[0].left()) / 系数) 0);
写入TXT((to_string(文件名) + “.txt“) to_string((shapes[0].part(i).y() - faces[0].top()) / 系数) 0);
//----------------------------------------------------------------------------
}
// Drawarrow(temp shapes[0].part(36).x() shapes[0].part(48).x() shapes[0].part(30).x() shapes[0].part(45).x() shapes[0].part(54).x() shapes[0].part(36).y() shapes[0]
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-08 22:52 Dlib_opencv\
目录 0 2017-11-12 09:01 Dlib_opencv\.vs\
目录 0 2017-11-12 09:01 Dlib_opencv\.vs\Dlib_opencv\
目录 0 2017-11-12 09:01 Dlib_opencv\.vs\Dlib_opencv\v14\
文件 53248 2018-03-08 22:52 Dlib_opencv\.vs\Dlib_opencv\v14\.suo
目录 0 2018-05-11 14:42 Dlib_opencv\Debug\
目录 0 2017-11-13 23:01 Dlib_opencv\Dlib_opencv\
文件 667 2017-11-12 10:09 Dlib_opencv\Dlib_opencv\DLIB19.7.props
文件 7730 2017-11-13 21:30 Dlib_opencv\Dlib_opencv\Dlib_opencv.vcxproj
文件 1248 2017-11-13 21:30 Dlib_opencv\Dlib_opencv\Dlib_opencv.vcxproj.filters
文件 282454 2017-11-12 16:04 Dlib_opencv\Dlib_opencv\SVM_DATA.xm
文件 46374 2017-10-30 10:03 Dlib_opencv\Dlib_opencv\anger_28.jpg
文件 503 2017-11-12 15:01 Dlib_opencv\Dlib_opencv\faceRecognition.h
文件 531 2017-11-12 15:01 Dlib_opencv\Dlib_opencv\featrueExtraction.h
文件 4036 2017-11-13 23:00 Dlib_opencv\Dlib_opencv\featureExtractioin.cpp
文件 3411 2017-11-13 21:29 Dlib_opencv\Dlib_opencv\main.cpp
文件 690 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\opencv3.3_DebugX64.props
文件 442 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\opencv3.3_DebugX86.props
文件 689 2017-11-12 10:09 Dlib_opencv\Dlib_opencv\opencv3.3_releaseX64.props
文件 99693937 2017-11-12 11:04 Dlib_opencv\Dlib_opencv\shape_predictor_68_face_landmarks.dat
文件 1668 2017-11-12 16:04 Dlib_opencv\Dlib_opencv\train2xm
文件 8100 2017-11-13 23:00 Dlib_opencv\Dlib_opencv\train_shape_predictor_ex.cpp
文件 343 2017-11-12 15:06 Dlib_opencv\Dlib_opencv\trian2xm
目录 0 2017-11-12 10:09 Dlib_opencv\Dlib_opencv\x64\
目录 0 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\x64\Debug\
文件 216 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\x64\Debug\Dlib_opencv.log
目录 0 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\x64\Debug\Dlib_opencv.tlog\
文件 666 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\x64\Debug\Dlib_opencv.tlog\CL.command.1.tlog
文件 33484 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\x64\Debug\Dlib_opencv.tlog\CL.read.1.tlog
文件 588 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\x64\Debug\Dlib_opencv.tlog\CL.write.1.tlog
文件 207 2017-11-12 09:17 Dlib_opencv\Dlib_opencv\x64\Debug\Dlib_opencv.tlog\Dlib_opencv.lastbuildstate
............此处省略626个文件信息
评论
共有 条评论