TrafficCV is a small OpenCV-based cross-platform program and library that runs different object detection models on live streams or videos of vehicle traffic to compute and estimate information such as vehicle speed, vehicle class, the number of vehicles passing through a Region of Interest (ROI) and so on. You specify the model to run using the --model
parameter and the video source using the --video
parameter together with an optional --args
parameter that specifies a comma-delimited set of model or detector arguments in the form key=value. .
TrafficCV can run models on traffic videos from YouTube and other video hosting sites using VLC which is installed by default on the Raspberry Pi. The vlc-stream
scripts accept as a parameter a file or URL and then creates a Multipart-JPEG (MPJPEG) stream on the current computer on port 18223. MPJPEG is a simple way to stream Motion-JPEG (M-JPEG) encoded videos over HTTP that can be processed by OpenCV. Any video source which can be decoded by VLC can be transcoded and streamed to OpenCV allowing you to analyze live-streamed videos in many different formats and locations.
Clone the repo and run pip install -r requirements.txt in the project folder. Models can be downloaded from here, and demo videos here. Expand the archive files in the project folder so you have a models
and demo_videos
folder. Depending on the models you want to use you should then install the TensorFlow Lite runtime or the EdgeTPU runtime.