Resize the camera stream

asked 2014-08-12 04:25:10 -0600

Dany B. gravatar image

updated 2014-08-12 08:05:52 -0600

Hi,

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()
.getDecorView().findViewById(R.id.image);

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

cameraBridge.setCameraIndex(_idCamera);

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

cameraBridge.setVisibility(SurfaceView.VISIBLE);
cameraBridge.setCvCameraViewListener(this);
cameraBridge.enableView();

I use the bellow method to retrieve the matrice.

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

Thanks,

edit retag flag offensive close merge delete

Comments

First you have to check if the minimum size that you mention is supported : You can do that :

 camera = Camera.open();
 parameters = camera.getParameters();
 List<Size>SupporetdSizes = parameters.getSupportedPreviewSizes();
itay gravatar imageitay ( 2014-10-02 09:24:44 -0600 )edit