Ask Your Question

skornos's profile - activity

2019-05-17 06:14:22 -0600 received badge  Popular Question (source)
2014-04-23 11:38:15 -0600 received badge  Supporter (source)
2014-04-22 05:09:40 -0600 commented question Comparehist assertion failed

thanks, such stupid mistake :)

2014-04-20 12:57:22 -0600 asked a question Comparehist assertion failed

Hi,

I am comparing two histograms in my Android project and every time I get this

OpenCV Error: Assertion failed (A.size == arrays[i0]->size) in void cv::NAryMatIterator::init(const cv::Mat, cv::Mat, uchar, int), file /home/reports/ci/slave_desktop/50-SDK/opencv/modules/core/src/matrix.cpp, line 3210*

My code looks like this

Mat faceMat0 = mGray.submat(faces_filtered.get(0).getRect());
Mat faceMat1 = mGray.submat(faces_filtered.get(1).getRect());

Mat hist0 = histogram(mGray);
Mat hist1 = histogram(mGray);

Imgproc.compareHist(faceMat0, faceMat1, Imgproc.CV_COMP_CORREL);

And histogram function is following

Vector<Mat> bgr_planes = new Vector<Mat>();                                                                                                                                                                                 
Core.split(src, bgr_planes);
MatOfInt histSize = new MatOfInt(256);
final MatOfFloat histRange = new MatOfFloat(0f, 256f);
boolean accumulate = false;
Mat b_hist = new  Mat();
Imgproc.calcHist(bgr_planes, new MatOfInt(0),new Mat(), b_hist, histSize, histRange, accumulate);
return b_hist;

Even if I try two same histograms with the same size, the result is always this error. Could you please tell me what I am doing wrong?

Thanks