I'm trying to set picture size to change the image capture resolution of camera in Android OpenCV project which using JavaCameraView. I select the best resolution from supported resolutions and try to set it. But no matter whichever resolution I try, it doesn't work. My resolution setting code goes like this -
List<Camera.Size> supportedSizes = params.getSupportedPictureSizes();
if(supportedSizes!=null && supportedSizes.size()>0) {
int maxSupportedWidth = 0, maxSupportedHeight = 0;
for(int i=0; i<supportedSizes.size(); i++) {
if(supportedSizes.get(i).width >= maxSupportedWidth)
maxSupportedWidth = supportedSizes.get(i).width;
}
for(int i=0; i<supportedSizes.size(); i++) {
if(supportedSizes.get(i).width == maxSupportedWidth &&
supportedSizes.get(i).height>=maxSupportedHeight) {
maxSupportedHeight = supportedSizes.get(i).height;
}
}
Log.d(TAG, "Setting image capture resolution to "+maxSupportedWidth+"x"+maxSupportedHeight);
params.setPictureSize(maxSupportedWidth, maxSupportedHeight);
}
mCamera.setParameters(params);
I tried calling this code in initializeCamera() function of JavaCameraView, then in onCameraViewStarted callback function and then also just before calling takePicture() function but doesn't seem to be working in any of the places. For some phones, it automatically captures large sized images but for others it doesn't. I'm presently using Redmi Phone with Android version 4.4.4 KTU84P. I tried making a different app without OpenCV using SurfaceView and android Camera class. I added the same function to set the maximum resolution and it works perfectly fine.
Please help. Any ideas on the topic would be appreciated.