简体   繁体   English

如何从相机逐帧捕获而不在 Android 上保存视频?

[英]How to capture frame by frame from camera without saving video on Android?

I need to send via client/server communication (android to pc) differents frames captured from the back camera of the phone.我需要通过客户端/服务器通信(android 到 pc)发送从手机后置摄像头捕获的不同帧。 Basically, I don't need to register the video and save it to my local device, I only need to start the camera and then, when I receive a custom callback made by me, I need to take the current frame and convert it to an array of bytes(?) to send it to my computer and then turn it back to an image with openCV, for machine learning analysis.基本上,我不需要注册视频并将其保存到我的本地设备,我只需要启动相机,然后,当我收到我制作的自定义回调时,我需要获取当前帧并将其转换为一个字节数组(?)将其发送到我的计算机,然后将其转回带有 openCV 的图像,用于机器学习分析。

What's a possible way to achieve this?有什么可能的方法来实现这一目标? Should I use the Camera library, the surface view or there are better ways?我应该使用相机库、表面视图还是有更好的方法? What's the way to get the current frame showed in the camera preview?在相机预览中显示当前帧的方法是什么?

The easiest way to implement this would be using CameraX .实现这一点的最简单方法是使用CameraX

Other (manual) way of implementing this would be attaching a SurfaceTexture as the camera stream consumer, attach a consumer to it (Surface), implement appropriate image decoding and then pass the result to the OpenCV module, eg using TextureView and retrieving frames from listener's onSurfaceTextureUpdated method , getting bitmap from OpenGL texture afterwards.实现此目的的其他(手动)方法是将SurfaceTexture附加为相机 stream 消费者,将消费者附加到它(Surface),实施适当的图像解码,然后将结果传递给 OpenCV 模块,例如使用TextureView并从侦听器中检索帧onSurfaceTextureUpdated 方法,之后从 OpenGL 纹理中获取 bitmap。

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

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