我有代码段
display('Descriptor Extraction...');
DESCRIPTORS = {};
descriptor_for_each_class = {};
num_classes = length(imgs_dir);
IMAGES = {};
for i = 1:num_classes
class_name = classes{i};
fprintf('Feature Extraction for CLASS %s\n',class_name);
full_path = fullfile(imgs_path,class_name);
class_dir = dir(full_path);
image_names = {class_dir(3:length(class_dir)).name};
num_imgs = length(image_names);
descriptors = {};
parfor j = 1:num_imgs
image_name = image_names{j};
%fprintf('Feature Extraction for IMAGE %d/%d\n',j,num_imgs);
img_path = fullfile(full_path,image_name);
I = imread(img_path(:,:));
I = standarizeImage(I);
I = rgb2gray(I) ;
IMAGES{i,j}.I = I;
IMAGES{i,j}.class_name = class_name;
IMAGES{i,j}.name = image_name;
[f, d] = vl_dsift(I, 'size', binSize) ;
descriptors{j}=d;
end
DESCRIPTORS = [DESCRIPTORS descriptors];
end
当parfor部分完成一个纪元时,在第二纪元的开头,Matlab给出了以下错误:
Error using parallel_function (line 589)
Assertion failed.
Error in feat_extraction (line 34)
parfor j = 1:num_imgs
我找不到代码上的错误。有什么想法吗?
答案 0 :(得分:2)
我通过更改parfor部分来解决问题,如下所示
descriptors = {};
images = {};
parfor j = 1:num_imgs
image_name = image_names{j};
%fprintf('Feature Extraction for IMAGE %d/%d\n',j,num_imgs);
img_path = fullfile(full_path,image_name);
I = imread(img_path(:,:));
images{j}.I = I;
images{j}.class_name = class_name;
images{j}.image_name = image_name;
I = standarizeImage(I);
I = rgb2gray(I) ;
%IMAGES{i,j}.name = image_name;
[f, d] = vl_dsift(I, 'size', binSize) ;
descriptors{j}=d;
end
ALL_DATA{i}=images;
DESCRIPTORS = [DESCRIPTORS descriptors];
end