From 91a06ec4322e8d109dffb9eef60bbc355aeb1731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Wed, 13 Aug 2025 02:59:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0ShotService=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9calculateRecognitionBoxes=E5=87=BD=E6=95=B0=E4=BB=A5?= =?UTF-8?q?=E6=8E=A5=E6=94=B6matched=5Fpersons=E5=8F=82=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E5=9C=A8ShotTabContent=E4=B8=AD=E9=9B=86=E6=88=90?= =?UTF-8?q?=E8=AF=A5=E5=87=BD=E6=95=B0=E4=BB=A5=E4=BC=98=E5=8C=96=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E6=A1=86=E8=AE=A1=E7=AE=97=E9=80=BB=E8=BE=91=E3=80=82?= =?UTF-8?q?=E5=90=8C=E6=97=B6=EF=BC=8C=E5=9C=A8PersonDetectionScene?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E6=9C=AA=E8=AF=86=E5=88=AB=E5=87=BA?= =?UTF-8?q?=E4=BA=BA=E5=83=8F=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/Interaction/ShotService.ts | 6 ++++-- components/pages/work-flow/use-edit-data.tsx | 4 +++- components/ui/person-detection.tsx | 6 +++++- components/ui/shot-tab-content.tsx | 21 ++++++++++++-------- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/service/Interaction/ShotService.ts b/app/service/Interaction/ShotService.ts index b0e7c4d..3d68847 100644 --- a/app/service/Interaction/ShotService.ts +++ b/app/service/Interaction/ShotService.ts @@ -50,7 +50,7 @@ export interface UseShotService { /** 设置角色简单数据 */ setSimpleCharacter: (characters: SimpleCharacter[]) => void; /** 计算识别框 */ - calculateRecognitionBoxes: (containerElement: HTMLElement) => Array<{ + calculateRecognitionBoxes: (containerElement: HTMLElement, matched_persons: MatchedPerson[]) => Array<{ left: number; top: number; width: number; @@ -405,7 +405,8 @@ export const useShotService = (): UseShotService => { * @returns 计算后的识别框属性数组 */ const calculateRecognitionBoxes = ( - containerElement: HTMLElement + containerElement: HTMLElement, + matched_persons: MatchedPerson[] = [] ): Array<{ /** 横向定位坐标 */ left: number; @@ -422,6 +423,7 @@ 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 diff --git a/components/pages/work-flow/use-edit-data.tsx b/components/pages/work-flow/use-edit-data.tsx index 6ab662b..69172a5 100644 --- a/components/pages/work-flow/use-edit-data.tsx +++ b/components/pages/work-flow/use-edit-data.tsx @@ -27,7 +27,8 @@ export const useEditData = (tabType: string, originalText?: string) => { getVideoSegmentList, setSelectedSegment, regenerateVideoSegment, - filterRole + filterRole, + calculateRecognitionBoxes } = useShotService(); const { @@ -121,6 +122,7 @@ export const useEditData = (tabType: string, originalText?: string) => { setSelectedSegment, regenerateVideoSegment, filterRole, + calculateRecognitionBoxes, // role roleData, selectRole, diff --git a/components/ui/person-detection.tsx b/components/ui/person-detection.tsx index 81d61f2..62a3bbe 100644 --- a/components/ui/person-detection.tsx +++ b/components/ui/person-detection.tsx @@ -375,8 +375,12 @@ export const PersonDetectionScene: React.FC = ({ {/* 人物识别框和浮签 */} + {detections.length === 0 && ( +
+ 未识别出人像 +
+ )} {detections.map((person, index) => { - return (
{ onPersonClick?.(person); diff --git a/components/ui/shot-tab-content.tsx b/components/ui/shot-tab-content.tsx index 02bd772..54abe81 100644 --- a/components/ui/shot-tab-content.tsx +++ b/components/ui/shot-tab-content.tsx @@ -11,7 +11,6 @@ import FloatingGlassPanel from './FloatingGlassPanel'; import { ReplaceCharacterPanel } from './replace-character-panel'; import HorizontalScroller from './HorizontalScroller'; import { useEditData } from '@/components/pages/work-flow/use-edit-data'; -import { roleRecognitionResponse } from '@/app/service/usecase/ShotEditUsecase'; interface ShotTabContentProps { currentSketchIndex: number; @@ -32,7 +31,8 @@ export function ShotTabContent({ userRoleLibrary, fetchRoleShots, shotSelectionList, - applyRoleToSelectedShots + applyRoleToSelectedShots, + calculateRecognitionBoxes } = useEditData('shot'); const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex); @@ -65,14 +65,18 @@ export function ShotTabContent({ return; } setScanState('scanning'); - await filterRole(document.getElementById('person-detection-video') as HTMLVideoElement); - - if (roleRecognitionResponse.recognition_result.code === 200) { - setDetections(roleRecognitionResponse.recognition_result.data.matched_persons.map((person) => ({ + const containerElement = document.getElementById('person-detection-video') as HTMLVideoElement; + 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); + console.log('recognitionBoxes', recognitionBoxes); + setDetections(recognitionBoxes.map((person: any) => ({ id: person.person_id, name: person.person_id, - position: { top: person.bbox.y, left: person.bbox.x, width: person.bbox.width, height: person.bbox.height } + position: { top: person.top, left: person.left, width: person.width, height: person.height } }))); + setScanState('detected'); } else { setIsScanFailed(true); } @@ -80,7 +84,8 @@ export function ShotTabContent({ // 处理扫描超时/失败 const handleScanTimeout = () => { - setScanState('idle'); + setIsScanFailed(true); + setScanState('detected'); setDetections([]); };