When a picture is taken with the "OpenCV Tutorial3 - Camera Control" app the taken picture is freezed on the screen and the preview doesn't come back. I tested it with Smartphone Android 2.2.2 and Tablet Android 3.2.1 device: Both the same.
The relevant code:
Tutorial3Activity.java:
@SuppressLint("SimpleDateFormat")
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.i(TAG,"onTouch event");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
String currentDateandTime = sdf.format(new Date());
String fileName = Environment.getExternalStorageDirectory().getPath() +
"/sample_picture_" + currentDateandTime + ".jpg";
mOpenCvCameraView.takePicture(fileName);
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
return false;
}
Tutorial3View.java:
public void takePicture(final String fileName) {
Log.i(TAG, "Tacking picture");
PictureCallback callback = new PictureCallback() {
private String mPictureFileName = fileName;
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Log.i(TAG, "Saving a bitmap to file");
Bitmap picture = BitmapFactory.decodeByteArray(data, 0, data.length);
try {
FileOutputStream out = new FileOutputStream(mPictureFileName);
picture.compress(Bitmap.CompressFormat.JPEG, 90, out);
picture.recycle();
mCamera.startPreview();
} catch (Exception e) {
e.printStackTrace();
}
return;
}
};
mCamera.takePicture(null, null, callback);
}
What can I do to come back to the preview screen after taken a picture?
There is a mCamera.startPreview() command in the takePicture method but it seems not to have the effect to set the preview screen.