Object Counting (Present)

Overview

Object counting (present) is a solution within PeekingDuck’s suite of smart monitoring use cases. It counts the number of objects detected by PeekingDuck’s object detection models at the present point in time, and calculates statistics such as the cumulative average, maximum and minimum for further analytics. Up to 80 types of objects can be counted, including humans, vehicles, animals and even household objects. Thus, this can be applied to a wide variety of scenarios, from traffic control to counting livestock.

See also

For advanced counting tasks such as counting tracked objects over time or counting within specific zones, refer to PeekingDuck’s other smart monitoring use cases.

../_images/object_counting_present.gif

In the GIF above, the count and statistics change as the number of detected persons change. This is explained in the How It Works section.

Demo

To try our solution on your own computer, install and run PeekingDuck with the configuration file object_counting_present.yml as shown:

Terminal Session

[~user] > peekingduck run --config_path <path/to/object_counting_present.yml>

How It Works

There are 3 main components to this solution:

  1. Object detection,

  2. Count detections, and

  3. Calculate statistics.

1. Object Detection

We use an open source object detection model known as YOLOv4 and its smaller and faster variant known as YOLOv4-tiny to identify the bounding boxes of chosen objects we want to detect. This allows the application to identify where objects are located within the video feed. The location is returned as two x, y coordinates in the form \([x_1, y_1, x_2, y_2]\), where \((x_1, y_1)\) is the top left corner of the bounding box, and \((x_2, y_2)\) is the bottom right. These are used to form the bounding box of each object detected. For more information on how to adjust the yolo node, check out its configurable parameters.

../_images/yolo_demo.gif

2. Count Detections

To count the number of objects detected, we simply take the sum of the number of bounding boxes detected for the object category.

3. Calculate Statistics

The cumulative average, minimum and maximum over time is calculated from the count from each frame.

Nodes Used

These are the nodes used in the earlier demo (also in object_counting_present.yml):

nodes:
- input.visual:
    source: 0
- model.yolo:
    detect: ["person"]
- dabble.bbox_count
- dabble.statistics:
    identity: count
- draw.bbox
- draw.legend:
    show: ["count", "cum_avg", "cum_max", "cum_min"]
- output.screen

1. Object Detection Node

By default, the node uses the YOLOv4-tiny model for object detection, set to detect people. Please take a look at the benchmarks of object detection models that are included in PeekingDuck if you would like to use a different model or model type better suited to your use case.

2. Object Counting Node

dabble.bbox_count takes the detected bounding boxes and outputs the total count of bounding boxes. This node has no configurable parameters.

3. Statistics Node

The dabble.statistics node calculates the cum_avg, cum_max and cum_min from the output of the object counting node.

4. Adjusting Nodes

For the object detection model used in this demo, please see the documentation for adjustable behaviors that can influence the result of the object counting node.

For more adjustable node behaviors not listed here, check out the API Documentation.