Footfall counting API

Count people entering and leaving across a line on a camera view.

What it detects

Track entry and exit counts at a store entrance.

Camera setup

Draw a line one step outside the door. Send up to 16 successive frames about 0.2 seconds apart in one request, with their timestamps; for a continuous count, the Kirkwood SDK sends one frame per request and keeps the tracking between them.

Send a camera image.

Set KIRKWOOD_API_KEY on your server. Save a frame as frame.jpg.

Python POST /v1/analyze
import base64
import json
import os
import urllib.request

images = []
for i in range(10):
    with open(f"frame_{i}.jpg", "rb") as frame:
        images.append(base64.b64encode(frame.read()).decode())

body = json.loads('''{
  "images": [
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>",
    "<BASE64_JPEG>"
  ],
  "image_times_s": [
    0,
    0.2,
    0.4,
    0.6,
    0.8,
    1,
    1.2,
    1.4,
    1.6,
    1.8
  ],
  "pipeline": "detector",
  "lines": [
    {
      "id": "entrance",
      "name": "Front entrance",
      "a": [
        0.2,
        0.65
      ],
      "b": [
        0.8,
        0.65
      ],
      "in_side": "right"
    }
  ],
  "detections": {
    "return_boxes": true
  }
}''')
body["images"] = images
request = urllib.request.Request(
    "https://app.kirkwood.ai/v1/analyze",
    data=json.dumps(body).encode(),
    headers={
        "Authorization": "Bearer " + os.environ["KIRKWOOD_API_KEY"],
        "Content-Type": "application/json",
    },
    method="POST",
)
with urllib.request.urlopen(request, timeout=120) as response:
    print(json.dumps(json.load(response), indent=2))

Read the result

Read line_counts for IN and OUT totals and events for individual crossings. Each event carries the line id, direction, track id and time.

Try it on your footage.

Upload a video. Choose detector, draw an entrance line and run analysis.

Approved account required. Analysis uses credit. Images are retained for annotation and training.

Open the live Playground

API pricing

Billed per image analyzed. Contact us for your rate.

Request pricing

Before you integrate

Crossings require successive frames. One image cannot establish direction.

Are these unique visitor counts?

They are line crossings. A person leaving and returning can cross more than once. Cross-camera identity matching is not part of this example.

API guide