本文主要是介绍VS2019使用ImageWatch调试OpenCV,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、ImageWatch2019的安装
打开VS2019,点击扩展->管理扩展->联机->右上角搜索ImageWatch,然后根据提示进行安装。
2、ImageWatch的使用
新建一个项目,将下列代码拷贝进去。
// 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;
}
然后在Mat input
处设置断点,进入调试模式,然后选择视图->其他窗口->ImageWatch,即可。如下图所示。
3、常用功能
- 滚轮缩放
- 右键->LinkView:固定选定区域
- 在local中右键添加到Watch,监视图片。
这篇关于VS2019使用ImageWatch调试OpenCV的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!