【发布时间】:2014-04-10 14:55:50
【问题描述】:
我正在制作一个应用程序,我必须在其中打开摄像头并跟踪摄像头实时视频/流中的运动。然后检测当前帧中的人脸数量。
我已经使用 CIDetector 完成了面部检测部分,但无法进行运动检测。 谁能指导我怎么做。
我用过GPUImage,但它不支持多人脸检测。
【问题讨论】:
-
可以但是GPUImage没有多人脸检测
标签: ios core-image motion-detection
我正在制作一个应用程序,我必须在其中打开摄像头并跟踪摄像头实时视频/流中的运动。然后检测当前帧中的人脸数量。
我已经使用 CIDetector 完成了面部检测部分,但无法进行运动检测。 谁能指导我怎么做。
我用过GPUImage,但它不支持多人脸检测。
【问题讨论】:
标签: ios core-image motion-detection
我开发了一个类似的应用程序。我使用 OpenCV 进行运动检测和人脸检测。该过程将涉及将您的 Pixel Buffer ref 转换为 OpenCV Mat 对象,将其转换为灰度并执行 absDiff() 和 threshold() 函数来计算两个图像之间的差异(运动)。
然后,您可以再次处理同一帧的面孔。这可能不如现在可以使用 GPU 加速进行运动检测的 GPUImage 高效。
int motionValue;
// Blur images to reduce noise and equalize
cv::Mat processedFrame = cv::Mat(originFrame.size(), CV_8UC1);
cv::blur(originFrame, processedFrame, cv::Size(2,2));
// Get absolute difference image
cv::Mat diffMat;
cv::absdiff(processedFrame, prevFrame, diffMat);
// Apply threshold to each channel and combine the results
cv::Mat treshMat;
cv::threshold(diffMat, treshMat, kCCAlgorithmMotionSensitivity, 255, CV_THRESH_TOZERO);
// Find all contours
std::vector<std::vector<cv::Point> > contours;
cv::findContours(treshMat, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
// Count all motion areas
std::vector<std::vector<cv::Point> > intruders;
for (int i = 0; i < contours.size(); i++) {
double area = cv::contourArea(contours[i]);
//NSLog(@"Area %d = %f",i, area);
if (area > kCCAlgorithmMotionMinAreaDetection){
intruders.push_back(contours[i]);
motionValue += area;
}
}
【讨论】: