制作并检测证件照

基本信息

请求类型: HTTP/HTTPS

接口地址: http://apicall.id-photo-verify.com/api/cut_check_pic

请求方式: POST

数据类型: JSON

响应类型: JSON

接口状态: 启用

接口描述:

调用此接口,不会增加调用次数

此接口的程序会先制作证件照,然后对证件照进行检测

结果返回带水印图片、无水印图片、无水印已排版图片名字(均为多种颜色)和检测的结果。

带水印图片存储时间为 1 天,无水印图片存储时间为 7 天

通过名字获取带水印图片不会增加已调用次数

(通过获取图片的api获取无水印图片或无水印已排版图片会增加 1 次调用次数)

请求参数中“必须”项为false的,可以不用传递。如果传递自定义值,将会使用用户自定义阈值处理照片,阈值越高越容易检测通过,不传的话默认使用已经定义好的阈值处理

官网上对应的app_key应用类型必须为证件照检测与制作

下方请求参数中带" * "的参数为检测参数,由于我们检测算法会不定期更新,检测标准也可能会出现一些变化,为方便检测参数阈值及时调整,务必将请求放至服务端进行

请求参数

参数名称 是否必须 类型 描述 示例值
file true string 图片的base64格式(注意不包含base64的头部数据),或者图片在oss的key(见第十三个接口)  
spec_id true string 已有的规格ID,见页面上方的‘照片规格列表’ 1
app_key true string 已申请的app_key  
is_fair false int 是否美颜,默认为美颜  
fair_level false int 美颜等级,分为1,2,3,4,5等级,支持字典形式传输详见下方“参数说明3”,只在is_fair为1时有效 1
*head_length_max_p false int 脸部长度max  
*head_length_min_p false int 脸部长度min  
*head_occupy_max_p false int 脸部占比max  
*head_occupy_min_p false int 脸部占比min  
*eye_space_max_p false int 双眼间距max  
*eye_space_min_p false int 双眼间距min  
*hairline_top_max_p false string 为像素字符串时,表示头顶距离与图像顶部的距离像素,为数字0-100时,表示头顶距离与图像顶部的距离像素与图像高的比值 300px
*hairline_top_min_p false string 为像素字符串时,表示头顶距离与图像顶部的距离像素,为数字0-100时,表示头顶距离与图像顶部的距离像素与图像高的比值 10px
*eyes_center_left_max_p false int 双眼中心距图像左边缘max  
*eyes_center_left_min_p false int 双眼中心距图像左边缘min  
*eyes_space_bottom_max_p false int 双眼距图像下边缘max 414
*eyes_space_bottom_min_p false int 双眼距图像下边缘min 324
*shoulder_occupy false int 肩部占比  
*left_right_empty false int 左右各空  
*facial_width_max_p false int 脸部宽度max 284
*facial_width_min_p false int 脸部宽度min 180
width_px false int 像素宽度,最大不能超过1050  
height_px false int 像素高度,最大不能超过1500  
width_mm false int 宽度毫米(停用)  
height_mm false int 高度毫米(停用)  
file_size_max false int 文件大小最大值 40960
file_size_min false int 文件大小最小值 20480
size_options false string 尺寸说明  
ppi false int 分辨率 300
photo_format false string 照片格式  
bit_depth false int 位深度 24
compress false int 压缩比  
*facial_pose false int 人脸姿态,是人脸姿态 yaw pitch roll的集中判断见参数说明1 35
sight_line false int 视线水平,此参数为必检项,检测通过返回1,不通过为0
*facial_shelter false int 面部无遮挡(见下方参数说明2  
*eyes_close false int 闭眼 50
*eyes_nature false int 视线自然 50
*mouse_nature false int 嘴巴自然 50
*shoulder_equal false int 肩膀等高 50
*face_unbalance false int 阴阳脸 50
*glasses_glare false int 眼镜反光  
*glasses false int 是否佩戴眼镜,是thin_frame_glasses、thick_black_frame_glasses、sunglasses的综合判断 10
*thin_frame_glasses false int 细框/无框 眼镜 50
*thick_black_frame_glasses false int 粗黑框眼镜 50
*sunglasses false int 墨镜 50
*face_expression false int 脸部表情  
*face_center false int 脸部居中,此参数为必检项,不受传参的影响 1
face_color false int 色彩正常(已弃用)  
*face_blur false int 模糊程度 50
*face_noise false int 噪声程度 20
*face_over_kbt false int 过曝光 60
*bg_shadow false int 背景阴影 60
*clothes_similar false int 服装突出 90
*chin_bottom_min_p false int 下巴距图像下边缘min  
*shoulder_missed false int 身体完整性,是肩部完整 头部完整 下半身悬空的集中判断 60
*face_width_min false int 人脸脸颊宽度(不包含耳朵)与照片宽度的最小比例  
*face_width_max false int 人脸脸颊宽度(不包含耳朵)与照片宽度的最大比例  
original false int 程序会按照px = mm/25.4*original去设定照片的像素大小  
*missing_shoulder false int 肩部完整 30
*incomplete_head false int 头部完整 60
*lower_body_hanging false int 下半身悬空 30
*headpose_yaw false int 人脸姿态(见下方参数说明1 50
*headpose_pitch false int 人脸姿态(见下方参数说明1 50
*headpose_roll false int 人脸姿态(见下方参数说明1 50
*face_too_dark false int 照片过暗 60
*face_contrast false int 对比度异常 60
*body_posture false int 身体姿态 身子不正,自拍时斜向下,举手,手放脑后,抠鼻孔,托腮等 60
*hat_threshold false int 帽子检测 20
*bare_shouldered false int 光膀检测 60
*id_exist false int 手持证件照检测 60
*watermark_exist false int 照片有水印 50
*pn_mask_exist false int 照片有挂戴口罩 90
background_color false list 自定义照片背景色,详见“参数说明4  
ratios false list 自定义证件照制作比率,详见“参数说明5  
print_type false int 排版类型,1表示默认(一寸8张),2表示紧凑型(一寸10张)  
image_enhancement false int 图像细节增强控制参数,1表示是,0表示否,默认否, 处理后图片模糊程度会有所改善, 不美颜时无效 1
need_adjust_lighting false int 是否需要光照处理,1表示是,0表示否,默认否, 会按指定亮度进行调整 1
hor_align_type false int 裁剪方式 0表示中心裁剪(默认) 1表示耳朵裁剪 1
*head_pose false int 头部姿态异常 60
*decoration_occlusion false int 饰品遮挡 60
*pn_over_ps false int 过度ps,目前是第一个版本,需要使用请先联系客服咨询接口效果 60
*face_gazeNG false int 眼睛视线异常,目前是第一个版本,需要使用请先联系客服咨询接口效果 60
*deal_face_skincolor false int 肤色异常检测 60
pose_fix false int 是否需要做姿态调整 0表示否(默认,头像摆正依据双眼水平) 1表示是(会矫正双眼水平和肩膀水平) 1
*pn_neck_shadow_exist false int 脖子有阴影 60
out_endpoint false str 控制返回链接的域名,见参数说明7 https://oss-accelerate.aliyuncs.com
need_origin_beauty false int 是否需要对原图进行预美颜处理, 1表示是,0表示否,默认否,为1时接口耗时偶尔会额外增加30-40秒,大多数情况下额外增加5-6秒 1
origin_max_length false int 原图缩放参数,传此参数时,原图最长边像素大于此值时会被等比例缩放到此值,此时接口耗时会相对较短,且更加稳定,推荐传此参数为1500;不传此参数时不缩放(默认不缩放). 1500

响应参数

注:随着传入的spec_id的不同,响应数据的种类会有一些变化,名称列表和url列表内颜色顺序一一对应,url链接有效期为1个小时。
参数名称 类型 示例 描述
code number 200 状态码
result object    
source_file str app/5f6ca...e4fb6dc1.jpg 原图的云端存储路径(使用此路径作为此接口请求中的file将大大提高效率)
check object 1 检测结果汇总,各检测项中有一项未通过则为0,全部通过则为1
check_result object   各个参数的检查结果:1代表通过,0代表未通过
background_color number 1 背景色
bg_shadow number 1 背景阴影
chin_bottom number 1 下巴距图像下边缘
clothes_similar number 1 服装相似度
eye_space number 1 眼部距离
eyes_center_left number 1 双眼中心距图像左边缘
eyes_close number 1 闭眼程度
eyes_nature number 1 视线
eyes_space_bottom number 1 双眼中心距图像下边缘
face_blur number 1 模糊
face_center number 1 脸部居中
face_color number 1 脸部颜色(弃用)
face_expression number 1 脸部表情
face_noise number 1 脸部噪音
face_unbalance number 1 阴阳脸
facial_pose number 1 脸部姿态
facial_shelter number 1 脸部遮挡
facial_width number 1 脸部宽度
file_size number 1 文件大小
glasses number 1 眼镜样式
glasses_glare number 1 眼镜反光
hairline_top number 1 头顶发际线
head_length number 1 头部长度
shoulder_missed number 1 肩膀完整性(包括肩膀、头部和胸部完整性)
shoulder_equal number 1 肩膀等高
headpose_pitch number 1 头部姿态
headpose_roll number 1 头部姿态
headpose_yaw number 1 头部姿态
eyebrow_occlusion number 1 眉毛遮挡
eye_occlusion number 1 眼睛遮挡
nose_occlusion number 1 鼻子遮挡
mouth_occlusion number 1 嘴巴遮挡
cheek_occlusion number 1 脸颊遮挡
ear_occlusion number 1 耳朵遮挡
decoration_occlusion number 1 饰品遮挡
missing_shoulder number 1 肩膀完整性
incomplete_head number 1 头部完整性
lower_body_hanging number 1 下半身悬空
face_too_dark number 1 照片过暗
face_over_kbt number 1 过曝光
face_contrast number 1 对比度异常
body_posture number 1 身体姿态 身子不正,自拍时斜向下,举手,手放脑后,抠鼻孔,托腮等
hat_detection number 1 帽子检测
bare_shouldered number 1 光膀检测
id_exist number 1 手持证件照检测
watermark_exist number 1 照片有水印
pn_neck_shadow_exist number 1 脖子阴影
ppi number 1 分辨率
name string 图片的规格名称 图片的规格名称
file_name_wm list ["56c...lue3_wm", ...] 带水印图片名字,包括多种可选颜色
file_name_print_wm list ["56c...ue3_print_wm",...] 带水印排版图片名字,包括多种可选颜色
file_name list ["56c...8blue3",...] 无水印图片名字,包括多种可选颜色
file_name_print list ["56...98blue3_print",...] 无水印排版图片名字,包括多种可选颜色
is_print number 1 有无排版
size list [295, 413] 图片尺寸
size_print list [1795, 1205] 排版后图片尺寸
one_sheet_num number 8 排版的照片数量
not_check_result list [{"check_param": "face_blur", "param_message": "脸部模糊","check_value":40},...] 检测未通过参数,check_value表示算法检测出的结果值,为null时表示结果值未以明确的方式给出
img_wm_url_list list ["https://...",...], 带水印单张照url列表
print_wm_url_list list ["https://...",...], 带水印排版照url列表

python请求示例

import requests, json, base64
​
url = "http://apicall.id-photo-verify.com/api/cut_check_pic"
​
with open("test.png", 'rb') as f:
    pic = f.read()
​
headers = {"Content-Type": "application/json"}
​
data = {
    "spec_id": 391,
    "app_key": "您申请的app_key",
    "file": base64.b64encode(pic).decode()
}
data_json = json.dumps(data)
response = requests.post(url, headers=headers, data=data_json)
print(response.text)
							

响应示例

{
  "code": 200, 
  "not_check_result": [], 
  "result": {
    "check": 1, 
    "check_result": {
      "background_color": 1, 
      "clothes_similar": 1, 
      "eyes_close": 1, 
      "face_blur": 1, 
      "face_center": 1, 
      "face_noise": 1, 
      "facial_pose": 1, 
      "file_size": 1, 
      "headpose_pitch": 1, 
      "headpose_roll": 1, 
      "headpose_yaw": 1, 
      "name": "简历照片(一寸)", 
      "photo_format": 1, 
      "px_and_mm": 1, 
      "shoulder_equal": 1, 
      "sight_line": 1, 
      "spec_id": 391
    }, 
    "file_name": [
      "0d8400b2967a11ea9cfa00163e0070b633342blue3", 
      "0d8400b2967a11ea9cfa00163e0070b629211white3", 
      "0d8400b2967a11ea9cfa00163e0070b639814red3", 
      "0d8400b2967a11ea9cfa00163e0070b639486blue23", 
      "0d8400b2967a11ea9cfa00163e0070b688485grey3", 
      "0d8400b2967a11ea9cfa00163e0070b672410blue33"
    ], 
    "file_name_print": [
      "0d8400b2967a11ea9cfa00163e0070b633342blue3_print", 
      "0d8400b2967a11ea9cfa00163e0070b629211white3_print", 
      "0d8400b2967a11ea9cfa00163e0070b639814red3_print", 
      "0d8400b2967a11ea9cfa00163e0070b639486blue23_print", 
      "0d8400b2967a11ea9cfa00163e0070b688485grey3_print", 
      "0d8400b2967a11ea9cfa00163e0070b672410blue33_print"
    ], 
    "file_name_print_wm": [
      "0d8400b2967a11ea9cfa00163e0070b6blue3_print_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6white3_print_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6red3_print_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6blue23_print_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6grey3_print_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6blue33_print_wm"
    ], 
    "file_name_wm": [
      "0d8400b2967a11ea9cfa00163e0070b6blue3_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6white3_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6red3_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6blue23_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6grey3_wm", 
      "0d8400b2967a11ea9cfa00163e0070b6blue33_wm"
    ], 
    "img_wm_url_list": ["https://...","..."], 
    "is_print": 1, 
    "one_sheet_num": 8, 
    "print_wm_url_list": ["https://...","..."], 
    "size": [
      260, 
      378
    ], 
    "size_print": [
      1795, 
      1205
    ]
  }
}