2011-07-18 21:50:36 +08:00
|
|
|
package org.opencv.test.objdetect;
|
|
|
|
|
2011-07-20 00:08:26 +08:00
|
|
|
import org.opencv.core.Mat;
|
2012-04-14 05:50:59 +08:00
|
|
|
import org.opencv.core.MatOfRect;
|
2011-07-20 00:08:26 +08:00
|
|
|
import org.opencv.core.Size;
|
|
|
|
import org.opencv.imgproc.Imgproc;
|
2011-07-18 21:50:36 +08:00
|
|
|
import org.opencv.objdetect.CascadeClassifier;
|
2011-08-03 21:12:39 +08:00
|
|
|
import org.opencv.objdetect.Objdetect;
|
2011-07-18 21:50:36 +08:00
|
|
|
import org.opencv.test.OpenCVTestCase;
|
|
|
|
import org.opencv.test.OpenCVTestRunner;
|
|
|
|
|
|
|
|
public class CascadeClassifierTest extends OpenCVTestCase {
|
2011-08-02 21:47:40 +08:00
|
|
|
|
|
|
|
private CascadeClassifier cc;
|
|
|
|
|
2011-07-18 21:50:36 +08:00
|
|
|
@Override
|
|
|
|
protected void setUp() throws Exception {
|
|
|
|
super.setUp();
|
2011-08-02 21:47:40 +08:00
|
|
|
|
2011-07-18 21:50:36 +08:00
|
|
|
cc = null;
|
|
|
|
}
|
|
|
|
|
2011-08-02 21:47:40 +08:00
|
|
|
public void testCascadeClassifier() {
|
|
|
|
cc = new CascadeClassifier();
|
2019-05-24 16:45:09 +08:00
|
|
|
assertNotNull(cc);
|
2011-08-02 21:47:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void testCascadeClassifierString() {
|
|
|
|
cc = new CascadeClassifier(OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH);
|
2019-05-24 16:45:09 +08:00
|
|
|
assertNotNull(cc);
|
2011-08-02 21:47:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRect() {
|
|
|
|
CascadeClassifier cc = new CascadeClassifier(OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH);
|
2012-04-14 05:50:59 +08:00
|
|
|
MatOfRect faces = new MatOfRect();
|
2011-08-02 21:47:40 +08:00
|
|
|
|
|
|
|
Mat greyLena = new Mat();
|
|
|
|
Imgproc.cvtColor(rgbLena, greyLena, Imgproc.COLOR_RGB2GRAY);
|
|
|
|
|
|
|
|
// TODO: doesn't detect with 1.1 scale
|
2012-03-21 23:07:54 +08:00
|
|
|
cc.detectMultiScale(greyLena, faces, 1.09, 3, Objdetect.CASCADE_SCALE_IMAGE, new Size(30, 30), new Size());
|
2012-04-14 05:50:59 +08:00
|
|
|
assertEquals(1, faces.total());
|
2011-08-02 21:47:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectDouble() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectDoubleInt() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectDoubleIntInt() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectDoubleIntIntSize() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectDoubleIntIntSizeSize() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectListOfIntegerListOfDouble() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectListOfIntegerListOfDoubleDouble() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectListOfIntegerListOfDoubleDoubleInt() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectListOfIntegerListOfDoubleDoubleIntInt() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectListOfIntegerListOfDoubleDoubleIntIntSize() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectListOfIntegerListOfDoubleDoubleIntIntSizeSize() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testDetectMultiScaleMatListOfRectListOfIntegerListOfDoubleDoubleIntIntSizeSizeBoolean() {
|
|
|
|
fail("Not yet implemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testEmpty() {
|
|
|
|
cc = new CascadeClassifier();
|
|
|
|
assertTrue(cc.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void testLoad() {
|
|
|
|
cc = new CascadeClassifier();
|
|
|
|
cc.load(OpenCVTestRunner.LBPCASCADE_FRONTALFACE_PATH);
|
2019-05-24 16:45:09 +08:00
|
|
|
assertFalse(cc.empty());
|
2011-08-02 21:47:40 +08:00
|
|
|
}
|
2011-07-18 21:50:36 +08:00
|
|
|
|
|
|
|
}
|