Weapon detection API

Check camera images for a person holding a gun, knife, bat or club.

What it detects

Add held-weapon detection to checks at entrances and other monitored areas.

Detection
A gun, a knife, or a baseball bat or similar club held visibly in a person's hand.
Outside the definition
No weapon in anyone's hand. A holstered gun, a tool, a phone or an umbrella, or a bat or club that is not held (leaning, on a rack, in a bag).

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

with open("frame.jpg", "rb") as frame:
    image = base64.b64encode(frame.read()).decode()

body = json.loads('''{
  "images": [
    "<BASE64_JPEG>"
  ],
  "tags": [
    "weapon"
  ],
  "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 tags.weapon.answer and p_yes. A person box locates a detected person; it is not a dedicated weapon box.

Camera setup

Test small and partly hidden objects at the distances your cameras cover. Include tools, phones and umbrellas in your comparisons.

Try it on your footage.

Upload an image and select “Weapon”. 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

The tag covers a weapon held in a hand. A holstered gun or an unattended bat is outside its positive definition.

Does the API draw a box around the weapon?

The tag returns an image-level assessment. The standard detector returns its supported object boxes, including people; this is not a dedicated weapon-localization endpoint.

API guide