我有一个使用 openCV 检测人脸的视频流,然后如何捕获最靠近相机的人脸并将其保存到图像文件中
I have a video stream that detects faces using openCV, how could I then capture the face closest to the camera and save it to an image file?
所以我希望将最突出的脸捕获为图像文件。
以下是检测代码:
void detectAndDisplay(Mat frame)
{
std::vector<Rect> faces;
Mat gray;
cvtColor(frame, gray, CV_BGR2GRAY);
equalizeHist(gray,gray);
//find faces
face_cascade.detectMultiScale(gray, faces, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(30, 30));
for (size_t i = 0; i < faces.size(); i++)
{
Point center(faces[i].x + faces[i].width*0.5, faces[i].y + faces[i].height*0.5);
//draw around the face
ellipse(frame, center, Size(faces[i].width*0.5, faces[i].height*0.5), 0, 0, 360, Scalar(255, 255, 255), 4, 8, 0);
Mat faceROI = gray(faces[i]);
}
imshow(window_name, frame);
}
如果检测到的脸的大小足以描述其突出程度(实际上并非如此),那么,由于faces
的每个元素都是一个Rect
,您可以使用Rect::area()
作为度量。
相关文章:
- 如何使用按钮更新GTK3图像以使用C++从相机捕获图片
- 如何处理来自MIPI相机的12位图像?
- OpenCV 将相机中的图像与相同图像进行匹配不会产生 100% 匹配
- 如何使用OpenCV从已知的3D点云(在没有I的情况下构建)估计新图像I的相机姿态矩阵
- 如何将世界坐标转换为相机图像坐标
- OPENCV:如何使用5点算法从来自不同相机的两个图像之间的特征匹配来计算必需矩阵
- 如何将图像帧相机传递给wasm (C++)中的函数?
- 有没有办法避免在OpenCV中使用RTSP相机时缓冲图像?
- QCameraInfo无法从图像采集卡中识别多个相机
- 如何在 Unity Android 应用程序中的 OpenCV 中使用 ARCore 相机图像
- 使用缝合一组图像的相机参数使用针迹不同的图像集
- OPENCV(C ) - 从已知的3D对象和相机位置计算图像的2D坐标
- 如何使用win IoT在Raspberry Pi上的相机中显示视频流以及一些图像处理
- 如何使用JNI + OpenCV + NDK获取原始的android相机传感器图像数据
- 使用C++程序中的拉斯皮斯蒂尔读取相机图像
- OpenCV C++相机图像未保存到矩阵中
- 使用Qt显示相机图像会出现HIGHGUI错误:V4L/V4L2:VIDIOC_S_CROP
- 正在从线程获取相机图像
- openCV 立体声校准 - >将相机图像 A 扭曲为相机图像 B
- 使用ycbcr格式捕获相机图像