I'm java programmer and I'm using `opencv-2413.jar` library.
ByteArrayOutputStream streamBA = new ByteArrayOutputStream(); //wi - is instance of WritableImage (images with faces are big: 720p and 1080p, and correct. I save it to disk and they opens well) RenderedImage ri = SwingFXUtils.fromFXImage(wi, null); ImageIO.write(ri, "jpg", streamBA); byte[] img = streamBA.toByteArray(); MatOfByte rawImage = new MatOfByte(img); Mat image = Highgui.imdecode(rawImage, Highgui.CV_LOAD_IMAGE_GRAYSCALE); System.out.println(image.toString()); MatOfRect faces = new MatOfRect(); // I'm trying different cascades, the result is the same CascadeClassifier faceDetector = new CascadeClassifier();
faceDetector.detectMultiScale(image, faces);
System.out.println(faces.elemSize() + "\n");
for (Rect r : faces.toList()) {
System.out.println(r.x + " " + r.y);
}
Everything is going ok, but `faces.elemSize()` is always `0`. What I'm doing wrong?
ByteArrayOutputStream streamBA = new ByteArrayOutputStream(); //wi - is instance of WritableImage (images with faces are big: 720p and 1080p, and correct. I save it to disk and they opens well) RenderedImage ri = SwingFXUtils.fromFXImage(wi, null); ImageIO.write(ri, "jpg", streamBA); byte[] img = streamBA.toByteArray(); MatOfByte rawImage = new MatOfByte(img); Mat image = Highgui.imdecode(rawImage, Highgui.CV_LOAD_IMAGE_GRAYSCALE); System.out.println(image.toString()); MatOfRect faces = new MatOfRect(); // I'm trying different cascades, the result is the same CascadeClassifier faceDetector = new CascadeClassifier(