Ask Your Question

Revision history [back]

onCameraFrame: receive image from camera without addings

Hello,

I am realizing an Android application. I have used face-detection samples given my OpenCV to create a face tracking application.

In my Mat tmp, I want to save the inputFrame without red rectangles around faces. If I'm testing the code below on a device, where I return tmp and add rectangles around faces only in rgb, I received though an image where faces are detected (red rectangles). Can someone explain me why I don't receive only the frame delivering by the camera?

@Override
public Mat onCameraFrame(CvCameraViewFrame inputFrame){
        gray = inputFrame.gray();
        rgb = inputFrame.rgba();
        tmp=inputFrame.rgba();

        int height = gray.rows();
        if (height > 0){
            absoluteFaceSize = Math.round(height * relativeFaceSize);
            classifierFace.detectMultiScale(gray, faceDetections, 1.1, 3, 2, new Size(absoluteFaceSize,absoluteFaceSize), new Size());
            for (Rect rect : faceDetections.toArray())
            Core.rectangle(rgb, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(255,0,0), 5);
        return tmp;
}

Charlotte.