动作检测
从视频片段中追踪并提取指定人物的动作数据,输出可直接用于驱动 3D 角色的动作文件。支持通过 person_ids 精确锁定多人场景中的特定人物。
典型应用场景
- 单人动作捕捉:从舞蹈、体育等视频中直接提取人物动作
- 多人场景精确追踪:配合姿态检测接口,锁定特定人物后再执行动作捕捉
本页使用的 API 参考 POST /videos/motion_detections
基础示例
bash
curl -X POST 'https://api.v2fun.ai/api/v1/videos/motion_detections' \
-H "Authorization: Bearer $V2FUN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"input_video": "videos/example.mp4",
"start_time_seconds": 1.5,
"duration_seconds": 3
}'javascript
// Node.js 18+; set V2FUN_API_KEY in your environment.
const response = await fetch("https://api.v2fun.ai/api/v1/videos/motion_detections", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.V2FUN_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input_video": "videos/example.mp4",
"start_time_seconds": 1.5,
"duration_seconds": 3
}),
});
const data = await response.json();python
import os
import requests
resp = requests.post(
"https://api.v2fun.ai/api/v1/videos/motion_detections",
headers={
"Authorization": f'Bearer {os.environ["V2FUN_API_KEY"]}',
"Content-Type": "application/json",
},
json={
"input_video": "videos/example.mp4",
"start_time_seconds": 1.5,
"duration_seconds": 3
},
)
print(resp.json())java
import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
String body = "{\"input_video\":\"videos/example.mp4\",\"start_time_seconds\":1.5,\"duration_seconds\":3}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.v2fun.ai/api/v1/videos/motion_detections"))
.header("Authorization", "Bearer " + System.getenv("V2FUN_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());核心用例
视频片段动作捕捉
指定视频、起始时间和时长,系统截取对应片段并追踪其中人物,生成标准化动作数据。可配合 person_ids 在多人场景中精确锁定特定目标。
bash
curl -X POST 'https://api.v2fun.ai/api/v1/videos/motion_detections' \
-H "Authorization: Bearer $V2FUN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"input_video": "videos/example.mp4",
"start_time_seconds": 0,
"duration_seconds": 5
}'javascript
// Node.js 18+; set V2FUN_API_KEY in your environment.
const response = await fetch("https://api.v2fun.ai/api/v1/videos/motion_detections", {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.V2FUN_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"input_video": "videos/example.mp4",
"start_time_seconds": 0,
"duration_seconds": 5
}),
});
const data = await response.json();python
import os
import requests
resp = requests.post(
"https://api.v2fun.ai/api/v1/videos/motion_detections",
headers={
"Authorization": f'Bearer {os.environ["V2FUN_API_KEY"]}',
"Content-Type": "application/json",
},
json={
"input_video": "videos/example.mp4",
"start_time_seconds": 0,
"duration_seconds": 5
},
)
print(resp.json())java
import java.net.URI;
import java.net.http.*;
HttpClient client = HttpClient.newHttpClient();
String body = "{\"input_video\":\"videos/example.mp4\",\"start_time_seconds\":0,\"duration_seconds\":5}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.v2fun.ai/api/v1/videos/motion_detections"))
.header("Authorization", "Bearer " + System.getenv("V2FUN_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());输入视频
输出结果
