Using cascade files and OpenCV 2
in
Contributed Library Questions
•
1 year ago
I've been working on training an object-detector with OpenCV 2 (using opencv_traincascade) and have had good success implementing the resulting XML file in Python. I was sad to find that installing OpenCV 2 broke the Processing library, so I tried installing the JavaCVPro library. While it works using an image of a face and one of the pre-built cascade files, it throws a weird error and quits when I try to use my XML file:
Any suggestions would be great - I like using and teaching Processing, so getting this working again would be fantastic.
- import hypermedia.video.*;
- import java.awt.Rectangle;
- String imageFilename = "face.jpg";
- String cascadeFilename = "cascade.xml";
- OpenCV cv;
- PImage img;
- void setup() {
- img = loadImage(imageFilename);
- size(img.width, img.height);
- image(img, 0,0);
-
- cv = new OpenCV(this);
- cv.allocate(img.width, img.height);
- cv.copy(img.pixels, img.width, 0,0, img.width, img.height, 0,0, img.width, img.height);
- cv.convert(GRAY);
- //cv.cascade(sketchPath("") + "frontalface.xml"); // this cascade works...
- cv.cascade(sketchPath("") + cascadeFilename); // mine doesn't...
-
- Rectangle[] found = cv.detect(1.2, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 60,60);
- println("Found: " + found.length);
- stroke(255);
- noFill();
- for (Rectangle f : found) {
- rect(f.x, f.y, f.width, f.height);
- }
- }
- public void stop() {
- cv.stop();
- super.stop();
- }
- OpenCV Error: Unspecified error (The node does not represent a user object (unknown type?)) in cvRead, file /Users/palimpseste/Development/OpenCV/opencv-2.x/svn/OpenCV/modules/core/src/persistence.cpp, line 4811
terminate called throwing an exception
Any suggestions would be great - I like using and teaching Processing, so getting this working again would be fantastic.
1