Point cloud visualize using depth frame API.
Inheritance: MonoBehaviour, ITangoDepth
 /// <summary>
 /// Use this for initialization.
 /// </summary>
 public void Start()
 {
     m_marker.SetActive(false);
     m_pointCloud       = FindObjectOfType <TangoPointCloud>();
     m_pointCloudFloor  = FindObjectOfType <TangoPointCloudFloor>();
     m_tangoApplication = FindObjectOfType <TangoApplication>();
 }
Example #2
0
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_camera              = GetComponent <Camera>();
        m_tangoApplication    = FindObjectOfType <TangoApplication>();
        m_arCameraPostProcess = gameObject.GetComponent <ARCameraPostProcess>();

        if (m_tangoApplication != null)
        {
            m_tangoApplication.OnDisplayChanged += _OnDisplayChanged;
            m_tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (m_tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled              = true;
                renderer.material.shader      = m_occlusionShader;
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
 void Start()
 {
     m_pointCloud = FindObjectOfType <TangoPointCloud>();
     cornerCount  = 0;
     corners      = new List <Vector3>();
     //Input.gyro.enabled = true;
 }
 /// <summary>
 /// Use this for initialization.
 /// </summary>
 public void Start()
 {
     m_marker.SetActive(false);
     m_pointCloud = FindObjectOfType<TangoPointCloud>();
     m_pointCloudFloor = FindObjectOfType<TangoPointCloudFloor>();
     m_tangoApplication = FindObjectOfType<TangoApplication>();
 }
Example #5
0
 void Start()
 {
     uiElemets = GameObject.FindGameObjectsWithTag("dynamic_UI");
     setMindMapReferenceColor(0);
     markers       = new List <GameObject> ();
     m_dynamicMesh = FindObjectOfType <TangoDynamicMesh>();
     m_pointCloud  = FindObjectOfType <TangoPointCloud>();
 }
Example #6
0
    /// @cond
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_pointCloud       = FindObjectOfType <TangoPointCloud>();
        m_tangoApplication = FindObjectOfType <TangoApplication>();

        // All child objects are disabled until the floor is found.
        foreach (Transform t in transform)
        {
            t.gameObject.SetActive(false);
        }
    }
    /// @cond
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
        m_pointCloud = FindObjectOfType<TangoPointCloud>();
        m_tangoApplication = FindObjectOfType<TangoApplication>();

        // All child objects are disabled until the floor is found.
        foreach (Transform t in transform)
        {
            t.gameObject.SetActive(false);
        }
    }
Example #8
0
    void Start()
    {
        m_tangoApplication = FindObjectOfType <TangoApplication>();
        m_pointCloud       = FindObjectOfType <TangoPointCloud>();
        m_imagebuffer      = new TangoUnityImageData();

        if (m_tangoApplication != null)
        {
            m_tangoApplication.Register(this);
        }
        else
        {
            Debug.Log("No Tango Manager found in scene.");
        }
    }
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_screenSpaceMesh = new Mesh();
        m_camera          = GetComponent <Camera>();

        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        m_arCameraPostProcess = gameObject.GetComponent <ARCameraPostProcess>();
        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }

            // Pass YUV textures to shader for process.
            YUVTexture textures = tangoApplication.GetVideoOverlayTextureYUV();
            m_screenMaterial.SetTexture("_YTex", textures.m_videoOverlayTextureY);
            m_screenMaterial.SetTexture("_UTex", textures.m_videoOverlayTextureCb);
            m_screenMaterial.SetTexture("_VTex", textures.m_videoOverlayTextureCr);
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled = true;

                // Set the renderpass as background renderqueue's number minus one. YUV2RGB shader executes in
                // Background queue which is 1000.
                // But since we want to write depth data to Z buffer before YUV2RGB shader executes so that YUV2RGB
                // data ignores Ztest from the depth data we set renderqueue of PointCloud as 999.
                renderer.material.renderQueue = BACKGROUND_RENDER_QUEUE - 1;
                renderer.material.SetFloat("point_size", POINTCLOUD_SPLATTER_UPSAMPLE_SIZE);
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
    /// <summary>
    /// Inspector GUI event for immediate-mode Editor GUI.
    /// </summary>
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        TangoPointCloud inspectedObject = (TangoPointCloud)target;

        if (TangoPrefabInspectorHelper.CheckForTangoApplication(inspectedObject, ref m_tangoApplication))
        {
            TangoPrefabInspectorHelper.CheckDepthPermissions(m_tangoApplication);

            // Need motion tracking to transform points to world space.
            TangoPrefabInspectorHelper.CheckMotionTrackingPermissions(m_tangoApplication);

  //          TangoPrefabInspectorHelper.CheckAreaDescriptionPermissions(m_tangoApplication,
//                                                                        inspectedObject.m_useAreaDescriptionPose);
        }
    }
    /// <summary>
    /// Use this for initialization.
    /// </summary>
    public void Start()
    {
//        m_marker.SetActive(false);
        m_pointCloud       = FindObjectOfType <TangoPointCloud>();
        m_pointCloudFloor  = FindObjectOfType <TangoPointCloudFloor>();
        m_tangoApplication = FindObjectOfType <TangoApplication>();

        markerDrop = new bool[m_marker.Length];
        for (int i = 0; i < m_marker.Length; i++)
        {
            markerDrop [i] = false;
        }

        for (int i = 0; i < copyPosition.toBePlaced.Length; i++)
        {
            sceneDictionary.Add(i, copyPosition.toBePlaced[i]);
        }
    }
    // Use this for initialization
    void Start()
    {
        tangoPointCloud = gameObject.GetComponent <TangoPointCloud> ();

        pointsBuffer      = new Vector3[bufferSize][];
        timestampBuffer   = new double[bufferSize];
        pointsCountBuffer = new int[bufferSize];
        offsetBuffer      = new int[bufferSize];

        for (int i = 0; i < bufferSize; i++)
        {
            pointsBuffer [i] = new Vector3[MAX_POINT_COUNT];
            offsetBuffer [i] = bufferSize - i - 1;
        }

        m_mesh = GetComponent <MeshFilter>().mesh;
        m_mesh.Clear();

        m_renderer = GetComponent <Renderer>();
    }
Example #13
0
    public void Start()
    {
        _pointCloud = FindObjectOfType<TangoPointCloud>();

        if (_pointCloud == null)
        {
            Debug.LogError("TangoPointCloud is NULL, required to find floor.");
            return;
        }

        _tangoApplication = FindObjectOfType<TangoApplication>();

        if (_tangoApplication == null)
        {
            Debug.LogError("TangoApplication is NULL, required to find floor.");
            return;
        }


        //initialize
        _pointCloud.FindFloor();
    }
Example #14
0
    /// @cond
    /// <summary>
    /// Initialize the AR Screen.
    /// </summary>
    public void Start()
    {
        m_camera = GetComponent <Camera>();

        TangoApplication tangoApplication = FindObjectOfType <TangoApplication>();

        tangoApplication.OnDisplayChanged += _OnDisplayChanged;
        m_arCameraPostProcess              = gameObject.GetComponent <ARCameraPostProcess>();
        if (tangoApplication != null)
        {
            tangoApplication.Register(this);

            // If already connected to a service, then do initialization now.
            if (tangoApplication.IsServiceConnected)
            {
                OnTangoServiceConnected();
            }

            CommandBuffer buf = VideoOverlayProvider.CreateARScreenCommandBuffer();
            m_camera.AddCommandBuffer(CameraEvent.BeforeForwardOpaque, buf);
            m_camera.AddCommandBuffer(CameraEvent.BeforeGBuffer, buf);
        }

        if (m_enableOcclusion)
        {
            TangoPointCloud pointCloud = FindObjectOfType <TangoPointCloud>();
            if (pointCloud != null)
            {
                Renderer renderer = pointCloud.GetComponent <Renderer>();
                renderer.enabled              = true;
                renderer.material.shader      = m_occlusionShader;
                pointCloud.m_updatePointsMesh = true;
            }
            else
            {
                Debug.Log("Point Cloud data is not available, occlusion is not possible.");
            }
        }
    }
Example #15
0
 void Start()
 {
     m_pointCloud = FindObjectOfType <TangoPointCloud>();
 }
Example #16
0
 void Start()
 {
     spawnObject  = (GameObject)Resources.Load("Prefabs/SampleStage");
     m_pointCloud = FindObjectOfType <TangoPointCloud>();
 }
Example #17
0
 void Awake()
 {
     source                   = GetComponent <AudioSource>();
     tengoPointCloud          = gameObject.GetComponent <TangoPointCloud>();
     tangoDeltaPoseController = GameObject.Find("Tango Delta Camera").GetComponent <TangoDeltaPoseController>();
 }
 public void Start()
 {
     menuScript   = tangoController.GetComponent <MenuScript>();
     m_pointCloud = FindObjectOfType <TangoPointCloud>();
 }
Example #19
0
 /// <summary>
 /// Use this for initialization.
 /// </summary>
 public void Start()
 {
     m_pointCloud       = FindObjectOfType <TangoPointCloud>();
     m_pointCloudFloor  = FindObjectOfType <TangoPointCloudFloor>();
     m_tangoApplication = FindObjectOfType <TangoApplication>();
 }
Example #20
0
 public TangoTouchProjector(TangoApplication tangoApplication, TangoPointCloud pointCloud)
 {
     _tangoApplication = tangoApplication;
     _pointCloud       = pointCloud;
     _tangoApplication.Register(this);
 }
Example #21
0
    //public void RenderHand(TangoPointCloud pointCloud)
    //{
    //    List<int> indices = new List<int>();
    //    List<points> closePoints = new List<points>();

    //    int idx = 0;
    //    for (int i=0; i<pointCloud.m_pointsCount; i++)
    //    {
    //        if (Vector3.Distance(pointCloud.m_points[i], camera.transform.position) > 0.7f)
    //            continue;
    //        points newPoint = new points(pointCloud.m_points[i] , 0);
    //        closePoints.Add(newPoint);
    //        indices.Add(idx);
    //        idx++;
    //    }
    //    int currId = 1;
    //    int numPoints = cluster(closePoints, closePoints[0], 0, currId);
    //    Debug.Log(numPoints);

    //    List<Vector3> temp = new List<Vector3>();
    //    indices.Clear();
    //    idx = 0;
    //    foreach (points point in closePoints)
    //    {
    //        //renderer.material.SetColor("_Color", Color.red);
    //        if (point.classId == 1)
    //        {
    //            temp.Add(point.position);
    //            indices.Add(idx);
    //            idx++;
    //        }
    //    }
    //    mesh.Clear();
    //    mesh.vertices = temp.ToArray();
    //    mesh.SetIndices(indices.ToArray(), MeshTopology.Points, 0);

    //}

    public void RenderHand(TangoPointCloud pointCloud)
    {
        if (firstTime)
        {
            firstTime = false;
            //StartCoroutine(SpawnBlock());
        }
        List <int>     closePoints   = new List <int>();
        List <Vector3> closePointPos = new List <Vector3>();
        List <int>     indices       = new List <int>();
        int            idx           = 0;

        for (int i = 0; i < pointCloud.m_pointsCount; i++)
        {
            if (Vector3.Distance(pointCloud.m_points [i], camera.transform.position) > 1f)
            {
                continue;
            }
            closePoints.Add(i);

            indices.Add(idx);
            idx++;
            closePointPos.Add(pointCloud.m_points [i]);
        }
        numPoints = idx;
        mesh.Clear();
        if (numPoints < HAND_POINT_THRESH)
        {
            isHandVisible = false;
            handObject.SetActive(false);
            return;
        }
        else
        {
            isHandVisible = true;
            handObject.SetActive(true);
        }

        Vector3 centroid = pointCloud.GetAverageFromFilteredPoints(closePoints);

        //mesh.vertices = closePointPos.ToArray();
        //mesh.SetIndices(indices.ToArray(), MeshTopology.Points, 0);
        if (handQueue.Count > 3)
        {
            handQueue.Dequeue();
        }
        handQueue.Enqueue(centroid);
        Vector3 acc = new Vector3(0, 0, 0);

        Vector3[] handArray = handQueue.ToArray();
        for (int i = 0; i < handQueue.Count; i++)
        {
            acc += handArray [i];
        }
        acc /= handQueue.Count;
        initialHandObjPos = finalHandObjPos;
        Vector3 snappedPos = VoxelExtractionPointCloud.Instance.FromGrid(VoxelExtractionPointCloud.Instance.ToGrid(acc));

        //for (int i = 0; i < VoxelConsts.PT_THRES; i++ )
        //    VoxelExtractionPointCloud.Instance.grid.setVoxel(VoxelExtractionPointCloud.Instance.ToGrid(acc));
        //Debug.Log(snappedPos.x + " " + snappedPos.y + " " + snappedPos.z);
        finalHandObjPos = acc + new Vector3(0.5f, 0.5f, 0.5f);
        if (initialHandObjPos != finalHandObjPos)
        {
            StartCoroutine("MoveHand");
        }
        //handObject.transform.position = finalHandObjPos;
    }