Ask Your Question
0

onCameraFrame: receive image from camera without addings

asked 2013-08-21 00:11:39 -0600

charlottepel gravatar image

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2013-08-21 00:57:16 -0600

Moster gravatar image

The reason is most likely that tmp and rgb are pointing to the same object, although I maybe shouldnt say pointing in java. So in the end its the same object and this object gets edited. You should maybe copy rgb to tmp.

tmp = rgb.clone() (hope this is also correct in java)

edit flag offensive delete link more

Comments

Thanks a lot, it seems that it was exactly what I needed. The function clone is also correct in Java.

charlottepel gravatar imagecharlottepel ( 2013-08-21 01:23:17 -0600 )edit

Question Tools

Stats

Asked: 2013-08-21 00:11:39 -0600

Seen: 2,064 times

Last updated: Aug 21 '13