CameraFragment icon indicating copy to clipboard operation
CameraFragment copied to clipboard

Camera Preview after take a photo

Open RHoumaidy opened this issue 8 years ago • 14 comments

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,

RHoumaidy avatar Aug 24 '17 09:08 RHoumaidy

cant you just show/hide an imageView with the captured image?

wengelef avatar Sep 26 '17 10:09 wengelef

@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,

RHoumaidy avatar Oct 01 '17 19:10 RHoumaidy

are you starting the PreviewActivity in the ResultListener? If so, just skip that step.

wengelef avatar Oct 02 '17 17:10 wengelef

I am having the same issue. and i am not calling the PreviewActivity. Can you please elaborate with code

arshdoda avatar Oct 03 '17 05:10 arshdoda

@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

RHoumaidy avatar Oct 03 '17 07:10 RHoumaidy

@wengelef that's exactly my problem, I skipped starting the PreviewCamera, and now the camera fragment just showing the captured photo,

RHoumaidy avatar Oct 03 '17 07:10 RHoumaidy

interesting, will look into it tomorrow

wengelef avatar Oct 03 '17 10:10 wengelef

did you check the sample app? I cannot reproduce your problem.

wengelef avatar Oct 05 '17 14:10 wengelef

yes when picture is captured it shows the image in the fragment

arshdoda avatar Oct 05 '17 14:10 arshdoda

@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.

RHoumaidy avatar Oct 08 '17 22:10 RHoumaidy

@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 avatar Oct 09 '17 07:10 wengelef

@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)

arshdoda avatar Oct 11 '17 07:10 arshdoda

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

wengelef avatar Nov 17 '17 12:11 wengelef

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();
                }
            }
        });
    }

polaris0227 avatar Mar 31 '18 13:03 polaris0227