forked from 77media/video-flow
修复问题,人脸识别数据
This commit is contained in:
parent
1c57d04ed1
commit
09137b23e3
@ -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[];
|
||||
}
|
||||
/**
|
||||
* 使用的角色信息
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user