Changing CSV output from pixels to a known distance?

I have been working with deeplabcut to track points for the purpose of calculating general movement statistics. I have a known scale bar in frame throughout my videos.

Is it possible/has anyone found a way to take set a scale so that the CSV output would be converted from pixels to meters? Alternatively, is there a way to measure the pixel to meter conversion simply using the GUI?

I have thought of a few work-arounds: using ImageJ to determine pixel to meter conversion, train a network to track my scale bar so I can get the distance in pixels, etc.
However, I would prefer to get my pixel to distance measurement from deeplabcut if possible and would prefer to avoid training a network for this as I’m working off a CPU.

1 Like

Hi @Aspen_Kozak - you can load the .h5 files in Jupyter (for example), and then simply multiply the relevant columns in the HDF5 file by the distance metric you want to use. You can see the the pixels are relative to the image origin (top left corner) - when you run deeplabcut.plot_trajectories, you would get these plots, or in the notebook I link below you can reproduce and customize them:


Here is a notebook you can use:

I.e., let’s say in your image 100 pixels = 100 cm then of course you can convert easily to 100 pixels = 100 cm (1 pixel = 1 cm), etc.

Hi Mackenzie,
Thank you–much appreciated! The depth of literature and user advice you have created has been extremely helpful in using deeplabcut.

1 Like

thanks so much! :slight_smile: :slight_smile: