필터 지우기
필터 지우기

how to solve that out of memory

조회 수: 1 (최근 30일)
Pan
Pan 2012년 3월 3일
Hi,
this is my code,
function f1()
clear all;
obj1 = mmreader('can.avi');
obj2 = mmreader('watch.avi');
obj3 = mmreader('can.avi');
obj4 = mmreader('watch.avi');
vid1 = read(obj1);
vid2 = read(obj2);
vid3 = read(obj3);
vid4 = read(obj4);
frame1 = 1;
frame2 = 50;
frame3 = 30;
frame4 = 1;
f4 = 1;
hst1=0;
hst2=0;
hst3=0;
hst4=0;
h = figure('Name','Video ', 'NumberTitle','off','Color',[1,1,1],'Toolbar','none','Visible','on', 'Position',[80 40 1000 700],...
'Resize','on');
hstat1 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 630 25 25]);
hstat2 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 550 25 25]);
hstat3 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 480 25 25]);
hstat4 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 410 25 25]);
hplay1 = uicontrol('unit','pixel','style','pushbutton','string','藥罐_PLAY',...
'position',[50 630 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play1_callback});
hplay2 = uicontrol('unit','pixel','style','pushbutton','string','手錶_PLAY',...
'position',[50 550 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play2_callback});
hplay3 = uicontrol('unit','pixel','style','pushbutton','string','書本_PLAY',...
'position',[50 480 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play3_callback});
hplay4 = uicontrol('unit','pixel','style','pushbutton','string','手機_PLAY',...
'position',[50 410 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play4_callback});
hstop1 = uicontrol('unit','pixel','style','pushbutton','string','藥罐_STOP',...
'position',[50 330 70 40],'backgroundColor',[0.2,1,0],'callback',@stop1_callback);
hstop2 = uicontrol('unit','pixel','style','pushbutton','string','手錶_STOP',...
'position',[50 250 70 40],'backgroundColor',[0.2,1,0],'callback',@stop2_callback);
hstop3 = uicontrol('unit','pixel','style','pushbutton','string','書本_STOP',...
'position',[50 170 70 40],'backgroundColor',[0.2,1,0],'callback',@stop3_callback);
hstop4 = uicontrol('unit','pixel','style','pushbutton','string','手機_STOP',...
'position',[50 90 70 40],'backgroundColor',[0.2,1,0],'callback',@stop4_callback);
hexit = uicontrol('unit','pixel','style','pushbutton','string','EXIT',...
'position',[50 10 70 40],'backgroundColor',[1,0,0],'callback',@exit_callback);
while (1)
if hst1==1
subplot(2,2,1); imshow(vid1(:,:,:,frame1));
if frame1 < size(vid1,4)
frame1 = frame1+1;
else
frame1 = 1;
end
end
if hst2==1
subplot(2,2,2); imshow(vid2(:,:,:,frame2));
if frame2 < size(vid2,4)
frame2 = frame2+1;
else
frame2 = 1;
end
end
if hst3==1
subplot(2,2,3); imshow(vid3(:,:,:,frame3));
if frame3 < size(vid3,4)
frame3 = frame3+1;
else
frame3 = 1;
end
end
if hst4==1
subplot(2,2,4); imshow(vid4(:,:,:,frame4));
if frame4 < size(vid4,4)
frame4 = frame4+1;
else
frame4 = 1;
end
% else
% subplot(2,2,4); imshow(vid2(:,:,:,1));
end
drawnow;
if f4 ==10000
break;
% else f4 = f4+1;
end
end
function play1_callback(hObject0,eventdata0)
set(hstat1,'value',1);
hst1=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','藥罐_播放中');
end
function play2_callback(hObject1,eventdata1)
set(hstat2,'value',1);
hst2=1;
set(hplay2 ,'backgroundColor',[1,1,0],'string','手錶_播放中');
end
function play3_callback(hObject2,eventdata2)
set(hstat3,'value',1);
hst3=1;
set(hplay3 ,'backgroundColor',[1,1,0],'string','書本_播放中');
end
function play4_callback(hObject3,eventdata)
set(hstat4,'value',1);
hst4=1;
set(hplay4 ,'backgroundColor',[1,1,0],'string','手機_播放中');
end
function stop1_callback(hObject,eventdata)
set(hstat1,'value',0);
hst1=0;
set(hplay1 ,'backgroundColor',[0.3,0.7,1],'string','藥罐_PLAY');
end
function stop2_callback(hObject,eventdata)
set(hstat2,'value',0);
hst2=0;
set(hplay2 ,'backgroundColor',[0.3,0.7,1],'string','手錶_PLAY');
end
function stop3_callback(hObject,eventdata)
set(hstat3,'value',0);
hst3=0;
set(hplay3 ,'backgroundColor',[0.3,0.7,1],'string','書本_PLAY');
end
function stop4_callback(hObject,eventdata)
set(hstat4,'value',0);
hst4=0;
set(hplay4 ,'backgroundColor',[0.3,0.7,1],'string','手機_PLAY');
end
function exit_callback(hObject,eventdata)
f4=10000;
stop1_callback;
close gcf;
end
end
but I run it, matlab show this message
??? Not enough memory available for 537 frames.
Error in ==> mmreader.read at 67
videoFrames = read(getImpl(obj));
Error in ==> GUIf1 at 11
vid3 = read(obj3);
I don't know that I should how to do.
My computer is 32 bits and RAM is 4.0G.
Pleas give me some advice. Thank you.
  댓글 수: 1
Jan
Jan 2012년 3월 4일
It wastes a lot of time, if you remove all functions from the memory using "clear all", such that reading them again from the disk and parsing them is required.
There might be some arguments for "clear variables" inside a script (although I do not knwo any), but inside a function even this less brute form of "clear" is meaningless.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2012년 3월 4일
If you use a 64 bit system and Matlab version, you can use more than the 3GB RAM, which are available under Matlab/32 only.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 3월 3일
You really only have two different videos. Do not read each video twice. Instead re-use the data that has already been read.
obj1 = mmreader('can.avi');
obj2 = mmreader('watch.avi');
vid1 = read(obj1);
vid2 = read(obj2);
vid3 = vid1;
vid4 = vid2;
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 3월 4일
If the above was just for testing and eventually you will have four different videos, then see my response to
http://www.mathworks.com/matlabcentral/answers/30739-error-out-of-memory

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by