Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Resize the camera stream

Hi,

I'm trying to resize the camera stream in my android app. The default size is 780x480, 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,

Resize the camera stream

Hi,

I'm trying to resize the camera stream in my android app. The default size is 780x480, 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,