在矩阵上绘制图像

时间:2013-12-07 10:34:42

标签: android opencv alpha face-detection

我已经在android平台上的openv cv中开始开发了。我在绘制矩阵时遇到了问题。我有rgba矩阵,我想在该矩阵上绘制图像。我已经完成了一些代码但是没有在该矩阵上绘制图像。请帮助。

我的代码:

private Mat get_template(CascadeClassifier clasificator, Rect area, int size) {
    Mat template = new Mat();
    Mat mROI = mGray.submat(area);
    MatOfRect eyes = new MatOfRect();
    Point iris = new Point();
    Mat img = null;
    Mat cokeBGR;
    Mat cokeRGBA;
    Mat m;
    Rect round = null;
    Rect eye_template = new Rect();
    clasificator.detectMultiScale(mROI, eyes, 1.15, 5,
            Objdetect.CASCADE_FIND_BIGGEST_OBJECT
                    | Objdetect.CASCADE_SCALE_IMAGE, new Size(50,50 ),
            new Size());

    Rect[] eyesArray = eyes.toArray();
    Mat vyrez;
    int radius;


    for (int i = 0; i < eyesArray.length; i++) {

        /*Toast.makeText(context, "lenght id = "+eyesArray.length, 2000).show();*/
        Rect e = eyesArray[i];
        e.x = area.x + e.x;
        e.y = area.y + e.y;
        Rect eye_only_rectangle = new Rect((int) e.tl().x,
                (int) (e.tl().y + e.height * 0.4), (int) e.width,
                (int) (e.height * 0.6));
        mROI = mGray.submat(eye_only_rectangle);
        vyrez = mRgba.submat(eye_only_rectangle);

        Core.MinMaxLocResult mmG = Core.minMaxLoc(mROI);
    //  String imgPath = "android.resource//"
        //Mat openImag = imread(Path);
        Core.circle(vyrez, mmG.minLoc, 2,new Scalar(255,255,0,-2500005),20);
        iris.x = mmG.minLoc.x + eye_only_rectangle.x;
        iris.y = mmG.minLoc.y + eye_only_rectangle.y;
        eye_template = new Rect((int) iris.x - size / 2, (int) iris.y- size / 2, size, size);

        // eye ball rectangle
        /*Core.rectangle(mRgba, eye_template.tl(), eye_template.br(),
                new Scalar(0,0, 0, 0 ), 4);
    */

        template = (mRgba.submat(eye_template)).clone();
        return template;
    }
    return template;
}

0 个答案:

没有答案
相关问题