Tutorial: Image Watch for Debugging

Image Watch is a plug-in for Microsoft Visual Studio that lets you to visualize in-memory images (cv::Mat 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.

Reference

Installation

Visual Studio Community

How to use

Exercise Code

// 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;


int main(int argc, char *argv[])
{
  
    Mat input;
    input = imread("testImage.jpg",1);;
    if (input.empty())
    {
      cout << "Image Load Fail!!" << endl;
      return -1
    } 
    cout << "Detecting edges in input image" << endl;
    Mat edges;
    Canny(input, edges, 10, 100);

    return 0;
}

Process

If an image has a thumbnail, left-clicking on that image will select it for detailed viewing in the Image Viewer on the right. The viewer lets you pan (drag mouse) and zoom (mouse wheel). It also displays the pixel coordinate and value at the current mouse position.

Right-click on the Image Viewer to bring up the view context menu and enable Link Views (a check box next to the menu item indicates whether the option is enabled).

The Link Views feature keeps the view region fixed when flipping between images of the same size. To see how this works, select the input image from the image list–you should now see the corresponding zoomed-in region in the input image

Last updated

Was this helpful?