【问题标题】:Insufficient Memory Error: Bag of Words OpenCV 2.4.6 Visual Studio 2010内存不足错误:词袋 OpenCV 2.4.6 Visual Studio 2010
【发布时间】:2016-06-16 09:50:15
【问题描述】:

我正在使用 SURF 和 SIFT 特征以及 SVM 分类器来实现词袋模型。我想训练(2876 张图像的 80%)并测试(2876 张图像的 20%)它。我将dictionarySize 设置为1000。我的计算机配置是intel Xeon(2 个处理器)/ 32GB RAM/ 500GB HDD。在这里,只要需要,就会读取图像,而不是存储它们。 喜欢,

    std::ifstream file("C:\\testFiles\\caltech4\\train0.csv", ifstream::in);
    if (!file) 
    {
        string error_message = "No valid input file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    }
    string line, path, classlabel;
    printf("\nReading Training images................\n");
    while (getline(file, line)) 
    {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness,classlabel);
        if(!path.empty()) 
        {
            Mat image = imread(path, 0);


            cout << " " << path << "\n";
            detector.detect(image, keypoints1);
            detector.compute(image, keypoints1,descriptor1);
            featuresUnclustered.push_back(descriptor1); 
        }
    }

在这里,train0.csv 包含带有标签的图像的路径。它在读取图像、计算描述符并将其添加到要聚类的特征时从这个循环中停止。控制台出现以下错误:

【问题讨论】:

  • 图像加载看起来不错。可能是 featuresUnclestered 太大了
  • 如何使用 featuresUnclustered 因为我想使用整个数据集?
  • 嗯,你先看看是不是真的有问题。
  • 它适用于 500 张图像的小型数据集。
  • 有没有办法像 Weka 那样增加分配给它的内存?

标签: opencv visual-c++ computer-vision k-means feature-extraction


【解决方案1】:

在这里,在代码中,我将读取的图像大小调整为 256*256;减少了对内存的要求。因此,错误消失了。

        Mat image = imread(path, 0);
        resize(image,image,Size(256,256));
        cout << " " << path << "\n";
        detector.detect(image, keypoints1);
        detector.compute(image, keypoints1,descriptor1);
        featuresUnclustered.push_back(descriptor1); 

但是,它可能会出现在更大的数据集上。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-23
    相关资源
    最近更新 更多