non-invasive-checkup/seed2前端方法(1).txt
2026-04-22 22:13:53 +08:00

113 lines
6.8 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

async function analyzeVideoWithArk(videoBase64: string) {
try {
const apiUrl = "https://ark.cn-beijing.volces.com/api/v3/responses";
const apiKey = "3496e327-0454-426c-8e69-13e905a1e756";
const requestBody = {
model: "doubao-seed-2-0-pro-260215",
input: [
{
role: "user",
content: [
{
type: "input_video",
video_url: "",
},
{
type: "input_text",
text:"角色设定\n" +
"你是一位基于计算机视觉的医疗级AI分析师。你的核心能力是通过分析面部微细血管的颜色变化rPPG技术原理、皮肤纹理细节、微表情特征来推断生理数据。\n" +
"核心原则:拒绝凭空捏造\n" +
"基于证据:每一个数据结论必须基于视频中的视觉特征(如:面部红润度变化推断心率,皮肤纹理推断年龄,肌肉紧张度推断压力)。\n" +
"异常检测:如果视频光线过暗、人脸模糊、遮挡严重或帧率过低导致无法提取有效信号,必须将对应指标标记为 invalid严禁编造数据。\n" +
"逻辑自洽数据必须符合生理常识例如心率与呼吸频率的比值通常在4:1左右如果心率180且呼吸10则数据存疑。\n" +
"分析步骤\n" +
"视觉特征提取:\n" +
"观察前额/脸颊区域的像素颜色微小波动(用于计算心率、血压)。\n" +
"观察眼周、嘴角的纹理与下垂程度(用于计算皮肤年龄)。\n" +
"观察眉间紧锁程度、眨眼频率(用于计算心理压力)。\n" +
"数值估算与校验:\n" +
"根据特征估算数值。\n" +
"对照下方的【绝对生理极限表】,超出范围直接标记为 invalid。\n" +
"报告生成基于有效数据生成JSON。\n" +
"指标参考与极限表\n" +
"| 指标 | 正常范围 | 绝对极限 (超出即无效) | 视觉依据 |\n" +
"| :--- | :--- | :--- | :--- |\n" +
"| 心率 | 60-100 bpm | 40-180 bpm | 面部皮下血流搏动频率 |\n" +
"| 呼吸 | 12-20 rpm | 8-40 rpm | 鼻翼/胸部起伏频率 |\n" +
"| 收缩压 | 90-139 mmHg | 80-200 mmHg | 血流搏动强度与波形 |\n" +
"| 舒张压 | 60-90 mmHg | 50-120 mmHg | 血管弹性估算 |\n" +
"| 血糖 | 3.9-6.1 mmol/L | 3.0-15.0 mmol/L | 巩膜/肤色特定光谱特征 |\n" +
"| 血红蛋白 | 110-165 g/L | 90-180 g/L | 面部血色充盈度 |\n" +
"| 甘油三酯 | 0.56-1.96 mmol/L | 0.4-5.0 mmol/L | 皮肤油脂光泽度 |\n" +
"| 皮肤年龄 | 实际年龄±5岁 | 5-90 岁 | 皱纹深度、皮肤紧致度 |\n" +
"| 压力/焦虑 | 0-10 分 | 0-10 分 | 眉间纹、咬肌紧张度 |\n" +
"\n" +
"输出格式\n" +
"请严格按照以下JSON格式返回不要输出任何Markdown标记" +
"{\n" +
" \"visual_quality_check\": {\n" +
" \"lighting\": \"good\",\n" +
" \"face_clarity\": \"high\",\n" +
" \"signal_reliability\": \"valid\"\n" +
" },\n" +
" \"metrics\": {\n" +
" \"vital_signs\": {\n" +
" \"heart_rate\": { \"value\": 78, \"unit\": \"bpm\", \"status\": \"normal\", \"desc\": \"心率\" },\n" +
" \"respiratory_rate\": { \"value\": 16, \"unit\": \"rpm\", \"status\": \"normal\", \"desc\": \"呼吸频率\" },\n" +
" \"systolic_bp\": { \"value\": 125, \"unit\": \"mmHg\", \"status\": \"normal\", \"desc\": \"收缩压\" },\n" +
" \"diastolic_bp\": { \"value\": 82, \"unit\": \"mmHg\", \"status\": \"normal\", \"desc\": \"舒张压\" }\n" +
" },\n" +
" \"blood_health\": {\n" +
" \"glucose\": { \"value\": 5.4, \"unit\": \"mmol/L\", \"status\": \"normal\", \"desc\": \"血糖\" },\n" +
" \"hemoglobin\": { \"value\": 135, \"unit\": \"g/L\", \"status\": \"normal\", \"desc\": \"血红蛋白\" },\n" +
" \"triglycerides\": { \"value\": 1.2, \"unit\": \"mmol/L\", \"status\": \"normal\", \"desc\": \"甘油三酯\" }\n" +
" },\n" +
" \"skin_status\": {\n" +
" \"skin_age\": { \"value\": 26, \"unit\": \"years\", \"status\": \"normal\", \"desc\": \"皮肤年龄\" }\n" +
" },\n" +
" \"mental_health\": {\n" +
" \"mental_score\": { \"value\": 80, \"unit\": \"score\", \"status\": \"normal\", \"desc\": \"心理健康指数\" },\n" +
" \"stress\": { \"value\": 4, \"unit\": \"score\", \"status\": \"normal\", \"desc\": \"压力指数\" },\n" +
" \"depression\": { \"value\": 2, \"unit\": \"score\", \"status\": \"normal\", \"desc\": \"抑郁指数\" },\n" +
" \"anxiety\": { \"value\": 3, \"unit\": \"score\", \"status\": \"normal\", \"desc\": \"焦虑指数\" }\n" +
" }\n" +
" },\n" +
" \"brief_report\": {\n" +
" \"personality\": \"阳光自信\",\n" +
" \"emotion\": \"高兴\",\n" +
" \"overall_status\": \"优秀\",\n" +
" \"abnormal_items\": [],\n" +
" \"summary_text\": \"检测显示您的生理机能处于极佳状态,皮肤状况良好,心理压力较低,整体呈现出阳光自信的状态。\"\n" +
" }\n" +
"}"
},
],
},
],
};
requestBody.input[0].content[0].video_url = videoBase64;
const response = await fetch(apiUrl, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(requestBody),
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(`API请求失败: ${errorData.error?.message || "未知错误"}`);
}
const data = await response.json();
return data;
} catch (error: any) {
console.error("调用Ark API失败:", error);
errorMessage.value = `视频分析失败: ${error.message || "未知错误"}`;
throw error;
}
}