|
|
@ -89,15 +89,15 @@ def handle_video_frame(message): |
|
|
|
image = Image.open(BytesIO(img_data)) |
|
|
|
results = model.predict(source=image, iou=0.5, conf=0.25) |
|
|
|
det = results[0] |
|
|
|
checkVedioResult(det) |
|
|
|
checkVedioResult(message, det) |
|
|
|
frame_count += 1 # 更新帧计数器 |
|
|
|
frame_count %= frame_rate_divider # 更新帧计数器 |
|
|
|
# print(99777,frame_count) |
|
|
|
# if studentStatus[message["userId"]]: |
|
|
|
# print(f"学生{message['userId']}已作弊", f"{studentStatus[message['userId']]}") |
|
|
|
# print(f"学生{message['userId']}已作弊", f"{studentStatus[message['userId']]}") |
|
|
|
|
|
|
|
|
|
|
|
def checkVedioResult(det): |
|
|
|
def checkVedioResult(message, det): |
|
|
|
# 如果有有效的检测结果 |
|
|
|
# {"cheating": "疑似作弊", "good": "良好", "normal": "正常"} |
|
|
|
if det is not None and len(det): |
|
|
@ -114,7 +114,19 @@ def checkVedioResult(det): |
|
|
|
"class_id": class_id, # 类别ID |
|
|
|
} |
|
|
|
results.append(result) # 将结果添加到列表 |
|
|
|
print(587744, results) |
|
|
|
zuobiItem = { |
|
|
|
"userId": message["userId"], |
|
|
|
"msg": class_id, |
|
|
|
"type": class_id, |
|
|
|
"create_at": time.strftime( |
|
|
|
"%Y-%m-%d %H:%M:%S", time.localtime(time.time()) |
|
|
|
), |
|
|
|
"update_at": time.strftime( |
|
|
|
"%Y-%m-%d %H:%M:%S", time.localtime(time.time()) |
|
|
|
), |
|
|
|
"isExit": 1, |
|
|
|
} |
|
|
|
addzuobi(zuobiItem) |
|
|
|
|
|
|
|
|
|
|
|
@socketio.on("talk", namespace="/ws/video") |
|
|
|