I have calculated the distance between fixed object and moving object in a video. Using this distance I am trying to calculate the displacement of moving object in consecutive frame.

3 views (last 30 days)
rohan gupta
rohan gupta on 20 Nov 2014
Edited: rohan gupta on 21 Nov 2014
I have tried doing it, but I am getting error.
if true
% code
end X(r)=thisCentroid(:,1);
if r>=2
save dist_c dist_c;
for k=2:numberOfFrames
The error which I am getting while running the code is
  • Attempted to access dist_c(2); index out of bounds because numel(dist_c)=1 .
Error in Untitled2 (line 92)

Answers (1)

sandeep on 20 Nov 2014
Try using pdist() function to calculate the distance between two points and save it to an array. It is not clear in the code about k value from the loop. It looks your dist_c has only one value and you are trying access from the second value.
  1 Comment
rohan gupta
rohan gupta on 20 Nov 2014
I tried using pdist(), its not working. I am still getting same error
When I comment the
I am able to get the distance between stationary object and moving object for all the frames. Now I am trying to find the displacement of the moving object with respect to stationary object by subtracting the obtained distance of previous frame & present frame. In my video there are in all 900 frames.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!