Skip to content

Distance Measurement

Version v1

Measure the distance between two bounding boxes on a 2D plane using a camera positioned perpendicular to the plane. This method requires footage from this specific perspective, along with either a reference object of known dimensions placed in the same plane as the bounding boxes or a pixel-to-centimeter ratio that defines how many pixels correspond to one centimeter.

Type identifier

Use the following identifier in step "type" field: roboflow_core/distance_measurement@v1to add the block as as step in your workflow.

Properties

Name Type Description Refs
name str The unique name of this step..
object_1_class_name str The class name of the first object..
object_2_class_name str The class name of the second object..
reference_axis str The axis along which the distance will be measured..
calibration_method str Select how to calibrate the measurement of distance between objects..
reference_object_class_name str The class name of the reference object..
reference_width float Width of the reference object in centimeters.
reference_height float Height of the reference object in centimeters.
pixel_ratio float The pixel-to-centimeter ratio of the input image, i.e. 1 centimeter = 100 pixels..

The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.

Available Connections

Check what blocks you can connect to Distance Measurement in version v1.

The available connections depend on its binding kinds. Check what binding kinds Distance Measurement in version v1 has.

Bindings
  • input

    • predictions (Union[object_detection_prediction, instance_segmentation_prediction]): The output of a detection model describing the bounding boxes that will be used to measure the objects..
    • reference_object_class_name (string): The class name of the reference object..
    • reference_width (float): Width of the reference object in centimeters.
    • reference_height (float): Height of the reference object in centimeters.
    • pixel_ratio (float): The pixel-to-centimeter ratio of the input image, i.e. 1 centimeter = 100 pixels..
  • output

    • distance_cm (integer): Integer value.
    • distance_pixel (integer): Integer value.
Example JSON definition of step Distance Measurement in version v1
{
    "name": "<your_step_name_here>",
    "type": "roboflow_core/distance_measurement@v1",
    "predictions": "$steps.model.predictions",
    "object_1_class_name": "car",
    "object_2_class_name": "person",
    "reference_axis": "vertical",
    "calibration_method": "<block_does_not_provide_example>",
    "reference_object_class_name": "reference-object",
    "reference_width": 2.5,
    "reference_height": 2.5,
    "pixel_ratio": 100
}