showing front and back camera at a time in one surface - android

I have open camera preview for many times in surface view..but this time it is really challenging.I have to show front and back camera in same time in one surface view..I have no idea how to deal with this .
Please guide me..any tutorial will be very helpful for me..I am showing the preview which I have to do with front and back cameras

Like described in the API:
Your application should only have one Camera object active at a time
for a particular hardware camera.
here:
http://developer.android.com/reference/android/hardware/Camera.html#open%28%29
So, it is not possible and not recommended to use two camera objects at the same time.

Related

How do I enable front and back camera on Android Studio Virtual Device?

I'm using an AVD on Android Studio. The app I'm using performs verification, first taking a photo with the back camera, and then switching to the front camera to take a selfie. But the problem I'm having is that I can't seem to use both cameras. Whichever one I don't assign "webcam0" shows a black screen. To get the front facing camera to work for the selfie, I need to assign "webcam0" and either "emulate" or "virtualscreen" to the back. But then the back camera doesn't work.
How do I get both to work? I really need to be able to take a photo with the front and back camera. Thanks in advance for your help!

Unity3D - Using phone's camera for two packages in the same project [duplicate]

This question already has answers here:
Using both front and back cameras simultaneously android
(3 answers)
Closed 5 years ago.
I want to use front and back Camera of device both at same time. In my app, first half of the screen will display preview of back camera and next half of the screen will display front camera preview.
I have tried this with setting two different camera previews but when I open my app, first half of the screen(which displays back camera preview) does not display the preview. And second half of the screen(which displays front facing Camera) displays back facing Camera(strange).
According to Camera.open(int) documentation:
Your application should only have one Camera object active at a time
for a particular hardware camera.
This means if both camera hardware (front and back) are different and can be opened at same time.
In my application, I am using the same above api. This does not give any exception or error when I open and call Camera.startPreview(); for both cameras at same time. But still it is not working. I can see only one camera preview at a time.
Is there anything which I am missing here to use both cameras at same time?
I got simultaneous dual camera access working on the HTC ONE M8
Video: http://youtu.be/lt8N1Lpa9Zw
Feel free to use my code from here: https://bitbucket.org/jens_grubert/androiddualcameracapture/
Same as a single camera... Just double.
Two SurfaceHolders, and two Camera instances.
http://developer.android.com/reference/android/hardware/Camera.html
https://stackoverflow.com/a/4591023/1602230
http://developer.sprint.com/show_thread.do?forumId=528&threadid=26999&messageId=78914
Using both cameras on android: "Fail to connect to camera service"
Refered from https://stackoverflow.com/a/8411122/1602230
No
Your application should only have one Camera object active at a time for a particular hardware camera.
look at this http://developer.android.com/reference/android/hardware/Camera.html#open(int)

Android: Preview picture after capture, before save

I got a full camera app up and running, but I'd like to have the captured picture show on the screen before saving them (they're not going to the gallery). I've googled extensively and I can't find anything on the topic. I also have no idea how to start, so any advice or links to relevant information I didn't find would be wonderful. Thanks!
First of all, I'm assuming you are using the original Camera APIs, not Camera2. That functionality is really built into the preview capturing, so I'm assuming your code is just clearing the preview too quickly.
After calling Camera.startPreview() to render the live preview on the active surface, at some point Camera.takePicture() is called to trigger the image capture and the result is returned to the PictureCallback. As soon as the image is captured, the camera preview surface is frozen on that frame until it is restarted. So as long as you don't call Camera.startPreview() again inside of onPictureTaken() to restart that process, the SurfaceView will remain frozen on the frame you want the user to see already.
Then if they want to save, you can write the JPEG data to disk, and if not toss away the data.

How do I know camera preview has started and I am ready to take a picture?

I am making an application that will shoot a photo automatically from the back camera every 10 seconds. But the problem is that I am not able to detect whether the preview has started or not. I want to take a picture as soon as a camera preview is available. Anyone knows a method which triggers when a camera preview is ready ?

capture photo from both front and back camera simultaneously

I would like to develop an Android application which has the technique of capturing a photo from camera(both front and back) at simultaneously.I searched over internet but unfortunately I couldn't find any better solution.
note for example if I capture the photo from back camera,once it captured from back means then it has to start front camera automatically for capture a photo.
You need to approach this problem step by step.
First build functionality to take picture by back camera.
Once you have done that, then build functionality to take picture by front camera (most of the code will be the same, just setting the back/font camera will be different.
Once you have these two options built, separately, then you can combine the two by making it a three-step process: 1) take picture by back camera 2) switch the camera to front 3) take picture by front camera.
Again, as mentioned, taking picture by back and front cameras are not different, it only involves switching the cameras.
Edited after seeing new comment:
If you are using the built-in camera, that is using intents, then this task is not going to be an automatic and immediate thing. I thought you were building custom camera, where you can do all this by code (without intents and built-in camera). But anyways, you can still do it.
So now, the process will be:
Use intent to go to Camera.
Take a picture (which is by default back camera). Do whatever you
want to do with this picture, save, process, etc.
Use another intent to go to Camera again. This time, add an extra to your intent to so the camera defaults to front camera intent.putExtra("android.intent.extras.CAMERA_FACING", 1);
Take picture again.
Refer to this thread for how to launch front camera with intent:
How to launch front camera with intent?

Categories

Resources