visual studio 2019 图像监视:在Visual Studio调试器中查看内存中图像

Image Watch是一款用于Visual Studio 2019的插件,可在调试C++应用时可视化内存中的图像。本文介绍了如何下载和安装Image Watch,以及如何在调试过程中利用它来观察和理解代码对图像的操作。步骤包括安装插件、设置项目以支持OpenCV图像,并在调试时通过Local窗口和Image Watch查看图像。

Image Watch is a plug-in for Microsoft Visual Studio that lets you to visualize in-memory images (cv::Mat or IplImage_ objects, for example) while debugging an application. This can be helpful for tracking down bugs, or for simply understanding what a given piece of code is doing.
总的来说Image Watch 就是一个debug时候对于图像的观察的窗口。

stepone:

1.download the Image Watch Installer for visual studio 2019,安装程序是一个单文件,文件的后缀名是.vsix。

The introduction of Image Watch Installer
Image Watch is a watch window for viewing in-memory bitmaps when debugging native C++ code.

The current version has built-in support for OpenCV image types (cv::Mat, cv::Mat_<>, CvMat, _IplImage). To enable user-defined image types please refer to the Image Watch documentation.

This version works with Visual Studio 2019.

Quick Start: Simply break in the debugger and select View > Other Windows > Image Watch. Alternatively, click on the magnifying glass icon next to an image variable in your Locals window or on the debugger Data Tip.

在这里插入图片描述
==2double click on the .vsix file ==
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.when the installer has finished, make sure to restart Visual Studio to complete the installation.
关闭visual studio, 安装完成后重新打开visual studio
在这里插入图片描述
打开View Install Log,可以看到拓展程序的安装位置, 已成功完成到 Visual Studio Community 2019 的安装。扩展已经安装到 C:\USERS\ADMINISTRATOR\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\16.0_823E3688\EXTENSIONS\JQWAAQUV.YU4\

steptwo:

新建一个项目进行测试,window控制台项目
在这里插入图片描述
在这里插入图片描述

stepthree:

1.对项目进行property sheet opencv的设置参考,是对debug进行设置
2复制下面的代码:(这个程序中并设置窗口去显示图像,以此来测试这个ImageWatch )因为是built-in

/ Test application for the Visual Studio Image Watch Debugger extension
#include <iostream>                        // std::cout
#include <opencv2/core/core.hpp>           // cv::Mat
#include <opencv2/imgcodecs/imgcodecs.hpp>     // cv::imread()
#include <opencv2/imgproc/imgproc.hpp>     // cv::Canny()
using namespace std;
using namespace cv;
void help()
{
    cout
        << "----------------------------------------------------" << endl
        << "This is a test program for the Image Watch Debugger " << endl
        << "plug-in for Visual Studio. The program loads an     " << endl
        << "image from a file and runs the Canny edge detector. " << endl
        << "No output is displayed or written to disk."
        << endl
        << "Usage:"                                               << endl
        << "image-watch-demo inputimage"                          << endl
        << "----------------------------------------------------" << endl
        << endl;
}
int main(int argc, char *argv[])
{
    help();
    if (argc != 2)
    {
        cout << "Wrong number of parameters" << endl;
        return -1;
    }
    cout << "Loading input image: " << argv[1] << endl;
    Mat input;
    input = imread(argv[1], IMREAD_COLOR);
    cout << "Detecting edges in input image" << endl;
    Mat edges;
    Canny(input, edges, 10, 100);
    return 0;
}

3对活动解决方案进行设置:
在这里插入图片描述

在这里插入图片描述
4.因为程序中有char*argv[],所以要对add the command line argument of your input image to your project,,这个是这个程序的自己的独特之处而已
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
5.查看本地局部变量 Debug->Windows->Locals,就会出现上面的图那样
Note that the built-in Local window will display text only.

6.如果想要查看built-in 的图像形式, View->Other Windows->Image Watch
**Note that Image Watch is like Visual studio’s Local window. **
Visual Studio will remember whether you had Image Watch open, and where it was located between debugging sessions.
This means that you only have to do this once-the next time you start debugging, Image Watch will be back where you left.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值