capture photo from both front and back camera simultaneously

巧了我就是萌 提交于 2019-12-31 04:50:07

问题


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.


回答1:


You need to approach this problem step by step.

  1. First build functionality to take picture by back camera.
  2. 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.
  3. 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:

  1. Use intent to go to Camera.
  2. Take a picture (which is by default back camera). Do whatever you want to do with this picture, save, process, etc.
  3. 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);

  4. Take picture again.

Refer to this thread for how to launch front camera with intent: How to launch front camera with intent?



来源:https://stackoverflow.com/questions/23785236/capture-photo-from-both-front-and-back-camera-simultaneously

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!