a video in which I have to get the exact motion of a moving object and calculate the coordinates of that object before and after the movement.
Ältere Kommentare anzeigen
Hello . I have a video in which I have to get the exact motion of a moving object and obtain the coordinates of that object before and after the movement. Can you help me??
Antworten (2)
William Rose
am 29 Mär. 2022
0 Stimmen
@Haniye R, if the object is a well defined point in image 1 and image 2, then you can compute the motion in pixel coordinates:
PixelMotion=[px2-px1,py2-py1]
where px1,py1; px2,py2 are the pixel coordinates in images 1 and 2.
If you need motion in physical units such as meters, and if you only have one camera, then you need to make some assumptions and calibrate the image. For example, you assume the object is moving in a plane perpendicular to the camera view axis, and you orient the camera so that this is approximately true. You place a meterstick in the scene at that distance, to calibrate the image. Better yet, two perpendicular meter sticks. Then you can compute how many x pixels equals 1 meter (nx) and how many y pixels equals 1 meter (ny). Use those conversion factors to convert PixelMotion to MeterMotion:
MeterMotion=[(px2-px1)/nx,(py2-py1)/ny]
For motion in 3D, you need at least two, and preferably more, cameras. Calibration is complicated, to put it mildly.
6 Kommentare
William Rose
am 29 Mär. 2022
I opened the video you provided. I should have done that first :). I see that a calibraiton scale in the x direction is already provided (analagous to placing a meter stick in the image), and the movement is in a plane perpendicular to the camera axis, exactly as I recommended. Use the scale bar to compute nx, the number of pixels per meter in the x direction. Since there is no vertical scale bar, assume ny=nx. Freeze the image at different frames. Get the pixel coordinates of the + sign on the pendulum bob at each frame of interest. Convert to meters using the equations I gave above.
Haniye R
am 30 Mär. 2022
Haniye R
am 30 Mär. 2022
William Rose
am 30 Mär. 2022
Google "extract frames from video". You will find many options. One of the answers is here. I used his answer #2, which involves using VLC media player. I chose this because I already have VLC on my system. I followed the instructions and I set the recording ratio to 5, which means VLC will save every 5th frame. Then I closed VLC, to save the setting changes. Then I reopened VLC and opened the file 2.mpg. VLC saved every 5th frame in the Pictures folder on my Windows machine. The file names are scene00001.png, scene00005.png, ..., scene000146.png. Thirty files in all.
Open the last still image, scene000146.png. This image has the scale bar. Open it with any program that will show you your cursor poisition within the image. For example, you can open it with the Paint program, if you have a Windows system.
Move the cursor to the 0 line on the scale and to the 60 cm line. The horizontal pixel coordinates are 301 at 0 and 795 at 60 cm. Therefore the scale is (795-301)pixels/60cm = 8.23 pixel/cm.
Move the cursor to the + sign on the pendulum bob. Notice that the cursor coordinates are (828,655). Save this in a text file. Find the position of the + sign in the other frames. Add those coordinates to the text file. Now read the file in to a program of your choice, such as Matlab or Excel. Convert the pixel coordinates to centimeters, using the scale factor. You can determine the resting pendulum position from the first few frames, and subtract that position from the other values. This would establish an origin at the resting position.
Since vertical pixel coordinates increase going down, by convention, the y values do likewise. Negate the y values, if you prefer to have y positive up.
Good luck.
Haniye R
am 1 Apr. 2022
William Rose
am 1 Apr. 2022
@Haniye R, you're welcome.
Kategorien
Mehr zu C4ISR finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

