Camera Preview after take a photo
Hello,
I am using the Camera fragment, and here is my problem: when i take a photo the camera fragment preview the captured photo and no live preview of the camera shown again, i need to take a series of photos without previewing the captured photo, right now i am recreating the hole activity in order to clear the camera preview - and that is not a efficient solution - please help me or guide me to another solution
Bests,
cant you just show/hide an imageView with the captured image?
@wengelef the problem is after taking a photo, a preview of the captured image is showed instead of the live preview of the camera, I want to take multiple images without preview them after capture,
are you starting the PreviewActivity in the ResultListener? If so, just skip that step.
I am having the same issue. and i am not calling the PreviewActivity. Can you please elaborate with code
@arshdoda right now I just recreate the Camera Fragment after take a photo, but this cause a black screen for 2 or 3 second for re-initializing the camera
@wengelef that's exactly my problem, I skipped starting the PreviewCamera, and now the camera fragment just showing the captured photo,
interesting, will look into it tomorrow
did you check the sample app? I cannot reproduce your problem.
yes when picture is captured it shows the image in the fragment
@wengelef the sample app show the preview activity, I am asking if there is a way to capture multiple images without preview any one, if i don't show the preview activity, the capture image showed in the fragment @arshdoda , and can't take another image.
@wengelef the sample app show the preview activity, I am asking if there is a way to capture multiple images without preview any one, if i don't show the preview activity, the capture image showed in the fragment @arshdoda , and can't take another image.
CameraFragmentMainActivity doesn't show a Preview, just a Toast and it seems to fit exactly what you need to do. I really can't reproduce your Problem with a bunch of devices. Which device and SDK version are you deploying on?
@wengelef I tried with CameraFragmentMainActivity. It first apture image then shows the toast of image path and the screen freezes. Then, i clicked again on the capture button App crashes with error:
10-11 12:39:14.415 4841-4859/com.github.florent37.camerafragment.sample E/AndroidRuntime: FATAL EXCEPTION: BaseCameraManager Process: com.github.florent37.camerafragment.sample, PID: 4841 java.lang.RuntimeException: takePicture failed at android.hardware.Camera.native_takePicture(Native Method) at android.hardware.Camera.takePicture(Camera.java:1434) at android.hardware.Camera.takePicture(Camera.java:1379) at com.github.florent37.camerafragment.internal.manager.impl.Camera1Manager$3.run(Camera1Manager.java:167) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61)
okay, i could actually reproduce the behavior in the Sample App with a Galaxy S5. Did you ever solve your Problem? When i rapidly start CameraFragments i get #24
You have to change Camera1Manager.java to continue showing preview.
camera.startPreview();
public void takePhoto(File photoFile, final CameraPhotoListener cameraPhotoListener, final CameraFragmentResultListener callback) {
this.outputPath = photoFile;
this.photoListener = cameraPhotoListener;
EventBus.getDefault().post(new RecordStateEvent(RecordStateEvent.State.Photo));
backgroundHandler.post(new Runnable() {
@Override
public void run() {
setCameraPhotoQuality(camera);
try {
camera.takePicture(null, null, new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] bytes, Camera camera) {
Camera1Manager.this.onPictureTaken(bytes, camera, callback);
camera.startPreview();
}
});
} catch (Exception e) {
Log.e(TAG, "takePhoto error: "+e.getMessage()+" (usually caused by a double tap on photo trigger)");
if(cameraPhotoListener!=null)
cameraPhotoListener.onPhotoTakeError();
}
}
});
}