Ask Your Question
1

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

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

ollydbg23 gravatar image

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

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: https://github.com/renatoGarcia/gdb-imshow

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 http://effbot.org/zone/pil-imaging-not-installed.htm , 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
0

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

ollydbg23 gravatar image

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

edit flag offensive delete link more

Comments

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 -0600 )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: https://sourceforge.net/projects/visu...

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

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

Y Simson gravatar image

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

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 cv_imshow.py 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/cv_imshow.py (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: https://github.com/cuekoo/GDB-ImageWatch

edit flag offensive delete link more

Comments

I also tried using 2to3 cv_imshow.py

Y Simson gravatar imageY Simson ( 2017-02-14 08:04:39 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 2,739 times

Last updated: Feb 15 '17