简体   繁体   English

构建与Android应用程序通信的C ++程序的最佳方法

[英]Best way to build a C++ program that communicates with an Android app

I'm working right now on a openCV project, that does some video processing. 我现在正在处理一个openCV项目,该项目进行一些视频处理。

I have a C++ program that runs on a PC, with some cameras connected, and it does the calculation and stuff and an Android app that controls the C++ program (something like aperture settings and starting some special calculations etc) and has a livestream of one camera. 我有一个在PC上运行的C ++程序,连接了一些相机,它进行计算和处理,还有一个Android应用程序来控制C ++程序(例如光圈设置和启动一些特殊计算等),并具有一个实时流相机。

The question is: How can these apps communicate. 问题是:这些应用程序如何通信。 I thought about two TCP sockets. 我想到了两个TCP套接字。

  • one for the LiveStream 一个用于LiveStream
  • one for the control 一个用于控制

What do you think? 你怎么看? Will this work or is the a better way to implement this. 这项工作是可行的还是实现此目的的更好方法。

Thank you very much. 非常感谢你。

You've got a good guess. 你有一个很好的猜测。 Sockets is a good solution for you. 套接字是您的理想解决方案。

But TCP socket for video stream is really bad practice. 但是用于视频流的TCP套接字确实是不好的做法。 In case of minor network issues you'll get annoying hangs, etc. 如果出现较小的网络问题,则会出现令人讨厌的挂起等情况。

Use UDP socket for LiveStream. 对LiveStream使用UDP套接字。 Just be ready, that some of packets can be missed if WiFi signal is low or smth. 请做好准备,如果WiFi信号低或模糊,可能会丢失某些数据包。

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

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