我正在尝试在 gdb 中调试时查看 Opencv 矩阵。
我尝试使用这个脚本 cv_imshow.py .
首先,当 sourcing import Image
不起作用时。它失败了,因为 gdb 使用没有 PIL 或 Pillow 的 python 3。
然后我为 Python 3 安装了 Pillow:
pip3 安装枕头
然后将 import Image
替换为:
从 PIL 导入图像
剩下的问题是将 cv_imshow.py 从 python 2 转换为 python 3。
这是我做的:
- 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))
还将 unicode
替换为 str
但是当我输入
(gdb) source /home/user/gdb-imshow/cv_imshow.py
(gdb) cv_imshow img_color
我收到以下错误:
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
如何修复这个错误?使此脚本与 python 3 兼容?
使用 Ubuntu 14.04 LTS, GDB 7.7.1
最佳答案
您不是第一个尝试将此脚本用于 python 3 的人。您检查过 this 了吗? ?
关于python - 在 GDB、C++ 中调试 OpenCV 矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42228554/