当前位置: 首页 > news >正文

image watch自定义

安装image watch模块除了可以查看OpenCV,也可以查看自定义的图像格式。

可以参考的官方文档: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/image-watch/image-watch-reference?view=vs-2015

可以从 C:\Users\USERNAME\AppData\Local\Microsoft\VisualStudio\17.0_6e3f40f8\Extensions\a14eewtt.z12 文件夹看到OpenCV的配置文件 ImageWatchOpenCV.natvis 进行对照参考

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"><UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" MenuName="Add to Image Watch"/><!-- OpenCV cv::Mat --><Type Name="cv::Mat"><AlternativeType Name="cv::Mat_&lt;*&gt;"/><UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" /></Type><Type Name="cv::Mat"><AlternativeType Name="cv::Mat_&lt;*&gt;"/><DisplayString Condition="(flags&amp;7)==0">{{UINT8, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><DisplayString Condition="(flags&amp;7)==1">{{INT8, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><DisplayString Condition="(flags&amp;7)==2">{{UINT16, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><DisplayString Condition="(flags&amp;7)==3">{{INT16, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><DisplayString Condition="(flags&amp;7)==4">{{INT32, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><DisplayString Condition="(flags&amp;7)==5">{{FLOAT32, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><DisplayString Condition="(flags&amp;7)==6">{{FLOAT64, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><DisplayString Condition="(flags&amp;7)==7">{{USER, {((flags&amp;0xfff)&gt;&gt;3)+1} x {cols} x {rows}}}</DisplayString><Expand><Synthetic Name="[type]" Condition="(flags&amp;7)==0"><DisplayString>UINT8</DisplayString></Synthetic><Synthetic Name="[type]" Condition="(flags&amp;7)==1"><DisplayString>INT8</DisplayString></Synthetic><Synthetic Name="[type]" Condition="(flags&amp;7)==2"><DisplayString>UINT16</DisplayString></Synthetic><Synthetic Name="[type]" Condition="(flags&amp;7)==3"><DisplayString>INT16</DisplayString></Synthetic><Synthetic Name="[type]" Condition="(flags&amp;7)==4"><DisplayString>INT32</DisplayString></Synthetic><Synthetic Name="[type]" Condition="(flags&amp;7)==5"><DisplayString>FLOAT32</DisplayString></Synthetic><Synthetic Name="[type]" Condition="(flags&amp;7)==6"><DisplayString>FLOAT64</DisplayString></Synthetic><Item Name="[channels]">((flags&amp;0xfff)&gt;&gt;3)+1</Item><Item Name="[width]">cols</Item><Item Name="[height]">rows</Item><Item Name="[data]">data</Item><Item Name="[stride]">step.p[0]</Item></Expand></Type>
</AutoVisualizer>

然后结合官方示例文档:

struct My8BitRGBImage 
{ unsigned int ncols; unsigned int nrows; unsigned char* data; 
};--------------------
<?xml version="1.0" encoding="utf-8"?> 
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010"> <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1"  MenuName="Add to Image Watch"/> <Type Name="My8BitRGBImage"> <UIVisualizer ServiceId="{A452AFEA-3DF6-46BB-9177-C0B08F318025}" Id="1" /> </Type> <Type Name="My8BitRGBImage"> <Expand> <Synthetic Name="[type]"> <DisplayString>UINT8</DisplayString> </Synthetic> <Synthetic Name="[channels]"> <DisplayString>RGB</DisplayString> </Synthetic> <Item Name="[width]">ncols</Item> <Item Name="[height]">nrows</Item> <Item Name="[data]">data</Item> <Item Name="[stride]">ncols*3</Item> </Expand> </Type>   
</AutoVisualizer>

所以Type Name设置为class类名,图像内部需要设置 type|channels|width|height|data|stride等参数。
如果要对模板类进行处理(模版类的中括号<(&lt;) >(*&gt;) &(&amp;)),需要针对类型去做type区分, 这里的Condition=就相当于 switch-case,type支持的数据类型从官方文档可以查到:

image Watch supports these channel types:
INT8, UINT8
INT16, UINT16
INT32
FLOAT16
FLOAT32
FLOAT64

编写好.natvis 并保存在

C:\Users\%USERNAME%\Documents\Visual Studio 2022\Visualizers

即可支持自定义图像格式。

http://www.hskmm.com/?act=detail&tid=36444

相关文章:

  • 基于混沌单纯形法改进的布谷鸟搜索算法
  • 中国开发者如何选择最适合的代码管理工具?四大平台横向评测
  • 2025年散热模组厂家推荐排行榜:CPU散热模组,显卡散热模组,服务器散热模组,工业设备散热模组公司推荐
  • Cinder-创造性编程入门指南-全-
  • 2025 年防腐桥架厂家最新推荐榜:聚焦企业专利技术、品质管控及知名客户合作案例的权威解析
  • 2025年法兰保护罩厂家推荐排行榜,阀门保温罩,法兰罩,法兰防溅罩,法兰保护套,专业防护与定制服务深度解析
  • 2025年10月抗老面霜评测榜:紧致提亮真实数据排行
  • 软件工程第二次团队作业——构建智能体
  • 2025年10月抗老面霜对比榜:五款热门单品数据化排名
  • 2025年小型低温冷冻机厂家权威推荐榜:工业风冷/一体式螺杆低温/工业低温冷冻设备专业选购指南
  • 2025年10月企业数字化转型服务商评测榜:精选五强排名
  • 2025年不锈钢水箱厂家权威推荐榜:方形/圆形/消防/生活/保温/承压/装配式/焊接水箱,专业制造与耐用品质全面解析
  • 【转】广义积分——极限审敛法(六年考四次!)
  • 2025年10月企业数字化转型服务商推荐榜:五强对比评测
  • 数据挖掘之人工智能与机器学习
  • 产品经理必看!在线白板如何嵌入产品经理工作流
  • 2025 年窗帘厂家最新推荐权威排行榜:精准剖析各品牌核心优势,涵盖定制/智能/遮光/母婴/办公室等多类型窗帘选购指南
  • 2025年DevSecOps工具生态全景观察:从代码托管到安全左移的实践演进
  • 用AI帮你一天写完一个网站:流程解析
  • KO01创建内部订单
  • 基于MSP430单片机与DS3231时钟芯片的开发
  • Deepseek分析选择家用桶装水
  • SVN 常用命令与 TortoiseSVN 使用指南
  • 10/22
  • 服务器同步软件是什么?主要有哪几种类型?
  • 完整教程:Mysql主从复制
  • 2025年10月工程管理系统推荐榜:斗栱云领衔十强对比
  • 2025年10月石墨电极厂家推荐榜:十强对比与选购指南
  • 2025年蒸发冷空调厂家权威推荐榜:工业制冷节能环保空调,车间厂房商用空调系统优质品牌精选
  • Gitee DevOps平台:本土化创新如何重塑企业研发效能