Validate measurements in mixed reality using a spatial test filter

Using the Measure in MR control, you can create a spatial test filter to validate whether an object with known width, depth, and height dimensions will fit in a space. This topic will guide you through creating a test app that you can use to validate the collected measurements, including:

  • Inserting the Measure in MR control into an application to measure volumes.
  • Setting up Expected Measurements (Items) to help users maintain context in the mixed-reality experience.
  • Creating a spatial test filter using the Bounding Depth, Bounding Width, and Height properties from the measurement outputs.

Prerequisites

Create a blank canvas app.

Tip

  • The mixed-reality controls work best in well-lit environments with flat-textured surfaces. When establishing tracking, point the device at the surface you want to track and slowly pan the device from right to left in broad arm motions. If tracking fails, exit and enter the mixed-reality view to reset the tracking and try again.
  • LIDAR-enabled devices will also result in better tracking.

Set up minimum dimensions input fields

First, we’ll set up the dimensions to validate measurements.

  1. Select the Insert tab, and insert three Text labels on the canvas.

    Screenshot showing how to insert a text label from the menu.

  2. Change Text properties for the added labels to Minimum Width, Minimum Depth, and Minimum Height.

    Screenshot showing placed text labels.

  3. Select the Insert tab, insert three Text Input controls, and position them next to the three labels inserted in the previous step.

  4. Rename Text Input controls to minWidth, minDepth, and minHeight.

  5. For all three Text Input controls added in the previous step, set the Format property to Number and set the Default property value to 1.0.

    Screenshot showing text inputs and properties.

Insert and bind the Measure in MR control

Next, we’ll set up the Measure in MR control to allow users to capture measurements, and bind the output value we'll use to validate the measurement.

  1. Select the Insert tab.

  2. Expand Mixed Reality.

  3. Select Measure in MR, and place it at the bottom of the application.

    Screenshot showing insertion of a Measure in MR control.

  4. Update the following properties for the Measure in MR control.

    Property name Value
    Unit of measurement Feet or Meters
    Measurement type Volume
    Box Draw True

    Screenshot showing Measurement type and Unit of measurement property values.

  5. Select the Items property from the upper-left side of the screen for the Measure in MR control, and update the formula to the following.

    Table({label:"Test Volume"})
    

    This formula creates a table with the label of "Test Volume" as a single expected measurement output.

    Screenshot showing formula bar settings for Items.

  6. Set the ItemsLabels property of the Measure in MR control to "label".

    Screenshot showing advanced property settings for Items and ItemsLabels.

  7. Set the OnMixedRealitySelect property to the following formula.

    Set(testVolume, LookUp(MeasureInMR1.Measurements, Label = "Test Volume"));
    

    This formula sets the "testVolume" variable with the value of the label looked up from the mixed-reality control's measurements property.

    Screenshot showing property setting for OnMixedRealitySelect.

Perform the measurement test and display the results

  1. Select the Insert tab, and insert four Text labels.

    Screenshot showing four added text labels.

  2. Set the Text property of the added labels as the following.

    1. First label:

          If(IsBlankOrError(testVolume), "No Measurement captured",
          If(testVolume.Height >= Value(minHeight.Text) &&
          ((testVolume.BoundingWidth >= Value(minWidth.Text) && testVolume.BoundingDepth >= Value(minDepth.Text)) ||
          (testVolume.BoundingWidth >= Value(minDepth.Text) && testVolume.BoundingDepth >= Value(minWidth.Text))),
          "Fit Test Succeeded", "Fit Test Failed"))
      

      This formula determines whether the measurement tests succeeded, failed, or aren't captured depending on the height, width, and depth parameter values.

      Screenshot showing the formula for the spatial test predicate.

    2. Second label:

      Concatenate("Bounding Width: ", Text(testVolume.BoundingWidth))
      

      This formula updates the label text and the relevant measurement parameter, in this case—"width".

    3. Third label:

      Concatenate("Bounding Depth: ", Text(testVolume.BoundingDepth))
      
    4. Fourth label:

        Concatenate("Bounding Height: ", Text(testVolume.Height))
      

    With all four label formulas updated, the screen should look like the following.

    Screenshot showing the final completed application.

Test the app

Press F5 on the keyboard, or select the preview button to run the app in preview mode. Then, select Measure in MR to get the labels populated with data.

You can verify that the bindings are working as expected by changing values in the three text input fields to check that the filter is updating properly.

The values for Bounding Width and Bounding Depth can be swapped when performing the test. After saving and publishing the app, you can open it on a mixed-reality–enabled device to test whether an object with the specified dimensions will fit within the bounds of any measurement captured.

Filtering a data source

This sample application only tests for a single set of user-specified dimensions. However, you can extend it to work as a filter for any data source by applying the formula as a Filter predicate.

For example, let's say that our app contains a reference to a Dataverse table named Products that includes three columns—Width, Depth, and Height (corresponding to each product's dimensions). To filter the collection to only those measurements that would fit within a measured volume, we can apply the following formula.

If(IsBlankOrError(testVolume), Products,
    Filter(Products, testVolume.Height >= Height &&
        ((testVolume.BoundingWidth >= Width && testVolume.BoundingDepth >= Depth) ||
        (testVolume.BoundingWidth >= Depth && testVolume.BoundingDepth >= Width))))

See also