1
votes

I am using unity, i simply want AR core to draw and measure a distance between 2 points but and its working fine but the points are always on the detected plane ...my need is to detect points anywhere not depending on the detected plane just like this app. http://armeasure.com i found something related to feature point but i don't know much as i am new to ARcore.

i tried commenting the trackablehitflag.planewithpolygon in the HElloAR script in example project

  TrackableHit hit;
            TrackableHitFlags raycastFilter =TrackableHitFlags.FeaturePointWithSurfaceNormal;
           // TrackableHitFlags.PlaneWithinPolygon 
            if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
            {
                // Use hit pose and camera pose to check if hittest is from the
                // back of the plane, if it is, no need to create the anchor.
             /*   if ((hit.Trackable is DetectedPlane) &&
                    Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position,
                        hit.Pose.rotation * Vector3.up) < 0)
                {
                    Debug.Log("Hit at back of the current DetectedPlane");
                }*/
             //   else
             //   {
                    // Choose the Andy model for the Trackable that got hit.
                    GameObject prefab;
                //    if (hit.Trackable is FeaturePoint)
                    //{
                        prefab = AndyPointPrefab;
                   // }
                    //else
                    //{
                  //      prefab = AndyPlanePrefab;
                    //}

                    // Instantiate Andy model at the hit pose.
                    var andyObject = Instantiate(prefab, hit.Pose.position, hit.Pose.rotation);
    }

after disabling the points were not even instantiating on the featurepoint hit flag

1

1 Answers

0
votes

For placing the points, there are several ways to add points not on a place, For example you can place an anchor anywhere in your view relative to the camera, independently of a plane.

The problem is the depth of the point. In the picture below all lines are exactly the same length from a 2D point of view, but clearly the user is probably trying to measure items at different depths.

enter image description here

When you place an anchor relative to the camera you have to explicitly specify the depth. For example, you place it at the centre of the camera preview at a depth of 2 meters.

If you are able to ensure that each anchor the user adds is at a known depth, or with a depth value specified, then you should be able to add the anchors with a 3d world coordinate and do your measurement. Unfortunately, for real work applications this is not usually possible as there user will not know the depth and current devices do not have depth sensors.

There are frameworks that are looking at adding depth sensing to devices that have just a camera - e.g. smartphones with no dedicated depth sensing hardware. One (commercial) example is 6D: https://www.6d.ai