【问题标题】:Motion detection from camera live stream in iOS来自 iOS 中摄像机实时流的运动检测
【发布时间】:2014-04-10 14:55:50
【问题描述】:

我正在制作一个应用程序,我必须在其中打开摄像头并跟踪摄像头实时视频/流中的运动。然后检测当前帧中的人脸数量。

我已经使用 CIDetector 完成了面部检测部分,但无法进行运动检测。 谁能指导我怎么做。

我用过GPUImage,但它不支持多人脸检测。

【问题讨论】:

标签: ios core-image motion-detection


【解决方案1】:

我开发了一个类似的应用程序。我使用 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;
        }
    }

【讨论】:

  • 是的 Vald 我已经使用 GPU 图像制作了我的整个应用程序。但不幸的是,它没有人脸识别功能。这就是我使用 Open cv 的原因。你能给我打开 cv 中的运动检测代码吗?因为我已经尝试过你所说的这个逻辑,但是有很多问题
  • 检查我编辑的回复。这只是一个sn-p。每次调用比较函数时,您都必须保持对前一帧的引用。这将是比较函数的 sn-p,向您展示检测运动和计算运动值的不同方式。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-22
  • 2020-02-23
  • 1970-01-01
  • 2015-11-25
相关资源
最近更新 更多