This后描绘了一个非常类似的问题,以我的,但是我是新来的,被告知后的新问题。非常感谢任何人的帮助。Train_hog.cpp OpenCV的3.1示例 - 无法通过正确的路径参数
@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());
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功能由于load_images函数无法打开图像文件,因此在传递目录路径时我做错了什么。
有人点我在正确的方向,或告诉我它是什么,我做错了,请。
预先感谢您。