图像处理代码的调试
C++ 中的图像处理/计算机视觉/计算机图形应用程序可以进行哪些调试?您用什么来跟踪方法的错误/部分结果?
到目前为止我发现的只是一种在线调试工具和一种离线调试工具:
两者都非常过时,并且不是我所期望的。
对于离线调试来说,似乎有用的是某种类型的图像日志记录,比如说一组命令,使您能够将图像与文本一起编写(可能以 HTML 的形式,可能是分层的),简单在编译时和运行时都关闭,并且它可以得到最不显眼的效果。
输出可能如下所示(来自我们简单工具的输出):
http://tsh.plankton.tk/htmldebug/d8egf100-RF -SVM-RBF_AC-LINEAR_DB.html
您知道一些朝这个方向发展的代码吗?
如果有任何提示,我将不胜感激。
What kind of debugging is available for image processing/computer vision/computer graphics applications in C++? What do you use to track errors/partial results of your method?
What I have found so far is just one tool for online and one for offline debugging:
- bmd: attaches to a running process and enables you to view a block of memory as an image
- imdebug: enables printf-style of debugging
Both are quite outdated and not really what I would expect.
What would seem useful for offline debugging would be some style of image logging, lets say a set of commands which enable you to write images together with text (probably in the form of HTML, maybe hierarchical), easy to switch off at both compile and run time, and the least obtrusive it can get.
The output could look like this (output from our simple tool):
http://tsh.plankton.tk/htmldebug/d8egf100-RF-SVM-RBF_AC-LINEAR_DB.html
Are you aware of some code that goes in this direction?
I would be grateful for any hints.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从光线追踪的角度来看,也许其中一些视觉方法对您也有用(我的计划之一是写一篇关于此类技术的简短论文):
表面法线可视化。帮助寻找表面不连续性。 (没有方便的图像,外观非常让人想起法线贴图)
color <- rgb(normal.x+0.5、normal.y+0.5、normal.z+0.5)
< strong>距离可视化。有助于发现表面不连续性以及查找最近点时的错误。 (图像取自我的废弃光线追踪器)
颜色 <- (intersection.z-min)/范围,...
边界体积遍历可视化。帮助可视化边界体积层次结构或其他层次结构,并帮助查看遍历热点,例如代码分析器(例如Kd树)。 (http://ompf.org/forum 的 tbp 创造了术语Kd-vision).
color <- number_of_traversal_steps/f
边界框可视化(图像来自 picogen 左右,几年前)。帮助验证分区。
color <- const
立体声。 也许对您的情况有用至于真实的立体外观。我必须承认我从未使用过它进行调试,但当我想到这一点时,它在实现新型 3d 基元和树时可能非常有用(图像来自gladius,这是统一实时和非实时光线的尝试追踪)
您只需渲染位置稍有偏移的两个图像,重点关注某个点
命中或未命中可视化。可能有助于查找 epsilon 错误。 (图像取自metatrace)
如果(命中)颜色= const_a;
else color = const_b
几种技术的混合。
lerp(debug_a, debug_b)
if(y%2==0) debug_a else debug_b
您可能会在 http://phresnel.org , http://phresnel.deviantart.com , http://picogen.deviantart.com ,也许http://greenhybrid.deviantart.com (旧帐户)。
Coming from a ray tracing perspective, maybe some of those visual methods are also useful to you (it is one of my plans to write a short paper about such techniques):
Surface Normal Visualization. Helps to find surface discontinuities. (no image handy, the look is very much reminiscent of normal maps)
color <- rgb (normal.x+0.5, normal.y+0.5, normal.z+0.5)
Distance Visualization. Helps to find surface discontinuities and errors in finding a nearest point. (image taken from an abandoned ray tracer of mine)
color <- (intersection.z-min)/range, ...
Bounding Volume Traversal Visualization. Helps visualizing a bounding volume hierarchy or other hierarchical structures, and helps to see the traversal hotspots, like a code profiler (e.g. Kd-trees). (tbp of http://ompf.org/forum coined the term Kd-vision).
color <- number_of_traversal_steps/f
Bounding Box Visualization (image from picogen or so, some years ago). Helps to verify the partitioning.
color <- const
Stereo. Maybe useful in your case as for the real stereographic appearance. I must admit I never used this for debugging, but when I think about it, it could prove really useful when implementing new types of 3d-primitives and -trees (image from gladius, which was an attempt to unify realtime and non-realtime ray tracing)
You just render two images with slightly shifted position, focusing on some point
Hit-or-not visualization. May help to find epsilon errors. (image taken from metatrace)
if (hit) color = const_a;
else color = const_b
Some hybrid of several techniques.
lerp(debug_a, debug_b)
if(y%2==0) debug_a else debug_b
You may find some more glitches and debugging imagery on http://phresnel.org , http://phresnel.deviantart.com , http://picogen.deviantart.com , and maybe http://greenhybrid.deviantart.com (an old account).
一般来说,我更喜欢将当前处理的图像的字节数组转储为原始数据三元组,并运行 Imagemagick 以使用数字(例如 img01.png)从中创建 png。这样我就可以很容易地跟踪算法。 Imagemagick 使用系统调用从程序中的函数运行。这使得在不使用任何图像格式的外部库的情况下进行调试成为可能。
如果您使用 Qt,另一种选择是使用 QImage 并不时使用 img.save("img01.png"),就像使用 printf 进行调试一样。
Generally, I prefer to dump bytearray of currently processed image as raw data triplets and run Imagemagick to create png from it with number e.g img01.png. In this way i can trace the algorithms very easy. Imagemagick is run from the function in the program using system call. This make possible do debug without using any external libs for image formats.
Another option, if you are using Qt is to work with QImage and use img.save("img01.png") from time to time like a printf is used for debugging.
与您正在寻找的内容相比,它有点原始,但我已经使用标准日志记录和编写图像文件完成了您在OP中建议的操作。通常,日志记录和信号导出过程以及分段存在于单元测试中。
信号被赋予标识符(通常是输入文件名),该标识符可以被扩充(通常是进程名称或阶段)。
对于处理器的开发来说,还是相当方便的。
为消息添加 html 很简单。在这种情况下,您可以轻松生成可查看的 html 输出 - 您不需要生成任何 html,只需使用 html 模板文件,然后插入消息。
如果您没有得到好的推荐,我会自己做(因为我已经针对多种信号类型做过多次)。
it's a bit primitive compared to what you are looking for, but i have done what you suggested in your OP using standard logging and by writing image files. typically, the logging and signal export processes and staging exist in unit tests.
signals are given identifiers (often input filename), which may be augmented (often process name or stage).
for development of processors, it's quite handy.
adding html for messages would be simple. in that context, you could produce viewable html output easily - you would not need to generate any html, just use html template files and then insert the messages.
i would just do it myself (as i've done multiple times already for multiple signal types) if you get no good referrals.
在 Qt Creator 中,您可以在普通 C++ 调试器中单步执行代码时观看图像修改,请参见 http://labs.qt.nokia.com/2010/04/22/peek-and-poke-vol-3/
In Qt Creator you can watch image modification while stepping through the code in the normal C++ debugger, see e.g. http://labs.qt.nokia.com/2010/04/22/peek-and-poke-vol-3/