Ask Your Question

GDB pretty printer for showing iplImage or cv::Mat?

asked 2013-04-25 06:11:26 -0500

ollydbg23 gravatar image

updated 2013-04-25 09:09:45 -0500

Hi, I'm considering a GDB pretty printer to show a IplImage or cv::Mat in a window when I'm debugging a C/C++ program, I Googled and find only one:

I have GDB(python enabled, PIL library installed, WinXP), but I get "_imaging C module error in python PIL" error if I try to run the command "cv_imshow img" which img is a cv::Mat or IplImage * under GDB.

Anyone has encounter the same issue?

BTW: I have tried the way said in , command "import _imaging" runs correctly. So, it looks like my issue is only happens under GDB command line.

Edit: I see the OpenCV official release already contains a python binding, E.g. In OpenCV 2.4.4, there is a file: OpenCV-2.4.4.exe\opencv\build\python\2.7\cv2.pyd. Can I use this python interface to show an IplImage when I'm debugging an C/C++ OpenCV application?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-12-09 03:34:34 -0500

ollydbg23 gravatar image

updated 2013-12-09 03:36:17 -0500

edit flag offensive delete link more


Hi, I haven't got any email notification about your replies in year 2017, and I see your post now in year 2019. Many thanks

ollydbg23 gravatar imageollydbg23 ( 2019-01-26 08:53:23 -0500 )edit

BTW, in year 2015, I have released a python script which can show the image in a separate thread of the GDB, which don't make GDB hangs when showing the image, you can have a look at here:

ollydbg23 gravatar imageollydbg23 ( 2019-01-26 09:01:52 -0500 )edit

answered 2017-02-14 08:03:28 -0500

Y Simson gravatar image

updated 2017-02-15 02:50:38 -0500

I had the same problem. You need to install Pillow for Python 3: pip3 install Pillow

Then replace the import Image with: from PIL import Image

The remaining problem is to convert from python 2 to python 3.

Here is what I did:

-return (seq[pos:pos + size] for pos in xrange(0, len(seq), size))
+return (seq[pos:pos + size] for pos in range(0, len(seq), size))

Also replaced unicode() withstr()

However when I type

(gdb) source /home/MAGICLEAP/user/gdb-imshow/ (gdb) cv_imshow img_color

I get the following error:

CV_8U with 3 channels, 512 rows and 512 cols Python Exception <class 'typeerror'=""> argument must be a sequence: Error occurred in Python command: argument must be a sequence

* EDIT *I found a forked version of this script that is compatible with python 3 and works like a charm:

edit flag offensive delete link more


I also tried using 2to3

Y Simson gravatar imageY Simson ( 2017-02-14 08:04:39 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2013-04-25 06:11:26 -0500

Seen: 1,909 times

Last updated: Feb 15 '17