Building Real-Time Crowd Management Systems

Building Real-Time Crowd Management Systems

Yash Sonawane
Computer Vision

> You can check out our codebase on crowd management here. Contains the foundation code to get your own crowd management system up and running!

Crowd management is the process of monitoring and controlling how people move in shared spaces. It aims to prevent overcrowding, ensure safety, and maintain smooth operations during high footfall. As foot traffic grows, manual monitoring becomes harder to scale. Traditional systems rely heavily on human observation. They often miss early signs of congestion or risk and by the time someone reacts, it's too late.

To solve this, many public spaces now rely on automated systems. CCTV feeds, sensors, and software track how people move, gather, and disperse in real time. These systems detect crowd density, monitor flow, and predict issues before they escalate.

Need for Crowd Management 

Managing crowds in busy places like airports, malls, and events is about more than keeping people safe. It also helps improve security and makes operations run smoothly. Plus, the data collected can provide valuable business insights. Let’s explore these major uses of crowd management.

Safety and Security

Safety is the top priority in any crowded space. Real-time monitoring helps authorities detect unusual crowd sizes and movement early on. This early warning system allows for quick action, stopping accidents before they happen.

Security threats are also handled more effectively. Suspicious behavior like loitering or abandoned bags can trigger immediate alerts. This gives security teams the chance to respond before situations get worse. Airports, stadiums, and busy transport hubs especially benefit from these systems, where safety and security cannot be compromised.

The systems can also manage access points, keep an eye on busy zones, and help plan safe exit routes. When they work with emergency teams, it becomes easier to make quick and smart decisions. This is especially important in places like airports, stadiums, and large public events, where every second counts.

Operational Efficiency and Business Insights

Another big advantage is operational efficiency. Automated crowd management provides accurate, real time data. This helps organizers make better decisions on where to deploy staff and how to manage crowd flow. For example, event planners can use this data to position security and open emergency routes effectively.

The data collected also offers valuable business insights. Retailers can see which areas of a store attract the most visitors, helping them optimize product placement and staffing. Shopping malls and city centers can analyze visitor movement to design better layouts and plan promotions more effectively.

At large events like concerts or sports games, organizers use crowd data to increase revenue by directing attendees toward concession stands and merchandise areas. At the same time, they improve overall safety and make the visitor experience better.

How to build a Crowd Management System?

Preprocessing

Crowd management systems begin with real-time video capture using modern IP-based CCTV cameras that comply with ONVIF or RTSP standards. These cameras are capable of streaming high-resolution video (1080p or even 4K) and are positioned to ensure maximum coverage with minimal blind spots.

Synchronization

All cameras must be synchronized to the same clock. This ensures that frames captured across different views represent the exact same moment in time. If cameras are even slightly out of sync, a person moving between zones might appear at different times in each feed, breaking cross-camera tracking and leading to double-counting or missed detections.

Basic systems use NTP (Network Time Protocol), which offers millisecond-level synchronization, sufficient for general surveillance. Advanced setups use PTP (Precision Time Protocol), which provides sub-microsecond accuracy. PTP is hardware-assisted and is essential when the system fuses data across overlapping cameras in real time.

Video Ingestion

Video feeds are securely transmitted via RTSP or ONVIF and ingested using tools like GStreamer, FFmpeg, or OpenCV. Once ingested, the video streams are processed either centrally or at the edge.

Edge computing devices like the NVIDIA Jetson or Dell Edge Gateway can be deployed near camera sources to reduce latency and bandwidth usage. These devices handle tasks such as frame extraction, resizing, denoising, and optionally, background subtraction or motion detection.

Why edge preprocessing matters:

  • Reduces upstream data volume by filtering irrelevant frames
  • Preserves privacy by keeping raw video local
  • Sends only compressed frames or extracted metadata to central servers or the cloud

After the video is ingested, the preprocessing pipeline prepares the frames for machine learning. Frames are decoded and sampled, then resized to fit the model’s input size (like 512×512 for FFNet or 2048×2048 for APGCC). Pixel values are normalized, and color formats are converted (for example, from BGR to RGB).

Sometimes, techniques like histogram equalization or Gaussian blur are used to adjust lighting and make the model more reliable in different conditions. Region-of-interest (ROI) masking can also be applied to ignore parts of the frame that don’t matter, like static backgrounds or the sky.

The final result is a batch of clean, ready-to-use tensors, which may include extra info like timestamps, camera IDs, or GPS data. These are then sent to an inference engine like ONNX Runtime, TensorRT, or PyTorch, where models run in real time to produce useful crowd analytics.

Deep Learning Models for Crowd Management

Once the video frames are preprocessed, the next step is machine learning. This is where deep learning models analyze the frames to estimate crowd size, density, and individual positions. But not all areas require the same level of detail.

For example, a crowded airport gate demands high precision, while an open plaza may only need rough counts and basic alerts. That’s why we use a hybrid approach with two different models:

  • APGCC runs on the server and is used for detailed analysis in high-traffic or high-security zones.
  • FFNet runs on edge devices and is optimized for fast, efficient counting in general monitoring areas.

Each model is tuned for its environment, APGCC for accuracy, FFNet for speed and scalability. Together, they provide both depth and flexibility across different parts of a venue.

APGCC on the Server

APGCC is a powerful, compute-intensive model designed for detailed crowd analysis, especially in dense, occluded scenes where standard models often fail. It brings two core innovations:

  • Auxiliary Point Guidance (APG):
    Traditional point-based models have trouble matching detected points (proposals) to the actual people (targets) when crowds are very dense. APG solves this by introducing auxiliary positive and negative points during training. These points help the model learn where people really are, making it more accurate at finding individuals, even when their heads are partly hidden or blocked. This makes APGCC ideal for high-security zones like stadium entrances, airport queues, or metro gates where precise person-level localization matters.

  • Implicit Feature Interpolation (IFI):
    IFI allows the model to extract features at arbitrary spatial locations instead of fixed sampling grid points. This makes it robust to varying head sizes and densities. Whether people are packed closely together or spread out, APGCC dynamically adjusts its feature representation, improving both count and localization accuracy.

To handle its heavy computing needs, APGCC runs on powerful GPU servers like NVIDIA A100, T4, or V100. This lets it process video frames from many cameras at the same time. The results show the total number of heads, the exact pixel locations of each detected head, and, if needed, heatmaps that display crowd density.

FFNet on the Edge

At the edge, models must deliver fast and efficient results while running on limited hardware. FFNet is designed specifically for edge AI platforms like NVIDIA Jetson Xavier and Orin. It’s a compact, resource-friendly model that performs real-time crowd counting with low memory and power consumption.


FFNet extracts information from the scene at multiple scales, allowing it to accurately handle crowds of different sizes and distances. Its Focus Transition Modules (FTMs) use dynamic convolution, which means the model adapts how it processes features based on the spatial context. This improves accuracy by ensuring even small or distant individuals are detected, without adding extra computational load 

Results using FFNet 

FFNet processes smaller video frames and creates a density map to estimate crowd size. It does not give exact locations like APGCC but is effective for general crowd monitoring, alerts, and occupancy tracking.

Running FFNet on edge devices provides fast response times of 30 to 80 milliseconds per frame. It reduces network load by sending only summary data such as counts and alerts. This helps protect privacy because the raw video never leaves the device. The system is also easy to scale. You can support more cameras by adding more edge units.

Using two models, one on the server and another at the edge, is a setup that works well in practice. But it’s not the only way. The choice depends on the specific needs of the deployment.

For high-accuracy use cases like managing crowds at security checkpoints, server-side models like APGCC are the best fit. They offer strong precision and detailed output.

For fast, scalable monitoring across many locations, edge models like FFNet are more suitable. They work well on lightweight hardware and respond quickly.

Other models can also be used depending on what matters most, whether that’s speed, cost, hardware limits, or how easy the results are to interpret.

Multi-Camera Post-Processing

After individual deep learning models analyze each camera’s feed the next challenge is to merge these fragmented views into a single global picture. This post-ML stage is critical for accurate tracking, counting, and alerting across large, overlapping camera networks.

Shown above is homography warping, the first step, which aligns each camera’s view to a shared top-down perspective. Since every camera sees the scene from a different angle, their outputs, like head positions or density maps, aren’t naturally aligned. Warping uses precomputed transformation matrices to map all these outputs onto a common ground plane. This step is crucial for making sure that the same person appearing in multiple overlapping cameras isn’t mistakenly treated as multiple individuals.

Once everything is spatially aligned, the system performs multi-camera fusion to clean up duplicate detections. In overlapping zones, a person may still be detected more than once. To resolve this, the system applies Non-Maximum Suppression (NMS), to  compare overlapping detections and keeps only the one with the highest confidence. 

To further improve accuracy, visibility masks give more weight to regions seen by multiple cameras. If several cameras agree on a detection, it’s treated as more trustworthy. Together, warping and fusion ensure that the system delivers a unified, accurate view of the crowd without overcounting or missing people.

With a fused view in place, global tracking connects detections across time and space. Trackers like DeepSORT and ByteTrack associate individuals frame-to-frame, even as they move between cameras. Together, these post-processing steps turn raw detections into a consistent, live map of crowd movement across zones. 

Handling Data at Scale

Building a crowd management system is easy. Scaling it across a city with thousands of video feeds is the challenge. A small test with five cameras usually works fine, but handling real-time data at city scale either breaks the system or proves its design. The key difference is how the data is managed.

Handling Data on Edge

In large-scale systems, the key challenge is managing data efficiently. Instead of moving heavy raw video, these systems move insights. Raw video demands too much bandwidth, slows transmission, drives up storage costs, and makes searching difficult. To solve this, video is processed right at the source, either in the cameras or nearby edge devices. Simple models like FFNet extract only essential information like crowd counts, density maps, and coordinates. 

This lightweight data powers real-time alerts, dashboards, and analytics without the overhead of raw footage. This data flows through event buses like Kafka or Pulsar and immediately splits into two directions.

  • First, a time-series database collects and organizes live metrics such as crowd counts by area, how quickly crowds form, and congestion levels.
  • Second, a high-speed NoSQL store indexes location-based data and alert events, allowing for fast geospatial queries and incident analysis.

Every piece of data is tagged with a timestamp, location, and follows a set format from the beginning. This means no cleanup is needed later. The data is instantly ready for real-time analysis and display. Keeping data clean and organized is the key to real-time awareness at scale.

Handling Raw Video

Raw video isn’t completely discarded. Cameras break their streams into five-minute chunks, compress them, and store them in systems like MinIO or S3. Only important segments tied to critical events are kept long-term. Other footage is kept for seven to thirty days, then deleted or moved to cold storage. This keeps costs predictable and follows rules like GDPR.

The much smaller metadata is kept longer. It supports analytics, reporting, and trend tracking, and helps connect live and archived footage without searching through huge amounts of video.

In critical areas such as entry gates and high-traffic zones,  raw video streams are sent to cloud-based systems like APGCC for advanced analysis. This tiered approach balances processing load and ensures that important events receive the detailed attention they require.

Scalability and Automation

Scalability isn’t just about adding more servers. It means building the system so every part can grow smoothly as needed. For example, Kafka handles more video feeds by adding brokers, which share the workload. Databases get bigger by splitting data into pieces called shards, so they can work faster without slowing down. Storage systems add more nodes to hold more data safely and keep it easy to access.

At the edge, devices save data locally when the network goes down. Once the connection is back, they send the data automatically. This way, the system keeps running without problems, even if parts of the network have issues or get busy.

Automation is essential to handle all this data smoothly. Tools like Airflow manage tasks such as cleaning up old data, summarizing information, archiving, and deleting files without anyone having to do it manually. Data is grouped and updated regularly every hour, day, and week so reports and trends are always current and easy to access. Alerts are organized by time and location, making it quick to find important events. 

Core functionalities & Applications

Crowd management systems are already in use at airports, train stations, stadiums, retail spaces, and city centers. They are changing how these large environments are monitored and controlled.

In transport hubs, real-time people count how many passengers are in each area. Entry and exit flows are constantly monitored, giving operators a live view of occupancy across terminals and platforms. This visibility is critical to detect congestion early. Airports use this data to adjust staffing at security checkpoints. Train stations reroute passengers before crowding becomes a problem. Bus terminals change schedules based on actual foot traffic.

Density estimation adds a deeper level of insight. It shows how tightly packed people are in a space. When a zone becomes too crowded, the system sends alerts. Operators can then open extra gates or redirect flows to prevent bottlenecks without building new infrastructure.

The picture showcases density estimation using heatmaps

Large venues like stadiums and festivals use these systems to create a live, top-down view by combining multiple video feeds. Heatmaps show where crowds are gathering, such as at gates or exits, allowing organizers to deploy staff or adjust signage quickly. The system also learns from past events, predicting crowd surges before they happen and helping prevent issues during busy times like after a game or during a main performance.

Retailers use similar technology to understand how customers move inside stores. Entry and exit data helps match staffing to demand. Heatmaps and movement tracking reveal which sections attract attention, where customers linger, and which areas are overlooked. Unlike simple counters, these systems track flow and behavior, showing how changes to store layouts impact shopping patterns. This turns physical stores into spaces that can be measured and optimized as easily as websites.

In cities, this technology provides valuable insights for urban planning. Planners can see how pedestrians actually use sidewalks, crossings, and public plazas instead of relying on assumptions. During large events like festivals or protests, AI combines live feeds from cameras, drones, and sensors into one dashboard. This helps officials coordinate teams and respond faster to unexpected crowd movements.

Over time, the system improves by learning from patterns and refining its predictions. What begins as basic visibility evolves into foresight, giving operators the ability to manage real-world movement with precision.

Want to build a Crowd Management System?

If you're planning to deploy or scale a real-time crowd monitoring system, we can help you build one that works at city scale, under pressure, and without breaking the bank. From smart data pipelines to edge processing and compliance-ready storage, we design systems built to last.

Contact us today and let's build a system that keeps people safe, informed, and moving.

Subscribe to stay informed

Subscribe to our newsletter to stay updated on all things AI!
Subscribe
Awesome, you subscribed!
Error! Please try again.