Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Train_hog.cpp OpenCV 3.1示例-无法传递正确的路径参数_C++_Opencv - Fatal编程技术网

C++ Train_hog.cpp OpenCV 3.1示例-无法传递正确的路径参数

C++ Train_hog.cpp OpenCV 3.1示例-无法传递正确的路径参数,c++,opencv,C++,Opencv,这篇文章描述了一个和我非常相似的问题,但我是新来的,被告知要发布一个新问题。非常感谢任何人的帮助 @Franksey我也有同样的问题。我在这条线上走过这条路 {@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 但是,当我在生成后运行调试器时,它会给出以下错误 程序

这篇文章描述了一个和我非常相似的问题,但我是新来的,被告知要发布一个新问题。非常感谢任何人的帮助

@Franksey我也有同样的问题。我在这条线上走过这条路
{@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

但是,当我在生成后运行调试器时,它会给出以下错误
程序“[0x3CF0]opencv.exe”已退出,代码为-1(0xFFFFFF)。

创建制动点时,我意识到在执行
file.open((前缀+文件名).c_str());

无效加载图像(常量字符串和前缀、常量字符串和文件名、向量&img\u lst)
{
弦线;
ifstream文件;
打开((前缀+文件名).c_str());
如果(!file.is_open())
{

cerr解决了它!这是一个愚蠢的错误,多亏了Windows

pos.lst和neg.lst,其中实际上是pos.lst.txt和neg.lst.txt,因为文件扩展名被隐藏。感谢您设法解决了我的问题


我不得不切换到Windows,因为我需要使用Visual Studio,一旦这个项目结束,Visual Studio将恢复到Ubuntu!

解决了它!这是一个愚蠢的错误,多亏了Windows

pos.lst和neg.lst,其中实际上是pos.lst.txt和neg.lst.txt,因为文件扩展名被隐藏。感谢您设法解决了我的问题

我不得不切换到Windows,因为我需要使用Visual Studio。一旦这个项目结束,Visual Studio将恢复到Ubuntu

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());
}
}