I'm using the Microsoft
extension Image Watch to preview OpenCV
images.
I'm trying to visualize images that are inside a container by adding their container key, but the Visual Studio
debugger watch window doesn't support directly adding a variable inside a container.
For example:
#include <opencv2/opencv.hpp>
struct MyStruct {
cv::Mat img;
};
int main() {
cv::Mat img(64, 64, CV_8UC3, cv::Scalar(0, 0, 255));
map["a"].img = img;
cv::Mat myImg = map["a"].img;
}
When I try to visualize the image by adding into the watch window map["a"].img
, it's invalid.
I need to add it from inspecting/iterating the map, until find the desired key:
It only works entering this name: ((std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,MyStruct>,void *>*)0x0000026e1a358a70)->_Myval.second.img
After a lot of searches, I have found this: Natvis framework.
I wonder if it could work for this use case, I have never used natvis before.
I followed the tutorial and added a new .natvis
to my project:
Project > Add new item > Visual C++ > Utility > Debugger visualization file (.natvis).
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
</AutoVisualizer>
And now I'm completely lost, I have re-read the examples but I still couldn't figure out how to create the specific view to be able to preview the image by its key, i.e. map["a"].img
.