1 | initial version |
I just ran into this problem and solved it. The important things to note are the following areas within the native library:
CV_Assert(nimages > 0 && dims > 0);
CV_Assert(rsz == dims*2 || (rsz == 0 && images.depth(0) == CV_8U));
CV_Assert(csz == 0 || csz == dims);
dims
is the number of elements in the histSize vector, rsz
is the range vector size, and csz
is the channel vector size. Looking at your code we can see that the third assertion fails because the channel size (your channels
vector) is of size 3, but the size of your histSize
vector is only 1! So what you should do is change
MatOfInt histSize=new MatOfInt(256);
to
MatOfInt histSize=new MatOfInt(256, 256, 256);
now of course you will get an assertion error on the second assertion in the native code above, so you should then notice that your ranges
vector must be modified to satisfy the requirement of rsz == dims*2
, in other words, specify a range for each bucket like so:
MatOfFloat ranges=new MatOfFloat(0.0f,255.0f, 0.0f, 255.0f, 0.0f, 255.0f);
Hope this helps
2 | note about ranges |
I just ran into this problem and solved it. The important things to note are the following areas within the native library:
CV_Assert(nimages > 0 && dims > 0);
CV_Assert(rsz == dims*2 || (rsz == 0 && images.depth(0) == CV_8U));
CV_Assert(csz == 0 || csz == dims);
dims
is the number of elements in the histSize vector, rsz
is the range vector size, and csz
is the channel vector size. Looking at your code we can see that the third assertion fails because the channel size (your channels
vector) is of size 3, but the size of your histSize
vector is only 1! So what you should do is change
MatOfInt histSize=new MatOfInt(256);
to
MatOfInt histSize=new MatOfInt(256, 256, 256);
now of course you will get an assertion error on the second assertion in the native code above, so you should then notice that your ranges
vector must be modified to satisfy the requirement of rsz == dims*2
, in other words, specify a range for each bucket like so:
MatOfFloat ranges=new MatOfFloat(0.0f,255.0f, 0.0f, 255.0f, 0.0f, 255.0f);
Hope this helps
Edit: Also, you should think about using 256.0f instead of 255.0f in your ranges since it is exclusive on the top (it says it somewhere in the documentation but I don't have a link)