1 | initial version |
If you use Camera (Android) instead of VideoCapture, you can do it this way:
Camera.Parameters params = mCamera.getParameters();
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
// position: variable where you choose between different supported resolutions,
// this varies from phone to phone, even the order can be different,
// ex. ascending or descending order.
mFrameWidth = (int) sizes.get(position).width;
mFrameHeight = (int) sizes.get(position).height;
params.setPreviewSize(mFrameWidth, mFrameHeight);
PS: I initially wrote this answer thinking the question was about using Camera object.
2 | No.2 Revision |
If you use Camera (Android) instead of VideoCapture, you can do it this way:
Camera.Parameters params = mCamera.getParameters();
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
// position: variable where you choose between different supported resolutions,
// this varies from phone to phone, even the order can be different,
// ex. ascending or descending order.
mFrameWidth = (int) sizes.get(position).width;
mFrameHeight = (int) sizes.get(position).height;
params.setPreviewSize(mFrameWidth, mFrameHeight);
mCamera.setParameters(params); // mCamera is a Camera object
PS: I initially wrote this answer thinking the question was about using Camera object.
3 | No.3 Revision |
If you use Camera (Android) instead of VideoCapture, you can do it this way:
Camera.Parameters params = mCamera.getParameters();
List<Camera.Size> sizes = params.getSupportedPreviewSizes();
// position: variable where you choose between different supported resolutions,
// this varies from phone to phone, even the order can be different,
// ex. ascending or descending order.
mFrameWidth = (int) sizes.get(position).width;
mFrameHeight = (int) sizes.get(position).height;
params.setPreviewSize(mFrameWidth, mFrameHeight);
mCamera.setParameters(params); // mCamera is a Camera object
PS: I initially wrote this answer thinking the question was about using Camera object.object.
So for your case it should be something like this:
mFrameWidth = (int) sizes.get(position).width;
mFrameHeight = (int) sizes.get(position).height;
vc.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, mFrameWidth);
vc.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, mFrameHeight);
Be aware that getSupportedPreviewSizes() gives you video sizes and getSupportedPictureSizes() gives you camera/photograph sizes, which are different.