Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging unmanaged C++ images in Visual Studio

I do write lots of image processing code with lots of different images involved on unmanaged C++ under Visual Studio 2010. I want to be able to watch them almost as easily, as a simple identifier while step-by-step debugging.

My current solution is to use some function which exports image in Matlab console. It is ok, but requires modification to source code, while I want to do it just while debugging. So the best option is just image popping up while hovering containing variable by mouse. But writing some command ExportToMatlab(image) in Command Window is enough. I don't know how to do even this, however.

There is the very similar question "Debugging image rendering in Visual C++, any helpful add-ins?", but it is too old and I found no acceptable answers in that discussion. Some tools are .NET-based (see image below), some requires additional code to be written (that's what I currently am using), and some projects are frozen or unfinished.

Screenshot from DebuggerVisualizer

I can spend some time on implementing appropriate solution, so links to some good guides on how to customize debugger visualizer in VS are welcome too.

Update

I've created a Visual Studio extension based on Expression Evaluator Add-In. It is available to download from its SourceForge project page, called NativeViewer. Check for description on how to use it.

like image 215
Mikhail Avatar asked Jan 31 '12 13:01

Mikhail


People also ask

Can you debug C in Visual Studio?

Visual Studio Code supports the following debuggers for C/C++ depending on the operating system you are using: Linux: GDB. macOS: LLDB or GDB. Windows: the Visual Studio Windows Debugger or GDB (using Cygwin or MinGW)

How do I debug native code in Visual Studio?

For Visual Basic, select Debug in the left pane, select the Enable native code debugging check box, and then close the properties page to save the changes. Select Debug in the left pane, select the Enable native code debugging check box, and then close the properties page to save the changes.

How do I enable debugging in Visual Studio?

In the Visual Studio toolbar, make sure the configuration is set to Debug. To start debugging, select the profile name in the toolbar, such as <project profile name>, IIS Express, or <IIS profile name> in the toolbar, select Start Debugging from the Debug menu, or press F5.

What is visual debug?

Visual debugging provides the Visual Debug view for you to interact with your COBOL or PL/I debug session. With this view, you can visualize the stack trace, set breakpoints, and run to a selected call path. Notes: Visual debugging is not available in IBM® Debug for z Systems™.


1 Answers

I can't actually believe that nobody suggested Image Watch yet. It's the most amazing add-in ever. It shows you a view with all your Mat variables (images (gray and color), matrices) while debugging, there's useful stuff like zooming or contrast-stretching and you can even apply more complex functions directly in the plugin in real-time. It makes debugging of any kind of image operations a breeze and it's immensely helpful if you do calculations and linear algebra stuff with your cv::Mat matrices.

enter image description here

like image 53
Ela782 Avatar answered Oct 08 '22 15:10

Ela782