Hello,
Some days ago I wrote (copy paste) using the samples in Javacvpro, this script for face detection using WebCam, which used to work well:
import codeanticode.gsvideo.*;import monclubelec.javacvPro.*;import java.awt.*;
PImage imgSrc, imgDest;
Rectangle[] faceRect;
GSCapture cam;OpenCV opencv;
int widthCapture=320; // largeur captureint heightCapture=240; // hauteur captureint fpsCapture=20; // framerate (image/secondes) pour la capture video
long millis0=0; // variable de mémorisation de millis
void setup(){colorMode(RGB, 255,255,255); // fixe format couleur R G B pour fill, stroke, etc...fill(0,0,255); // couleur remplissage RGB - noFill() si pas de remplissagestroke (0,0,255); // couleur pourtour RGB - noStroke() si pas de pourtourrectMode(CORNER); // origine rectangle : CORNER = coin sup gauche | CENTER : centreimageMode(CORNER); // origine image : CORNER = coin sup gauche | CENTER : centreellipseMode(CENTER); // origine cercles / ellipses : CENTER : centre (autres : RADIUS, CORNERS, CORNERframeRate(30);// Images par seconde - The default rate is 60 frames per second
size(widthCapture*2,heightCapture*2); // ouvre une fenêtre xpixels x ypixelsbackground(0,0,0); // couleur fond fenetre
cam = new GSCapture(this, widthCapture, heightCapture);cam.start();opencv = new OpenCV(this); // initialise objet OpenCV à partir du parent Thisopencv.allocate(widthCapture,heightCapture); // crée les buffers image de la taille voulue
opencv.cascade("FRONTALFACE_ALT", true);faceRect = opencv.detect(true);
}
void draw() {if (cam.available() == true) {cam.read(); // acquisition d'un frameimgSrc=cam.get(); // récupère l'image GS video dans Pimageopencv.copy(imgSrc); // charge l'image dans le buffer openCV
image(opencv.image(), 0, 0);faceRect = opencv.detect(true);println("numero de caras detectadas =" + faceRect.length + ".");opencv.drawRectDetect (0, 0, 1, color(255,255,0), 3 , true, color(0,0,255), true); // tracé avec les paramètres
}}
Today I ran processing with the code and didn’t work, I got this message:
OpenCV Error: Null pointer (Invalid classifier cascade) in cvHaarDetectObjectsForROC, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/OpenCV-2.3.1/modules/objdetect/src/haar.cpp, line 1041
Exception in thread "Animation Thread" java.lang.RuntimeException: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/OpenCV-2.3.1/modules/objdetect/src/haar.cpp:1041: error: (-27) Invalid classifier cascade in function cvHaarDetectObjectsForROC
at com.googlecode.javacv.cpp.opencv_objdetect.cvHaarDetectObjects(Native Method)
at monclubelec.javacvPro.OpenCV.detect(Unknown Source)
at monclubelec.javacvPro.OpenCV.detect(Unknown Source)
at MyFaceDetect.setup(MyFaceDetect.java:65)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphics.requestDraw(PGraphics.java:674)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:680)
And processing points the problem in:
Has any one experience the same problem? The thing is with another samples Javacvpro works well.
I’m using OSX Lion, I getting crazy traying to fix this, has anyone and idea whats happening?
Salutations.