VS2019使用ImageWatch调试OpenCV

1、ImageWatch2019的安装

打开VS2019,点击扩展->管理扩展->联机->右上角搜索ImageWatch,然后根据提示进行安装。

2、ImageWatch的使用

新建一个项目,将下列代码拷贝进去。

// Test application for the Visual Studio Image Watch Debugger extension
#include                         // std::cout
#include            // cv::Mat
#include      // cv::imread()
#include      // 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;
}

然后在Mat input处设置断点,进入调试模式,然后选择视图->其他窗口->ImageWatch,即可。如下图所示。
VS2019使用ImageWatch调试OpenCV_第1张图片

3、常用功能

  • 滚轮缩放
  • 右键->LinkView:固定选定区域
  • 在local中右键添加到Watch,监视图片。

你可能感兴趣的:(openCV)