在ARcore

时间:2019-05-19 20:27:34

标签: unity3d arcore

我使用的是单位,我只是想让AR核心绘制并测量2个点之间的距离,但是它的工作原理还不错,但是这些点始终在检测到的平面上...我的需要是不依赖于就像这个程序一样检测到飞机。 http://armeasure.com 我发现了一些与特征点有关的东西,但是我对ARcore并不陌生。

我尝试在示例项目的HElloAR脚本中注释trackablehitflag.planewithpolygon

  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);
    }

禁用这些点后,甚至都没有在特征点命中标记上实例化

1 个答案:

答案 0 :(得分:0)

要放置点,有几种方法可以不在地点上添加点,例如,可以相对于摄影机在视图中的任意位置放置锚点,而与平面无关。

问题在于该点的深度。在下面的图片中,从2D角度看,所有线条的长度都完全相同,但是很明显,用户可能正在尝试测量不同深度的物品。

enter image description here

相对于摄像机放置锚点时,必须明确指定深度。例如,将其放置在相机预览的中心2米深处。

如果能够确保用户添加的每个锚点处于已知深度或指定的深度值,则应该能够添加3d世界坐标的锚点并进行测量。不幸的是,对于实际应用而言,这通常是不可能的,因为用户将不知道深度,并且当前设备没有深度传感器。

有些框架正在考虑向仅具有摄像头的设备添加深度感测-例如没有专用深度感应硬件的智能手机。一个(商业)示例是6D:https://www.6d.ai