AI Gun Detection — Deployment Guide

View source on GitHub
Preset

NVIDIA Jetson

Real-time gun detection with Frigate NVR on NVIDIA Jetson. Detections trigger recordings and snapshots, and alerts can go to other systems over MQTT.

  • Devices: NVIDIA Jetson (reComputer); IP camera optional — demo videos run without one.
  • Software: Docker and NVIDIA Container Toolkit on the target device.
  • Network: camera, Jetson and this computer on the same network.
1

Initialize Cameras

Get the RTSP stream URL of your IP camera. Skip this if you only use the demo videos.

Wiring
  1. Connect the IP camera to the same network as the Jetson
  2. Find the camera's IP in your router's DHCP client list or the manufacturer's tool
  3. Open the camera's web interface (usually http://<camera-ip>) and confirm RTSP is enabled
  4. Note the RTSP URL and test it in VLC (Media > Open Network Stream)

Common RTSP URL formats:

  • Hikvision: rtsp://admin:password@<ip>:554/Streaming/Channels/101 (main stream) or /102 (sub stream)
  • Dahua: rtsp://admin:password@<ip>:554/cam/realmonitor?channel=1&subtype=0 (main) or &subtype=1 (sub)
  • Generic ONVIF: Use the camera's ONVIF discovery tool to find the stream URL

Use the sub stream for detection and the main stream for recording.

Troubleshooting
SymptomFix
Cannot access camera web interfaceTest with ping <camera-ip>; make sure camera and computer are on the same subnet
RTSP stream not workingConfirm RTSP is enabled, check username/password, test in VLC first
Camera not found on networkPower cycle the camera, check the Ethernet cable, use the manufacturer's discovery tool (e.g., Hikvision SADP, Dahua ConfigTool)
2

Deploy Frigate

Deploy Frigate NVR and the gun detection model to the NVIDIA Jetson.

Deployment method

Deploy to a Jetson on the network over SSH.

Wiring
  1. Connect the Jetson to the same network as your computer
  2. Enter the Jetson's IP address and SSH credentials
  3. Optionally enter RTSP camera URLs (up to 2)
  4. Click Deploy. First startup takes 5-10 minutes to compile the model
What you will be asked for(filled in the SenseCraft Solution app)
  • Camera 1 RTSP URL (optional)
  • Camera 2 RTSP URL (optional)
Troubleshooting
SymptomFix
NVIDIA runtime not foundsudo apt install nvidia-container-toolkit && sudo systemctl restart docker
Port 5000 already in usedocker stop $(docker ps -q --filter publish=5000)
Slow first startupModel compilation takes 5-10 minutes the first time only
Container keeps restartingRun docker logs frigate; usually a GPU memory or driver issue
RTSP camera not showingVerify the URL in VLC, then edit config/config.yml as in step 3 and restart
After Deployment

Open http://<device-ip>:5000. The two demo videos show gun detection boxes; RTSP cameras you entered appear as well.

3

Open Dashboard

Click below to open the Frigate dashboard.

Troubleshooting
SymptomFix
Page not loadingMake sure the previous step deployed successfully
Wrong host/portIf you deployed to a remote device, use its IP in the URL
After Deployment

Quick Verification

  1. Open the Frigate dashboard and check the Birdseye view for all cameras
  2. Confirm gun detection boxes appear on the demo videos
  3. Click an event to see its timestamped snapshot

Adding or Modifying Cameras

SSH into the device and edit the configuration:

cd ~/gun-detection-frigate
nano config/config.yml

Add camera entries under cameras::

  my_camera:
    enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://admin:password@192.168.1.100:554/Streaming/Channels/101
          roles:
            - detect
            - record
    detect:
      width: 1920
      height: 1080
      fps: 5
    objects:
      track:
        - gun

Save and restart Frigate:

docker compose restart

Next Steps

  • Configure alerts over MQTT (port 1883)
  • Adjust the detection threshold in config/config.yml (objects.filters.gun.threshold)
  • Set recording retention (record.retain.days)
  • Frigate Documentation