Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to count the vehicles of non-uniform speed in a video without using computer vision toolbox?

1 visualización (últimos 30 días)
clc
clear all
n=0;
% Read movie
SF = 1; %Starting Frame
MV = mmreader('a.avi'); %To read Movie
EF = MV.NumberofFrames ; %Ending Frame
img = read(MV,1); %reading particular frame
A = double(rgb2gray(img)); %motion vector works on Gray Image formate
[height width] = size(A); %Movie size?
% motion estimation
h1 = figure(1);
for f = SF: EF %Frame from SF To EF
B = A;
img = read(MV,f);
A = double(rgb2gray(img));
%Foreground Detection
thresh=11;
fr_diff = abs(A-B);
for j = 1:width
for k = 1:height
if (fr_diff(k,j)>thresh)
fg(k,j) = A(k,j);
else
fg(k,j) = 0;
end
end
end
subplot(2,2,1) , imagesc(img), title (['Orignal Sequence Frame#',int2str(f)]);
subplot(2,2,2) , imshow(mat2gray(A)), title ('Previous Frame');
subplot(2,2,3) , imshow(mat2gray(B)), title ('Next Frame');
sd=imadjust(fg);
level=graythresh(sd);
m=imnoise(sd,'gaussian',0,0.025);
k=wiener2(m,[5,5]);
bw=im2bw(k,level);
[labeled,numObjects] = bwlabel(bw,4);
n=n+numObjects;
subplot(2,2,4) , imagesc(bw), title (['Foreground #',n]);
hold off;
pause (.1);
% saveas(h1,strcat('Result-Paris-',num2str(f)),'jpg');
end
disp(n);
The above is the code,which converts the frames into binary images and find the frame difference to detect the foreground objects. But it doesnt compute the correct count because I dont know to fix the correct interval between frames. Kindly help me in completing it.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by