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

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,

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 VideoCapture.read(Mat) 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).
getWindow().getDecorView().findViewById(R.id.image);
// Camera c = Camera.open(_idCamera);
// 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.setCameraIndex(_idCamera);

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

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

And the listener method.

@Override
public Mat onCameraFrame(CvCameraViewFrame inputFrame)
{
    this._image = inputFrame.rgba().clone();
    Log.d(tag, "onCameraFrame : " + this._image.size());
    this._waitForImage.release();
    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 ?