0

我有用于拍摄实时视频的代码,并且我有在图像上绘制两条线的代码,所以我想将这两个代码组合在一起,当一个对象出现在线上时,颜色会发生变化。我该怎么做呢?

下面是两个 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;
4

1 回答 1

0

查找 Simulink 演示viptrackpeople。您可以尝试将视频源块从“多媒体文件”更改为阻止“来自视频设备的图像”,然后使用您的 MATLAB 处理代码添加一个块。我没有视频设备,因此无法验证这种方法。

于 2012-04-16T12:18:37.633 回答