Skip to main content
Ask Perceptron Mk1.5 to locate objects through chat completions. Name the categories and request the geometry your application needs: boxes for extents, points for centers, or polygons for boundaries.

Detect helmets and vests

Install perceptron>=0.4.0 and set PERCEPTRON_API_KEY. This example uses the public PPE image and asks for one box per visible helmet or safety vest.
Detections are annotation markup in message.content, not a separate JSON detections field. For example:
These values illustrate the format and are not measured detections from this image. Coordinates are normalized to 0–1000, with top-left followed by bottom-right. asset_idx="0" identifies the input image. Validate the label, selector, coordinate range, and box ordering before using a detection. Follow rendering annotations to draw these boxes. For a center-point workflow, change the annotation format to "point" and ask for each object’s center; use "polygon" when an outline better represents the target.

Return counts as structured data

For applications that need numbers, request a constrained count response. Install jsonschema, then run this after the client and image setup above:
This is a separate request, so its counts can differ from the first request’s detections. If totals must match the displayed overlay exactly, count the validated annotations by category in your application. A valid schema ensures the expected structure; it does not establish that every item was detected. Occlusion and small objects can affect counts.

Define the target precisely

Use clear category descriptions and explain borderline cases: “high-visibility safety vest” is more specific than “vest.” For subtle targets, supply a labeled reference image through in-context image learning. With several images, request asset_idx on every annotation and select the corresponding dimensions when rendering. For objects moving through a video, use video tracking. Separate detections from independent images do not create persistent object identities.

Choose the endpoint

The examples above select perceptron-mk1.5 on /v1/chat/completions and return normalized annotation markup. The separate Detect API provides a managed detection workflow with its own supported model and target-image pixel coordinates. Its request and response formats differ from the chat-completion examples on this page.