简体   繁体   English

Android:Camera2捕获图像

[英]Android: Camera2 capturing image

I was trying to capture a photo using this sample using both front and back camera, which is done inside this fragment . 我正尝试使用此示例使用前后摄像头捕获照片,此操作是在此片段内完成的。

Obviuosly the onCaptureCompleted is called after each capture, so I wanted to get that picture from "TotalCaptureResult result" but I coudn't, also it seem's that the onCaptureCompleted is never called when I try to take a picture with the front camera. 显然,每次捕获后都会调用onCaptureCompleted,因此我想从“ TotalCaptureResult结果”中获取该图片,但是我不知道,而且当我尝试使用前置摄像头拍摄图片时似乎也从未调用过onCaptureCompleted。

So how to get the captured image from both front and back camera? 那么如何从前置和后置摄像头获取捕获的图像呢? any help or hint is really appreciated. 任何帮助或提示,我们都感激不尽。

you shouldn't do this as cameras on different devices might not have support for it. 您不应该这样做,因为不同设备上的相机可能不支持它。 android is fragmented and camera behaviour differs amony devices. android支离破碎,相机行为也不同于amony设备。

for one camera you can do this : Capture Image from Camera and Display in Activity 对于一台摄像机,您可以执行以下操作: 从摄像机捕获图像并在活动中显示

Try this one 试试这个

In OnactivityResult you will get your image. 在OnactivityResult中,您将获得图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM