Skip to content

View OpenCV Mat in GDB, Code from: [Visualize in memory OpenCV image or matrix from GDB pretty printers](https://sourceware.org/ml/gdb/2013-04/msg00104.html)

Notifications You must be signed in to change notification settings

pvangoor/gdb-opencv-viewer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

View OpenCV Mat in GDB, Code from: Visualize in memory OpenCV image or matrix from GDB pretty printers

How to use

  • Required packages: opencv, python wrapper for opencv (cv2), python, numpy
  • Clone this repository
git clone git@github.com:beenfrog/gdb-opencv-viewer.git
  • Add the follow lines in ~/.gdbinit. The alias command is optional.
source /FULL-PATH-OF-THE-FILE/cvplot.py
alias view = plot
alias imshow = plot
  • Usage
plot m, the m is an object of cv2::Mat
view m, if you set alias view = plot
imshow m, if you set alias imshow = plot

Demo

  • debug and view image in gdb:
cd gdb-opencv-viewer
mkdir Debug && cd Debug
cmake -DCMAKE_BUILD_TYPE=Debug .. && make
gdb ./viewer
break 26
run
plot img_color
plot img_gray
  • view Mat in vector: if just use the follow command:
plot img_vec[0]
plot img_vec[1]

we will get:

Python Exception <class 'gdb.error'> Could not find operator[].: 
Error occurred in Python command: Could not find operator[].

and the right way to view the mat in vector is:

pvector img_vec
plot $1
plot $2

See more in next section.

  • NOTE: There may be some bugs with the imshow in python under GNU/Linux, which make you unable to close the image by click the "close" button on the dialog, but you can just click the image and press any key to close the image dialog.

Others

It is easy to print the C++ STL elements such as vector, map with GDB evaluators/views/utilities

  • Install
wget http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt
cat dbinit_stl_views-1.03.txt >> ~/.gdbinit
  • Demo (continue from the previous demo)
pvector vec
pmap str_int_map char* int
...
see more from the raw file: dbinit_stl_views-1.03.txt

Similar Projects to Show Image in GDB

About

View OpenCV Mat in GDB, Code from: [Visualize in memory OpenCV image or matrix from GDB pretty printers](https://sourceware.org/ml/gdb/2013-04/msg00104.html)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 79.5%
  • C++ 14.2%
  • CMake 6.3%