I have an Android App with OpenCV which should be able to change the frame size of the JavaCameraView at runtime. Because a lot processing on the delivered frame I set the resolution of the frame at App start on 320 x 280. I do this like that:
protected void onCreate(Bundle savedInstanceState) {
cameraView = (JavaCameraView) findViewById(R.id.cam_view);
cameraView.setMaxFrameSize(320, 280);
cameraView.setCvCameraViewListener(this);
I created a RadioButton Group in which I can choose the resolution for the frame. Here is my code;
resolutionChange = new Dialog(this);
resolutionChange.requestWindowFeature(Window.FEATURE_NO_TITLE);
resolutionChange.setContentView(com.finarx.opencv.camera.R.layout.resdialog);
RadioGroup resChange = (RadioGroup) resolutionChange.findViewById(com.finarx.opencv.camera.R.id.resChange);
resChange.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group,
int checkedId) {
if (checkedId == com.finarx.opencv.camera.R.id.lowest) {
cameraView.setMaxFrameSize(320, 280);
resolutionChange.dismiss();
} else if (checkedId == com.finarx.opencv.camera.R.id.low) {
cameraView.setMaxFrameSize(480, 320);
resolutionChange.dismiss();
} else if (checkedId == com.finarx.opencv.camera.R.id.vga) {
cameraView.setMaxFrameSize(640, 480);
resolutionChange.dismiss();
} else if (checkedId == com.finarx.opencv.camera.R.id.higher) {
cameraView.setMaxFrameSize(800, 600);
resolutionChange.dismiss();
} else if (checkedId == com.finarx.opencv.camera.R.id.highest) {
cameraView.setMaxFrameSize(1280, 720);
resolutionChange.dismiss();
}
}
});
In fact, nothing happens to the resolution of the frame when I choose another resolution. Of course I also tried to reinitiate the cameraView object. Is there anything I miss?