Search code examples
iosroomplan

Getting measurements with RoomPlan


JSON for the CapturedRoom object in iOS RoomPlan library looks like this:

"walls": [
{
      "completedEdges": [ ],
      "story": 0,
      "curve": null,
      "identifier": "1786EBF8-1C92-486A-9B99-D6168FDF6052",
      "parentIdentifier": null,
      "confidence": {
            "high": { }
      },
      "category": {
            "wall": { }
      },
      "dimensions": [
            2.6529655,
            2.415,
            0
      ],
      "transform": [
            -0.50751626,
            0,
            0.8616421,
            0,
            0,
            1,
            0,
            0,
            0.8616421,
            0,
            0.50751626,
            0,
            -0.49793836,
            -0.16968237,
            -0.6089062,
            1
      ],
      "polygonCorners": [ ]
}

Documentation for this object from apple is here.

I'm wondering, since apps using LiDAR are able to take accurate measurements, how would I be able to do the same with the RoomPlan data? Is there some conversion that can tell me the length and width of my wall with this data? I'm finding very little documentation in regards to measurements of the data.


Solution

  • So it turns out it is very simple, you can figure out the size based purely on the dimensions array:

    "dimensions": [
          2.6529655,
          2.415,
          0
    ]
    

    These values are the length, height, and width respectively. Since this is a wall the width is 0, as it's just a scan of the surface. The values are already in meters, so in this case my wall is 2.65 meters wide, and 2.42 meters high. For other objects scanned in the room, all 3 would be populated, and also be in meters.

    I'm sure it gets a little more complicated if polygonCorners has information, as it means the object isn't a perfect rectangle, but for simple objects this is an easy way to grab measurements.