This project will no longer be maintained by Intel.
This project has been identified as having known security escapes.
Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.
Intel no longer accepts patches to this project.
Details | |
---|---|
Target OS: | Ubuntu* 18.04 LTS |
Programming Language: | C++ |
Time to Complete: | 45 min |
This application is one of a series of IoT reference implementations illustrating how to develop a working solution for a particular problem. It demonstrates how to create a smart video IoT solution using Intel® hardware and software tools. This people counter solution detects people in a designated area, providing number of people in the frame, their average duration in the frame, and the total count.
The counter uses the Inference Engine included in the Intel® Distribution of OpenVINO™ toolkit. A trained neural network detects people within a designated area by displaying a bounding box over them. It counts the number of people in the current frame, the duration that a person is in the frame (time elapsed between entering and exiting a frame), and the total number of people detected, and then sends the data to a local web server using the Paho* MQTT C client libraries.
- 6th to 8th generation Intel® Core™ processors with Iris® Pro graphics or Intel® HD Graphics.
-
Ubuntu* 18.04 LTS
Note: We recommend using a 4.14+ Linux* kernel with this software. Run the following command to determine your kernel version:uname -a
-
OpenCL™ Runtime Package
-
Intel® Distribution of OpenVINO™ toolkit 2020 R3 release
-
Node v6.17.1
-
Npm v3.10.10
-
MQTT Mosca* server
Refer to Install Intel® Distribution of OpenVINO™ toolkit for Linux* to learn how to set up the toolkit.
Install the OpenCL™ Runtime Package to run inference on the GPU. It is not mandatory for CPU inference.
Steps to clone the reference implementation:
sudo apt-get update && sudo apt-get install git
git clone https://github.com/intel-iot-devkit/people-counter-cpp.git
This application uses the person-detection-retail-0013 Intel® model, that can be accessed using the model downloader. The model downloader downloads the .xml and .bin files that will be used by the application.
To install the dependencies of the RI and to download the person-detection-retail-0013 Intel® model, run the following command:
cd <path_to_the_people-counter-cpp_directory>
./setup.sh
Make sure the npm and node versions are exact, using the commands given below:
node -v
The version should be v6.17.1
npm -v
The version should be v3.10.10
Note: If the Node and Npm versions are different, run the following commands:
sudo npm install -g n
sudo n 6.17.1
Note: After running the above commands, please open a new terminal to proceed further. Also, verify the node and npm versions from the new terminal.
Go to people-counter-cpp directory:
cd <path_to_people-counter-cpp_directory>
cd webservice/server
npm install
npm i jsonschema@1.2.6
cd ../ui
npm install
There are three components that need to be running in separate terminals for this application to work:
- MQTT Mosca server
- Node.js* Web server
- FFmpeg server
Go to people-counter-cpp directory:
cd <path_to_people-counter-cpp_directory>
Ensure that no process is running at port address 3000 using the following command:
sudo lsof -i:3000
Navigate to the node-server
path and run the server using following commands:
cd webservice/server/node-server
node ./server.js
If successful, this message will appear in the terminal:
connected to ./db/data.db
Mosca server started.
Open a new terminal and run the commands below:
cd ../../ui
npm run dev
If successful, this message will appear in the terminal:
webpack: Compiled successfully.
Open a new terminal and run the below commands:
cd ../..
sudo ffserver -f ./ffmpeg/server.conf
Open a new terminal in the current directory and run the below command to set up the environment variables required to run the Intel® Distribution of OpenVINO™ toolkit applications:
source /opt/intel/openvino/bin/setupvars.sh
Note: This command only needs to be executed once in the terminal where the application will be executed. If the terminal is closed, the command needs to be executed again.
This application uses the SSD derived person detection model bundled with the Intel® Distribution of OpenVINO™ toolkit. To do a clean re-build, run the following commands:
cd ieservice
mkdir -p build && cd build
cmake ..
make
The new version of the software will be built as people-counter/ieservice/bin/intel64/Release/obj_recognition. Switch to the directory where the main application was built:
cd ../bin/intel64/Release
Set up the needed MQTT environment variables:
export MQTT_SERVER=localhost:1884
export MQTT_CLIENT_ID=cvservice
./obj_recognition -i Pedestrain_Detect_2_1_1.mp4 -m /opt/intel/openvino/deployment_tools/tools/model_downloader/intel/person-detection-retail-0013/FP32/person-detection-retail-0013.xml -d CPU -thresh 0.65 | ffmpeg -v warning -f rawvideo -pixel_format bgr24 -video_size 768x432 -i - http://localhost:8090/fac.ffm
Note:To see the output on web based interface, open the link http://localhost:8080 on browser. Refresh the browser window if the video does not play automatically.
-
To use GPU in 16-bit mode, use the following command:
./obj_recognition -i Pedestrain_Detect_2_1_1.mp4 -m /opt/intel/openvino/deployment_tools/tools/model_downloader/intel/person-detection-retail-0013/FP16/person-detection-retail-0013.xml -d GPU -thresh 0.65 | ffmpeg -v warning -f rawvideo -pixel_format bgr24 -video_size 768x432 -i - http://localhost:8090/fac.ffm
To see the output on web based interface, open the link http://localhost:8080 on browser.
-
To use GPU in 32-bit mode, use the following command:
./obj_recognition -i Pedestrain_Detect_2_1_1.mp4 -m /opt/intel/openvino/deployment_tools/tools/model_downloader/intel/person-detection-retail-0013/FP32/person-detection-retail-0013.xml -d GPU -thresh 0.65 | ffmpeg -v warning -f rawvideo -pixel_format bgr24 -video_size 768x432 -i - http://localhost:8090/fac.ffm
To see the output on web based interface, open the link http://localhost:8080 on browser.
Note: The Loading time for GPU is more, so it might take few seconds to display the output. If request busy error is observed, please restart the ffmpeg server and try again.
./obj_recognition -i Pedestrain_Detect_2_1_1.mp4 -m /opt/intel/openvino/deployment_tools/tools/model_downloader/intel/person-detection-retail-0013/FP16/person-detection-retail-0013.xml -d MYRIAD -thresh 0.65 | ffmpeg -v warning -f rawvideo -pixel_format bgr24 -video_size 768x432 -i - http://localhost:8090/fac.ffm
To see the output on web based interface, open the link http://localhost:8080 on browser.
Note: The Intel® Neural Compute Stick can only run FP16 models. The model that is passed to the application, through the -m <path_to_model> command-line argument, must be of data type FP16.
Use the camera ID followed by -i
, where the ID is taken from the video device (the number X in /dev/videoX). On Ubuntu, to list all available video devices use the following command:
ls /dev/video*
For example, if the output of the above command is /dev/video0, then camera ID would be: 0
Run the application:
./obj_recognition -i 0 -m /opt/intel/openvino/deployment_tools/tools/model_downloader/intel/person-detection-retail-0013/FP32/person-detection-retail-0013.xml -d CPU -thresh 0.65 | ffmpeg -v warning -f rawvideo -pixel_format bgr24 -video_size 768x432 -i - http://localhost:8090/fac.ffm
To see the output on web based interface, open the link http://localhost:8080 on browser.
Note: Use the camera's resolution with -video_size
to observe the output on the web based interface.