Ask Your Question
0

Comparehist assertion failed

asked 2014-04-20 12:57:22 -0600

skornos gravatar image

updated 2014-04-20 13:17:41 -0600

berak gravatar image

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

edit retag flag offensive close merge delete

Comments

1

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

- - - - - - - - - - - - - - - - - ^^

you are using the grayscale -submats here, not your histograms

berak gravatar imageberak ( 2014-04-21 04:10:15 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-04-22 05:09:40 -0600

skornos gravatar image

thanks, such stupid mistake :)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-04-20 12:57:22 -0600

Seen: 2,574 times

Last updated: Apr 20 '14