Ask Your Question

Dany B.'s profile - activity

2014-08-12 08:05:52 -0500 received badge  Editor (source)
2014-08-12 04:34:28 -0500 received badge  Student (source)
2014-08-12 04:25:10 -0500 asked a question Resize the camera stream


I'm trying to resize the camera stream in my android app. The default size is 720x480, and i want to rescale at the minimum supported size which is 320x240. My solution keeps the old aspect ratio, and don't find a way to redefine the new ratio. Does anyone know a solution?

CameraBridgeViewBase cameraBridge = (CameraBridgeViewBase) ((Activity) context).getWindow()

Camera c =;
Parameters parameters = c.getParameters();
parameters.setPictureSize(_widthImage, _heightImage);
parameters.setPreviewSize(_widthImage, _heightImage);
c = null;


cameraBridge.setMaxFrameSize(_widthImage, _heightImage);
cameraBridge.getHolder().setFixedSize(_widthImage, _heightImage);


I use the bellow method to retrieve the matrice.

public Mat onCameraFrame(CvCameraViewFrame inputFrame)
    this._image = inputFrame.rgba().clone();
    return inputFrame.rgba();


2014-07-25 10:12:18 -0500 asked a question Android - How get Mat from camera ?

I'm trying to retrieve images (Mat) from camera on android device, and I have some problems.

I first tried to use VideoCapture class with method but i get error 11 (SIGSEGV) when i open the camera. I think this bug is caused by hardware camera management because it works on emulator/webcam.

So, to avoid this bug, i choose to use CameraBridgeViewBase class.

CameraBridgeViewBase cameraBridge = (CameraBridgeViewBase) ((Activity) context).
// Camera c =;
// List<Size> sizes = c.getParameters().getSupportedPictureSizes();
// c.release();
// c = null;
// for (int i = 0; i < sizes.size(); i++)
// {
// Log.d(tag, sizes.get(i).width + "x" + sizes.get(i).height);
// }


// cameraBridge.setMaxFrameSize(_widthImage, _heightImage);
// cameraBridge.getHolder().setFixedSize(_widthImage, _heightImage);
// cameraBridge.getHolder().setFixedSize(1, 1);


And the listener method.

public Mat onCameraFrame(CvCameraViewFrame inputFrame)
    this._image = inputFrame.rgba().clone();
    Log.d(tag, "onCameraFrame : " + this._image.size());
    return inputFrame.rgba();
    // return null;

It works, I get a Mat for each frame displayed but I would like to hide the preview.

I also have a ratio problem with Mat when I change the maxFrameSize (commented code). I have to minimize image size to improve image processing. The default size is 720x480 (ratio 3:2). My size is the minimum supported size : 320x240 (ratio 4:3).

Do you have any idea to solve my problems ?