Gravio Blog
December 9, 2021

[Tutorial] Easy IoT: When is your Office, Store or Waiting room busiest?

Tutorial on how to see how busy your Office, Store or Waiting room is by using a simple people counting feature using a USB or Network Camera with Gravio, so that you can learn and enhance how people use and interact with your environments.
[Tutorial] Easy IoT: When is your Office, Store or Waiting room busiest?

As part of our series on Easy IoT, we’re creating simple but effective solutions with Gravio that enable non-technical teams to create simple experiences for their office, retail or other work environments. And this article is special because it can be done using the Free edition of Gravio!


Here we’re using Gravio's free people counting feature to see how busy your office or retail space waiting room gets over time, and even let you know when it’s getting too busy!

This solution helps answer and solve questions like:

  1. What days and times are we busiest?
  • Stores: customers can come in and out very frequently during peak hours - or even minutes, let’s optimise for when we’re busiest
  • Waiting rooms and spaces: are they consistently busy throughout the day or just certain times
  • Offices: staff may choose certain days of the week, and hours of the day to do their work flexibly - let’s make sure there’s space and comfort at all times
  1. I want to know when we’re getting too busy, so we can help keep our customers or visitors happy

How you use this information may also vary e.g. with Offices you may mostly be interested in the early to mid-morning rush, whereas for waiting areas it’s more about spacing out appointments throughout the day.

The above helps you gain insights into your environment in ways that you couldn’t before, and more easily than with other solutions that require technical skills, as well as the time to build a solution and keep it working.


  • Gravio Basic subscription
  • 1 x USB Camera (Mac only) OR a Network camera with ONVIF support and Wifi to access it (note ONVIF support varies by camera) - more info here or video here
  • A computer (Mac or Windows) with Gravio Studio and Gravio HubKit installed, set up and ready to go!
  • Google Sheets to analyse and visualise our data


Reminder: for your Gravio environment to work throughout the day for the period you're interested in, your computer will need to stay switched on so that Gravio can capture and process all the data from the camera(s).


Note: we use macOS for this article, but you should be able to follow along with Windows too.

Part 1. Setup your camera (USB or Network) in Gravio Studio

Whether using a USB (or built-in) or Network (ONVIF) cameras, Gravio Studio will show the camera options just the same. Just make sure they're either plugged into your computer or are set up and accessible from the same network.

1. Open Gravio Studio and select your local HubKit environment

Gravio Studio available Hubs view

2. Go to the Device tab, then click the Device List button

Device List button location

3. In the Device List modal, in the left-hand column Camera section, you should see your camera(s), like a USB or ONVIF camera. Select the Camera you want to use, and update the settings as below:

  • Capture Type: Picture
  • Capture Interval (in seconds): 3600 (i.e. every hour, take a photo to analyse)
Device List modal view


  • Capture Interval is the amount between updates from Gravio, if you have a high or really variable rate of people coming in and out of the area you are counting, you may want to increase the level to say once every 10-30 minutes

If you want to see the Images captured along with frames around the faces, tick Save Image and Draw Detected Area Frame.

Part 2. Setup the People Counter Inference Model

Click Settings > Image Inference Model in the left-hand menu > Click Deploy for NumberOfPeopleTensorFlow

Note: This will take a moment to download the model, depending on your internet speed.

Image Inference Model list

Part 3. Setup your environment

1. Create an Area, named after your environment, like Smart Shop / Store, Office, Waiting Room, we’ll use Smart Store.

Add new Area button

2. The dialog should then ask you to create a Layer, call it People Counter, then scroll to the bottom of the list and select 'NumberOfPeopleTensorFlow' and click Add

New Layer modal view

3. Select your new Smart Store layer on the right-hand side, click (+) button and select your Camera and click Bind, click Close.

Available Devices list for binding to new layer

4. Then click On in the list Device list next to your People Counter layer - this starts the capture interval for the camera.

Devices associated with layer

Part 4. Creating Actions - how to do things with your People counts

1. Open the Actions panel, and create a new Action called PeopleCountCSV

2. Click Add Step, select a File Write step, and enter the following info:

  • Filename: people-count-temp.csv
  • Add a Pre Mapping (+)
  • Enter: cv.Payload in the first input, and "Timestamp,People Count\n"
Action view for File Write step

3. Add a Sensor Data DB step, and enter the following info:

  • Area Id: Smart Store (or whatever you named yours)
  • Layer ID: People Counter 
  • From Previous: 1 - this will be for 1 day i.e. today (we set the Timescale next)
  • Timescale: Days
Action view for Sensor Data DB

4. Add a File Write step, and enter the following info:

  • Filename: people-counter-temp.csv
  • Check the Append checkbox
  • Add a Pre Mapping (+) and enter: cv.Payload in the first input, and DateFormat(cv.Payload.Timestamp, "2006-02-01 15:04:05")+","+cv.Payload.Data+"\n"
Action view for File Write step

Tip: If you want to test an Action, simply click the Play button in the top right

Then depending on your computer's operating system the file is in the following location: Windows: C:\ProgramData\HubKit\action\actmgr\data\ or macOS: /Library/Application Support/HubKit/action/scripts/actmgr/data/

5. Add an Exec step, and enter the following:

  • Command: cp people-count-temp.csv people-count-`date +%F`.csv
  • Output: select Stdout and Stderr
Action view for Exec step

6. Once you're done you can close the Action (it will save automatically).

Part 5. Creating Triggers - creating a daily spreadsheet with your People counts for analysis

The idea with a Trigger is to make an Action happen under certain circumstances e.g. an event happening, like a Button being pushed, or in our case, at a certain time of day we want a snapshot of our data over a period: Today’s hourly People Counts, taken at the end of the working day, so that we can analyse that information separately or against other days.

  • Open Triggers view
  • Click the Clock+ icon to create a Timer Trigger:
Trigger view Add Timer Trigger button

Then enter the following details into the Trigger:

  • Timer Trigger Name: Export Today’s People Count
  • In Schedule Tab:
  • Repeat: Daily
  • Start at: 22 H 05 M 00 S - But set this as per your needs (e.g. Store closes at 10pm, so 22 H)
  • In Action tab, select the PeopleCountCSV action
  • Click Add
  • Then tick On in the Trigger list for your new trigger to enable it

Note: your HubKit has to be on at the times this Trigger is run, so don’t forget to leave your computer on for the hours you’re interested in!

Timer Trigger configuration setup

Setup complete!

Your setup is now complete and should start capturing the number of people in your space every hour, and then on a daily basis you will have a file created for the day with those stats. 

(As mentioned above, you can always run an action independently to create those files to start analysis sooner!)


Part 6. Analysis: Open and analyse your daily People Count CSVs

We're using Google Sheets to analyse the data here:

1. Create a new / Blank sheet

2. Click File > Import

3. Click the Upload tab, then Select a file from your device

4. Look for and select the day's .csv file you're interested in analysing (according to your computer's operating system):

Windows: C:\ProgramData\HubKit\action\actmgr\data\
macOS: /Library/Application Support/HubKit/action/scripts/actmgr/data/

5. In the modal the comes up, Click Import data

6. Create a new column in the new sheet next to the Timestamp column, and in the first row insert Hour of Day text as a heading

Under the Hour of Day insert the following function =TEXT(A2, "hAM/PM") (we'll use it to label our charts later). 

7. This should then show an hour (depending on your data) formatted like the below:

Google Sheet function

8. Select the bottom right corner of the cell and drag that down to create the Hours of Day for each of your rows, it should look something like the following:

Highlighted hours to chart

9. Then select one of the Hour of Day cells, and click Insert > Chart

Google Sheets should then do some auto-magic and create the following:

Chart showing Hour of Day and Number of people data

If Google didn't automatically create the chart for you, you can do the following:

  1. Click Add X-axis in the Chart editor column on the right-hand side
  2. Select all the values for the Hour of Day column, click OK
  3. Then click Add Series and select all the values for in the Number of People column, Click OK

You should now have a chart that shows how busy your space is during the different hours of the day.

As a next goal, you could import data for additional days and compare those to see more patterns, like the following:

Advanced chart showing more comparative data - across days of week

And another example for comparing data over time to identify patterns for the same day over multiple weeks:

Advanced chart showing more comparative data - across a specific day


In many environments there’s a lot of data that doesn't get captured and therefore can't be analysed, which in turn can help gain understanding and learnings from our environments so that we can enhance them and more. 

Starting to capture information about your environment will help reveal insights that you didn't know were a thing, or didn't know you needed, and wouldn't have been able to capture otherwise. Once you start exploring your environment with IoT, you can discover more and more.

Latest Posts
[Tutorial] Using Ollama, LLaVA and Gravio to Build a Local Visual Question and Answer AI Assistant
Tutorial on how to use Gravio, Ollama, LLaVA AI to build a local Visual Question and Answer (VQA) application. Anyone can build this solution without coding required and deploy it as a PoC or even in a production environment if the use case fits.
Monday, June 3, 2024
Read More