简体   繁体   English

如何在Javacv中将面部检测中的矩形更改为椭圆形?

[英]How to change rectangles in a face detection to ellipses in Javacv?

Here is my code which uses rectangles to mark detected faces. 这是我的代码,它使用矩形标记检测到的面部。 How can I make ellipses around faces instead? 我该如何在脸部周围制作椭圆形? Is there a cvEllipse class instead of a cvRectangle ? cvEllipse类而不是cvRectangle吗? I tried to write like this but it seems cvEllipse doesn't exist or its name is different. 我试图这样写,但是cvEllipse似乎不存在或名称不同。

    CvHaarClassifierCascade cascade = new  CvHaarClassifierCascade(cvLoad(XML_FILE));
    CvMemStorage storage = CvMemStorage.create();
    CvSeq sign = cvHaarDetectObjects(
        img,
        cascade,
        storage,
        1.5,
        3,
        CV_HAAR_DO_CANNY_PRUNING
    );

    cvClearMemStorage(storage);

    total_Faces = sign.total();     

    for(int i = 0; i < total_Faces; i++){
        CvRect r = new CvRect(cvGetSeqElem(sign, i));
        cvRectangle(
            img,
            cvPoint(r.x(), r.y()),
            cvPoint(r.width() + r.x(), r.height() + r.y()),
            CvScalar.RED,
            2,
            CV_AA,
            0
        );

        x=r.x();
        y=r.y();
        h=r.height();
        w=r.width();

    }         
import static org.bytedeco.javacpp.opencv_core.cvPoint;
import static org.bytedeco.javacpp.opencv_core.cvScalar;
import static org.bytedeco.javacpp.opencv_core.cvSize;
import static org.bytedeco.javacpp.opencv_imgproc.cvEllipse;

----

cvEllipse(img, cvPoint(), cvSize(), 2d, CV_AA, 0d, CvScalar.RED);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM