1

I am currently working on an Android application and would like to make back projection. The tutorial I am following is :

http://docs.opencv.org/doc/tutorials/imgproc/histograms/back_projection/back_projection.html#back-projection

The problem I am having is when I use Imgproc.calcHist(...). I cannot seem to figure out what parameters I should pass to this function, which is currently as follows and is giving me an OpenCV error where the assertion fails:

listHueList = new ArrayList<Mat>() {{ add(mHueMat);}};
ch = new MatOfInt(0,0); 
mMaskMat = new Mat();
mHistMat = new Mat();
range = new MatOfFloat(0, 256);
Imgproc.calcHist(listHueList, ch, mMaskMat, mHistMat, new MatOfInt() , range);

Could someone be kind enough as to translate the parameters in the tutorial link above to ones which I can easily use through Java syntax?

Thank you

test
  • 2,538
  • 4
  • 35
  • 52
  • possible duplicate of [Back Projection in Java with OpenCV](http://stackoverflow.com/questions/17044147/back-projection-in-java-with-opencv) – Rui Marques Feb 21 '14 at 00:01

1 Answers1

0

Look this code. It works for me!

java.util.List<Mat> matList = new LinkedList<Mat>();
            matList.add(image_gray);
            Mat histogram = new Mat();
            MatOfFloat ranges=new MatOfFloat(0,256);
            Imgproc.calcHist(
                    matList, 
                    new MatOfInt(0), 
                    new Mat(), 
                    histogram , 
                    new MatOfInt(25), 
                    ranges);
            System.out.println("histogram\n"+histogram.dump());
rafaoc
  • 586
  • 7
  • 21