|
|
@ -19,6 +19,7 @@ from car import CAR
|
|
|
|
#from PiCamera_H264_Server import stream
|
|
|
|
#from PiCamera_H264_Server import stream
|
|
|
|
import threading
|
|
|
|
import threading
|
|
|
|
import cv2
|
|
|
|
import cv2
|
|
|
|
|
|
|
|
import requests
|
|
|
|
app = Flask(__name__, static_url_path='')
|
|
|
|
app = Flask(__name__, static_url_path='')
|
|
|
|
# 照片保存路径
|
|
|
|
# 照片保存路径
|
|
|
|
PHOTO_PATH = "photo.jpg"
|
|
|
|
PHOTO_PATH = "photo.jpg"
|
|
|
@ -66,6 +67,31 @@ def gen_frames(): # generate frame by frame from camera
|
|
|
|
# def capture_frame_route():
|
|
|
|
# def capture_frame_route():
|
|
|
|
# img_str = capture_frame()
|
|
|
|
# img_str = capture_frame()
|
|
|
|
# return jsonify(img_str)
|
|
|
|
# return jsonify(img_str)
|
|
|
|
|
|
|
|
@app.route('/control/sendit', methods=['POST'])
|
|
|
|
|
|
|
|
def send_command():
|
|
|
|
|
|
|
|
# 定义目标 IP 地址、端口和路由
|
|
|
|
|
|
|
|
ip = "192.168.98.204"
|
|
|
|
|
|
|
|
port = 3000
|
|
|
|
|
|
|
|
route = "sendit2"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 从请求中获取消息内容
|
|
|
|
|
|
|
|
data = request.json
|
|
|
|
|
|
|
|
message = data.get('message')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if message is None:
|
|
|
|
|
|
|
|
return jsonify({"error": "缺少 message 参数"}), 400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 构建完整的 URL
|
|
|
|
|
|
|
|
url = f"http://{ip}:{port}/{route}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 发送 POST 请求
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
response = requests.post(url, json={'message': message})
|
|
|
|
|
|
|
|
response.raise_for_status() # 检查请求是否成功
|
|
|
|
|
|
|
|
return f"命令已发送,服务器响应: {response.text}"
|
|
|
|
|
|
|
|
except requests.exceptions.RequestException as e:
|
|
|
|
|
|
|
|
return f"请求失败: {str(e)}", 500
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/capture')
|
|
|
|
@app.route('/capture')
|
|
|
|
def capture_image():
|
|
|
|
def capture_image():
|
|
|
|
global picam2
|
|
|
|
global picam2
|
|
|
|