This reference implementation showcases a retail capacity limit application, line monitoring application, one-way monitoring application and social distancing application.
- Retail capacity limit application showcases where a people counter keeps track of how many people are in the store based on the detected people entering and exiting the store. Single virtual line is configured for both entrance and exit areas to indicate the limits of entering and exiting the area of interest.
- One-way retail application monitors if people are walking in the correct direction in a one-way direction store aisle and reports the people walking in the wrong direction.
- Line monitoring retail application counts people standing in, waiting line at a retail store. The application estimates how many people are waiting in a line by doing an intersection between the people detected and a virtual line.
- Social distancing application gives count of people who do not maintain social distance.
Select Configure & Download to download the reference implementation and the software listed below.
Time to Complete
20 - 30 minutes
The below hardware is recommended for use with this reference implementation. See the Recommended Hardware page for other suggestions.
- Ubuntu* 18.04.3 LTS
- 6th to 11th Generation Intel® Core™ processors with Intel® Iris® Plus Graphics or Intel® HD Graphics
- USB webcam (optional)
How It Works
The application uses the Inference Engine and Model Downloader included in the Intel® Distribution of OpenVINO™ toolkit doing the following steps:
- Ingests video from a file, processing frame by frame.
- Detects people in the frame using a pre-trained DNN model.
- Extracts features from people detected using a second pre-trained DNN in order to do a tracking of the people.
- If analytics field is socialdistancing in the camera_config.json file, then the application computes Euclidean distance between all the people and checks to see whether any people are violating N pixels apart.
- If analytics field is capacitylimit in the camera_config.json file, then the application checks if people cross the predefined virtual gates based on the coordinates and identify in which direction the virtual gate was closed to determine if it is an entry or exit event.
- The people counter is updated based on the entry and exit data.
- If analytics field is capacitylimit in the camera_config.json file, then the application checks if any of the tracked persons are not going in the predefined allowed direction.
- The oneway counter is updated based on the people violating the specified direction.
- If analytics field is linemonitoring in the camera_config.json file, then the application checks for the count of people in the line area. The queue line area is defined by a virtual line in the configuration file. The result of the amount of people in line are showcased in the screen.
- Store total violations count of social distancing data in InfluxDB*.
- Visualize the stored data of InfluxDB on Grafana* dashboard.
The DNN models are optimized for Intel® architecture and are included with the Intel® Distribution of OpenVINO™ toolkit.
Select Configure & Download to download the reference implementation and then follow the steps below to install it.
- Open a new terminal, go to the downloaded folder and unzip the downloaded RI package:
- Go to social_distancing_for_retail_settings/ directory:
- Change permission of the executable edgesoftware file:
chmod 755 edgesoftware
- Run the command below to install the Reference Implementation:
- During the installation, you will be prompted for the Product Key. The Product Key is contained in the email you received from Intel confirming your download.
- When the installation is complete, you see the message “Installation of package complete” and the installation status for each module.
- Go to the working directory:
NOTE: In the command above, <version> is the Intel® Distribution of OpenVINO™ toolkit version.
Step 2: Build the Docker Images
NOTE: Run the commands mentioned below from the working directory, unless specified otherwise.
Build the Docker images with the command:
sudo -E docker-compose build
Run the Application
NOTE: The steps below use sample videos included with the Reference Implementation. For instructions on how to run the application with feed from a camera or how to use other videos, see Optional Steps section.
- Set the HOST_IP environment variable with the command:
export HOST_IP=$(hostname -I | cut -d' ' -f1)
- Start the application with the command:
sudo -E docker-compose up -d
- Check if the containers are running properly with the command:
sudo -E docker-compose ps
- Check retailpandemic container logs with the command:
sudo docker logs -f retailpandemic
Visualize the Data on Grafana
1. Open an Internet Browser and go to http://localhost:3000.
NOTE: If accessing remotely, go to http://:3000. Get host system IP address using: hostname -I | cut -d' ' -f1
2. Log in with user as admin and password as admin.
3. Click Home and Select the RPS to open the main dashboard.
Below are the dashboards for different analytics, which are mentioned in the camera_config.json.
To open the Grafana Dashboard for a particular camera with the detection results and other data metrics, click on the camera feed on the small window, as shown in the figure below.
NOTE: To close the small window with camera feed, click the close button (X) on the top left corner of the window.
To view the detection results of all the configured camera feeds, click on View All Streams from top right corner from the main Grafana Dashboard, i.e., RPS (refer to Figure 7: Grafana Main Dashboard – RPS)
NOTE: To open combined streams in full tab go to http://localhost:5000/get_all_streams.
Configure the Input
The camera_config.json file on the working directory contains all the necessary configurations including the path to default input video. If you wish to change the input, edit camera_config.json file and add the required information. The role of elements in the camera_config.json file are:
- analytics: Name of the application such as socialdistance, linemonitoring, onewaymonitoring and capacitylimit.
- capacity_coords: Coordinates of the door/line segment.
- capacity_limit: Total capacity of people in retail.
- oneway_coords: Coordinates of the door/line segment.
- oneway_area: Buffer area of interest around the coordinates to find oneway violation.
- oneway_direction: Direction of violation such as “Up”, “Down”, “Right” or “Left”.
- linemonitoring_coords: Coordinates of the door/line segment.
- device: Hardware Device to be used for inferencing. (e.g.: CPU)
NOTE: Supported hardware devices are CPU, HDDL and MYRIAD. You can also use a combination of these using MULTI (e.g.: MULTI:CPU,HDDL)
- path: path to the input video.
NOTE: Input videos should always be placed in the /resources folder. To use camera stream instead of video, replace the video file name with /dev/video0. To use RTSP stream instead of video, replace the video file name with the RTSP link.
NOTE: If any of the device value in camera_config.json has MYRIAD, add the following line to smartcity service in docker-compose.yml file:
Validate the configuration file after changes (optional) with the command:
cd app/ && python3 validate_config.py && cd ../
Restart the container:
sudo docker restart retailpandemic
Stop the application
Stop all the containers using the command:
sudo docker-compose down
Summary and Next Steps
This application successfully leverages Intel® Distribution of OpenVINO™ toolkit plugins for detecting and measuring distance between the people and storing data to InfluxDB*.
To continue learning, see the following guides and software resources:
Limitation in Distance between Individual Cameras
The distance between individual cameras, which is configured using their geographic coordinates, should not exceed to the range of hundreds of kilometers. If the distance exceeds the limit, all the Map drop pins may not be displayed on the home screen.
Issue with Running the Application on GPU Device
You might face an issue running the application on GPU device.
Address already in use
If running the application results in Error starting userland proxy: listen tcp4 0.0.0.0:3000: bind: address already in use, use the following command to check and force stop the process:
sudo kill $(pgrep grafana)
NOTE: If the issue persists, it may be possible that Grafana is running in a Docker container. In that case, stop the container using:
sudo docker stop $(sudo docker ps -q --filter expose=3000)
If you're unable to resolve your issues, contact the Support Forum.
Product and Performance Information
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.