CvTemplateMatcher.java 文件源码

java
阅读 42 收藏 0 点赞 0 评论 0

项目:FlashLib 作者:
public MatchResult match(Mat scene, Mat templ, Method method, Mat img) {

    int result_cols = scene.cols() - templ.cols() + 1;
    int result_rows = scene.rows() - templ.rows() + 1;
    Mat result = new Mat(result_rows, result_cols, CV_32FC1);
    Imgproc.matchTemplate(scene, templ, result, method.ordinal());
    //Core.normalize(result, result, 0, 1, 32,-1,new Mat());

    MinMaxLocResult mmr = Core.minMaxLoc(result);


    Point matchLoc;
    double maxVal;
    if (method.ordinal() == Imgproc.TM_SQDIFF
            || method.ordinal() == Imgproc.TM_SQDIFF_NORMED) {

        matchLoc = mmr.minLoc;
        maxVal = mmr.minVal;
    }
    else {
        matchLoc = mmr.maxLoc;
        maxVal = mmr.maxVal;
    }

    MatchResult currResult = new MatchResult(matchLoc.x +(templ.cols()/2),matchLoc.y +(templ.rows()/2),0,maxVal);
    return currResult;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号