人脸检测
人脸检测是 POST /v2/face-recognition/face-validation,即检测引擎的别名。image 必填。若省略,本路由把 min_score 设为 0.5,把 search_mode 设为 FAST。实际载荷是 face_count、faces(含 score 和 bbox)、imageDimensions 和 engine。
调用返回的内容
face_countfaces[].score与faces[].bboximageDimensions与engine
使用场景
- 活体检测前先数人脸。
- 读取主脸的框。
- 只有图像时使用默认分数和模式。
API 参考
Endpoint
POST https://api.verifik.co/v2/face-recognition/face-validation
先读 face_count。faces 的每一项都有 score 和 bbox。imageDimensions 是解码后的宽和高。engine 是检测器名称。
Headers
| 名称 | 值 | 说明 |
|---|---|---|
| Content-Type | application/json | 请求格式 |
| Accept | application/json | 响应格式 |
| Authorization | Bearer <token> | 客户端 JWT |
Parameters
| 名称 | 类型 | 必填 | 示例 | 说明 |
|---|---|---|---|---|
image | string | 是 | data:image/jpeg;base64,AAAA | base64 或 data URI 的人脸图像。必填。 |
min_score | number | 否 | 0.5 | 可选。本路由默认填 0.5。 |
search_mode | string | 否 | FAST | 可选。本路由默认填 FAST。另一个值是 ACCURATE。 |
Request
- Node.js / JavaScript
- Python
- cURL
import axios from "axios";
const options = {
method: "POST",
url: "https://api.verifik.co/v2/face-recognition/face-validation",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Bearer <your_token>",
},
data: {
"image": "data:image/jpeg;base64,AAAA"
},
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error.response ? error.response.data : error.message);
}
import requests
url = "https://api.verifik.co/v2/face-recognition/face-validation"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer <your_token>",
}
payload = {
"image": "data:image/jpeg;base64,AAAA",
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
curl -X POST "https://api.verifik.co/v2/face-recognition/face-validation" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer <your_token>" \
-d '{"image":"data:image/jpeg;base64,AAAA"}'
Response
- 200(找到记录)
- 409(缺少参数)
- 404(未找到)
- 401(未授权)
- 500(数据源不可用)
{
"data": {
"face_count": 1,
"faces": [
{
"score": 0.97,
"bbox": [
80,
60,
280,
320
]
}
],
"imageDimensions": {
"width": 640,
"height": 480
},
"engine": "insightface"
},
"signature": {
"dateTime": "November 27, 2026 12:00 PM",
"message": "Certified by Verifik.co"
}
}
{
"code": "MissingParameter",
"message": "\"image\" is required"
}
{
"code": "NotFound",
"message": "Record not found."
}
{
"code": "UNAUTHORIZED",
"message": "Authentication required"
}
{
"code": "InternalServerError",
"message": "The official source is temporarily unavailable. Please retry shortly."
}
说明
- 只有
image必填。 - 省略的
min_score变为0.5,省略的search_mode变为FAST。 - 响应使用
bbox,不是单独的特征点对象。 - 在
Authorization头中发送 Bearer JWT。 - JSON 示例只说明字段形状。实际调用返回你所发送数值对应的记录。
- 不要发送绕过缓存的标志。本页只记录客户端参数。
沙盒
| 场景 | 参数 | 结果 |
|---|---|---|
| 数据源有记录 | image only | 含 face_count、faces、imageDimensions 和 engine 的 200。 |
| 缺少必填值 | Omit image | 409 MissingParameter。 |
| 未知的值 | min_score: 0.8, search_mode: "ACCURATE" | 使用你发送的分数和模式返回 200。 |
401 when the bearer token is missing or rejected.