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函數無法打開圖像文件,因此在傳遞目錄路徑時我做錯了什麼。
有人點我在正確的方向,或告訴我它是什麼,我做錯了,請。
預先感謝您。