Using a Nvidia Jetson Nano running OpenDataCam, it simple count people and vehicles on almost any video feed, and send the data to a InfluxDB Cloud instance using Node-RED via a cellular connection for remote deployments.
Complete details and instructions for this project can be found on the Hologram blog. This page only supplies supporting information and code.
To use nodered-flow.json, you need to install additional nodes
npm install node-red-contrib-stackhero-influxdb-v2
The D-Link DWM-222 that I used for this project required some additional setup, and you might find this information relevant for other modems as well.
Dongles intended for Windows machines will start by showing as a mass storage device for driver download, and then change to modem mode when it detects a driver. To force this switch on Linux, we use USB_ModeSwitch. There were no configuration files for my modem, so I had to create a custom config file, using the vendor and product IDs that I was able to get by running lsusb
.
Bus 001 Device 005: ID 2001:ac01 D-Link Corp.
Create the config file
sudo nano /etc/usb_modeswitch.d/2001\:ac01
Copy the following contents into the file.
# D-Link DWM-222 A2
DefaultVendor=0x2001
DefaultProduct=0xac01
TargetVendor=0x2001
TargetProduct=0x7e3d
StandardEject=1
OptionMode=0
Open the udev rules file for USB_ModeSwitch
sudo nano /lib/udev/rules.d/40-usb_modeswitch.rules
Add the following entry
# D-Link DWM-222 A2
ATTR{idVendor}=="2001", ATTR{idProduct}=="ac01", RUN+="usb_modeswitch '/%k'"
Restart the Jetson, and run lsusb
to check if the modeswitch worked. The result should be
Bus 001 Device 005: ID 2001:7e3d D-Link Corp.
Check if ModemManager detects the modem using mmcli -L
If not the modem was probably not assigned a serial ID. This can be confirmed by running ls /dev/ttyUSB*
, which should return nothing.
Assign the dongle a ID
sudo modprobe option;sudo sh -c "echo 2001 7e3d > /sys/bus/usb-serial/drivers/option1/new_id"
Running ls /dev/ttyUSB*
should now return ttUSB0
to ttyUSB4
Running mmcli -L
should now show the modem
The rest of the Network Manager setup instructions are in the Hologram blog post
If your USB web cam is not detected by OpenDataCam, after updating config file sudo nano ~/opendatacam/config.json
"VIDEO_INPUT": "usbcam"
-
Verify if you have an usbcam detected
ls /dev/video* # Output should be: /dev/video0
-
Check what resolution and framerate your webcam supports, by running
v4l2-ctl --list-formats-ext
. In my case it was 800x600 at 7.5 FPS (15/2 FPS). -
Update the opendatacam/config.json file as follows
"VIDEO_INPUTS_PARAMS": { "usbcam": "v4l2src device=/dev/video0 ! video/x-raw, framerate=15/2, width=800, height=600 ! videoconvert ! appsink" }
-
(Optional) If your device is on
video1
orvideo2
instead of defaultvideo0
, changeVIDEO_INPUTS_PARAMS > usbcam
to your video device, for example if /dev/video1
- JetsonHacks: Projects for the Jetson series of devices
- Jetson Setup note by Raspberry Pi Valley: A collection of notes on setting up various packages on the Jetson Nano
- Object Detection in 10 lines of code: A cool little tutorial from Nvidia
- Hello AI World: A more comprehensive series of tutorials from Nvidia