APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

Measuring Distance from Point Mass to Polyline in Tracker post and replies

Return to the Measuring Distance from Point Mass to Polyline in Tracker thread
Login to post to this thread

Measuring Distance from Point Mass to Polyline in Tracker
Jessica Rempel
2 Posts

Hello everyone,

I am using Tracker to analyze a videos of cyclists, and I would like to measure the distance from the tracked point (Point Mass) to a reference line (Polyline) over time. The reference line represents the edge of the road.

I am wondering if there is a built-in way in Tracker to:

Automatically calculate the perpendicular distance from a Point Mass to a Polyline.

Store these distances as a new data column for plotting/exporting over time.

Has anyone solved this problem or can suggest a workflow to track distances relative to a line efficiently?

Thank you for your help!


Replies to Measuring Distance from Point Mass to Polyline in Tracker

Re: Measuring Distance from Point Mass to Polyline in Tracker -
Vratislav Pechanec
6 Posts

Hello Jessica,
I am not sure I understand you well, could you send a picture of your idea?

Maybe you can set the Tracker coordinate system to the bicycle with moving Origin, Angle and/or Scale and measure the Point Mass position directly.

Best regards,
Vratislav



Re: Measuring Distance from Point Mass to Polyline in Tracker -
Jessica Rempel
2 Posts

Hello Vratislav,

thank you for your response. I'd like to track the distance between the side of the road (curb/ kerb) and the bike to analyse the postion on the road and the influence of "door-dashing" fear.

I'd love to define the curb as a reference line instead of referencing to the X-Axis.

Does that help?

Best regards, Jessica

Attached File: Screenshot20251124122052.png



Re: Measuring Distance from Point Mass to Polyline in Tracker -
Vratislav Pechanec
6 Posts

Hello Jessica,

Thank you for the screenshot of your video.

Maybe I am not too experienced Tracker user nor I do not know all Tracker features but if your camera is fixed and does not follow the bike (i.e. the curb lies on the same place in the video frame during the record and so its position is not time-dependent) I would try to read x and y coordinates of the curb in your co-ordinate system, put them for example into a spreadsheet to plot its graph and use for example a polynomial regression function for its approximation. This way you obtain a regression equation of curb_y=f(curb_x) i.e. curb vertical position=f(horizontal position), i.e. the curb reference curve. Then in the Tracker you can use item "Define..." to display a Data Builder where you can define new custom variable for calculating your bike distance from the curb, something like dist=curb_y(x)-y.

For more details about the data builder see paragraph 8. Defining new data columns with Data Builder in the Plot View chapter (https://physlets.org/tracker/help/plotview.html) of the Tracker Help (https://physlets.org/tracker/help/frameset.html).

Further interesting Tracker feature is the External model (https://physlets.org/tracker/help/datatrack.html).

I hope it is not over-engineered. ;-)

Best regards,

Vratislav



Re: Measuring Distance from Point Mass to Polyline in Tracker -
Douglas Brown Avatar
Douglas Brown
465 Posts

Hi Jessica, here's something that might work:

1. Open the video in Tracker, set its clip properties (start frame, step size, etc), and set the scale. Leave the origin and angle fixed. Save this tab as a TRK file.
2. Open the saved TRK in a second tab.
3. In the first tab, track the cyclist with a point mass and save the changed TRK. Each y-value is the point's perpendicular distance from the (fixed) x-axis (not yet what you want!).
4. In the second tab, uncheck the fixed origin and angle boxes in the Coordinate System menu. Then in each frame set the origin and angle such that the x-axis is right on the curb. Save this tab as a second TRK file.
5. In the second tab, choose Edit|Copy Object|Coordinate System.
6. In the first tab, choose Edit|Paste Coordinate System. The y-values are now measured from the curb in each frame!
7. You can choose Edit|Undo Edit Coordinate System and Edit|Redo Edit Coordinate System to switch between the fixed axis and the curb axes.

Does this work for you?  Doug



>  I'd like to track the distance between the side of the
> road (curb/kerb) and the bike to analyse the position
> on the road and the influence of "door-dashing" fear.
>
>
> I'd love to define the curb as a reference line
> instead of referencing to the X-Axis.



Re: Measuring Distance from Point Mass to Polyline in Tracker -
Vratislav Pechanec
6 Posts

Hello Doug,
that's great method! Thank you for the idea. :-)

Vratislav



Re: Measuring Distance from Point Mass to Polyline in Tracker -
Fernando Ferro
16 Posts

Hi,
It is certainly possible to measure it, but if what you need is an estimate of speed and trajectory for a forensic case, then when the source is a video and the camera is moving, you have two problems to solve:

1-Tracking the curb line, which is easy to do in Tracker.
2-Accounting for a possible change in FPS. This isn't so straightforward in Tracker. I recommend checking the video's properties with MediaInfo or ffmpeg beforehand to avoid unpleasant surprises later.
Tracker does not handle variable frame rate videos well. This is beyond its control, as it depends on a third-party player. More and more videos use variable frame rates to reduce file size.
Best regards
Fernando



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book