Maskcam - Crowd Face Mask Usage Monitoring based on Jetson Nano¶
Due to the ravages of the COVID - 19, in many public places, we often see the requirement to wear a mask. There are usually managers at the gate of the area to observe whether people are wearing masks. Maybe it's a very simple task for humans, but if we combines it with Jetson Nano, graphics capture and edge computing with AI, it will be a very interesting and socially valuable task.
MaskCam was developed by Berkeley Design Technology, Inc. (BDTI) and Tryolabs S.A., with development funded by NVIDIA. MaskCam is offered under the MIT License. For more information about MaskCam, please see the report from BDTI. If you have questions, please email BDTI at email@example.com.
In this project, we will use the NVIDIA® Jetson Nano™ 4GB Developer Kit along with other accessories. At the same time, you can choose the A206 Carrier Board from Seeed, which has the same size and functional design as NVIDIA's official carrier board, and also, it has excellent stability and versatility.
NVIDIA® Jetson Nano™ 4GB Developer Kit (JetPack 4.6)
A206 Carrier Board(optional)
7-inch hdmi monitor and HDMI cable
USB Docking Station
Mouse and Keyboard
5V 4A Power Adapter
PC with Windows11 (or Windows10/Ubuntu18.04/ OSX Big Sur)
Video Software (Display RTSP streams,like VLC/QuickTime/PotPlayer)
Jetson Nano Setup¶
Step 1. Download MaskCam container from Docker Hub.¶
sudo docker pull maskcam/maskcam-beta
Step 2. Find Jetson Nano IP Address with the command
Step 3. Start MaskCam with docker.¶
Remember to connect your Jetson Nano with a USB camera, and then, tab the command below into the terminal.
sudo docker run --runtime nvidia --privileged --rm -it --env MASKCAM_DEVICE_ADDRESS=<your-jetson-ip> -p 1883:1883 -p 8080:8080 -p 8554:8554 maskcam/maskcam-beta
<your-jetson-ip> with your own Jetson Nano's IP address in this command.
If you don't want to use the default input device, there are also two different commands to choose and replace the command above.
Use the /dev/video1 camera device:
#Use the /dev/video1 camera device sudo docker run --runtime nvidia --privileged --rm -it --env MASKCAM_INPUT=v4l2:///dev/video1 --env MASKCAM_DEVICE_ADDRESS=<your-jetson-ip> -p 1883:1883 -p 8080:8080 -p 8554:8554 maskcam/maskcam-beta
#Use the CSI camera device sudo docker run --runtime nvidia --privileged --rm -it --env MASKCAM_INPUT=v4l2://0 --env MASKCAM_DEVICE_ADDRESS=<your-jetson-ip> -p 1883:1883 -p 8080:8080 -p 8554:8554 maskcam/maskcam-beta
Step 4. View the live vedio stream through the
Streaming at rtsp://aaa.bbb.ccc.ddd:8554/maskcam
aaa.bbb.ccc.ddd is the address that you provided in
You can copy-paste that URL into your RSTP streaming viewer on another computer. In the video stream, if you are not wearing a mask, you will see a red frame on your face. Otherwise, you will see a green frame.
MQTT Server Setup¶
In addition to the basic function, it also includes the function of the remote server in this library which means your PC can receive statistics from the device, store them in a database, and have a web-based GUI frontend to display them.
In this article, all demos about the server are based on Window11 system host, you can also find the instruction using Linux system through this article: Maskcam.
Step1. Install Docker and Docker-compose on your PC¶Download the installation package of Docker from its official website: https://docs.docker.com/get-docker/
Note: If there exists a message that says
WLS 2 installization is incomplete. in the progress of installization, click the link in the prompt box, download and install thee Linux kernel update package.
The you can run
Step2. Set up build directory¶
Windows PowerShell as administrator
Move to the root of the drive which you will be using, such as :
Download MaskCam repo :
Invoke-WebRequest https://github.com/bdtinc/maskcam/archive/refs/heads/main.zip -OutFile e:\maskcam.zip
Unzip it to the path
Expand-Archive e:\maskcam.zip -DestinationPath e:\maskcam
Move To the maskcam server folder, which has four containers: the Mosquitto broker, backend API, database, and Streamlit frontend.
Then, create the
.env files by copying the default templates:
cp database.env.template database.env cp frontend.env.template frontend.env cp backend.env.template backend.env
<DATABASE_NAME> fields with your own values
Step3. Build and run local server¶
After editing the database environment file, you're ready to build all the containers and run them with a single command:
sudo docker-compose up -d
Next, open a web browser and enter the server IP to visit the frontend webpage:
<server IP> with your own IP address.
If you see a
ConnectionError in the frontend, wait a couple more seconds and reload the page. The backend container can take some time to finish the database setup.
If you wait a couple more seconds and reload the page but it is still a
ConnectionError in the frontend, please make sure the ports: <5432> and <80> are not being occupied or listened up.
If you visit the frontend webpage successfully the first time but failed the next, the best way to solve it currently is to re-install docker.
Step4. Point Jetson Nano at your local server¶
Return to your Jetson Nano's terminal, and then run the maskcam container with the command below:
sudo docker run --runtime nvidia --privileged --rm -it --env MQTT_BROKER_IP=<server IP> --env MQTT_DEVICE_NAME=my-jetson-1 --env MASKCAM_DEVICE_ADDRESS=<your-jetson-ip> -p 1883:1883 -p 8080:8080 -p 8554:8554 maskcam/maskcam-beta
<server IP> and
<your-jetson-ip> with your own server and Jetson Nano's IP address.
After that, you can choose your device on webpage as shown below:
Finally, you can see the data collected by Jetson Nano transmitting to the Server.