OpenCV  4.10.0-dev
Open Source Computer Vision
Loading...
Searching...
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

Capabilities

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

Installation

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

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

python
import sys
print(sys.version_info)
end

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.

Usage

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 mat_pretty_printer.py - np.set_printoptions controls everything matrix display-related.