Occupancy counting API
Count people inside a zone you draw on a camera image.
What it detects
Measure occupancy in a lobby, seating area or section of a shop.
Camera setup
Send polygon points as image fractions from zero to one. A single image can return zone occupancy; consecutive frames also support entry and exit events.
Send a camera image.
Set KIRKWOOD_API_KEY on your server. Save a frame as frame.jpg.
import base64
import json
import os
import urllib.request
with open("frame.jpg", "rb") as frame:
image = base64.b64encode(frame.read()).decode()
body = json.loads('''{
"images": [
"<BASE64_JPEG>"
],
"pipeline": "detector",
"zones": [
{
"id": "lobby",
"name": "Lobby",
"kind": "occupancy",
"points": [
[
0.1,
0.3
],
[
0.9,
0.3
],
[
0.9,
0.95
],
[
0.1,
0.95
]
]
}
],
"detections": {
"return_boxes": true
}
}''')
body["images"] = [image]
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 zones for the occupancy of each zone. A person is counted when their detected feet are inside its polygon.
Try it on your footage.
Upload a video. Choose detector, draw a zone and run analysis.
Approved account required. Analysis uses credit. Images are retained for annotation and training.
Open the live PlaygroundBefore you integrate
This measures visible occupancy in the selected area. It does not infer people behind walls or outside the camera view.
Can I set an occupancy limit?
Your application can compare the returned occupancy with your own limit and trigger an alert. The zone itself returns a count.