From 09137b23e36e9a4f08905410aa5337a5ebe62de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=BE=99?= Date: Thu, 14 Aug 2025 17:06:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BA=BA=E8=84=B8=E8=AF=86=E5=88=AB=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/DTO/movieEdit.ts | 14 +------------- app/service/Interaction/ShotService.ts | 16 ++++++---------- components/ui/shot-tab-content.tsx | 2 +- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/api/DTO/movieEdit.ts b/api/DTO/movieEdit.ts index 851c8aa..9aefa10 100644 --- a/api/DTO/movieEdit.ts +++ b/api/DTO/movieEdit.ts @@ -541,19 +541,7 @@ export interface MatchedPerson { /**高度 小数百分比形式 */ height: number; } -/** - * 角色识别结果数据 - * @description AI识别图片中人物后的详细结果 - */ -export interface RecognitionResultData { - /** 目标图片URL */ - target_image_url: string; - /** 检测到的总人数 */ - total_persons_detected: number; - /** 匹配的人物列表 */ - matched_persons: MatchedPerson[]; -} /** * 角色识别响应结果 * @description API返回的角色识别完整响应 @@ -565,7 +553,7 @@ export interface RecognitionResult { /** 响应消息 */ message: string; /** 识别结果数据 */ - data: RecognitionResultData; + data: MatchedPerson[]; } /** * 使用的角色信息 diff --git a/app/service/Interaction/ShotService.ts b/app/service/Interaction/ShotService.ts index da6bdf6..d6f312b 100644 --- a/app/service/Interaction/ShotService.ts +++ b/app/service/Interaction/ShotService.ts @@ -402,7 +402,7 @@ export const useShotService = (): UseShotService => { ); console.log("角色识别结果:", recognitionResult); setMatched_persons( - recognitionResult.recognition_result.data.matched_persons + recognitionResult.recognition_result.data ); return recognitionResult; } catch (recognitionError) { @@ -441,21 +441,17 @@ export const useShotService = (): UseShotService => { const containerRect = containerElement.getBoundingClientRect(); const containerWidth = containerRect.width; const containerHeight = containerRect.height; - console.log('recognitionBoxes-width-height', containerWidth, containerHeight); // 计算识别框属性 return matched_persons .map((person) => { - // 取出bbox信息 - const bbox = (person as any).bbox; - if (!bbox) return null; // 计算绝对坐标和尺寸(百分比转像素) - const left = (bbox.x || 0) * containerWidth; - const top = (bbox.y || 0) * containerHeight; - const width = (bbox.width || 0) * containerWidth; - const height = (bbox.height || 0) * containerHeight; - + const left = Number((person.x || 0).toFixed(4)) * containerWidth; + const top = Number((person.y || 0).toFixed(4)) * containerHeight; + const width = Number((person.width || 0).toFixed(4)) * containerWidth; + const height = Number((person.height || 0).toFixed(4)) * containerHeight; + console.log('left-top-width-height', left, top, width, height); return { left, top, diff --git a/components/ui/shot-tab-content.tsx b/components/ui/shot-tab-content.tsx index 9187510..0e273c5 100644 --- a/components/ui/shot-tab-content.tsx +++ b/components/ui/shot-tab-content.tsx @@ -77,7 +77,7 @@ export function ShotTabContent({ const roleRecognitionResponse = await filterRole(containerElement); console.log('roleRecognitionResponse', roleRecognitionResponse); if (roleRecognitionResponse && roleRecognitionResponse.recognition_result.code === 200) { - const recognitionBoxes = calculateRecognitionBoxes(containerElement, roleRecognitionResponse.recognition_result.data.matched_persons); + const recognitionBoxes = calculateRecognitionBoxes(containerElement, roleRecognitionResponse.recognition_result.data); console.log('recognitionBoxes', recognitionBoxes); setDetections(recognitionBoxes.map((person: any) => ({ id: person.person_id,