UNLOCK API
Vẽ viền quanh

Vẽ viền quanh

Cách gửi tác vụ Vẽ viền quanh tới UNLOCK API bằng createTask hoặc in.php: tên loại tác vụ, mọi tham số, object solution, trường proxy và code mẫu bằng 7 ngôn ngữ.
Giá
$0.60 $0.0006 mỗi tác vụ
Bạn gửi
Ảnh dạng base64 và vật cần vẽ viền quanh
Bạn nhận
Các điểm của đường viền đã vẽ

Tổng quan và giá

Tên loại tác vụ

Loại này chỉ có một tên.
DrawAroundTask

Object task

type
StringBắt buộc
Tên loại tác vụ. Không phân biệt chữ hoa, chữ thường. DrawAroundTask
body
StringBắt buộc
Ảnh dạng base64 (JPG, PNG hoặc GIF), tối đa khoảng 100 KB. Được phép có tiền tố data:.
comment
StringTùy chọn
Hướng dẫn cho người giải, ví dụ câu hỏi hiện phía trên ảnh.

Các trường không có trong danh sách này được chuyển nguyên cho người giải.

Request

POST /createTask
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "DrawAroundTask",
    "body": "/9j/4AAQSkZJRgABAQ...",
    "comment": "Draw around the dog"
  }
}

Object solution

Trả về trong solution khi status là ready.
canvas
Array
Đường viền vẽ quanh vật thể, dạng danh sách điểm.
POST /getTaskResult
{
  "errorId": 0,
  "taskId": 1001,
  "status": "ready",
  "solution": {
    "canvas": [
      [
        {
          "x": 10,
          "y": 20
        },
        {
          "x": 60,
          "y": 22
        },
        {
          "x": 58,
          "y": 80
        }
      ]
    ]
  },
  "cost": "0.0006",
  "createTime": 1791640000,
  "endTime": 1791640014,
  "solveCount": 1
}

Code mẫu

import time, requests

API = "https://unlock-api.com"
KEY = "YOUR_API_KEY"

task = requests.post(f"{API}/createTask", json={
    "clientKey": KEY,
    "task": {
      "type": "DrawAroundTask",
      "body": "/9j/4AAQSkZJRgABAQ...",
      "comment": "Draw around the dog"
    }
}).json()
if task["errorId"]:
    raise SystemExit(task["errorCode"])

for _ in range(60):   # 60 x 5 s = the 5 minute task limit
    time.sleep(5)
    r = requests.post(f"{API}/getTaskResult", json={"clientKey": KEY, "taskId": task["taskId"]}).json()
    if r["errorId"]:
        raise SystemExit(f"{r['errorCode']}: {r.get('errorDescription', '')}")   # failed tasks are refunded
    if r["status"] == "ready":
        print(r["solution"])
        break
else:
    raise SystemExit("timed out")

Phương thức form in.php

Cùng tác vụ đó với request form kiểu cũ. res.php trả kết quả dạng văn bản.
in.php, res.php
curl -s "https://unlock-api.com/in.php" -d "key=YOUR_API_KEY&method=base64&canvas=1&textinstructions=Draw+around+the+dog&body=BASE64_IMAGE&json=1"
# {"status":1,"request":"1001"}

curl -s "https://unlock-api.com/res.php?key=YOUR_API_KEY&action=get&id=1001&json=1"
# {"status":0,"request":"CAPCHA_NOT_READY"}  then  {"status":1,"request":"ANSWER"}

API form: in.php và res.php