我有一个带有OpenCV的Android应用程序,应该能够在运行时更改JavaCameraView的帧大小。由于对传递帧的大量处理,我在应用程序启动时将帧的分辨率设置为320 x 280。我是这样做的:
protected void onCreate(Bundle savedInstanceState) {
cameraView = (JavaCameraView) findViewById(R.id.cam_view);
cameraView.setMaxFrameSize(320, 280);
cameraView.setCvCameraViewListener(this);
我创建了一个单选按钮组,用于选择画面的分辨率。这是我的代码:
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();
}
}
});
实际上,当我选择其他分辨率时,帧的分辨率并没有改变。当然,我也尝试重新初始化cameraView对象。我错过了什么吗?