I am using opencv_249 dll in java. Using below code to compare two image matrices. The code is throwing some exception which I am not able to resolve.
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;
}
The code is throwing following exception:
OpenCV Error: Assertion failed (H1.type() == H2.type() && H1.type() == CV_32F) in cv::compareHist,
file ..\..\..\..\opencv\modules\imgproc\src\histogram.cpp,
line 1985
Exception in thread "main"
CvException [org.opencv.core.CvException:
cv::Exception: ..\..\..\..\opencv\modules\imgproc\src\histogram.cpp:1985:
error: (-215) H1.type() == H2.type() && H1.type() == CV_32F
in function cv::compareHist ]
at org.opencv.imgproc.Imgproc.compareHist_0(Native Method)
at org.opencv.imgproc.Imgproc.compareHist(Imgproc.java:3051)
at ImageComparator.main(ImageComparator.java:88)
Could anyone tell what is being missed out in the code?
****OpenCV Error: Assertion failed (H1.type() == H2.type() && H1.type() == CV_32F) in...
As the error message tells you an assertion failed. Both input image have to be of the same type and that type must be CV_32F.
Maybe you noticed that your input type is CV_32FC3?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.