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 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

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


Login/Signup to Answer

Question Tools

1 follower


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

Seen: 1,442 times

Last updated: Feb 15 '17