Determine dimensions of objects in mesh


#1

Hi!

The app I created will be used to calculate the dimensions of a wall. Using the RANSAC algorithm I want to determine which coordinates belong to the wall and which are for example from the ceiling. This should be no problem. But when I have determined all vertices of the wall, how do I determine the dimensions of the surface? Put it differently, how do I convert the distance between 2 vertices in the mesh to a distance in meters?

I’ve done some research, but I still don’t know where to start and which data sources from the SDK I should use. Hope someone could help me get started.


#2

I would recommend taking a look at the room capture sample app available in the SDK download.

That application includes a rudimentary measurement functionality.

Specifically, take a look at the following function in MeshViewController.mm:

- (void)enterMeasurementState:(MeasurementState)state

This function has the following line that might be helpful to you:

float distance = GLKVector3Length(GLKVector3Subtract(_pt2, _pt1));


#3

Thank you for your reply Anthony. I already found this in de app. But if I’m correct, this will only calculate the distance of the two points in vector space. I need this distance translated to the distance in meters. Do you have any ideas on how to get this translation done?


#4

You can find the code to convert vectors to meters below, but I encourage you to take a deeper look into our sample apps

        self.measurementButton.enabled = true;
        [self.measurementButton setTitle:@"Clear" forState:UIControlStateNormal];
        
        float distance = GLKVector3Length(GLKVector3Subtract(_pt2, _pt1));
        if (distance > 1.0f)
            _rulerText.text = [NSString stringWithFormat:@"%.2f m", distance];
        else
            _rulerText.text = [NSString stringWithFormat:@"%.1f cm", distance*100];
        _circle2.hidden = false;
        [self hideMeshViewerMessage:self.measurementGuideLabel];