android - 将相机嵌入到 Activity 中(直播)

标签 android stream camera android-activity live

我目前正在研究如何将来自相机的实时照片/视频流嵌入到我的应用程序的 Activity 中。理想情况下,会有某种 ImageView 可以直接显示来自相机的流。通过点击此 View ,可能会启动通常的相机 Activity 。最终目标是识别此 ImageView 中的二维码,这可能会使事情变得更加复杂。

所有这些都可以通过使用 ZXing 轻松完成。库,但我没有看到以上述方式组合它的方法。这甚至可能吗?关于我应该更详细地了解哪些内容,您能给我一些提示吗?

Wireframe

最佳答案

Ideally there would be some sort of ImageView that would directly display the stream coming in from the camera.

这叫做 the camera preview , 它通常使用 SurfaceViewTextureView

By tapping on this view the usual camera activity might be started.

SurfaceViewTextureView 应该响应 onClick(),或者更糟的是 onTouchEvent()

The final goal is to recognize QR codes within this ImageView, which might make things even more complicated.

你可能会这么说。 :-)

All of this can be done pretty easy by using the ZXing library

ZXing 不是图书馆。 ZXing 是一个开源项目,发布了 Barcode Scanner 应用程序、一些集成类以帮助您从您的应用程序启动 Barcode Scanner 应用程序,以及用于非 Android 环境的代码。

虽然我没有尝试过,但网上有一些将 ZXing 整合到库中的方法。还有一些其他条形码扫描库可用,但我也没有尝试过。原则上,其中之一应该能够让您将可扫描的预览嵌入到更大的 Activity 中。

关于android - 将相机嵌入到 Activity 中(直播),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23044739/

相关文章:

android - SurfaceView 中的缩放和拖动功能

java - 用摄像头读取二维码 - Android

swift - 我的自定义相机 View 有什么问题?

java - Android_Eclipse 代码不确认 if 语句

android - 如何创建华为安卓模拟器

c# - ASP.NET MVC 的 FileStreamResult 是否比直接写入响应输出流效率低,还是我遗漏了什么?

stream - 更改 common lisp 中的默认阅读器

Android Gradle 插件 : Property 'applicationId' is not annotated with an input or output annotation

android - Android:音频问题

ios - 相机处于横向模式