diff --git a/components/ui/person-detection.tsx b/components/ui/person-detection.tsx index 62a3bbe..f1ef4fe 100644 --- a/components/ui/person-detection.tsx +++ b/components/ui/person-detection.tsx @@ -45,6 +45,7 @@ type Props = { videoSrc?: string; detections: PersonDetection[]; triggerScan: boolean; + triggerSuccess: boolean; onScanStart?: (currentTime?: number) => void; onScanTimeout?: () => void; onScanExit?: () => void; // 扫描退出回调 @@ -59,6 +60,7 @@ export const PersonDetectionScene: React.FC = ({ videoSrc, detections, triggerScan, + triggerSuccess, onScanStart, onScanTimeout, onScanExit, @@ -375,8 +377,8 @@ export const PersonDetectionScene: React.FC = ({ {/* 人物识别框和浮签 */} - {detections.length === 0 && ( -
+ {detections.length === 0 && triggerSuccess && ( +
未识别出人像
)} diff --git a/components/ui/shot-tab-content.tsx b/components/ui/shot-tab-content.tsx index 54abe81..480466a 100644 --- a/components/ui/shot-tab-content.tsx +++ b/components/ui/shot-tab-content.tsx @@ -37,7 +37,7 @@ export function ShotTabContent({ const [selectedIndex, setSelectedIndex] = useState(currentSketchIndex); const [detections, setDetections] = useState([]); - const [scanState, setScanState] = useState<'idle' | 'scanning' | 'detected'>('idle'); + const [scanState, setScanState] = useState<'idle' | 'scanning' | 'detected' | 'failed' | 'timeout'>('idle'); const [isScanFailed, setIsScanFailed] = useState(false); const [isLoadingLibrary, setIsLoadingLibrary] = useState(false); const [isReplaceLibraryOpen, setIsReplaceLibraryOpen] = useState(false); @@ -82,10 +82,10 @@ export function ShotTabContent({ } }; - // 处理扫描超时/失败 + // 处理扫描超时 const handleScanTimeout = () => { setIsScanFailed(true); - setScanState('detected'); + setScanState('timeout'); setDetections([]); }; @@ -97,9 +97,10 @@ export function ShotTabContent({ // 处理检测到结果 const handleDetectionsChange = (newDetections: PersonDetection[]) => { - if (newDetections.length > 0 && scanState === 'scanning') { - setScanState('detected'); - } + // console.log('handleDetectionsChange', newDetections); + // if (newDetections.length > 0 && scanState === 'scanning') { + // setScanState('detected'); + // } }; // 处理人物点击 打开角色库 @@ -317,6 +318,7 @@ export function ShotTabContent({ videoSrc={shotData[selectedIndex]?.videoUrl[0]} detections={detections} triggerScan={scanState === 'scanning'} + triggerSuccess={scanState === 'detected'} onScanTimeout={handleScanTimeout} onScanExit={handleScanExit} onDetectionsChange={handleDetectionsChange}