问题
I'm trying to write a client-server type of application. Client app installed in Google Glass uses the camera for video capture. The image frames are sent over to the server app installed in an android smartphone. I am currently doing this via Bluetooth which seems to be slow. My current image settings is 320x240, 4 channels. Each frame sent is about 307200bytes which might be too big for Bluetooth to handle but I'm not so sure. It takes about 2 seconds for each frame to be written to the OutputStream. I am using OpenCV and I'm sending the frame via Bluetooth in the public Mat onCameraFrame(CvCameraViewFrame inputFrame)
method.
The MyGlass app for Google Glass has a ScreenCast feature where the UI displayed in the Glass is sent to the paired Android phone. This is done via Bluetooth and is so much faster than my implementation.
I don't need a high fps stream. 5-10 fps should be tolerable. The android phone will do computer vision techniques in this stream.
Can anyone suggest a good approach to this?
回答1:
You could try to encode your image in Base64 to send them via Bluetooth using a protocol like XML, JSON or 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.
Alternatively, it's better to encode the frames to JPEG on the server side and then decode them on the client side. 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. See imwrite() for the list of supported formats and flags description.
来源:https://stackoverflow.com/questions/28231045/send-camera-stream-from-google-glass-to-android-device