当前位置: 代码迷 >> 综合 >> 人脸检测截图
  详细解决方案

人脸检测截图

热度:89   发布时间:2023-09-30 21:49:16.0

一.描述

检测出人脸,获取人脸的开始的横纵坐标、长宽,作为rect保存到新的文件中。

部分代码:

/*计算总人脸数*/
face_number = vframe.size() + face_number;
for (int i = 0; i<vframe.size(); i++){
if (vframe[i].pos[4]>0.9){


for (int j = 0; j < 5; j++){
circle(frameImg1, Point(vframe[i].fps[j * 2 + 1], vframe[i].fps[j * 2 + 0]), 3, Scalar(0, 255, 255), -1);
rectangle(frameImg1, Point(vframe[i].pos[0], vframe[i].pos[1]), Point(vframe[i].pos[0] + vframe[i].pos[2], vframe[i].pos[1] + vframe[i].pos[3]), Scalar(0, 0, 255), 2, 8, 0); 

}
Mat imageROI;
//方法一
imageROI = frameImg1(Rect(vframe[i].pos[0], vframe[i].pos[1], vframe[i].pos[2], vframe[i].pos[3]));
/*保存图像地址*/
string file_path = "F:\\qq_friend_down_pic\\test1\\" + savepath + "_" + to_string(i) + ".jpg";


cout << "savepath =  " << file_path << "\n";
imwrite(file_path, imageROI);
cv::putText(frameImg1, num2str(vframe[i].pos[4]), Point(vframe[i].pos[0], vframe[i].pos[1]), CV_FONT_HERSHEY_SIMPLEX, 0.5, Scalar(255, 100, 0), 2, 2);
}
}

  相关解决方案