Android:如何使用相同的相机意图捕获多张照片 [英] Android: How to capture multiple photos with the same camera intent

查看:122
本文介绍了Android:如何使用相同的相机意图捕获多张照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个Android应用程序,它可以一张一张地拍照,存储照片,为用户提供预览等...所有这些任务都是以ACTION_IMAGE_CAPTURE类型完成的.
因此,用户每次要拍照时,都应单击启动意图的拍照按钮",并在等待几秒钟以启动照相机后,用户才可以拍照;之后,用户拍摄并接受了照片,相机关闭,并且通过onActivityResult方法将拍摄的照片(作为预览的位图)返回给调用类.
现在,如果您要拍摄一张以上的照片,那么此过程可能非常繁琐.

I made an Android app that takes photos one by one, stores them, gives a preview to the user, etc...all of these tasks are accomplished with an intent of type ACTION_IMAGE_CAPTURE.
So, each time that the user wants to make a photo, he should click on the "take photo button" that starts an intent, and after having waited some seconds to start the camera, the user is able to take a picture; after that the photo is taken and accepted by the user, the camera closes and the picture taken is given back (as a bitmap for the preview) to the calling class via an onActivityResult method.
Now, if you want to do more than one photo, this procedure can be really tedious.

因此,我想为我的应用程序提供一种模式,允许用户拍摄多于一张的照片,而无需上面提到的所有慢镜头.
为了澄清起见,我不想进行连拍模式(在预定义的时间间隔后自动拍摄照片),但我想使用户能够单击快门以按需要的时间拍摄照片,而不会被其他人打断.事情.

So, I would like to provide my app with a modality that allows the user to take more than one photo without all the slow stuff mentioned above.
Just to clarify, I don't want to make a burst mode (photos taken automatically after predefined intervals of time) but I want to make the user able to click the shutter to take photos as much time as he wants without being interrupted by other things.

在网上搜索时,我发现了一些信息,在我看来,有三种可能的追求方式:
-对"INTENT_ACTION_STILL_IMAGE_CAMERA"进行意图:该目标易于实现,但是摄像头界面在很大程度上取决于实现目标时所调用的应用(例如,在我的One Plus 3上,为此应用程序调用的应用程序是"Camera FV-5 Lite",在仿真设备上是另一种)...因此,我认为无法控制被调用应用程序的界面或行为(对于例如,在通过Intent调用的应用程序上可以切换到视频模式,但这在我正在设计的应用程序中不可能实现);
-使用软件包"Camera2" ( https://developer.android.com/reference/android/hardware/camera2/package-summary.html ):Google在 https://github.com/search?utf8=%E2%9C%93&q=android -Camera2& type = ,但我不完全了解采用这条路线的难度如何;
-自己制作拍照代码:我认为这是最困难的方法.

Searching on the net, I found some information and it seems to me that there are three possible ways to pursue:
- making an intent to "INTENT_ACTION_STILL_IMAGE_CAMERA": this one is easy to implement, but the camera interface will depend heavily on the app that is called when the intent is made (for example on my One Plus Three, the app called to accomplish this task is "Camera FV-5 Lite", on the emulated device is another one)...as a consequence, I think that is not possible to control the interface or the behavior of the called app (for example, on the app called via intent is possible to switch to video mode, but this shouldn't be possible to do in the app that I'm designing);
- using the package "Camera2" (https://developer.android.com/reference/android/hardware/camera2/package-summary.html): Google provides some examples of this package here https://github.com/search?utf8=%E2%9C%93&q=android-Camera2&type= but I don't fully understand how can be difficult to take this route;
- make a picture taking code by yourself: I think that this is the most difficult way.

中级开发人员是否可以按照上述一种方法(或另一种方法)完成此任务?

It is possible for a beginner-intermediate developer to accomplish this task following one of the way mentioned above (or a different one)?

类似的问题:
-从Android设备上拍摄多张照片:这里被问到如何加快处理并减少一张照片和另一张照片之间的延迟;
-使用自动生成的ImageView s创建画廊:这个问题是关于更新动态画廊,并通过不同的意图将照片拍到ACTION_IMAGE_CAPTURE;
-如何在消除相机意图之前拍摄多张照片?:此人谈论的目的是INTENT_ACTION_STILL_IMAGE_CAMERAContentObserver结合使用的解决方案,如上所述,我不想继续这样做;
-捕获多张照片时出现的问题:应用程序停止响应,相机预览变为绿色,并且未保存图片:一篇旧文章,讨论了拍摄多张照片时的问题,但是一个答案很有趣,因为提到了Camera2.

Similar questions:
- Taking Multiple Photos from Android device : here is asked how to speed up the process and reduce the lag between one photo and another one;
- Making a gallery with automatically generated ImageView s: this question is about updating the gallery dynamically with photos made via different intents to ACTION_IMAGE_CAPTURE;
- How to take multiple photos before dismissing camera intent?: this one talks about the solution with the intent to INTENT_ACTION_STILL_IMAGE_CAMERA coupled with a ContentObserver, that I don't want to pursue as mentioned above;
- Issues when capturing Multiple Photos: app stops responding, camera preview turns to green and no picture is saved: old post that talks about issues when capturing more than one photo, but one answer is interesting because Camera2 is mentioned.

推荐答案

意图"INTENT_ACTION_STILL_IMAGE_CAMERA"

making an intent to "INTENT_ACTION_STILL_IMAGE_CAMERA"

这实际上与您的其他任何选项都不相似.例如,您不知道是否拍摄了照片,照片的存储位置等.

This is not really analogous to any of your other options. For example, you have no idea if any pictures were taken, where they were stored, etc.

因此,我认为无法控制被调用应用的界面或行为

as a consequence, I think that is not possible to control the interface or the behavior of the called app

正确.这与ACTION_IMAGE_CAPTURE相同.

使用软件包"Camera2"

using the package "Camera2"

这与自己制作拍照代码"相同,不同之处在于,您为此确定了特定的Android API.

This is the same as "make a picture taking code by yourself", except that you identified a particular Android API for it.

中级初学者可以按照上述方法之一(或其他方法)来完成此任务吗?

It is possible for a beginner-intermediate developer to accomplish this task following one of the way mentionned above (or a different one)?

使用第三方相机库(Fotoapparat,CameraKit-Android等).

Use a third-party camera library (Fotoapparat, CameraKit-Android, etc.).

这篇关于Android:如何使用相同的相机意图捕获多张照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆