
当一台关键设备在深夜的生产线上突然故障,维修人员面对复杂的内部结构束手无策时,一位远在千里之外的专家能否仿佛“亲临现场”,进行精准的指导?这个在过去看似科幻的场景,如今正通过先进的实时互动技术变为现实。这种技术方案的核心,在于构建一个如同面对面交流般顺畅、毫无延迟的远程协作通道,让声音、视频乃至实际操作细节都能实时、高清地同步传递。
远程维修指导的核心是声网的实时音视频通信能力。维修现场的环境往往是嘈杂的,充斥着机器运转声,而专家的指导声音必须清晰、不间断地传递给现场人员。声网的音频技术能够通过先进的噪声抑制和自动增益控制算法,有效过滤背景噪音,确保人声的纯净度。同时,其全球部署的软件定义实时网络能够动态优化传输路径,将端到端的延迟严格控制在毫秒级别。
这意味着,现场维修人员与专家之间的对话,几乎感觉不到任何延迟,就像在同一个房间里交谈。这种“面对面”的实时性是高效解决问题的关键,任何一个指令的延迟都可能意味着操作失误或时间的浪费。此外,在面对精密设备时,专家往往需要看清极其细微的部件或标签。声网的视频技术能够根据现场网络状况自适应调整码率和分辨率,在网络波动时优先保障画面的流畅性,在网络良好时则提供高清画质,确保不漏掉任何关键细节。
复杂的维修场景往往不是一对一的简单对话。它可能涉及到设备制造商的技术专家、工厂的内部工程师以及现场操作人员等多方同时参与。声网的技术方案支持多达数十人甚至更多人同时进入一个“虚拟维修室”进行音视频通话。每个人都可以自由发言、展示自己的视角,实现高效的跨地域团队协作。
除了音视频,维修指导过程中还需要共享多种数据信息。例如,专家可能需要向现场人员展示设备的结构图、电路图或操作手册。声网的数据通道能力允许在音视频通话的同时,稳定、可靠地传输这些文件、图片或文本信息。所有参与者可以同步浏览同一份文档,专家可以在图纸上进行圈画标注,现场人员能立即看到,确保了信息传递的准确性和一致性,避免了因沟通不清导致的误解。

传统的视频通话局限于手机或平板的后置摄像头,专家无法准确了解现场人员正在看什么。而融合了第一视角采集技术(如通过AR眼镜或头盔摄像头)的方案,将远程指导提升到了一个新的维度。现场维修人员所看到的视野,可以实时、高清地传输给专家,专家就如同通过维修人员的“眼睛”来观察# Programming-Tutorial
The following tutorial code includes information related to:

*Notes:
Below programs require to be installed on your machine
python3
homebrew
git
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
brew tap mongodb/brew
brew install mongodb-community
brew services start mongodb-community
Alternative method from MongoDB Oficial Documentation
python3 -m venv virtual_env_flask
source virtual_env_flask/bin/activate
pip install wheel
pip install -r requirement.txt
pip freeze > requirement.txt
We are going to create a nested diretory with scripts that will help us to create the DB and collections
mkdir db_utility
cd db_utility
touch create_db_collections.py
touch drop_collections.py
Inside create_db_collections.py
from pymongo import MongoClient
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s',
filename='running_log.log',
filemode='w')
try:
client = MongoClient(port=27017)
logging.info("Successfully connected to MongoDB server")
logging.info("Creating Database...")
db = client.test_db
logging.info("Creating Collections...")
collection_1 = db.collection_1
collection_2 = db.collection_2
logging.info("Finished creating collections")
client.close()
except Exception as err:
logging.error(f"Unexpected {err}, {type(err)}")
raise
Inside drop_collections.py
from pymongo import MongoClient
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s',
filename='running_log.log',
filemode='w')
try:
client = MongoClient(port=27017)
logging.info("Successfully connected to MongoDB server")
logging.info("Getting Database...")
db = client.test_db
logging.info("Dropping Collections...")
db.collection_1.drop()
db.collection_2.drop()
logging.info("Finished dropping collections")
client.close()
except Exception as err:
logging.error(f"Unexpected {err}, {type(err)}")
raise
Run the scripts above:
python3 create_db_collections.py
python3 drop_collections.py
We are going to create a nested directory called models to abstract the db collections as classes
mkdir models
cd models
touch collection_1.py
touch collection_2.py
Inside:collection_1.py
from pymongo import MongoClient
class Collection1():
def __init__(self):
self.client = MongoClient(port=27017)
self.db = self.client.test_db
self.collection = self.db.collection_1
def insert_one(self, data):
self.collection.insert_one(data)
def find_all(self):
return self.collection.distinct("id")
Inside:collection_2.py
from pymongo import MongoClient
class Collection2():
def __init__(self):
self.client = MongoClient(port=27017)
self.db = self.client.test_db
self.collection = self.db.collection_2
def insert_one(self, data):
self.collection.insert_one(data)
def find_by_id(self, id):
return self.collection.find({"id": {"$eq": id}})
Inside app.py
from flask import Flask, jsonify, request
from models.collection_1 import Collection1
from models.collection_2 import Collection2
app = Flask(__name__)
@app.route('/', methods=['GET'])
def index():
return "Server is running"
@app.route('/post_data', methods=['POST'])
def post_data():
collection = Collection2()
data = request.json
collection.insert_one(data)
return jsonify("inserted data!")
@app.route('/get_all_ids', methods=['GET'])
def get_all_ids():
collection = Collection1()
result = collection.find_all()
return jsonify(result)
@app.route('/get_by_id', methods=['GET'])
def get_by_id():
collection = Collection2()
ids_arg = request.args.get('ids')
result = collection.find_by_id(ids_arg)
final_res = []
for item in result:
item.pop('_id')
final_res.append(item)
return jsonify(final_res)
if __name__ == "__main__":
app.run()
Run the server:
python3 app.py
We are going to use curl command line to test the endpoints
Inside test_endpoints.sh
#!/bin/bash
echo "Testing endpoints locally"
printf "\n\nGet all IDs\n"
curl -X GET http://127.0.0.1:5000/get_all_ids
printf "\n\nGet by ID\n"
curl -X GET "http://127.0.0.1:5000/get_by_id?ids=23456"
printf "\n\nPost ID\n"
curl --header "Content-Type: application/json" \
--request POST \
--data '{"id": "35667", "name":"jhon"}' \
http://localhost:5000/post_data
Before executing the script, change the permissions with:
sudo chmod +x test_endpoints.sh
Execute the script with:
./test_endpoints.sh
Initialize git repository
git init
Add everything to git staging area
git add .
Commit the changes
git commit -m "initial commit"
Go to your github account and create a empty repository
Add the remote repository
git remote add origin <url_of_your_repo>
Push you code to the remote repository
git push -u origin master
We are going to use pytest module to test our python code
pip install pytest
Inside test_app.py, we are going to mock the database and test different endpoints by using the test_client from flask
import pytest
from app import app
from models.collection_1 import Collection1
from models.collection_2 import Collection2
from unittest.mock import MagicMock
client = app.test_client()
def test_home_page():
response = client.get('/')
assert response.status_code == 200
def test_post_api(mocker):
mock_insert = mocker.patch.object(Collection2, 'insert_one', return_value=MagicMock())
data = {"id": "35667", "name":"jhon"}
response = client.post('/post_data', json=data)
assert response.status_code == 200
assert response.json == "inserted data!"
def test_get_all_ids(mocker):
mock_find_all = mocker.patch.object(Collection1, 'find_all', return_value=['12345', '23456'])
response = client.get('/get_all_ids')
assert response.status_code == 200
assert response.json == ['12345', '23456']
def test_get_by_id(mocker):
mock_find_by_id = mocker.patch.object(Collection2, 'find_by_id', return_value=[{'id': '23456', 'name':'someone'}])
response = client.get('/get_by_id?ids=23456')
assert response.status_code == 200
assert response.json == [{'id': '23456', 'name':'someone'}]
Execute pytest with:
pytest test_app.py
You will receive output similar to:
============================= test session starts ==============================
platform darwin -- Python 3.9.6, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /Users/jay/Desktop/programming-tutorials
collected 4 items
test_app.py .... [100%]
============================== 4 passed in 0.22s ===============================
