Skip to content

Latest commit

 

History

History
83 lines (69 loc) · 3.47 KB

README.md

File metadata and controls

83 lines (69 loc) · 3.47 KB

Traffic counter Raspberry Pi 4

output image

Traffic counter with a camera on a bare Raspberry Pi 4.

License

Specially made for a Raspberry Pi 4, see Q-engineering deep learning examples
See YouTube movie.


Dependencies.

To run the application, you have to:

  • A Raspberry Pi 4 with a 64-bit Bullseye operating system.
  • Raspbian's libcamera-apps source code installed ($ sudo apt install libcamera-dev)
  • The Tencent ncnn framework installed. Install ncnn
  • OpenCV 64-bit installed. Install OpenCV 4.5
  • Code::Blocks installed. ($ sudo apt-get install codeblocks)

Installing the app.

To extract and run the network in Code::Blocks
$ mkdir MyDir
$ cd MyDir
$ wget https://github.com/Qengineering/Traffic-Counter-RPi_64-bit/archive/refs/heads/main.zip
$ unzip -j main.zip
Your MyDir folder must now look like this:

.
├── include
│   ├── BYTETracker.h
│   ├── dataType.h
│   ├── kalmanFilter.h
│   ├── lapjv.h
│   ├── lccv.hpp
│   ├── libcamera_app.hpp
│   ├── libcamera_app_options.hpp
│   └── STrack.h
├── LICENSE
├── nanodet_m.bin
├── nanodet_m.param
├── README.md
├── src
│   ├── BYTETracker.cpp
│   ├── kalmanFilter.cpp
│   ├── lapjv.cpp
│   ├── lccv.cpp
│   ├── libcamera_app.cpp
│   ├── libcamera_app_options.cpp
│   ├── STrack.cpp
│   ├── traffictrack.cpp
│   └── utils.cpp
├── Traffic.mp4
└── TrafficTracking.cbp

Running the app.

To run the application load the project file TrafficTracking.cbp in Code::Blocks.
We overclocked our Raspberry Pi 4 to 1950MHz to get the highest FPS.
As usual, ensure good cooling!


Camera.

If you want to run the app with a camera you have to uncomment line 18 in traffictrack.cpp and recompile the software.

#define CAMERA

We use the Bullseye LCCV camera code because it is a feather-light camera code leaving most of the computer time for deep learning calculations.


Final remark.

It's a lot of room for improvement. The current NanoDet model has been trained with the COCO set. In everyday use, you don't need all 80 classes when monitoring traffic. Only a few classes could do that. It makes the model faster and more accurate.
Another improvement could be the tracker. Here we use the Byte Tracking. Because only traffic moves to or from the camera, tracking can be simplified. And on the other hand, be more robust. As you will experience, traffic towards the camera is harder to detect than traffic driving away.


paypal