How a virtual fence works
A virtual fence is a line or polygon that an operator draws over a camera’s view in video analytics software. When a tracked object crosses the line, or enters the zone, the software raises an event: an alarm on the operator’s screen, a bookmark in the recording, a relay output to a siren or a message to another system. Camera makers and video management software usually call the line version line crossing detection or a tripwire, and the area version intrusion or region entrance detection.
Nothing is installed on the ground. The fence exists only in the image, so it can be moved, reshaped or scheduled from a screen. That makes it useful where a physical barrier is impractical, such as platform edges, track access points, loading bays and corridors that must stay open.
The term also describes GPS collars that keep livestock inside a boundary. That is a different technology, with no cameras involved, and this page covers the video analytics meaning only.
Types of virtual fence rule
Most analytics engines offer the same handful of rules. They can be combined on one camera, and each can be limited to certain object classes, sizes and times of day.
-
//
Line crossing. An event when an object crosses a drawn line, in one direction or both. A one-way line catches people going the wrong way through a ticket gate or exit.
-
//
Intrusion or region entrance. An event when an object enters a zone, or stays inside it longer than a set time, which filters out someone who only clips a corner.
-
//
Region exit. The reverse: an alert when something leaves an area, such as a vehicle leaving a secure compound.
-
//
Loitering. An alert when a person stays in a zone longer than expected, for example by a perimeter fence or a cash machine.
-
//
Object left or removed. An alert when an item appears in, or disappears from, a watched area.
Motion-based vs AI virtual fences
Early virtual fences used video motion detection: the software compared pixels between frames and treated any change crossing the line as an event. That works indoors under steady light, but outdoors it reacts to swaying trees, headlights, rain, cloud shadows and animals. Operators soon learn to ignore the alarms. AI-based analytics run an object detection model on each frame, so the fence only responds to the classes you choose, typically people and vehicles.
| Approach | What triggers it | False alarms | Processing | Typical use |
|---|---|---|---|---|
| Motion-based tripwire | Any pixel change crossing the line | High outdoors (weather, lights, animals) | Light, runs in most cameras | Indoor areas with stable lighting |
| AI virtual fence | A classified person, vehicle or object | Much lower, filtered by class and size | AI model on a camera, NVR or edge computer | Perimeters, platforms, yards, restricted areas |
| Physical perimeter sensor | Vibration, beam break or buried cable | Varies with weather and wildlife | Dedicated alarm panel | High-security perimeters, often paired with cameras |
Many sites combine the two: a perimeter intrusion detection system on the fence line, and cameras with AI analytics to verify each alarm before anyone is sent out.
Where virtual fences are used
A virtual fence suits any area where people or vehicles should not go, or should only go one way, and where a barrier would get in the way of normal operation.
-
//
Rail and metro platforms. Alerts when someone steps beyond the platform edge line or enters the track from a ramp end.
-
//
Perimeters and compounds. Lines along fences, gates and walls in depots, substations, ports and construction sites.
-
//
Restricted areas. Zones around staff-only doors, plant rooms and loading bays, with schedules so the rule only arms out of hours.
-
//
Ticket gates and exits. One-way lines that catch people entering through an exit or passing a gate the wrong way.
-
//
Vehicle routes. Lines that detect vehicles entering pedestrian areas or traveling the wrong way along a one-way lane.
Where the analytics runs
The fence rule can run in three places. Many IP cameras run simple line crossing on board, which suits a small number of cameras. A recorder can run the analytics for every camera it records: an AI network video recorder adds a GPU or AI accelerator to detect people and vehicles across all its channels. A separate edge computer can also take the camera streams over the network and send events to the video management software, usually over ONVIF, the camera interoperability standard.
Running the analytics on site keeps alerts fast and avoids streaming every camera to the cloud. Our industrial NVRs include Jetson-based AI recorders with PoE camera ports, and our guide to PoE in surveillance and NVR systems covers how the cameras are powered and connected. The station AI NVR case study shows virtual fences and occupancy counting at a metro station.
Setting up a virtual fence that works
Most problems with virtual fences come from the camera view rather than the software. A few rules of thumb help:
- Mount the camera so people and vehicles cross the line side-on, not straight towards the lens, where their position is hard to judge.
- Keep the target large enough in the image for the detector, typically a few dozen pixels high at the far end of the zone.
- Draw the line a little inside the real boundary, so the object is fully in view when it crosses.
- Add infrared or white-light illumination for night use, or use a thermal camera on long perimeters.
- Set minimum dwell times and object sizes, and arm rules on a schedule where an area is only restricted out of hours.
Test with real walk-throughs by day and by night, and review the false alarms after the first week to tune the rules.
Quick answers on virtual fences
Virtual fences: common questions
Is line crossing detection the same as a virtual fence?
Yes, in practice. Line crossing detection is the name most camera makers give to a virtual fence drawn as a line. A zone version is usually called intrusion or region entrance detection.
Is a camera virtual fence the same as a GPS livestock fence?
No. Livestock virtual fencing uses GPS collars that warn animals with sound or vibration as they approach a mapped boundary. A camera virtual fence uses video analytics and has nothing attached to the person or vehicle.
Does a virtual fence work at night?
Yes, with the right lighting. Infrared illumination lets a standard camera see in the dark, and thermal cameras detect people by their heat over long distances. Accuracy depends on the target still being clear in the image.
Can a virtual fence replace a physical fence?
Not for keeping people out. It detects and alerts, but does not stop anyone. It suits areas that must stay open, and adds verification to physical fences on secure sites.
Is a virtual fence a machine safety guard?
No. General video analytics is not a safety-rated protective device. Machine guarding needs certified sensors such as light curtains or safety laser scanners.
We supply AI NVRs and edge AI computers with the operating system, drivers and analytics prerequisites installed as standard, and validate them with your cameras before they ship. Tell us the camera count, resolution and the rules you need, and we will size the recorder to match.