Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I can't detect full body in java

While I use haarcascade_upperbody.xml to detection in videocapture, I never get any error or problem but when I used haarcascade_fullbody.xml program couldn't detect anyone's body.. I am going to use finding human heigth...if you give some hints, solutions or advising another way for this problem...thanks for reading

here is my code :

package main;

import javax.swing.JOptionPane;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.highgui.VideoCapture;
import org.opencv.objdetect.CascadeClassifier;

public class ResimCek {

public void resimCek() throws InterruptedException{
    System.loadLibrary("opencv_java244");
    CascadeClassifier cascadeClassifier = new CascadeClassifier("haarcascade_fullbody.xml");
    VideoCapture cap = new VideoCapture(0);
    if(!cap.isOpened())
        JOptionPane.showMessageDialog(null, "Cam can not found", "Error", JOptionPane.ERROR_MESSAGE);

    Mat frame = new Mat();
    cap.retrieve(frame);
    Highgui.imwrite("cek.jpg", frame);
    cap.release();
    Mat resim = Highgui.imread("cek.jpg");
    MatOfRect rect = new MatOfRect();
    cascadeClassifier.detectMultiScale(resim, rect);
    Scalar renk = new Scalar(255, 0, 0);
    for(Rect dik : rect.toArray()){
        Core.rectangle(resim, new Point(dik.x, dik.y), new Point(dik.x+ dik.width, dik.y+dik.height), renk);
    }
    System.out.println(rect.height());
    Highgui.imwrite("dene.jpg", resim);
    }
}

I can't detect full body in java

While I use haarcascade_upperbody.xml to detection in videocapture, I never get any error or problem but when I used haarcascade_fullbody.xml program couldn't detect anyone's body.. I am going to use finding human heigth...if you give some hints, solutions or advising another way for this problem...thanks problem, I will very pleased...thanks for reading

here is my code :

package main;

import javax.swing.JOptionPane;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.highgui.VideoCapture;
import org.opencv.objdetect.CascadeClassifier;

public class ResimCek {

public void resimCek() throws InterruptedException{
    System.loadLibrary("opencv_java244");
    CascadeClassifier cascadeClassifier = new CascadeClassifier("haarcascade_fullbody.xml");
    VideoCapture cap = new VideoCapture(0);
    if(!cap.isOpened())
        JOptionPane.showMessageDialog(null, "Cam can not found", "Error", JOptionPane.ERROR_MESSAGE);

    Mat frame = new Mat();
    cap.retrieve(frame);
    Highgui.imwrite("cek.jpg", frame);
    cap.release();
    Mat resim = Highgui.imread("cek.jpg");
    MatOfRect rect = new MatOfRect();
    cascadeClassifier.detectMultiScale(resim, rect);
    Scalar renk = new Scalar(255, 0, 0);
    for(Rect dik : rect.toArray()){
        Core.rectangle(resim, new Point(dik.x, dik.y), new Point(dik.x+ dik.width, dik.y+dik.height), renk);
    }
    System.out.println(rect.height());
    Highgui.imwrite("dene.jpg", resim);
    }
}