Filter löschen
Filter löschen

How I can get optical flow from sequential frames?( the number of frames is 180)

2 Ansichten (letzte 30 Tage)
Hi everyone, I have a question about image processing, I have a clip from dataset ped2. I want to get optical flow from this clip. But in my clip there are all of frames and I dont want to use film from, in fact my inputs are sequntional frames that their formats are '.png'.
please help me...
How I can get optical flow from this sequentioal images? (the number of frames is 180)
I got to know with several algorithm for optical flow, for example opticalFlowLKDoG, opticalFlowLK and opticalFlowHS, I know how I can use from those algorithm for get optical flow for a film but for a sequentioal frames I dont know....

Akzeptierte Antwort

hatefe soleymany
hatefe soleymany am 24 Mai 2022
I could write it answer.
We can use this cod:
for clip=1:16
clipsize= [10 150 150 180 180 150 150 120 180 180 180 180 180 150 150 150];
for i=10:clipsize(clip)
L1=imread(['outfile\test' int2str(clip) '\new_img' num2str(i-1) '.png']);
L2=imread(['ourfile\test' int2str(clip) '\new_img' num2str(i) '.png']);
ww = 40;
w = round(ww/2);
% Reduce the size of the image
sc = 2;
im2c = imresize(L2, 1/sc);
C1 = corner(im2c);
C1 = C1*sc;
% Discard coners near the margin of the image
k = 1;
for iI1 = 1:size(C1,1)
x_i = C1(iI1, 2);
y_i = C1(iI1, 1);
if x_i-w>=1 && y_i-w>=1 && x_i+w<=size(L1,1)-1 && y_i+w<=size(L1,2)-1
C(k,:) = C1(iI1,:);
k = k+1;
Ix_m = conv2(L1,[-1 1; -1 1], 'valid'); % partial on x
Iy_m = conv2(L1, [-1 -1; 1 1], 'valid'); % partial on y
It_m = conv2(L1, ones(2), 'valid') + conv2(L2, -ones(2), 'valid'); % partial on t
u = zeros(round(length(C)./3),1);
v = zeros(round(length(C)./2),1);
% within window ww * ww
for k = 1:length(C(:,2))
iI1 = C(k,2);
j = C(k,1);
Ix = Ix_m(iI1-w:iI1+w, j-w:j+w);
Iy = Iy_m(iI1-w:iI1+w, j-w:j+w);
It = It_m(iI1-w:iI1+w, j-w:j+w);
Ix = Ix(:);
Iy = Iy(:);
b = -It(:); % get b here
A = [Ix Iy]; % get A here
nu = pinv(A)*b;
hold on;
quiver(C(:,1), C(:,2), u,v, 1,'r')

Weitere Antworten (1)

hatefe soleymany
hatefe soleymany am 24 Mai 2022




Community Treasure Hunt

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

Start Hunting!

Translated by