0
我有拍摄实时视频的代码,我有代码在图像上画两条线,所以我想将两个代码组合在一起,并且当一个对象出现在线上时,颜色会发生变化。我该怎么做呢?MATLAB的实时视频
以下是两个MATLAB程序。
代码用于拍摄视频直播:
clear;
dev_info = imaqhwinfo('winvideo',1);
celldisp(dev_info.SupportedFormats);
vid1 = videoinput('winvideo',1);
%out = imaqhwinfo(vid)
%This is for triggering:
num_frames=5;
triggerconfig(vid1, 'Manual')
set(vid1,'FramesPerTrigger',num_frames)
start(vid1);
trigger(vid1)
frame = getsnapshot(vid1);
image(frame);
%Here it will acquire five frames.
%Now move the data acquired to the workspace.
[data1 time1] = getdata(vid1,num_frames);
kk=length(time1);
elapsed_time = time1(kk) - time1(1);
%frame = getsnapshot(vid1); %This is to get a single frame.
%imaqmontage(data1)
%cleaning
delete(vid1);
clear vid1;
aviobj = avifile('example.avi')
for i=1:kk
F=data1(:,:,:,i);
aviobj = addframe(aviobj,F);
end
aviobj = close(aviobj);
%Then we can see the whole video clip.
mov = aviread('example.avi');
movie(mov)
%................
%Also, we can directly play the video from the video file.
mplay('example.avi');
代码的图像上绘制两条线:
im = imread('image.jpg');
imshow(im);
hold on;
line([27,1523],[1753,1753]);
line([7,1531],[1395,1395]);
hold off;
谢谢,但我不想使用Simulink你有任何其他的解决方案,请 – 2012-04-16 16:39:56