bytedeco/javacv

Is there a possibility in JavaCV to compare images that are not the same size when one is shorter and the other is narrower

Open

#1,977 创建于 2023年1月31日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Java (1,583 fork)batch import
help wantedquestion

仓库指标

Star
 (6,985 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

Hi, I'm looking for an algorithm to normalize images to be able to compare them with QualitySSIM.compute() method.

I've created the below code which works fine but just in case one picture is small than the second, but in case one is shorter and one is narrower the program failed.

    Mat result = new Mat();
    Mat resultMask = new Mat();
    opencv_imgproc.matchTemplate(base, screenShot, result, opencv_imgproc.TM_CCORR);

    double[] min = new double[2], max = new double[2];
    Point minLoc = new Point(), maxLoc = new Point();

    opencv_core.minMaxLoc(result, min, max, minLoc, maxLoc,resultMask);
    Rect r = new Rect(maxLoc, new Point(maxLoc.x() + 619, maxLoc.y() + 713));
    scrnShtForCompare = new Mat(bigMat, r);
}
 Scalar ssim = QualitySSIM.compute(base,screenshot, diffImage);
    double matchingPercentages=( (width+height) /(base.cols()+base.rows())) * ssim.get(0);

Any help??

贡献者指南