Face Detection Screenshot

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_34568522/article/details/80565103

I. Description

Human face is detected, obtaining horizontal and vertical coordinates of the start face, length and width, save to a new file as rect.

Part of the code:

/*计算总人脸数*/
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);
}
}

Guess you like

Origin blog.csdn.net/qq_34568522/article/details/80565103