Skip to content
On this page

人框检测接口

1.接口功能

该功能允许用户通过千面动捕服务接口检测图片中的人框信息。

2.请求方法

Post

3.请求路径

https://www.qmai.vip/business/uploadPic

4.请求参数

  • companyKey:必填,企业用户的上传凭证(可在用户详情页查看)。

  • picture:必填,上传图片。

5.响应信息

服务端将以 JSON 格式返回响应数据。示例数据为:

{
    'code': 0,
    'message': 'success',
    'data': {
        'message': 'SUCCESS',
        'multiAddr': '{"boxes":"[[71, 402, 177, 285], [270, 363, 134, 327]]"}',
        'status': '200',
        'videoStatus': ''
        }
}

6.python示例代码

import datetime
import json
import time
import traceback
import requests


def upload_image(key, image_path):
    try:
        url = f"https://www.qmai.vip/business/uploadPic"

        # Prepare the files and data for the POST request
        with open(image_path, 'rb') as image_file:
            files = {'picture': (image_path, image_file, 'image/jpeg')}
            data = {'companyKey': key}

            # Send POST request with file and key
            response = requests.post(url, files=files, data=data)

            # Process response
            now_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            if response.status_code == 200:
                try:
                    response_data = json.loads(response.text)
                    print(f"{now_time} Response: {response_data}")
                    if response_data["code"] == 0 and response_data["message"] == "success":
                        return True
                    else:
                        return False
                except json.JSONDecodeError:
                    print(f"{now_time} Failed to parse response JSON")
                    return False
            else:
                print(f"{now_time} Request failed with status code: {response.status_code}")
                return False
    except Exception as e:
        traceback.print_exc()
        return False


if __name__ == "__main__":
    key = ""
    # Specify the path to your image file
    image_path = r"112300.png"  # Replace with actual image path

    while True:
        if upload_image(key, image_path):
            print("Image uploaded successfully")
            break
        print("Retrying in 5 seconds...")
        time.sleep(5)