[英]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 单步执行代码,我可以看到没有任何内容被读取存储在Left或Right中
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.