cv::OutOfMemoryError while calculating (surf)descriptors

I'm trying to set up an object recognition system with 12x30 images with 1280x1024 pixels.

I'm using Visual Studio 2013, Windows 8.1 x64 with 8GB RAM and compile as x86. I get the following error message:

C:\opencv\sources\modules\core\src\alloc.cpp:52: error: (-4) Failed to allocate 74747652 bytes in function cv::OutOfMemoryError

According to the Task Manager, my software needs less than 1.600.000K memory and the RAM is at 84%. So I think that should not be the problem.

This is the code, where I get the error:

cv::Ptr<cv::SurfFeatureDetector> detector = cv::SurfFeatureDetector::create("SURF");
cv::Ptr<cv::SurfDescriptorExtractor> extractor = cv::SurfDescriptorExtractor::create("SURF");
std::map<std::string, std::vector<cv::Mat>> imageList;

// Filling the imageList

printMessageSlot("Starting: Compute Descriptors");

std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
cv::Mat training_descriptors(1, extractor->descriptorSize(), extractor->descriptorType());

for (const auto &imgList : imageList)
{
for (const auto &img : imgList.second)
{
detector->detect(img, keypoints);
extractor->compute(img, keypoints, descriptors);

training_descriptors.push_back(descriptors);
}
}
printMessageSlot("Ending: Compute Descriptors");


I'm not really sure what causes the problem. I tried to set the Heap and Stack Reservation Size in Visual Studio to 2GB, but I get the error message that there is not enought memory for that command.

I really don't know how to solve this. I could try to read just one folder (corresponding to object class) of Images, calculate the descriptors and than override the Images with the next folder/class. But that feels like more complicated than it should be.

How does it works, when I have more than that few (360) Images?

edit retag close merge delete