我正试图用Matlab来查看对象的速度,所以我想出了下面的代码
reader = vision.VideoFileReader ('C:\folder1\objectsandflow.avi');
viewer = vision.DeployableVideoPlayer;
optical = vision.OpticalFlow;
optical.OutputValue = 'Horizontal and vertical components in complex form';
videoPlayer = vision.VideoPlayer('Name','Motion Vector');
while isDone (reader)
I = step(reader);
of = step (optical, rgb2gray(I));
y = of .* conj(of);
step(viewThresh,y>mean(y(:)));
step(videoPlayer)
end
release(videoPlayer);
release(reader);问题是,我既看不到流的值(我的意思是我在寻找某些物体的速度,我可以使用Matlab对其进行搜索,对吗?)
同时,我不知道在这段代码不能的情况下,这是否能计算出我的对象的所有速度,如何在Matlab中计算多个速度呢?
发布于 2014-09-08 14:06:16
你的问题就在这两行:
step(viewThresh,y>mean(y(:)));
step(videoPlayer)试着用以下方法替换它们:
viewThresh = y;
viewThresh(y < mean(y(:))) = 0;
step(videoPlayer, viewThresh);您不需要step方法来进行y的阈值处理,因为您没有使用任何对象。当您在step对象上调用videoPlayer时,您必须传递希望显示的视频帧。
https://stackoverflow.com/questions/25684418
复制相似问题