简体   繁体   English

将相机流从Google Glass发送到Android设备

[英]Send camera stream from Google Glass to Android device

I'm trying to write a client-server type of application. 我正在尝试编写客户端-服务器类型的应用程序。 Client app installed in Google Glass uses the camera for video capture. 安装在Google Glass中的客户端应用程序使用相机进行视频捕获。 The image frames are sent over to the server app installed in an android smartphone. 图像帧将发送到安装在android智能手机中的服务器应用程序。 I am currently doing this via Bluetooth which seems to be slow. 我目前正在通过蓝牙(似乎很慢)执行此操作。 My current image settings is 320x240, 4 channels. 我当前的图像设置是320x240,4通道。 Each frame sent is about 307200bytes which might be too big for Bluetooth to handle but I'm not so sure. 发送的每个帧约为307200bytes,对于蓝牙来说可能太大了,但我不确定。 It takes about 2 seconds for each frame to be written to the OutputStream. 每个帧写入OutputStream大约需要2秒钟。 I am using OpenCV and I'm sending the frame via Bluetooth in the public Mat onCameraFrame(CvCameraViewFrame inputFrame) method. 我正在使用OpenCV,并且正在通过public Mat onCameraFrame(CvCameraViewFrame inputFrame)方法中的蓝牙发送帧。

The MyGlass app for Google Glass has a ScreenCast feature where the UI displayed in the Glass is sent to the paired Android phone. 适用于Google Glass的MyGlass应用程序具有ScreenCast功能,可将Glass中显示的UI发送到配对的Android手机。 This is done via Bluetooth and is so much faster than my implementation. 这是通过蓝牙完成的,比我的实现要快得多。

I don't need a high fps stream. 我不需要高fps的流。 5-10 fps should be tolerable. 5-10 fps应该可以容忍。 The android phone will do computer vision techniques in this stream. android手机将在此流中执行计算机视觉技术。

Can anyone suggest a good approach to this? 谁能建议一个好的方法吗?

You could try to encode your image in Base64 to send them via Bluetooth using a protocol like XML, JSON or protobuf. 您可以尝试在Base64中对图像进行编码,以使用诸如XML,JSON或protobuf之类的协议通过蓝牙发送图像。 Probably this is not the most efficient method but it could be the easiest for you at this moment. 可能这不是最有效的方法,但目前可能对您来说是最简单的方法。
But always take care if you want to access the data member of any cv::Mat , if frame.isContinuous() returns true then it can be used as a byte array otherwise it is not. 但是,如果要访问任何cv::Matdata成员,请frame.isContinuous() ,如果frame.isContinuous()返回true,则可以将其用作字节数组,否则不可以。

Alternatively, it's better to encode the frames to JPEG on the server side and then decode them on the client side. 另外,最好在服务器端将帧编码为JPEG,然后在客户端解码。 It will significantly decrease the size of data should be streamed over the network and could be useful due to the limited bandwidth of Bluetooth. 它将大大减少应通过网络流传输的数据大小,并且由于蓝牙的带宽有限而很有用。
OpenCV's imencode() and imdecode() will perform both side of compression. OpenCV的imencode()imdecode()将执行压缩的两面。 See imwrite() for the list of supported formats and flags description. 有关支持的格式和标志说明的列表,请参见imwrite()

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

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