简体   繁体   English

图像处理代码的调试

[英]Debugging of image processing code

What kind of debugging is available for image processing/computer vision/computer graphics applications in C++? 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: 到目前为止,我发现的只是一种在线工具和一种离线调试工具:

  1. bmd : attaches to a running process and enables you to view a block of memory as an image bmd :附加到正在运行的进程,并允许您将内存块作为映像查看
  2. imdebug : enables printf-style of debugging imdebug :启用printf样式的调试

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. 对于离线调试似乎有用的是某种形式的图像记录 ,可以说是一组命令,使您可以将图像与文本(可能以HTML的形式,可能是分层的)一起编写,并且易于在编译和关闭时关闭。运行时间,并且可以获得最少的干扰。

The output could look like this (output from our simple tool): 输出看起来像这样(我们简单工具的输出):
http://tsh.plankton.tk/htmldebug/d8egf100-RF-SVM-RBF_AC-LINEAR_DB.html 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. 我将不胜感激。

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): 从光线跟踪的角度来看,也许其中一些视觉方法对您也有用(这是我写一篇有关此类技术的简短论文的计划之一):

  1. 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)

  2. 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, ...

    在此处输入图片说明

  3. 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 (eg Kd-trees). 帮助可视化边界体积层次结构或其他层次结构,并帮助查看遍历热点,例如代码分析器(例如Kd树)。 (tbp of http://ompf.org/forum coined the term Kd-vision ). http://ompf.org/forum的 bp创造了术语Kd-vision )。

    在此处输入图片说明在此处输入图片说明

    color <- number_of_traversal_steps/f 颜色<-遍历步数/ f

  4. Bounding Box Visualization (image from picogen or so, some years ago). 边界框可视化 (几年前来自picogen的图像)。 Helps to verify the partitioning. 帮助验证分区。

    在此处输入图片说明

    color <- const 颜色<-常量

  5. 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) 我必须承认,我从未将其用于调试,但是当我考虑它时,当实现新类型的3d图元和-trees(来自gladius的图像,这是试图统一实时和非实时ray的尝试)时,它可能真的非常有用。跟踪)

    在此处输入图片说明

    You just render two images with slightly shifted position, focusing on some point 您只需渲染两个图像,并稍微移动一下位置,就可以集中在某个点上

  6. Hit-or-not visualization. 命中或不可视化。 May help to find epsilon errors. 可能有助于发现epsilon错误。 (image taken from metatrace) (图片来自metatrace)

    http://th01.deviantart.net/fs70/PRE/f/2010/309/b/0/debugging_a_c___in_s_anity_by_phresnel-d327c6w.png

    if (hit) color = const_a; 如果(命中)颜色= const_a; else color = const_b 其他颜色= const_b

  7. Some hybrid of several techniques. 几种技术的某种混合。

    1. Linear interpolation: lerp(debug_a, debug_b) 线性插值: lerp(debug_a, debug_b)
    2. Interlacing: if(y%2==0) debug_a else debug_b 隔行扫描: if(y%2==0) debug_a else debug_b
    3. Any combination of ideas, for example the color-tone from Bounding Box Visualization , but with actual scene-intersection and lighting applied 创意的任意组合,例如“ 边界框可视化”中的色调,但应用了实际的场景相交和照明

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). 您可能会在http : //phresnel.org,http : //phresnel.deviantart.com,http://picogen.deviantart.com以及http://greenhybrid.deviantart.com上找到更多故障和调试图像(旧帐户)。

Generally, I prefer to dump bytearray of currently processed image as raw data triplets and run Imagemagick to create png from it with number eg img01.png. 通常,我更喜欢将当前处理的图像的字节数组转储为原始数据三元组,然后运行Imagemagick从中创建png,例如img01.png。 In this way i can trace the algorithms very easy. 这样,我可以非常轻松地跟踪算法。 Imagemagick is run from the function in the program using system call. 使用系统调用从程序中的函数运行Imagemagick。 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. 如果您正在使用Qt,另一种选择是使用QImage并不时使用img.save(“ img01.png”),例如使用printf进行调试。

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. 与您要查找的内容相比,它有点原始,但是我已经使用标准日志记录和写入图像文件来完成您在OP中的建议。 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. 添加HTML消息将很简单。 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. 在这种情况下,您可以轻松产生可见的html输出-您不需要生成任何html,只需使用html模板文件,然后插入消息即可。

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/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM