我目前正在研究如何将来自相机的实时照片/视频流嵌入到我的应用程序的 Activity 中。理想情况下,会有某种 ImageView 可以直接显示来自相机的流。通过点击此 View ,可能会启动通常的相机 Activity 。最终目标是识别此 ImageView 中的二维码,这可能会使事情变得更加复杂。
所有这些都可以通过使用 ZXing 轻松完成。库,但我没有看到以上述方式组合它的方法。这甚至可能吗?关于我应该更详细地了解哪些内容,您能给我一些提示吗?
最佳答案
Ideally there would be some sort of ImageView that would directly display the stream coming in from the camera.
这叫做 the camera preview , 它通常使用 SurfaceView
或 TextureView
。
By tapping on this view the usual camera activity might be started.
SurfaceView
和 TextureView
应该响应 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/