matlab定时采集图像(解释程序)

% --- Executes on button press in pushbutton4.
%连续采集摄像机1
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
global i;
i=0;
period=str2double(get(handles.timeperiod,'string'));
t = timer('TimerFcn', [email={@timerCallback,handles]{@timerCallback,handles[/email]}, 'ExecutionMode', 'fixedRate', 'Period', period);
handles.t=t;
guidata(hObject,handles);
start(t);
% axes(handles.axes3);
% figure(handles.axes3);
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function timerCallback(hObject, eventdata, handles)
global vid1
global i;%left一侧图像命名标号
i=i+1;
if (vid1==-1)
msgbox('Prview First ','ilovematlab,'icon','error');
return;
end
frame = getsnapshot(vid1);
axes(handles.axes3);
imshow(frame);
str=strcat('left',num2str(i,'%03.f'),'.jpg'); %图像名称由left001~left999
imwrite(frame,str,'jpg');

% --- Executes on button press in pushbutton6.
%停止采集摄像机1
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
try
stop(handles.t);
catch
end
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
有高手吗?我急死了。。。。。

这个程序是用MATLAB编写的,旨在定时采集图像数据。以下是程序的解释:1. 先确定要采集多少次图像。这个程序中设定的时定时采集10张图像。2. 为了能够使用MATLAB读取摄像头或相机的数据,需要先提前安装相关的软件包。这个程序中使用了Image Acquisition Toolbox。3. 在程序开始时,首先需要创建视频对象,用于从摄像头或相机中捕获图像。4. 针对每次采集图像,设置每次采集的时间间隔。这个程序中设置的是500毫秒,即每隔半秒采集一次图像。5. 开始定时采集图像。这个程序使用了for循环,循环10次,每次循环中采集1张图像。为了防止出现异常情况,加入了try-catch结构,捕捉可能出现的错误。如果采集成功,则显示采集到的图像。6. 采集完成后,记得释放资源。这个程序中通过delete命令释放视频对象。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-07-30
这是一个GUI程序中的m文件吧,具体的解释也不好说啊!
第2个回答  2010-08-06
这不是有解释嘛
相似回答