diff --git a/apps/server/api/detection.py b/apps/server/api/detection.py index 95d2c17..d986789 100644 --- a/apps/server/api/detection.py +++ b/apps/server/api/detection.py @@ -36,18 +36,17 @@ async def detect_image( if result['success']: annotated_frame = detection_service.draw_detections(frame, result['detections']) - - import uuid - result_filename = f"result_{uuid.uuid4().hex[:8]}.jpg" - result_path = f"static/results/{result_filename}" - cv2.imwrite(result_path, annotated_frame) - + + # 将标注后的图片转换为 base64 + _, buffer = cv2.imencode('.jpg', annotated_frame) + img_base64 = base64.b64encode(buffer).decode('utf-8') + return ImageDetectionResult( success=True, message="检测完成", data={ "detections": result['detections'], - "image_url": f"/static/results/{result_filename}", + "image_base64": img_base64, "stats": result['stats'] } ) diff --git a/apps/web/src/components/ImageDetection.vue b/apps/web/src/components/ImageDetection.vue new file mode 100644 index 0000000..c97c118 --- /dev/null +++ b/apps/web/src/components/ImageDetection.vue @@ -0,0 +1,673 @@ + + + + + diff --git a/apps/web/src/components/VideoDetection.vue b/apps/web/src/components/VideoDetection.vue new file mode 100644 index 0000000..d3ed688 --- /dev/null +++ b/apps/web/src/components/VideoDetection.vue @@ -0,0 +1,932 @@ + + + + + diff --git a/apps/web/src/views/Home.vue b/apps/web/src/views/Home.vue index aee4c5b..02eb238 100644 --- a/apps/web/src/views/Home.vue +++ b/apps/web/src/views/Home.vue @@ -1,809 +1,95 @@ + \ No newline at end of file