Java Code Examples for org.opencv.imgproc.Imgproc.compareHist()

The following are Jave code examples for showing how to use compareHist() of the org.opencv.imgproc.Imgproc class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Face-detection-and-recognition-desktop-application   File: FaceDetectCropTest.java   Source Code and License Vote up 7 votes
public void compare_image(BufferedImage img_1, BufferedImage img_2) throws IOException {//Its called by above method compare_image()
    Mat mat_1 = conv_Mat(img_1);
    Mat mat_2 = conv_Mat(img_2);

    Mat hist_1 = new Mat();
    Mat hist_2 = new Mat();

    MatOfFloat ranges = new MatOfFloat(0f, 256f);
    MatOfInt histSize = new MatOfInt(25);

    Imgproc.calcHist(Arrays.asList(mat_1), new MatOfInt(0),
            new Mat(), hist_1, histSize, ranges);
    Imgproc.calcHist(Arrays.asList(mat_2), new MatOfInt(0),
            new Mat(), hist_2, histSize, ranges);

    double res = Imgproc.compareHist(hist_1, hist_2, Imgproc.CV_COMP_CORREL);
    Double d = new Double(res * 100);

    disp_percen(d.intValue());

}
 
Example 2
Project: Face-detection-and-recognition-desktop-application   File: FaceRecognizeFrame.java   Source Code and License Vote up 6 votes
public void compare_image(BufferedImage img_1, BufferedImage img_2) throws IOException {//Its called by above method compare_image()
    Mat mat_1 = conv_Mat(img_1);
    Mat mat_2 = conv_Mat(img_2);

    Mat hist_1 = new Mat();
    Mat hist_2 = new Mat();

    MatOfFloat ranges = new MatOfFloat(0f, 256f);
    MatOfInt histSize = new MatOfInt(25);

    Imgproc.calcHist(Arrays.asList(mat_1), new MatOfInt(0),
            new Mat(), hist_1, histSize, ranges);
    Imgproc.calcHist(Arrays.asList(mat_2), new MatOfInt(0),
            new Mat(), hist_2, histSize, ranges);

    double res = Imgproc.compareHist(hist_1, hist_2, Imgproc.CV_COMP_CORREL);
    Double d = new Double(res * 100);

    disp_percen(d.intValue());

}