当前位置: 首页>>代码示例>>C++>>正文


C++ Targets::at方法代码示例

本文整理汇总了C++中Targets::at方法的典型用法代码示例。如果您正苦于以下问题:C++ Targets::at方法的具体用法?C++ Targets::at怎么用?C++ Targets::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Targets的用法示例。


在下文中一共展示了Targets::at方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: recognize

FaceDetector_Surf::DetectedFace FaceDetector_Surf::recognize(const cv::Mat &in, cv::Rect roi, const Targets& targets, const TrackedFaces &lastlyTrackedFaces) {


    cv::Point center;
    center.x = roi.x + roi.width/2;
    center.y = roi.y + roi.height/2;

	for(size_t i = 0; i < lastlyTrackedFaces.size(); ++i){
        std::cout << "tracking" << std::endl;
		const TrackedFace* trackedFace = &lastlyTrackedFaces.at(i);
        cv::Point previousCenter;
        previousCenter.x = trackedFace->rect.x + trackedFace->rect.width/2;
        previousCenter.y = trackedFace->rect.y + trackedFace->rect.height/2;

        if(abs(center.x - previousCenter.x) <= 50 && abs(center.y - previousCenter.y) <= 50){
            std::cout << "tracked" << std::endl;
            DetectedFace detectedFace;
            detectedFace.isRecognized = true;
            detectedFace.target = trackedFace->target;
            detectedFace.index = trackedFace->index;
            _availableFlags.at(detectedFace.index) = false;
            return detectedFace;
        }
    }


    Score bestMatch;
    cv::Mat face = in(roi).clone();

    for(size_t i = 0; i < targets.size(); ++i){
        std::cout << "surf[" << i << "]" << std::endl;
        if(!_availableFlags.at(i)) continue;
        std::cout << "available" << std::endl;

        const Target* target =  &targets.at(i);
        cv::Mat model = target->picture;


        // Match the two images
        std::vector<cv::DMatch> matches;
        std::vector<cv::KeyPoint> keypoints1, keypoints2;
        rmatcher.match(model, face ,matches, keypoints1, keypoints2);


        // draw the matches
        /*cv::Mat imageMatches;
        cv::drawMatches(model,keypoints1,          // 1st image and its keypoints
                        face,keypoints2,            // 2nd image and its keypoints
                        matches,                    // the matches
                        imageMatches,               // the image produced
                        cv::Scalar(255,255,255));   // color of the lines*/

        if(matches.size() > bestMatch.first){
            bestMatch = Score(matches.size(), i);
        }
    }

    DetectedFace detectedFace;
    detectedFace.isRecognized = bestMatch.first > 13;
    if(detectedFace.isRecognized){
        detectedFace.target = targets.at(bestMatch.second);
        detectedFace.index = bestMatch.second;
        _availableFlags.at(detectedFace.index) = false;
    }
    else{
        Target target;
        target.picture = face;
        target.name = "Inconnu";
        detectedFace.target = target;
    }

    return detectedFace;
}
开发者ID:aureooms-ulb-2010-2015,项目名称:2012-2013-infof309-facetube,代码行数:73,代码来源:Algorithm_FaceDetector_Surf.cpp


注:本文中的Targets::at方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。