#include <QDebug>

#define log qDebug() << "[" << __FILE__ << ":" << __LINE__ << "]"


    cv::Mat resImage = cv::imread(resPath);
    cv::Mat targetImage = cv::imread(targetPath);
    if (resImage.empty() || targetImage.empty()) {
        log << "图像加载错误";
        return;
    }

    int h = targetImage.rows;
    int w = targetImage.cols;
    log << h << w;

    cv::Mat result;
    result.create(w, h, CV_32FC1);

    cv::matchTemplate(resImage, targetImage, result, cv::TM_CCOEFF_NORMED);

    double minVal = -1;
    double maxVal = -1;
    cv::Point minLoc;
    cv::Point maxLoc;
    cv::Point matchLoc;
    cv::minMaxLoc(result, &minVal, &maxVal, &minLoc, &maxLoc, cv::Mat());
    if (maxVal < 0.85) {
        log << "找到失败";
        return;
    }
    log << minVal;
    log << maxVal;
    log << minLoc.x << minLoc.y;
    log << maxLoc.x << maxLoc.y;    
01-06 09:36