hello, I have 10 frames and I want to delete the similar frames. how can I achieve it with (for loop) on multiple arrays

댓글 수: 2

Guillaume
Guillaume 2018년 12월 16일
What is a similar frame, mathematically?
Salim Dada
Salim Dada 2018년 12월 16일
like this
I=[0,0,0,0,0;0,0,90,0,0;0,0,90,0,0;90,90,90,0,0;0,0,0,0,0]
k=[0,0,0,0,0;0,0,90,0,0;0,0,90,0,0;90,90,90,0,0;0,0,0,0,0]

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

답변 (1개)

Mark Sherstan
Mark Sherstan 2018년 12월 16일

0 개 추천

As a video is just a bunch of pictures and pictures are just matrices you can subtract the two frames (or matrices) to find the differences. How you want to analyze the data or define change (e.g. - is it 5% change or less or more) I will leave up to you. This should put you in the right direction tho:
v = VideoReader('test.mp4');
framePrev = readFrame(v);
% Loop through video frame by frame
while hasFrame(v)
frameCurrent = readFrame(v);
frameCompare = frameCurrent-framePrev;
imshow(frameCompare)
framePrev = frameCurrent;
end

댓글 수: 4

Salim Dada
Salim Dada 2018년 12월 16일
thank you a lot, but this work if the two frames was the same matrex? and delete them?
I dont understand your question, can you please rephrase or provide an example? You can just store an index counter to track the frames you are happy with. E.g.
if tol < 0.05
idx(ii) = 1;
else
idx(ii) = 0;
end
Salim Dada
Salim Dada 2018년 12월 16일
I want to delete the redundant frames to compress the video
vIn = VideoReader('videoIn.mp4');
vOut = VideoWriter('videoOut.mp4');
open(vOut)
framePrev = readFrame(vIn);
while hasFrame(vIn)
frameCurrent = readFrame(vIn);
if (frameCurrent ~= framePrev)
writeVideo(vOut,frameCurrent)
end
framePrev = frameCurrent;
end
close(vOut)

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

태그

질문:

2018년 12월 16일

댓글:

2018년 12월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by