Exemple #1
0
 void onPointCloudsChanged(ARPointCloudChangedEventArgs args)
 {
     foreach (var pointCloudUpdated in args.updated)
     {
         numPointsUpdated += 1;
     }
 }
    private void PointCloudManager_pointCloudsChanged(ARPointCloudChangedEventArgs obj)
    {
        List <ARPoint> addedPoints = new List <ARPoint>();

        foreach (var pointCloud in obj.added)
        {
            foreach (var pos in pointCloud.positions)
            {
                ARPoint newPoint = new ARPoint(pos);
                addedPoints.Add(newPoint);
            }
        }
        savePoints(addedPoints);

        List <ARPoint> updatedPoints = new List <ARPoint>();

        foreach (var pointCloud in obj.updated)
        {
            foreach (var pos in pointCloud.positions)
            {
                ARPoint newPoint = new ARPoint(pos);
                updatedPoints.Add(newPoint);
            }
        }
        savePoints(updatedPoints);
    }
    /// <summary>
    /// Function that is called when point cloud is updated.
    /// </summary>
    /// <param name="obj">Object with parameters.</param>
    private void ARPointCloudManager_pointCloudsChanged(ARPointCloudChangedEventArgs obj)
    {
        if (addWhenTouched && !(Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Stationary))
        {
            return;
        }

        // here we use only the first element in array updated
        if (obj.updated.Count == 0)
        {
            return;
        }

        var updated = obj.updated[0];

        for (int i = 0; i < updated.positions.Length; ++i)
        {
            if (CheckPoint(updated.positions[i], updated.confidenceValues[i]))
            {
                voxelSet.AddPoint(updated.identifiers[i], updated.positions[i], updated.confidenceValues[i], Camera.current.transform.forward, uniteNearbyPoints);
            }
        }

        voxelSet.Update();
    }
Exemple #4
0
 void ARPointCloudManagerOnPointCloudsChanged(ARPointCloudChangedEventArgs pointCloudEvent)
 {
     UpdatePoints();
     if (PointCloudUpdated != null)
     {
         PointCloudUpdated(GetPoints());
     }
 }
        private void PointcloudChanged(ARPointCloudChangedEventArgs obj)
        {
            if (!m_generate)
            {
                return;
            }

            List <Vector3> addedPoints = new List <Vector3>();

            for (int i = 0; i < obj.updated.Count; i++)
            {
                ARPointCloud cloud = obj.updated[i];
                if (cloud.positions.HasValue)
                {
                    for (int x = 0; x < cloud.positions.Value.Length; x++)
                    {
                        // only allow points over the confidenceThreshhold
                        if (cloud.confidenceValues.Value[x] > m_confidenceThreshhold)
                        {
                            addedPoints.Add(cloud.positions.Value[x]);
                        }
                    }
                }
            }

            if (addedPoints.Count > 0)
            {
                // only do color calculation if colormode is on
                if (m_includeColors)
                {
                    UpdateCameraTexture();
                    List <Color> pointColors = new List <Color>();

                    for (int i = 0; i < addedPoints.Count; i++)
                    {
                        Vector2 screenpos    = cam.WorldToScreenPoint(addedPoints[i]);
                        Vector2 texturecoord = screenpos;
                        texturecoord.x = Mathf.Clamp01(texturecoord.x / Display.main.renderingWidth);
                        texturecoord.y = Mathf.Clamp01(texturecoord.y / Display.main.renderingHeight);

                        //  texturecoord.y = 1 - texturecoord.y;

                        // flip X
                        texturecoord.x = 1 - texturecoord.x;

                        pointColors.Add(m_cameraTexture.GetPixel((int)(texturecoord.y * m_cameraTexture.width), (int)(texturecoord.x * m_cameraTexture.height)));
                    }

                    m_manager.Populate(addedPoints.ToArray(), pointColors.ToArray());
                }
                else
                {
                    m_manager.Populate(addedPoints.ToArray());
                }
            }
        }
Exemple #6
0
    // Used to debug when the point cloud is changed
    void OnPointCloudChanged(ARPointCloudChangedEventArgs eventargs)
    {
        if (eventargs.updated.Count == 1)
        {
            foreach (var ptcloud in eventargs.updated)
            {
                mCurrentTrackedFeatureCount = ptcloud.positions.Length;
                Debug.Log("Cursor: Current tracked feature count = " + mCurrentTrackedFeatureCount);
            }

            timeOfLastPtCloudUpdate = Time.time;
        }
    }
 /// <summary>
 /// 检测anchor变化回调
 /// </summary>
 /// <param name="changeEvent"></param>
 public void PointChanged(ARPointCloudChangedEventArgs changeEvent)
 {
     for (int i = 0; i < changeEvent.added.Count; i++)
     {
         TrackPointPlane.Add(changeEvent.added[i]);
     }
     for (int i = 0; i < changeEvent.removed.Count; i++)
     {
         if (TrackPointPlane.Contains(changeEvent.removed[i]))
         {
             TrackPointPlane.Remove(changeEvent.removed[i]);
         }
     }
 }
 private void OnPointCloudsChanged(ARPointCloudChangedEventArgs eventArgs)
 {
     if (isRecording)
     {
         foreach (var pointCloud in eventArgs.updated) // for updated point cloud
         //foreach (var pointCloud in eventArgs.added) // for every added point cloud
         {
             Parallel.Invoke(
                 () => CalculateConfidance(pointCloud),
                 () => AddPointCloudToList(pointCloud)
                 );
         }
     }
 }
Exemple #9
0
 public void UpdatedCloudPoints(ARPointCloudChangedEventArgs change)
 {
     for (int i = 0; i < arPointCloud.identifiers.Value.Length; i++)
     {
         if (arPointCloud.confidenceValues.Value[i] > 0.4f)
         {
             points.Add(arPointCloud.positions.Value[i]);
         }
     }
     if (arPointCloud.identifiers.Value.Length >= 500)
     {
         updateCloudFlag = true;
     }
 }
Exemple #10
0
    private void HandleARPointCloudsChangedEvent(ARPointCloudChangedEventArgs obj)
    {
        // arPointCloudsCounter += obj.added.Count;
        // arPointCloudsCounter -= obj.removed.Count;

        arPointClouds.UnionWith(obj.added);
        arPointClouds.UnionWith(obj.updated);
        arPointClouds.ExceptWith(obj.removed);
        arPointCloudsCounter = 0;
        foreach (ARPointCloud aRPointCloud in arPointClouds)
        {
            arPointCloudsCounter += aRPointCloud.positions.Length;
        }
        UpdatePlaneCounterText();
    }
Exemple #11
0
    private void CloudUpdate(ARPointCloudChangedEventArgs obj)
    {
        if (!(Input.touchCount > 0 && Input.touches[0].phase == TouchPhase.Stationary))
        {
            return;
        }

        // here we use only the first element in array updated
        if (obj.updated.Count == 0)
        {
            return;
        }

        var updated = obj.updated[0];

        for (int i = 0; i < updated.positions.Length; ++i)
        {
            //if (Vector3.Distance(updated.positions[i], Camera.current.transform.position) < maxDistance)
            if (CheckPoint(updated.positions[i]))
            {
                VoxelSet.AddPoint(updated.identifiers[i], updated.positions[i], updated.confidenceValues[i], Camera.current.transform.forward, true);
            }
        }

        if (particlesShown)
        {
            cloudSystem.SetParticles(VoxelSet.GetParticles().ToArray());
        }
        if (online)
        {
            Mesh();
        }


        Consts.particles = VoxelSet.GetParticles();
        UpdateDebugInfo();
        if (drawVoxels)
        {
            DrawVoxels();
        }
    }
Exemple #12
0
 private void OnPointCloudChanged(ARPointCloudChangedEventArgs obj)
 {
     DisplayPlanesAndFeatures(planesAndFeaturesActive);
 }
Exemple #13
0
    //private void OnTrackedImagesChanged(ARTrackedImagesChangedEventArgs obj) {
    //    if (i > 1000) {
    //        foreach (ARTrackedImage image in obj.updated) {
    //            Quaternion rot = Quaternion.Inverse(mainCamera.transform.rotation) * transform.rotation;
    //            Debug.Log("Tracked image " + image.trackableId.ToString() +
    //                " has world position: " + image.transform.position.ToString("F8") +
    //                " , rotation in quaternions: " + image.transform.rotation.ToString("F8") +
    //                " and rotation in euler: " + image.transform.rotation.eulerAngles.ToString("F8") + "\n" +
    //                " Position relative to camera: " + mainCamera.InverseTransformPoint(image.transform.position).ToString("F8") +
    //                " , rotation in quaternions relative to camera: " + rot.ToString("F8") +
    //                " and rotation in euler relative to camera: " + rot.eulerAngles.ToString("F8"));
    //        }
    //        i = 0;
    //    } else {
    //        i += 1;
    //    }
    //}

    private void OnPointCloudChanged(ARPointCloudChangedEventArgs obj)
    {
        DisplayPointClouds(planesAndPointCloudsActive, obj.added);
    }
 private void OnPointCloudChanged(ARPointCloudChangedEventArgs pEventArgs)
 {
     //Debug.Log("Point Cloud Updated");
 }
Exemple #15
0
        public void SendFeaturePoints(ARPointCloudChangedEventArgs e)
        {
            var updates = ExtractPointCloudUpdates(e.updated);

            _cameraImageReceiver.TryGetLatestCameraImage(texture2D => OnCameraImageReceived(updates, texture2D));
        }
Exemple #16
0
 void PointCloudManager_PointCloudsChanged(ARPointCloudChangedEventArgs obj)
 {
     //Debug.Log("point cloud");
 }