How do you track a tip of a pendulium and plot its displacement against time?
I’m trying to track the horizontal motion of a tip of an oscillating pendulum and plot it’s displacement versus time graph. This y-axis is fixed through the frames.
I know i have to : 1) upload the video 2) read each frame 3) track a point on each frame 4) plot the displacement of that tip vs time
video: https://www.dropbox.com/scl/fi/9kauaf0lxm8i69ru04xsl/FR.mp4?rlkey=mzrt6ffxjli7c30e90ir0bcv6&st=sxodfpxh&dl=0
And so far, i’ve used this:
close all;clear all;
% read video file; xyobj is an matlab object
%there are files:
filename=’FR1-10-2.mp4′;
xyobj = VideoReader(filename);
% number available frames
nframes = xyobj.NumberOfFrames-1
% frame rate
framerate=xyobj.FrameRate
vidHeight = xyobj.Height
vidWidth = xyobj.Width
frame(1) = struct(‘cdata’, zeros(vidHeight, vidWidth, 3, ‘uint8′),’colormap’,[]);
figure(1)
% Specify the boundary of the region to cut
b3=220;b4=350;
b1=375;b2=640;
xmax=b4-b3;
ymax=b2-b1;
hold on
grid on
xlabel(‘x’)
ylabel(‘y’)
axis([ 1 xmax 1 ymax]);
kk=0;
for k1 = 1:nframes-1,
k=nframes-k1;
k
frame(1).cdata=read(xyobj,k);
oneframe=frame(1).cdata;
oneframecut=oneframe(b1:b2,b3:b4,:); % cut an area with ball only to help for recognition
for jp=1:206,
jp1=jp+50-1;
greenChannel = oneframecut(jp1,:, 2);
[xm,im]=min(greenChannel);
xedge(k,jp)=im;
pedge(k,jp)=xm;
end
%pause(0.1)
end
save FR.pos xedge -ascii
pedge1=cast(pedge,"double");
save FR.val pedge1 -ascii
Your help is really appreciated!I’m trying to track the horizontal motion of a tip of an oscillating pendulum and plot it’s displacement versus time graph. This y-axis is fixed through the frames.
I know i have to : 1) upload the video 2) read each frame 3) track a point on each frame 4) plot the displacement of that tip vs time
video: https://www.dropbox.com/scl/fi/9kauaf0lxm8i69ru04xsl/FR.mp4?rlkey=mzrt6ffxjli7c30e90ir0bcv6&st=sxodfpxh&dl=0
And so far, i’ve used this:
close all;clear all;
% read video file; xyobj is an matlab object
%there are files:
filename=’FR1-10-2.mp4′;
xyobj = VideoReader(filename);
% number available frames
nframes = xyobj.NumberOfFrames-1
% frame rate
framerate=xyobj.FrameRate
vidHeight = xyobj.Height
vidWidth = xyobj.Width
frame(1) = struct(‘cdata’, zeros(vidHeight, vidWidth, 3, ‘uint8′),’colormap’,[]);
figure(1)
% Specify the boundary of the region to cut
b3=220;b4=350;
b1=375;b2=640;
xmax=b4-b3;
ymax=b2-b1;
hold on
grid on
xlabel(‘x’)
ylabel(‘y’)
axis([ 1 xmax 1 ymax]);
kk=0;
for k1 = 1:nframes-1,
k=nframes-k1;
k
frame(1).cdata=read(xyobj,k);
oneframe=frame(1).cdata;
oneframecut=oneframe(b1:b2,b3:b4,:); % cut an area with ball only to help for recognition
for jp=1:206,
jp1=jp+50-1;
greenChannel = oneframecut(jp1,:, 2);
[xm,im]=min(greenChannel);
xedge(k,jp)=im;
pedge(k,jp)=xm;
end
%pause(0.1)
end
save FR.pos xedge -ascii
pedge1=cast(pedge,"double");
save FR.val pedge1 -ascii
Your help is really appreciated! I’m trying to track the horizontal motion of a tip of an oscillating pendulum and plot it’s displacement versus time graph. This y-axis is fixed through the frames.
I know i have to : 1) upload the video 2) read each frame 3) track a point on each frame 4) plot the displacement of that tip vs time
video: https://www.dropbox.com/scl/fi/9kauaf0lxm8i69ru04xsl/FR.mp4?rlkey=mzrt6ffxjli7c30e90ir0bcv6&st=sxodfpxh&dl=0
And so far, i’ve used this:
close all;clear all;
% read video file; xyobj is an matlab object
%there are files:
filename=’FR1-10-2.mp4′;
xyobj = VideoReader(filename);
% number available frames
nframes = xyobj.NumberOfFrames-1
% frame rate
framerate=xyobj.FrameRate
vidHeight = xyobj.Height
vidWidth = xyobj.Width
frame(1) = struct(‘cdata’, zeros(vidHeight, vidWidth, 3, ‘uint8′),’colormap’,[]);
figure(1)
% Specify the boundary of the region to cut
b3=220;b4=350;
b1=375;b2=640;
xmax=b4-b3;
ymax=b2-b1;
hold on
grid on
xlabel(‘x’)
ylabel(‘y’)
axis([ 1 xmax 1 ymax]);
kk=0;
for k1 = 1:nframes-1,
k=nframes-k1;
k
frame(1).cdata=read(xyobj,k);
oneframe=frame(1).cdata;
oneframecut=oneframe(b1:b2,b3:b4,:); % cut an area with ball only to help for recognition
for jp=1:206,
jp1=jp+50-1;
greenChannel = oneframecut(jp1,:, 2);
[xm,im]=min(greenChannel);
xedge(k,jp)=im;
pedge(k,jp)=xm;
end
%pause(0.1)
end
save FR.pos xedge -ascii
pedge1=cast(pedge,"double");
save FR.val pedge1 -ascii
Your help is really appreciated! image processing MATLAB Answers — New Questions