sir, Am doing a project based on camera based vehicle speed measurement we used block matching algorithm to compare first and last frame of the video captured could u pls help me out by suggesting a program code for this.

답변 (1개)

Mark Darwin
Mark Darwin 2019년 11월 27일

1 개 추천

% Copyright 2015-2016 The MathWorks, Inc.
%%
close all
clear
clc
tic
%% Set up video reader
videoReader = vision.VideoFileReader('buoyMotion.avi',...
'ImageColorSpace','Intensity');
%% Set up optical flow
of = opticalFlowHS;
of.Smoothness = 0.1;
% of = opticalFlowFarneback();
% of.NumPyramidLevels = 1;
% of = opticalFlowLK();
% of.NoiseThreshold = 0.01;
% of = opticalFlowLKDoG();
% of.NoiseThreshold = 1e-4;
%% Loop algorithm
while(~isDone(videoReader))
vidFrame = step(videoReader);
flowField = estimateFlow(of,vidFrame);
subplot(2,2,1);
plot(flowField,...
'DecimationFactor',[10 10],...
'ScaleFactor',50);
title('Optical Flow')
horizontalMotion = flowField.Vx;
objectsToRight = horizontalMotion > 1;
objectsToLeft = horizontalMotion < -1;
subplot(2,2,3);
imshow(objectsToRight);
title('Objects moving to the RIGHT side’)
subplot(2,2,4);
imshow(objectsToLeft);
title('Objects moving to the LEFT side')
robotLeftMotion = nnz(objectsToRight);
robotRightMotion = nnz(objectsToLeft);
if robotLeftMotion > robotRightMotion
movString = 'Moving to LEFT';
else
movString = 'Moving to RIGHT';
end
frameMov = insertText(vidFrame,[400 400],movString,...
'FontSize',26);
subplot(2,2,2);
imshow(frameMov)
title('Robot Movement')
drawnow;
End
%% Clean up
timeElapsed = toc
release(videoReader);

댓글 수: 1

Mark Darwin
Mark Darwin 2019년 11월 27일
video about motion for Block matching algoritm
https://drive.google.com/file/d/1v6YcZr4H_S5nKOd_jU4KS14djNYb4xc-/view?usp=sharing

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

질문:

2011년 9월 23일

댓글:

2019년 11월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by