Many shops, offices, and construction sites already have IP cameras installed, and many of them support ONVIF, a standard that lets cameras and software from different manufacturers work together. To run RF-DETR on an ONVIF camera, you need a way to read its live video stream and run inference without adding dedicated compute hardware at each site.
With Roboflow Cloud Streaming, you can run computer vision models on your existing cameras using Roboflow-managed GPUs. A lightweight Video Connector (opens in a new tab) runs on a computer you already own near your cameras, discovers ONVIF cameras, and reads their media profiles. The connector uses outbound connections only and runs no inference, so you don't need to buy GPU hardware or open ports on your router.
In this guide, you'll learn what ONVIF is and how a camera shares its RTSP stream. Then you'll set up the Video Connector, build a Roboflow Workflow that uses Roboflow's RF-DETR (opens in a new tab) to count people and vehicles, test and deploy it, and read the counts as JSON in your own application.
What is ONVIF?
A single building often has cameras from different brands. Video software still needs one common way to find each camera, read its settings and open its video. ONVIF provides that common way.
ONVIF defines how IP-based security products such as network cameras talk to video software. It provides standardized interfaces for effective interoperability of IP-based physical security products and services. In simple terms, it is a shared language that cameras and video software from different brands both speak.
Software that talks to an ONVIF camera is called an ONVIF client, and the conversation runs on web services (opens in a new tab). The client finds cameras with WS-Discovery (opens in a new tab) messages sent over UDP. It then sends SOAP messages over HTTP or HTTPS to read a camera's media profiles and ask for its stream address.
ONVIF does not carry the video itself. Instead, it tells software where the stream is. RTSP then starts and controls the video session, while RTP carries the video frames.
A device can conform to more than one profile. For example, a camera with local storage can conform to both Profile T and Profile G. Here are the ONVIF profiles (opens in a new tab) and what each one covers:
Profile
What it covers
Status
Profile S
Live video streaming and PTZ control
Deprecation in process; last conformance submissions March 31, 2027
Profile T
Video streaming with H.264 and H.265, imaging settings, motion and tampering alarms, and metadata streaming
Current
Profile G
Recording and storage on the device or over the network
Current
Profile M
Analytics metadata and events, such as object counting, face, and license plate recognition
Current
Profile A
Access control configuration: access rules, credentials, and schedules
Current
Profile C
Access control: site information, door access, events, and alarms
Current
Profile D
Access control peripherals such as card and biometric readers, keypads, locks, and sensors
Current
Profile V
Cloud video surveillance: live streaming, cloud recording, and event notifications
Release candidate
Profile Q
Out-of-the-box setup
Deprecated as of April 1, 2022
How does an ONVIF camera share its RTSP stream?
An ONVIF camera does not push video to anyone on its own. An ONVIF client first has to find the camera and ask which streams it offers. A typical client does this in five simple steps.
Find the camera: The client sends a WS-Discovery (opens in a new tab)Probe message to the local network over UDP. Each ONVIF camera in discoverable mode, which is the default (opens in a new tab), answers a matching probe with a ProbeMatches message. Its XAddrs field lists one or more addresses of the camera's device service. A client that already knows the camera's address can skip this step.
Ask for its services: A GetServices request to the device service returns the address of every other service on the camera, including the media service.
List the media profiles: A GetProfiles request returns the camera's media profiles. A media profile maps a video and/or audio source to a video and/or an audio encoder, PTZ and analytics configurations (opens in a new tab). One camera often has several, such as a high-resolution main stream and a smaller sub stream. A media profile is not the same as Profile S or Profile T. Those ONVIF profiles describe the features a conformant product supports, while a media profile is one stream setup on one camera.
Ask for the stream address: A GetStreamUri request with a profile token asks for "a URI that can be used to initiate a live media stream". The camera answers with an address such as rtsp://<camera-ip>:554/<stream-path>.
Discovery needs no login, and the ONVIF Core Specification (opens in a new tab) puts GetServices in the PRE_AUTH access class, so it needs none either. In this example, the client uses the camera's ONVIF username and password for media requests.
How does Cloud Streaming run RF-DETR without new hardware?
One way is to put an edge computer with a GPU next to the cameras. Cloud Streaming keeps only a light connector on site and moves the model to the cloud. Roboflow Cloud Streaming (opens in a new tab) runs a Workflow on live camera video with Roboflow-managed GPUs. It has three parts. A source supplies the video. A connector reaches cameras on a private network. A job runs one Workflow on one source.
The camera stays where it is, and a computer you already own forwards its video. All the heavy GPU work happens in Roboflow Cloud.
Why use Roboflow Cloud Streaming for ONVIF cameras?
Running a model on live cameras usually means servers, drivers and network rules to look after. Cloud Streaming takes most of that work off your plate.
No GPU hardware on site: The connector captures and sends video, and Roboflow runs the vision application on managed cloud GPUs.
Your network stays private: The connector is outbound-only, so the local network does not need to be publicly exposed.
Built for always-on video: Processing continues after the page is closed and resumes after supported source outages. Offline notifications (opens in a new tab) send an email when a camera goes offline.
Results where you need them: Each run can deliver video, JSON, Workflow sink events, Vision Events or saved captures.
Other ways to run the same Workflow, such as on your own servers, are compared in the deployment guide (opens in a new tab). For teams that already own ONVIF cameras, Cloud Streaming lets vision AI start on the cameras they have today.
How to run RF-DETR on an ONVIF camera with Cloud Streaming
The rest of this guide builds one complete application. A shop, a street corner or a construction site already has an ONVIF camera. The business wants to know how many people and vehicles are in view at any moment, without buying new devices. The developer wants those counts as clean JSON that other apps can use.
The solution runs RF-DETR on the camera stream and counts the people and vehicles it detects in each frame. It needs no counting line and no direction, so it works on any camera view.
Step 1: Confirm that the camera supports ONVIF
Start with the camera, since every later step depends on it. Search for the camera model in the ONVIF conformant products database (opens in a new tab) and check that it lists Profile S or Profile T for the firmware version the camera runs. Conformance is tied to a specific firmware version, so the model name alone is not enough.
On the camera's own settings page, make sure ONVIF is turned on. Write down the camera's IP address and the username and password it uses for ONVIF. Pick a computer on the same local network as the camera to run the connector, because ONVIF discovery uses multicast that may not cross VLANs (opens in a new tab).
With a supported camera and a computer on its network, the hardware side is ready.
Step 2: Pull the RTSP address from the camera with ONVIF
This step is optional, because the connector reads the camera's profiles on its own in Step 4. It is still a quick way to see the camera's streams before any cloud setup. The short Python script below sends the ONVIF requests from the earlier section and prints the RTSP address of every media profile.
The script needs Python 3.10 or later with the requests library (opens in a new tab). Run it on a computer on the camera's network. Without --host, it sends a WS-Discovery Probe and asks every camera that answers. With --host, it asks one camera directly, which helps when the camera sits on another VLAN. Add --port when the camera serves ONVIF on a port other than 80. The password is typed at a prompt, so it never lands in your shell history. The script logs in with HTTP digest authentication, so it cannot read cameras that accept only WS-UsernameToken.
Python
import argparse
import getpass
import socket
import uuid
import xml.etree.ElementTree as ET
import requests
from requests.auth import HTTPDigestAuth
DEVICE = "http://www.onvif.org/ver10/device/wsdl"
MEDIA1 = "http://www.onvif.org/ver10/media/wsdl"
MEDIA2 = "http://www.onvif.org/ver20/media/wsdl"
SCHEMA = "http://www.onvif.org/ver10/schema"
PROBE = (
'<?xml version="1.0" encoding="UTF-8"?>'
'<e:Envelope xmlns:e="http://www.w3.org/2003/05/soap-envelope"'
' xmlns:w="http://schemas.xmlsoap.org/ws/2004/08/addressing"'
' xmlns:d="http://schemas.xmlsoap.org/ws/2005/04/discovery">'
"<e:Header>"
"<w:MessageID>uuid:{message_id}</w:MessageID>"
"<w:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</w:To>"
"<w:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</w:Action>"
"</e:Header>"
"<e:Body><d:Probe/></e:Body>"
"</e:Envelope>"
)
def discover(address="239.255.255.250", port=3702, timeout=3.0):
"""Send a WS-Discovery Probe and return the device service address of every camera that answers."""
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 1)
sock.settimeout(timeout)
sock.sendto(PROBE.format(message_id=uuid.uuid4()).encode(), (address, port))
found = set()
try:
while True:
data, _ = sock.recvfrom(65535)
try:
reply = ET.fromstring(data)
except ET.ParseError:
continue
for xaddrs in reply.findall(".//{*}XAddrs"):
found.update(a for a in (xaddrs.text or "").split() if "/onvif/" in a)
except socket.timeout:
pass
finally:
sock.close()
return sorted(found)
def soap(url, body, auth):
"""POST one ONVIF request and return the parsed SOAP reply."""
envelope = f'<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Body>{body}</s:Body></s:Envelope>'
reply = requests.post(
url,
data=envelope.encode(),
auth=auth,
headers={"Content-Type": "application/soap+xml; charset=utf-8"},
timeout=5,
)
reply.raise_for_status()
return ET.fromstring(reply.content)
def stream_uris(device_url, auth):
"""Yield name, token, width, height and RTSP URI (or the error) for each media profile."""
services = soap(device_url, f'<GetServices xmlns="{DEVICE}"><IncludeCapability>false</IncludeCapability></GetServices>', auth)
xaddr = {s.findtext(f"{{{DEVICE}}}Namespace"): s.findtext(f"{{{DEVICE}}}XAddr") for s in services.iter(f"{{{DEVICE}}}Service")}
if MEDIA2 in xaddr: # Profile T cameras offer the Media2 service
media, url = MEDIA2, xaddr[MEDIA2]
profiles = soap(url, f'<GetProfiles xmlns="{MEDIA2}"><Type>VideoEncoder</Type></GetProfiles>', auth)
setup = "<Protocol>RTSP</Protocol>"
elif MEDIA1 in xaddr: # older Profile S cameras offer only the Media service
media, url = MEDIA1, xaddr[MEDIA1]
profiles = soap(url, f'<GetProfiles xmlns="{MEDIA1}"/>', auth)
setup = (
f'<StreamSetup><Stream xmlns="{SCHEMA}">RTP-Unicast</Stream>'
f'<Transport xmlns="{SCHEMA}"><Protocol>RTSP</Protocol></Transport></StreamSetup>'
)
else:
raise LookupError("the camera lists no media service")
for profile in profiles.iter(f"{{{media}}}Profiles"):
token = profile.get("token")
body = f'<GetStreamUri xmlns="{media}">{setup}<ProfileToken>{token}</ProfileToken></GetStreamUri>'
try:
uri = soap(url, body, auth).findtext(".//{*}Uri")
except requests.RequestException as error:
uri = f"no stream address ({error})" # report this profile and keep going
width = profile.findtext(".//{*}Resolution/{*}Width")
height = profile.findtext(".//{*}Resolution/{*}Height")
yield profile.findtext("{*}Name"), token, width, height, uri
def main():
parser = argparse.ArgumentParser(description="Print the RTSP address of every ONVIF media profile.")
parser.add_argument("--host", help="camera IP address, or leave it out to search the network")
parser.add_argument("--port", type=int, default=80, help="camera port for ONVIF (often 80)")
parser.add_argument("--user", required=True, help="camera user with ONVIF access")
args = parser.parse_args()
auth = HTTPDigestAuth(args.user, getpass.getpass("Camera password: "))
devices = [f"http://{args.host}:{args.port}/onvif/device_service"] if args.host else discover()
if not devices:
print("No ONVIF camera answered. Pass --host if the camera sits on another VLAN.")
for device in devices:
print(device)
try:
for name, token, width, height, uri in stream_uris(device, auth):
print(f" {name} ({token}) {width}x{height} {uri}")
except (requests.RequestException, LookupError) as error:
print(f" could not read profiles: {error}")
if __name__ == "__main__":
main()
Install the library and run the script with the camera's ONVIF user.
Shell
pip install requests
python onvif_rtsp.py --user admin
python onvif_rtsp.py --host 192.168.1.64 --user admin
Each output line is one media profile. Profile names, tokens and stream paths differ from brand to brand. If the camera cannot give a stream for a profile, that line shows the camera's error in place of the address.
http://192.168.1.64:80/onvif/device_service
mainStream (Profile_1) 1920x1080 rtsp://192.168.1.64:554/<stream-path>
subStream (Profile_2) 640x360 rtsp://192.168.1.64:554/<stream-path>
The script uses the newer Media2 service when the camera lists it, which Profile T cameras do, and the older Media service otherwise. In both cases it requests the RTSP transport, which the Media2 Service Specification (opens in a new tab) defines as "RTSP streaming RTP over TCP."
It is also worth checking the stream format before Roboflow uses it. ffprobe (opens in a new tab) from FFmpeg opens the RTSP address over TCP with the -rtsp_transport tcp (opens in a new tab) option and reports the codec, profile, resolution, frame rate and B-frame setting. This check puts the username and password inside the address, so delete the command from your shell history afterwards.
Shell
ffprobe -v error -rtsp_transport tcp -select_streams v:0 \
-show_entries stream=codec_name,profile,width,height,has_b_frames,avg_frame_rate \
-of default=noprint_wrappers=1 "rtsp://USER:PASSWORD@192.168.1.64:554/<stream-path>"
A stream that uses B-frames prints output like this.
The connector is a small program that runs on a computer next to the camera. It reads the camera on the local network and sends the video to Roboflow over an outbound connection.
The connector stops when its terminal closes or the computer sleeps. For a camera that runs every day, run it as a system service or with Docker (opens in a new tab) and keep only one copy running. Inside Docker, ONVIF discovery cannot see the local network from the default bridge network, so use host networking on Linux with --network host and --ui-addr=127.0.0.1:8070.
The computer you already had now works as a bridge between the camera and Roboflow Cloud.
Step 4: Add the ONVIF camera and choose a profile
This is where the connector does the ONVIF work for you. It finds the camera, reads its media profiles and turns the chosen profile into a live source.
On the Streams page, open the connector from the Connectors panel and find RTSP Cameras. You can also click Add Video Source, then Connect a Camera, and pick the connector under Add to an existing connector. Under Cameras found on the network, click Add next to your camera. Enter its credentials, click Add camera, then choose a profile (opens in a new tab).
Wait until the source shows Applied and plays live video. The camera then appears under Video Sources on the Streams page with a Live status. If the camera does not appear, add it by address instead. Click Add by RTSP URL, enter a name and the camera's RTSP address, such as one from Step 2, and type the username and password in their own fields. A recorder (NVR) works the same way, and Add streams under More streams on added devices turns each of its channels into its own source.
The camera is now a reusable Cloud Streaming source. The model that watches it comes in the next step.
Step 5: Build the RF-DETR counting Workflow
Here's the Workflow we'll build. It decides what happens to every frame: it detects people and vehicles and reports how many of each are in view. Here I use the pretrained rfdetr-medium model, and the Workflow chains six blocks.
Object Detection Model (opens in a new tab) runs rfdetr-medium with a confidence threshold of 0.4 and a class filter for six classes: person, bicycle, car, motorcycle, bus, and truck. Every detection comes with a bounding box, a class label and a confidence score.
Property Definition (opens in a new tab) named class_counts uses DetectionsPropertyExtract to read the class name of every detection and SequenceElementsCount to count each name. The result is a dictionary such as {"person": 8, "car": 17}.
A second Property Definition named frame_total uses SequenceLength to count all detections in the frame.
The Workflow needs nothing but the camera image, so the same definition works on any camera. It returns four outputs. counts holds the number of detections per class in each processed frame, and total holds their sum. predictions holds every bounding box with its class and confidence, and annotated_frame is the frame with the boxes, labels and counts drawn on it. Because the numbers describe one frame at a time, they rise and fall as people and vehicles come and go. They count detections, not unique people or vehicles. For a camera that faces a single door, a tracker and a Line Counter (opens in a new tab) can later add entry and exit totals.
A quick test shows what these outputs look like. On a sample street image (opens in a new tab) from Roboflow, the published Workflow returned these values for 35 detections.
Step 6: Test the Workflow with a preview
A preview is a short test run that you watch live. It is the safest first contact between the Workflow and real video, and the best moment to check that the counts match the scene.
Watch the annotated video closely. The boxes should sit on people and vehicles, and the numbers in the corner should match what the camera shows. If distant objects are missed, lower the confidence threshold in the Object Detection Model block and run the preview again. A lower threshold can also add false positives, so check for extra boxes as well. A clean preview means the Workflow is ready to go live.
The Workflow has no extra inputs, so the only choice is the image output. Pick annotated_frame under Visual Preview Output. The estimate shows an hourly rate, not a total (opens in a new tab). Click Start Processing to begin.
A running preview can also become a deployment. Select the running preview and click Deploy Stream, and it becomes a deployment with no restart. Promotion keeps the running Workflow and its sink settings, and it does not publish the draft.
A few habits keep a deployment predictable. Publishing a new Workflow version does not change a running deployment, so restart it to apply changes. To run only during opening hours, open the deployment's Activity and click Edit Schedule. Scheduling needs automatic recovery, which turns on after 30 seconds of steady processing. To get an email when the camera goes offline, open Offline Notifications on the Streams page, enable notifications, select the recipients and click Save. Emails cover cameras on included connectors when those cameras have a deployment with automatic recovery. Previews are excluded. To end a run, click Stop, then Stop processing, because closing the page does not stop the deployment.
RF-DETR now runs on the camera's video in Roboflow Cloud, with no GPU on site. The counts still need to reach the people who use them.
Step 8: Read the counts and send them to your app
Cloud Streaming offers several ways to read the Workflow outputs. Pick the one that fits who needs the numbers.
Annotated video plays in the Results panel of the camera page.
Latest Result shows the newest outputs, including counts and total.
Logs offers Download results, which exports recent results as JSON lines.
For an app, the live results feed is the main path. Your server sends a POST request to /{workspace}/video-jobs/v1/{jobId}/results/subscribe with a workspace API key that has the video-inference-job:read scope. The answer includes an eventsUrl for a WebSocket connection. Each result message carries a timestamp and the outputs keyed by output name, so counts and total arrive under their own names. The live results page (opens in a new tab) includes a complete Python client.
If your ONVIF camera supports pan, tilt, and zoom (PTZ), the model's detections can also steer the camera. The PTZ Tracking block in Roboflow Workflows uses ONVIF to move the camera toward a tracked object, zoom in on it, and return the camera to a preset position when it goes idle.
The block sends ONVIF movement commands straight to the camera, so you enter the camera's ONVIF settings in the block, and the Workflow has to run where it can reach the camera on the network. The camera also needs to support the ONVIF ContinuousMove service, and cameras with variable-speed movement follow objects more smoothly.
Troubleshooting ONVIF cameras in Cloud Streaming
Most problems with ONVIF cameras come from the network or the stream format, not from the model. The checks below cover the common ones.
A few questions come up often when teams first connect ONVIF cameras to vision AI.
Is ONVIF the same as RTSP?
No. ONVIF defines the web services that software uses to find a camera, read its settings and ask for its stream address. RTSP controls the video session, and RTP carries the frames.
Do all IP cameras support ONVIF?
No. To check, look up the camera model and firmware version in the ONVIF conformant products database (opens in a new tab). If a camera does not support ONVIF but still offers an RTSP stream, you can connect it to Cloud Streaming with Add by RTSP URL.
Which ONVIF profile does a camera need for vision AI?
Does running RF-DETR on an ONVIF camera need a local GPU or a public IP address?
No. With Roboflow Cloud Streaming, a Video Connector on a computer near the camera sends video over outbound connections only, and RF-DETR runs on Roboflow-managed GPUs.
How much does Cloud Streaming cost for one camera?
Roboflow Cloud Streaming lets you run computer vision on the ONVIF cameras you already have, without installing dedicated inference hardware. You can process live video continuously or on a schedule and send the results to your own applications.
Start by checking whether your cameras support ONVIF, then connect one to a Video Connector. Use the pretrained RF-DETR model from this guide, or swap in a model you trained in Roboflow to detect the objects that matter to you. When the first camera works, run the same Workflow on more cameras across your sites.