我正在尝试循环浏览111个图像的列表,并使用OpenCV存储每个图像的blob组合。不幸的是,for-in循环突然在第46个图像(数组的第45个索引)上结束,应用程序崩溃,发出错误Message from debugger: Terminated due to memory issue.
这里有什么问题?
NSArray *configBlobs = config[@"blobs"];
for (NSDictionary *configBlob in configBlobs)
{
uint32_t label = [configBlob[@"label"] unsignedIntValue];
NSString *imageFilename = configBlob[@"imageFilename"];
image = [UIImage imageNamed:imageFilename];
if (image == nil)
{
NSLog(@"Image not found in resources: %@", imageFilename);
continue;
}
cv::Mat mat;
UIImageToMat(image, mat);
cv::cvtColor(mat, mat, cv::COLOR_RGB2BGR);
Blob blob(mat, label);
blobClassifier->update(blob);
}
该应用程序在最后一个语句中崩溃。这是在我的BlobClassifier.h文件中:
/**
* Add a reference blob to the classification model.
*/
void update(const Blob &referenceBlob);
这是在我的BlobClassifier.cpp文件中:
void BlobClassifier::update(const Blob &referenceBlob)
{
referenceBlobDescriptors.push_back(createBlobDescriptor(referenceBlob));
}