How can I quantify or compare the movements of similar type of complex objects from 2 different videos? (Suppose I saved a particular frames from the videos).

조회 수: 3 (최근 30일)
I have 2 separate videos of similar type of objects moving slowly (back and forth or side-by-side). I want to compare and quantify the movements from 2 different videos. The videos are kind of black and white. One idea came to my mind: colormapping the videos/particular frame to indicate movement. Initially, I am trying to detect the edge, but from comparion seems unclear from edge detection. The code that I am using:
% dir = 'C:\Asif\Post processing';
% [fileName, filePath] = uigetfile({'*.*'},'MultiSelect', 'on', '', dir);
%
% if isequal(fileName, 0); errorMsg; return; end; [~, n] = size(fileName);
% if ischar(fileName)==1; n = 1; fileName = cellstr(fileName); end
%
% vr = VideoReader(fullfile(filePath, string(fileName)));
% vid = vr.read();
% vid = vid(:,:,:,1);
% imshow(vid)
ear = imread("ear.jpg");
ear = rgb2gray(ear);
[earEdge,thresh] = edge(ear,"log");
newEdge = edge(ear,"log",thresh/0.45);
imshow(newEdge)

답변 (1개)

Aastha
Aastha 2024년 8월 16일
Hi Md. Asif Hasan,
I understand you are trying to quantify motion of similar objects from two different videos using colour-mapping technique.
You can achieve this by estimating the optical flow of each moving object. By estimating optical flow between video frames, you can measure the velocities of objects in the video and then compare them.
You can estimate the optical flow in MATLAB using “estimateFlow” function that estimates the optical flow of the input video.
Here is the sample code where I compute optical flow for the video "video.mp4":
vidObj = VideoReader('video.mp4','CurrentTime',15); % Create a Video Reader object to read frames from the video ‘video.mo4’. Specify the time-stamp using the CurrentTime name-value argument
of = opticalFlowHS; % Specify the optical-flow method you want to use.
figure; % create a figure to visualize the motion vectors
rgbframe = (readFrame(vidObj)); % read a frame from the video
grayframe = im2gray(rgbframe); % convert the rgb frame to grayscale
flow = estimateFlow(of,grayframe); % estimate the optical-flow and store it in the flow variable
imshow(rgbframe) % visualize the RGB frame
hold on
plot(flow,'DecimationFactor',[10 10],'ScaleFactor',60); % plot the flow vectors
hold off
title('Frame Motion Visualization')
Refer to the following MathWorks documentation link for more information on
  • optical flow
  • estimateFlow” function
Hope this helps!

Community Treasure Hunt

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

Start Hunting!

Translated by