This is a (relatively) small utility to be used as a testbed for experimenting with stereo depth mapping in OpenCV.
I built this to find how well depth mapping works on the Nvidia Jetson Nano. Support is present for StereoBM and StereoSGBM, as well as experimental support for AANet+.
Hardware-wise, this utility has been used with the WaveShare IMX219-83 stereo camera.
Python 3.6 or higher is needed.
See this YouTube video for a brief(-ish) overview:
First, update submodules: git submodule update --init --recursive
You'll want to install requirements:
conda env create -f environment.yml
conda activate depthmapper
(note: PyTorch is optional)
Assuming you have a stereo camera board attached and available on /dev/video0
and /dev/video1
, you should be able to just run:
python3 main.py
By default, cameras are accessed using nvarguscamerasrc
which is specific to the Nvidia Jetson family. You should change this in lib/helpers.py
if this is incorrect for your hardware setup.
You can choose which algorithm is used via the -m
command line switch:
python main.py -m <algorithm>
options:
-m stereobm
-m stereosgbm
-m aanet
StereoBM is the default if this option is omitted.
AANet is an optionally supported algorithm, and as such you don't need PyTorch installed if you don't plan to use it.
If you do want it, you'll want to download a pre-trained model for it. These can be downloaded from here, then placed into ./models
. Make sure to update settings.conf
to the name of the model you wish to use.
For now, output is the generated disparity map and is shown in a new window. By default, the left hand frame the map corresponds to is shown too.
All configuration is to be done via a config file, named settings.conf
. I've made sure to write comments in the default configuration file to give an understanding of what each parameter does.
This file needs to live next to main.py
, and will be automatically loaded.
On the Nvidia Jetson, OpenCV is installed by default with Python bindings. However, you may wish to use a virtual environment for Python. I used an arm64
version of Miniforge3.
BSD 2-clause.
This software is freely available, but isn't very useful outside a bench testing scenario.