Train_hog.cpp OpenCV 3.1 示例 - 无法传递正确的路径参数
Train_hog.cpp OpenCV 3.1 Example - Cannot pass the proper path parameters
这篇文章描述了一个与我的非常相似的问题,但我是新来的,被告知要发布一个新问题。非常感谢任何人的帮助。
@Franksye 我遇到了同样的问题。我正在通过这一行中的路径 {@pd|C:/Cars/|pos_dir}{@p|Pos.lst|pos.lst}{@nd|C:/Cars/|neg_dir} {@n|Neg.lst|neg.lst}");
在文本文件Pos.lst中,我写了例如image0000.png,image0001.png彼此下方。
但是,当我在构建后运行调试器时,它给了我以下错误 The program '[0x3CF0] opencv.exe' has exited with code -1 (0xffffffff).
创建制动点时,我意识到它在执行file.open((prefix + filename).c_str());
时退出load_images函数
void load_images(const string & prefix, const string & filename, vector< Mat > & img_lst)
{
string line;
ifstream file;
file.open((prefix + filename).c_str());
if (!file.is_open())
{
cerr << "Unable to open the list of images from " << filename << " filename." << endl;
exit(-1);
}
bool end_of_parsing = false;
while (!end_of_parsing)
{
getline(file, line);
if (line.empty()) // no more file to read
{
end_of_parsing = true;
break;
}
Mat img = imread((prefix + line).c_str()); // load the image
if (img.empty()) // invalid image, just skip it.
continue;
#ifdef _DEBUG
imshow("image", img);
waitKey(10);
#endif
img_lst.push_back(img.clone());
}
}
我相信我在传递目录路径时做错了什么,因为load_images函数无法打开图像文件。
有人可以指出我正确的方向或告诉我我做错了什么吗?
提前谢谢你。
解决了!多亏了Windows,这是一个愚蠢的错误。
pos.lst 和 neg.lst实际上是 pos.lst.txt 和 neg.lst.txt因为文件扩展名被隐藏。感谢这篇文章设法解决了我的问题。
不得不切换到Windows,因为我需要使用Visual Studio,一旦这个项目结束,Visual Studio将恢复到Ubuntu!
相关文章:
- 如何反转整数参数包
- 使用C++库在Android项目中修改gradle中的cmake参数,用于插入指令的测试
- 如何使用默认参数等选择模板专业化
- 创建进程使用路径时出现错误事件:类型 "char *" 的 E0167 参数与类型 "LPWSTR" 的参数不兼容
- C 能够以其完整路径打开代码::块中的文件,但不能以相对路径作为命令行参数打开文件
- 从文件名中提取文件名,路径来自参数
- 使用 php 将带有命令行可执行文件路径的参数传递
- 如何将执行路径与文件路径和参数分开
- 向文件名参数(LPCSTR)添加预先声明的路径
- 从net.connman.Manager的GetService方法动态提取D-Bus参数和对象路径
- 添加文件路径参数
- Train_hog.cpp OpenCV 3.1 示例 - 无法传递正确的路径参数
- 缩短C++枚举成员的路径(使用 typedef 或 typename),以用作模板参数
- 更改系统命令参数的路径
- 如何将带有空格作为参数的路径添加到CreateProcess批处理文件中
- 如何在vc++中将路径作为参数传递到第二个应用程序中
- 在源文件中指定include前缀与在编译器的搜索路径参数中指定include前缀的优缺点是什么
- 如何将目录中所有具有完整路径的文件传递到execv中的参数数组
- 当构造函数具有相同的参数类型(文件路径)时,如何从数组创建(初始化)std::元组
- 在参数列表中使用绝对路径启动QProcess