Matlab中出现FileIO was not loaded from the file.

heluo240808 2014-11-11 10:11:08
最近用matlab 写了一个程序,涉及到文件的频繁读取操作,当读了2000多次后,出现下面的提示:
Caught "std::exception" Exception message is:
Message Catalog MATLAB:FileIO was not loaded from the file. Please check file location, format or contents
具体代码如下:

function getSiftValue
father = 'D:\users\luo_he\DATA';
mkdir(father, 'desData');
mkdir([father, '\', 'desData'], 'tempTrain');
mkdir([father, '\', 'desData'], 'tempTest');
Train = [father, '\', 'tempTrain'];
Test = [father, '\', 'tempTest'];
siftTrn = [father, '\', 'desData', '\', 'tempTrain'];
siftTst = [father, '\', 'desData', '\','tempTest'];
subTrn = dir(Train);
lenTrn = length(subTrn);
if isunix
command = '!./sift ';
else
command = '!siftWin32 ';
end
command = [command ' <tmp.pgm >tmp.key'];
%classDescriptors = [];
for i = 3 : lenTrn
className = subTrn(i).name;
imgNames = dir([Train, '\', className]);
imgNum = length(imgNames);
%open a file to save class descriptors
fileName = [siftTrn, '\', [className, '.des']];
classDes = fopen(fileName, 'a');
fprintf(classDes, '[type:sift]\n');
%fclose(classDes);
for j = 3 : imgNum
imgPth = [Train, '\', className, '\', imgNames(j).name];
image = imread(imgPth);
image = prcssImage(image);
[rows, cols] = size(image);
% in case of file open fail, try 10 times
for x = 1 : 10
f = fopen('tmp.pgm', 'w');
if f ~= -1
break;
end
end
if f ~= -1
fprintf(f, 'P5\n%d\n%d\n255\n', cols, rows);
fwrite(f, image', 'uint8');
fclose(f);
% Call keypoints executable
eval(command);
tmpkey = fopen('tmp.key', 'r');
keyData = fread(tmpkey);
fclose(tmpkey);
fwrite(classDes, keyData);
else
errfile = fopen([father, '\', 'error.txt'], 'a');
fprintf(errfile, 'open tmp.pgm error, when computing %s', imgPth);
fclose(errfile);
end
end
fclose(classDes);
end

subTst = dir(Test);
lenTst = length(subTst);
for i = 3 : lenTst
className = subTst(i).name;
mkdir(siftTst, className);
imgNames = dir([Test, '\', className]);
imgNum = length(imgNames);
for j = 3 : imgNum
imgPth = [Test, '\', className, '\', imgNames(j).name];
image = imread(imgPth);
image = prcssImage(image);
[rows, cols] = size(image);
fileName = [siftTst, '\', className, '\',imgNames(j).name, '.des'];
imgDes = fopen(fileName, 'a');
fprintf(imgDes, '[type:sift]\n');
%fclose(imgDes);
for x = 1 : 10
f = fopen('tmp.pgm', 'w');
if f ~= -1
break;
end
end
if f ~= -1
fprintf(f, 'P5\n%d\n%d\n255\n', cols, rows);
fwrite(f, image', 'uint8');
fclose(f);
% Call keypoints executable
eval(command);
tmpkey = fopen('tmp.key', 'r');
keyData = fread(tmpkey);
fclose(tmpkey);
fwrite(imgDes, keyData);
else
errfile = fopen([father, '\', 'error.txt'], 'a');
fprintf(errfile, 'open tmp.pgm error, when computing %s', imgPth);
fclose(errfile);
end
end
end

是在进行第二个大的for循环出现的问题,觉得不可能是文件出现的问题呀,因为之前对文件都执行上千次操作了,都没有问题。
这个问题困扰我好久了,希望有人能解惑。
...全文
968 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,424

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 其他开发语言
社区管理员
  • 其他开发语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧