Intrusion detection API
Detect people entering a restricted zone in a camera view.
What it detects
Draw a no-go zone around a restricted area.
Camera setup
Define the restricted area with normalized polygon points. Send successive frames in one request; the Kirkwood SDK keeps tracking state between requests.
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
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",
"zones": [
{
"id": "restricted",
"name": "Restricted yard",
"kind": "no_go",
"points": [
[
0.6,
0.3
],
[
0.95,
0.3
],
[
0.95,
0.95
],
[
0.6,
0.95
]
]
}
],
"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 zones for occupancy and events for zone_enter and zone_exit. Your application decides when an event should raise an alarm.
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
A no-go zone checks location. It does not establish a person’s identity or access permissions. Schedules and authorization belong in your application.
Can I limit alerts to after hours?
Yes, in your application: compare the event time with your site schedule before sending an alert. The API returns the zone event.