OpenCV  4.9.0-dev
Open Source Computer Vision
No Matches
Using OpenCV with gdb-powered IDEs

Table of Contents

Prev Tutorial: Installation in Linux
Next Tutorial: Using OpenCV with gcc and CMake

Original author Egor Smirnov
Compatibility OpenCV >= 4.0


This pretty-printer can show element type, is_continuous, is_submatrix flags and (possibly truncated) matrix. It is known to work in Clion, VS Code and gdb.

Clion example


Move into opencv/samples/gdb/. Place in a convenient place, rename gdbinit to .gdbinit and move it into your home folder. Change 'source' line of .gdbinit to point to your path.

In order to check version of python bundled with your gdb, use the following commands from the gdb shell:

import sys

If the version of python 3 installed in your system doesn't match the version in gdb, create a new virtual environment with the exact same version, install numpy and change the path to python3 in .gdbinit accordingly.


The fields in a debugger prefixed with view_ are pseudo-fields added for convenience, the rest are left as is. If you feel that the number of elements in truncated view is too low, you can edit - np.set_printoptions controls everything matrix display-related.