如何使用java中的opencv的Imgproc.compareHist方法确定两个图像之间的相似度?

时间:2017-03-31 09:36:05

标签: java opencv image-processing histogram image-comparison

我在java中使用 opencv_249 dll 。使用下面的代码比较两个图像矩阵。 代码抛出了一些我无法解决的异常。

scale_y_continuous(limits = c())

代码抛出以下异常:

static double compareImages(Mat main, Mat temp){
    main.convertTo(main, CvType.CV_32FC3);
    temp.convertTo(temp, CvType.CV_32FC3);
    Core.normalize(main, temp, 1.0, 0.0, Core.NORM_L1);
    double s=Imgproc.compareHist(main, temp, Imgproc.CV_COMP_CORREL);
    return s;
}

有人能告诉代码中遗漏了什么吗?

1 个答案:

答案 0 :(得分:0)

  

**** OpenCV错误:断言失败(H1.type()== H2.type()&& H1.type()== CV_32F)...

由于错误消息告诉您断言失败。 两个输入图像必须属于同一类型,并且该类型必须为CV_32F。

也许您注意到您的输入类型是CV_32FC3?