简体   繁体   English

Visual Studio调试器失败,但程序运行时运行良好......?

[英]Visual Studio debugger fails but program runs fine when built…?

I'm working on a stereo disparity program, I have left and right images that I'm trying to read in. However I'm getting an error when trying to debug, but it works fine if I just build it...So I've just reduced the code to something very simple... 我正在研究立体声差异程序,我有左右图像,我正在尝试读取。但是我在尝试调试时遇到错误,但如果我只是构建它就可以正常工作...所以我刚刚将代码简化为非常简单的东西......

#include <bunch of opencv bits...>

using namespace std;
using namespace cv;

int main()
{
    Mat Left= imread("Left.png", 0);    //read images as grayscale
    Mat Right= imread("Right.png", 0);

    while (true) {
        imshow("Left",Left);
        imshow("Right",Right);
    }

}

Running with debug (F5) I get to the line imshow("Left",Left); 运行调试(F5)我进入行imshow(“左”,左); and it crashes, reporting OpenCV Error: Bad flag (parameter or structure field) (unrecognized or unsupported array type) ....blah blah 并崩溃,报告OpenCV错误:坏标志(参数或结构字段)(无法识别或不支持的数组类型)....等等等等

Stepping through the code I can see that nothing is read stored in Left or Right 单步执行代码,我可以看到没有任何内容被读取存储在LeftRight中

However where things get really confusing is if I just build the program (F7) and run the .exe from explorer (Misc Projects\\SteroExp\\Debug).... it runs completely fine. 然而,如果我只是构建程序(F7)并从资源管理器运行.exe(Misc Projects \\ SteroExp \\ Debug)......那么事情变得非常令人困惑....它运行完全正常。

My thoughts.... Does VS run the debug version from a different temp directory somewhere on the PC where the images aren't stored? 我的想法...... VS是否在PC上某个不存储图像的不同临时目录中运行调试版本?

I'm using... W7 64bit, VS2010, C++, OpenCV 2.3.1 我正在使用... W7 64bit,VS2010,C ++,OpenCV 2.3.1

The problem is the current working directory. 问题是当前的工作目录。 When you run from explorer the current directory is 'Misc Projects\\SteroExp\\Debug' but when you from from the debugger it's 'Misc Projects\\SteroExp'. 当你从资源管理器运行时,当前目录是'Misc Projects \\ SteroExp \\ Debug',但是当你来自调试器时,它是'Misc Projects \\ SteroExp'。 The answer is to move your image files to the correct directory. 答案是将图像文件移动到正确的目录。

First, double-check that the working directory in Project | 首先,仔细检查Project |中的工作目录 Properties | 属性| Debugging > WorkingDirectory is set to a directory that contains those two files. Debugging> WorkingDirectory设置为包含这两个文件的目录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio c++ - 程序在没有调试器的情况下失败,与调试器一起工作正常 - Visual Studio c++ - program fails without debugger, works fine with debugger 时间问题? 程序可以在Visual Studio中正常运行,但不能独立运行 - Timing issue? Program runs fine in Visual Studio but not standalone Visual Studio - 分析时程序运行速度更快 - Visual Studio - Program runs faster when profiling 程序在Visual Studio调试器中挂起 - Program hangs in Visual Studio debugger 应用程序无法通过 Visual Studio 2003 启动 - CURLE_NOT_BUILT_IN Curl 错误显示在调试器中 - Application fails to launch via Visual Studio 2003 - CURLE_NOT_BUILT_IN Curl error displayed in debugger 在Visual Studio外部启动时,程序运行速度较慢 - Program runs slower when launched outside of Visual Studio OpenCV + Visual Studio 2008-程序在调试中运行良好,但在常规执行中访问冲突 - OpenCV+Visual Studio 2008 - Program runs fine in debug but access violation in regular execution 多项式类在调试器中运行良好,但在尝试构建和运行时却无法运行 - Polynomial Class runs fine in debugger but not when trying to build&run 当Visual Studio运行良好时,矢量迭代器上的LInux G ++编译器错误 - LInux g++ compiler errors on vector iterator when Visual Studio runs just fine 程序在Visual Studio中运行,但释放可执行文件崩溃 - Program runs in visual studio but release executable crashes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM