Why can't I use other cascades in OpenCV library

edited November 2017 in Kinect

I try to use camera and opencv library to detect my fist.

I can use the cascade file in example code , but when i tried to use other code on internet , it doesn't work.

for example : https://github.com/Aravindlivewire/Opencv/tree/master/haarcascade

I downloaded another aGest.xml from different place, it works well.

The code looks like the same as the code in the link above. but cascade file in Aravindlivewire's github can not be applied to my program.

Here is my code :

import gab.opencv.*; import java.awt.Rectangle; import KinectPV2.*; KinectPV2 kinect; OpenCV opencv;

Rectangle[] faces;

PImage apples;

void setup() {

 opencv = new OpenCV(this, 480,270);

 size(960, 540, P3D);

 kinect = new KinectPV2(this);

 kinect.enableColorImg(true);

 kinect.init();

 //opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);

 opencv.loadCascade("aGest.xml");  

 apples = new PImage(480,270,RGB);

}

void draw() {

 background(0);

 PImage img = kinect.getColorImage();

 apples.copy(img,0,0,1920,1080,0,0,480,270);

 opencv.loadImage(apples);

 opencv.useColor();

 image(opencv.getSnapshot(), 0, 0);

 faces = opencv.detect();

 noFill();

 stroke(0, 255, 0);

 strokeWeight(3);

 for (int i = 0; i < faces.length; i++) {

   rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);

   println(faces[i].x +" "+ faces[i].y);

} }

Sign In or Register to comment.