我正在尝试创建一个程序,其中一部分将使用 naoqi Python SDK 从我的 PC 网络摄像头将实时视频以帧(或换句话说图像)传输到 Pepper 的平板电脑。在机器人一侧会有一个程序使用 ALTabletService 的 showWebview 函数将图像显示为 html 网页。但是在这个过程开始后,它只进行了几秒钟,然后屏幕返回到它的主页。我猜机器人抢占了我的程序。但这不会发生在 playVideo 函数中。有没有办法克服这个问题?
PC端:
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
def gen(camera):
# Set our pipelines state to Playing.
video_pipeline.set_state(Gst.State.PLAYING)
audio_pipeline.set_state(Gst.State.PLAYING)
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') #sending frames to the webpage
@app.route('/video_feed')
def video_feed():
try:
return Response(stream_with_context(gen(VideoCamera())), mimetype='multipart/x-mixed-replace; boundary=frame')
except Exception:
return None
if __name__ == '__main__':
# app.run(host='0.0.0.0', port = http, debug=True, threaded=True)
http_server = WSGIServer(('0.0.0.0', http), app) #creating a server with open ip
http_server.serve_forever()
辣椒面:
tabletService = session.service('ALTabletService')
tabletService.loadUrl('http://' + user_ip + ':' + str(user_http_port) + '/')
tabletService.showWebview()