【问题标题】:OpenCV iOS program to detect user's mouth and measure width and heightOpenCV iOS程序检测用户的嘴巴并测量宽度和高度
【发布时间】:2017-04-12 10:43:38
【问题描述】:

我正在尝试使用 OpenCV iOS 程序来检测用户的嘴巴并从实时视频中测量它的宽度和高度。我正在搜索但找不到 opencv 示例。有没有人遇到过这样的 Opencv/或任何其他 iOS 示例程序来检测用户的嘴巴并测量视频或图像的宽度和高度?请分享信息。

谢谢

【问题讨论】:

    标签: ios opencv face-detection


    【解决方案1】:
    NSString *mouthCascadePath = [[NSBundle mainBundle] pathForResource:@"cascades/haarcascade_mcs_mouth"
                                                               ofType:@"xml"];//load the file from the app bundle
    cv::Mat cvImage;
    UIImageToMat(resImage, cvImage);
    cvtColor(cvImage, gray, CV_BGR2GRAY); // load input img in gray scale mode
    cv::CascadeClassifier mouthDetector;
    mouthDetector.load([mouthCascadePath UTF8String]);
    std::vector<cv::Rect> faceRects;
    double scalingFactor = 1.1;
    int minNeighbors = 2;
    int flags = 0;
    cv::Size minimumSize(30,30);
    // Detect Faces
    faceDetector.detectMultiScale(gray, faceRects,
                                       scalingFactor, minNeighbors, flags,
                                       cv::Size(30, 30) );
    
    cv::Mat faceROI;
    
    for(unsigned int i = 0; i < faceRects.size(); i++)
    {
     std::vector<cv::Rect> mouthRects;
    //Detect mouth in face
        mouthDetector.detectMultiScale(cvImage, mouthRects,
                                      scalingFactor, minNeighbors, flags,
                                      cv::Size(30, 30) );
    
            const cv:: Rect&mouth = mouthRects[0];
            int y = mouth.y - 0.15*mouth.height ;
            cv:: rectangle(cvImage, cv::Point(mouth.x ,y), cv::Point(mouth.x + mouth.width ,y + mouth.height), cvScalar(255,0,0), 1, 8, 0);
    }
    _imgview.image = MatToUIImage(cvImage);
    }
    

    复制上述代码,在 iOS 中使用 OpenCV 进行嘴部检测。

    【讨论】:

      猜你喜欢
      • 2015-06-25
      • 1970-01-01
      • 2016-10-21
      • 2019-05-24
      • 2023-04-06
      • 1970-01-01
      • 2010-10-29
      • 1970-01-01
      • 2016-10-08
      相关资源
      最近更新 更多