• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Tango.TangoPoseData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Tango.TangoPoseData的典型用法代码示例。如果您正苦于以下问题:C# TangoPoseData类的具体用法?C# TangoPoseData怎么用?C# TangoPoseData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TangoPoseData类属于Tango命名空间,在下文中一共展示了TangoPoseData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnTangoPoseAvailable

 /// <summary>
 /// Tango pose event.
 /// </summary>
 /// <param name="pose">Pose.</param>
 public void OnTangoPoseAvailable(TangoPoseData pose)
 {
     if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION &&
         pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
     {
         if (pose.status_code == TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
         {
             Statics.currentTangoState = TangoPoseStates.Running;
             UpdateTransform(pose);
             return;
         }
         else
         {
             Statics.currentTangoState = TangoPoseStates.Relocalizing;
         }
     }
     else if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE &&
              pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
     {
         if (pose.status_code == TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
         {
             UpdateTransform(pose);
         }
     }
     else
     {
         return;
     }
 }
开发者ID:AJCortex,项目名称:tango-examples-unity,代码行数:33,代码来源:PersistentStatePoseController.cs


示例2: OnTangoPoseAvailable

        public void OnTangoPoseAvailable( TangoPoseData pose )
        {
            // Get out of here if the pose is null
            if( pose == null ){//|| pose.status_code != TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID ) {
                Debug.Log( "TangoPoseData is null." );
                return;
            }

            if( TangoUtility.SetPose( pose ) ) {
                TangoUtility.SetUnityWorldToUnityCamera( transform );
            }

            //// The callback pose is for device with respect to start of service pose.
            //if( pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE &&
            //    pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE ) {

            //    //TangoUtility.InitExtrinsics( TangoPoseRequest.IMU_TO_DEVICE );
            //    if( TangoUtility.SetPose( pose ) ) {
            //        TangoUtility.SetUnityWorldToUnityCamera( transform );
            //    }

            //    //Matrix4x4 uwTuc = TangoUtility.GetUnityWorldToUnityCamera();

            //    //// Extract new local position
            //    //transform.position = uwTuc.GetColumn( 3 );

            //    //// Extract new local rotation
            //    //transform.rotation = Quaternion.LookRotation( uwTuc.GetColumn( 2 ), uwTuc.GetColumn( 1 ) );
            //}
        }
开发者ID:broostar,项目名称:youvebeentangoed,代码行数:30,代码来源:TangoPoseVis.cs


示例3: OnTangoPoseAvailable

 /// <summary>
 /// OnTangoPoseAvailable is called from Tango when a new Pose is available.
 /// </summary>
 /// <param name="pose">The new Tango pose.</param>
 public void OnTangoPoseAvailable(TangoPoseData pose)
 {
     if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION
         && pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE
         && pose.status_code == TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
     {
         m_relocalizationOverlay.SetActive(false);
     }
 }
开发者ID:AJCortex,项目名称:tango-examples-unity,代码行数:13,代码来源:RelocalizingOverlay.cs


示例4: PoseListener

        /// <summary>
        /// Initializes a new instance of the <see cref="Tango.PoseListener"/> class.
        /// </summary>
        internal PoseListener()
        {
            m_poseDataPool = new Stack<TangoPoseData>();

            // Add pre-allocated TangoPoseData objects to the
            // pool stack.
            for (int i = 0; i < SIZE_OF_POSE_DATA_POOL; ++i)
            {
                TangoPoseData emptyPose = new TangoPoseData();
                m_poseDataPool.Push(emptyPose);
            }
        }
开发者ID:reactivestudios,项目名称:MarcoTango,代码行数:15,代码来源:PoseListener.cs


示例5: PoseListener

        /// <summary>
        /// Initializes a new instance of the <see cref="Tango.PoseListener"/> class.
        /// </summary>
        public PoseListener()
        {
            m_motionTrackingData = null;
            m_areaLearningData = null;
            m_relocalizationData = null;
            m_poseDataPool = new Stack<TangoPoseData>();

            // Add pre-allocated TangoPoseData objects to the
            // pool stack.
            for(int i = 0; i < SIZE_OF_POSE_DATA_POOL; ++i)
            {
                TangoPoseData emptyPose = new TangoPoseData();
                m_poseDataPool.Push(emptyPose);
            }
        }
开发者ID:GulfstreamPD,项目名称:tango-examples-unity,代码行数:18,代码来源:PoseListener.cs


示例6: Reset

        /// <summary>
        /// Stop getting Tango pose callbacks.
        /// </summary>
        internal static void Reset()
        {
            // Avoid calling into tango_client_api before the correct library is loaded.
            if (m_poseAvailableCallback != null)
            {
                PoseProvider.ClearCallback();
            }

            m_poseAvailableCallback = null;
            m_motionTrackingData = new TangoPoseData();
            m_areaLearningData = new TangoPoseData();
            m_relocalizationData = new TangoPoseData();
            m_onTangoPoseAvailable = null;
            m_isMotionTrackingPoseAvailable = false;
            m_isAreaLearningPoseAvailable = false;
            m_isRelocalizaitonPoseAvailable = false;

#if UNITY_EDITOR
            m_mostRecentEmulatedRelocalizationTimestamp = -1;
#endif
        }
开发者ID:kyr7,项目名称:tango-examples-unity,代码行数:24,代码来源:PoseListener.cs


示例7: UpdateTransform

    private void UpdateTransform(TangoPoseData pose)
    {
        Vector3 tangoPosition = new Vector3((float)pose.translation [0],
                                            (float)pose.translation [2],
                                            (float)pose.translation [1]);

        Quaternion tangoRotation = new Quaternion((float)pose.orientation [0],
                                                  (float)pose.orientation [2], // these rotation values are swapped on purpose
                                                  (float)pose.orientation [1],
                                                  (float)pose.orientation [3]);

        Quaternion axisFix = Quaternion.Euler(-tangoRotation.eulerAngles.x,
                                              -tangoRotation.eulerAngles.z,
                                              tangoRotation.eulerAngles.y);

        transform.rotation = startingRotation * (rotationFix * axisFix);
        transform.position = (startingRotation * tangoPosition) + positionOffest;

        // Fire the state change event.
        if (preTangoState != Statics.currentTangoState) {
            EventManager.instance.TangoPoseStateChanged(Statics.currentTangoState);
        }
        preTangoState = Statics.currentTangoState;
    }
开发者ID:BrendaManrique,项目名称:tango-examples-unity,代码行数:24,代码来源:CustomPoseController.cs


示例8: GetPose

        public static TangoEnums.TangoPoseStatusType GetPose( double timestamp )
        {
            TangoCoordinateFramePair pair;
            TangoPoseData poseData = new TangoPoseData();

            pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE;
            pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
            PoseProvider.GetPoseAtTime( poseData, timestamp, pair );

            if( poseData.status_code != TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID ) {
                return poseData.status_code;
            }

            Vector3 position = new Vector3( (float)poseData.translation[0],
                                           (float)poseData.translation[1],
                                           (float)poseData.translation[2] );
            Quaternion quat = new Quaternion( (float)poseData.orientation[0],
                                             (float)poseData.orientation[1],
                                             (float)poseData.orientation[2],
                                             (float)poseData.orientation[3] );
            m_ssTd = Matrix4x4.TRS( position, quat, Vector3.one );

            return TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID;
        }
开发者ID:broostar,项目名称:youvebeentangoed,代码行数:24,代码来源:TangoUtility.cs


示例9: OnTangoDepthAvailable

    /// <summary>
    /// Callback that gets called when depth is available from the Tango Service.
    /// </summary>
    /// <param name="tangoDepth">Depth information from Tango.</param>
    public void OnTangoDepthAvailable(TangoUnityDepth tangoDepth)
    {
        // Calculate the time since the last successful depth data
        // collection.

        if (m_previousDepthDeltaTime == 0.0)
        {
            m_previousDepthDeltaTime = tangoDepth.m_timestamp;
        }
        else
        {
            m_depthDeltaTime = (float)((tangoDepth.m_timestamp - m_previousDepthDeltaTime) * 1000.0);
            m_previousDepthDeltaTime = tangoDepth.m_timestamp;
        }

        // Fill in the data to draw the point cloud.
        if (tangoDepth != null && tangoDepth.m_points != null)
        {
            m_pointsCount = tangoDepth.m_pointCount;
            if (m_pointsCount > 0)
            {
                _SetUpExtrinsics();
                TangoCoordinateFramePair pair;
                TangoPoseData poseData = new TangoPoseData();

                // Query pose to transform point cloud to world coordinates, here we are using the timestamp
                // that we get from depth.
                pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE;
                pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
                PoseProvider.GetPoseAtTime(poseData, m_previousDepthDeltaTime, pair);
                if (poseData.status_code != TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
                {
                    return;
                }

                Vector3 position = new Vector3((float)poseData.translation[0],
                                               (float)poseData.translation[1],
                                               (float)poseData.translation[2]);
                Quaternion quat = new Quaternion((float)poseData.orientation[0],
                                                 (float)poseData.orientation[1],
                                                 (float)poseData.orientation[2],
                                                 (float)poseData.orientation[3]);
                m_startServiceTDevice = Matrix4x4.TRS(position, quat, Vector3.one);

                // The transformation matrix that represents the pointcloud's pose.
                // Explanation:
                // The pointcloud which is in Depth camera's frame, is put in unity world's
                // coordinate system(wrt unity world).
                // Then we are extracting the position and rotation from uwTuc matrix and applying it to
                // the PointCloud's transform.
                Matrix4x4 unityWorldTDepthCamera = m_unityWorldTStartService * m_startServiceTDevice * Matrix4x4.Inverse(m_imuTDevice) * m_imuTDepthCamera;
                transform.position = Vector3.zero;
                transform.rotation = Quaternion.identity;

                //Vector3 minpts = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
                //Vector3 maxpts = new Vector3(float.MinValue, float.MinValue, float.MinValue);

                // Converting points array to world space.
                m_overallZ = 0;

                for (int i = 0; i < m_pointsCount; ++i)
                {
                    float x = tangoDepth.m_points[(i * 3) + 0];
                    float y = tangoDepth.m_points[(i * 3) + 1];
                    float z = tangoDepth.m_points[(i * 3) + 2];

                    m_points[i] = unityWorldTDepthCamera.MultiplyPoint( new Vector3(x, y, z));

                    m_overallZ += z;
                }
                m_overallZ = m_overallZ / m_pointsCount;

                // The color should be pose relative, we need to store enough info to go back to pose values.
                //m_renderer.material.SetMatrix("depthCameraTUnityWorld", unityWorldTDepthCamera.inverse);

                //VoxelExtractionPointCloud.Instance.computeDepthPlanes(ref unityWorldTDepthCamera, unityWorldTDepthCamera * new Vector4(0,0,0,1), minpts, maxpts);
                //if(isScanning)
                PerDepthFrameCallBack.Instance.CallBack(m_points, m_pointsCount);
            }
            else
            {
                m_overallZ = 0;
            }

        }
    }
开发者ID:nigelDaMan,项目名称:WeCanTango,代码行数:90,代码来源:TangoPointCloud.cs


示例10: _OnPoseAvailable

 /// <summary>
 /// Handle the callback sent by the Tango Service
 /// when a new pose is sampled.
 /// </summary>
 /// <param name="callbackContext">Callback context.</param>
 /// <param name="pose">Pose.</param>
 protected abstract void _OnPoseAvailable(IntPtr callbackContext, TangoPoseData pose);
开发者ID:gitunit,项目名称:Space-Sketchr,代码行数:7,代码来源:PoseListener.cs


示例11: OnTangoPoseAvailable

    /// <summary>
    /// Handle the callback sent by the Tango Service
    /// when a new pose is sampled.
    /// DO NOT USE THE UNITY API FROM INSIDE THIS FUNCTION!
    /// </summary>
    /// <param name="callbackContext">Callback context.</param>
    /// <param name="pose">Pose.</param>
    public void OnTangoPoseAvailable(TangoPoseData pose)
    {
        int currentIndex = 0;

        // Get out of here if the pose is null
        if (pose == null)
        {
            Debug.Log("TangoPoseDate is null.");
            return;
        }

        // The callback pose is for device with respect to start of service pose.
        if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE &&
            pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
        {
            currentIndex = DEVICE_TO_START;
        }
        // The callback pose is for device with respect to area description file pose.
        else if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION &&
                 pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
        {
            currentIndex = DEVICE_TO_ADF;
        }
        // The callback pose is for start of service with respect to area description file pose.
        else if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION &&
                 pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE)
        {
            currentIndex = START_TO_ADF;
        }

        // check to see if we are recently relocalized
        if(!m_isRelocalized)
        {
            m_isRelocalized = (currentIndex == 2);
        }

        if(pose.status_code == TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
        {
            // Create a new Vec3 and Quaternion from the Pose Data received.
            m_tangoPosition[currentIndex] = new Vector3((float)pose.translation [0],
                                                        (float)pose.translation [2],
                                                        (float)pose.translation [1]);

            m_tangoRotation[currentIndex] = new Quaternion((float)pose.orientation [0],
                                                           (float)pose.orientation [2], // these rotation values are swapped on purpose
                                                           (float)pose.orientation [1],
                                                           (float)pose.orientation [3]);
        }
        else // if the current pose is not valid we set the pose to identity
        {
            m_tangoPosition[currentIndex] = Vector3.zero;
            m_tangoRotation[currentIndex] = Quaternion.identity;
            m_isRelocalized = false;
        }

        // Reset the current status frame count if the status code changed.
        if (pose.status_code != m_status[currentIndex])
        {
            m_frameCount[currentIndex] = 0;
        }

        // Update the stats for the pose for the debug text
        m_status[currentIndex] = pose.status_code;
        m_frameCount[currentIndex]++;

        // Compute delta frame timestamp.
        m_frameDeltaTime[currentIndex] = (float)pose.timestamp - m_prevFrameTimestamp[currentIndex];
        m_prevFrameTimestamp [currentIndex] = (float)pose.timestamp;

        // This rotation needs to be put into Unity coordinate space. In unity +ve x is right,
        // +ve Y is up and +ve Z is forward while coordinate frame for Device wrt Start of service
        // +ve X is right, +ve Y is forward, +ve Z is up.
        // More explanation: https://developers.google.com/project-tango/overview/coordinate-systems
        Quaternion rotationFix = Quaternion.Euler(90.0f, 0.0f, 0.0f);

        // If not relocalized MotionTracking pose(Device wrt Start of Service) is used.
        if (!m_isRelocalized)
        {
            Quaternion axisFix = Quaternion.Euler(-m_tangoRotation[0].eulerAngles.x,
                                                  -m_tangoRotation[0].eulerAngles.z,
                                                  m_tangoRotation[0].eulerAngles.y);

            transform.rotation = m_startingRotation * (rotationFix * axisFix);
            transform.position = (m_startingRotation * (m_tangoPosition[0] * m_movementScale)) + m_startingOffset;

        }
        // If relocalized Device wrt ADF pose is used.
        else
        {
            Quaternion axisFix = Quaternion.Euler(-m_tangoRotation[1].eulerAngles.x,
                                                  -m_tangoRotation[1].eulerAngles.z,
                                                  m_tangoRotation[1].eulerAngles.y);

//.........这里部分代码省略.........
开发者ID:kevinahuber,项目名称:tango-examples-unity,代码行数:101,代码来源:AreaLearningPoseController.cs


示例12: TangoPoseToWorldTransform

        /// <summary>
        /// Convert a TangoPoseData into the Unity coordinate system. This only
        /// works on TangoPoseData that describes the device with respect to the
        /// start of service or area description. The result position and
        /// rotation can be used to set Unity's Transform.position and
        /// Transform.rotation.
        /// </summary>
        /// <param name="poseData">
        /// The input pose data that is going to be converted, please note that
        /// the pose data has to be in the start of service with respect to
        /// device frame.
        /// </param>
        /// <param name="position">The result position data.</param>
        /// <param name="rotation">The result rotation data.</param>
        public static void TangoPoseToWorldTransform(TangoPoseData poseData,
                                                     out Vector3 position,
                                                     out Quaternion rotation)
        {
            if (poseData == null)
            {
                Debug.Log("Invalid poseData.\n" + Environment.StackTrace);
                position = Vector3.zero;
                rotation = Quaternion.identity;
                return;
            }

            if (poseData.framePair.targetFrame != TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
            {
                Debug.Log("Invalid target frame of the poseData.\n" + Environment.StackTrace);
                position = Vector3.zero;
                rotation = Quaternion.identity;
                return;
            }

            if (poseData.framePair.baseFrame !=
                TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE &&
                poseData.framePair.baseFrame !=
                TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION)
            {
                Debug.Log("Invalid base frame of the poseData.\n" + Environment.StackTrace);
                position = Vector3.zero;
                rotation = Quaternion.identity;
                return;
            }

            Matrix4x4 startServiceTDevice = poseData.ToMatrix4x4();
            Matrix4x4 unityWorldTUnityCamera = UNITY_WORLD_T_START_SERVICE *
                                               startServiceTDevice *
                                               DEVICE_T_UNITY_CAMERA *
                                               m_devicePoseRotation;

            // Extract final position, rotation.
            position = unityWorldTUnityCamera.GetColumn(3);
            rotation = Quaternion.LookRotation(unityWorldTUnityCamera.GetColumn(2),
                                               unityWorldTUnityCamera.GetColumn(1));
        }
开发者ID:kyr7,项目名称:tango-examples-unity,代码行数:56,代码来源:TangoSupport.cs


示例13: _UpdateTransformation

    /// <summary>
    /// Update the camera gameobject's transformation to the pose that on current timestamp.
    /// </summary>
    /// <param name="timestamp">Time to update the camera to.</param>
    private void _UpdateTransformation(double timestamp)
    {
        TangoPoseData pose = new TangoPoseData();
        TangoCoordinateFramePair pair;
        pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE;
        pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
        PoseProvider.GetPoseAtTime(pose, timestamp, pair);

        m_status = pose.status_code;
        if (pose.status_code == TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
        {
            Vector3 m_tangoPosition = new Vector3((float)pose.translation[0],
                                                  (float)pose.translation[1],
                                                  (float)pose.translation[2]);

            Quaternion m_tangoRotation = new Quaternion((float)pose.orientation[0],
                                                        (float)pose.orientation[1],
                                                        (float)pose.orientation[2],
                                                        (float)pose.orientation[3]);

            Matrix4x4 ssTd = Matrix4x4.TRS(m_tangoPosition, m_tangoRotation, Vector3.one);

            // Here we are getting the pose of Unity camera frame with respect to Unity world.
            // This is the transformation of our current pose within the Unity coordinate frame.
            Matrix4x4 uwTuc = m_uwTss * ssTd * m_dTuc;

            // Extract new local position
            m_renderCamera.transform.position = uwTuc.GetColumn(3);

            // Extract new local rotation
            m_renderCamera.transform.rotation = Quaternion.LookRotation(uwTuc.GetColumn(2), uwTuc.GetColumn(1));
            m_frameCount++;
        }
        else
        {
            m_frameCount = 0;
        }
    }
开发者ID:reactivestudios,项目名称:MarcoTango,代码行数:42,代码来源:ARScreen.cs


示例14: _SetCameraExtrinsics

    /// <summary>
    /// The function is for querying the camera extrinsic, for example: the transformation between
    /// IMU and device frame. These extrinsics is used to transform the pose from the color camera frame
    /// to the device frame. Because the extrinsic is being queried using the GetPoseAtTime()
    /// with a desired frame pair, it can only be queried after the ConnectToService() is called.
    ///
    /// The device with respect to IMU frame is not directly queryable from API, so we use the IMU
    /// frame as a temporary value to get the device frame with respect to IMU frame.
    /// </summary>
    private void _SetCameraExtrinsics()
    {
        double timestamp = 0.0;
        TangoCoordinateFramePair pair;
        TangoPoseData poseData = new TangoPoseData();
        
        // Get the transformation of device frame with respect to IMU frame.
        pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
        pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
        PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
        Vector3 position = new Vector3((float)poseData.translation[0],
                                       (float)poseData.translation[1],
                                       (float)poseData.translation[2]);
        Quaternion quat = new Quaternion((float)poseData.orientation[0],
                                         (float)poseData.orientation[1],
                                         (float)poseData.orientation[2],
                                         (float)poseData.orientation[3]);
        Matrix4x4 imuTd = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));
        
        // Get the transformation of IMU frame with respect to color camera frame.
        pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_IMU;
        pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_CAMERA_COLOR;
        PoseProvider.GetPoseAtTime(poseData, timestamp, pair);
        position = new Vector3((float)poseData.translation[0],
                               (float)poseData.translation[1],
                               (float)poseData.translation[2]);
        quat = new Quaternion((float)poseData.orientation[0],
                              (float)poseData.orientation[1],
                              (float)poseData.orientation[2],
                              (float)poseData.orientation[3]);
        Matrix4x4 imuTc = Matrix4x4.TRS(position, quat, new Vector3(1.0f, 1.0f, 1.0f));

        // Get the transform of the Unity Camera frame with respect to the Color Camera frame.
        Matrix4x4 cTuc = new Matrix4x4();
        cTuc.SetColumn(0, new Vector4(1.0f, 0.0f, 0.0f, 0.0f));
        cTuc.SetColumn(1, new Vector4(0.0f, -1.0f, 0.0f, 0.0f));
        cTuc.SetColumn(2, new Vector4(0.0f, 0.0f, 1.0f, 0.0f));
        cTuc.SetColumn(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

        m_dTuc = Matrix4x4.Inverse(imuTd) * imuTc * cTuc;
    }
开发者ID:gitunit,项目名称:project-tango-poc,代码行数:50,代码来源:TangoARPoseController.cs


示例15: UpdateTangoEmulation

        /// <summary>
        /// INTERNAL USE: Update the Tango emulation state for color camera data.
        /// </summary>
        /// <param name="useByteBufferMethod">Whether to update emulation for byte-buffer method.</param>
        internal static void UpdateTangoEmulation(bool useByteBufferMethod)
        {
            // Get emulated position and rotation in Unity space.
            TangoPoseData poseData = new TangoPoseData();
            TangoCoordinateFramePair pair;
            pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE;
            pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE; 

            if (!PoseProvider.GetTimestampForColorEmulation(out m_lastColorEmulationTime))
            {
                Debug.LogError("Couldn't get a valid timestamp with which to emulate color camera. "
                               + "Color camera emulation will be skipped this frame.");
                return;
            }

            PoseProvider.GetPoseAtTime(poseData, m_lastColorEmulationTime, pair);
            if (poseData.status_code != TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
            {
                return;
            }
            
            Vector3 position;
            Quaternion rotation;
            TangoSupport.TangoPoseToWorldTransform(poseData, out position, out rotation);

            // Instantiate any resources that we haven't yet.
            _InternResourcesForEmulation();

            // Render. 
            EmulatedEnvironmentRenderHelper.RenderEmulatedEnvironment(m_emulatedColorRenderTexture,
                                                                      EmulatedEnvironmentRenderHelper.EmulatedDataType.COLOR_CAMERA,
                                                                      position, rotation);

            m_emulationIsDirty = true;
        }
开发者ID:kyr7,项目名称:tango-examples-unity,代码行数:39,代码来源:VideoOverlayProvider.cs


示例16: SetTransformUsingTangoPose

    /// <summary>
    /// Tranform Tango pose data to Unity transform.
    /// </summary>
    /// <param name="xform">Unity Transform output.</param>
    /// <param name="pose">Tango Pose Data.</param>
    private void SetTransformUsingTangoPose(Transform xform, TangoPoseData pose)
    {
        xform.position = new Vector3((float)pose.translation[0],
                                     (float)pose.translation[2],
                                     (float)pose.translation[1]) + m_initCameraPosition;
        
        Quaternion quat = new Quaternion((float)pose.orientation[0],
                                         (float)pose.orientation[2], // these rotation values are swapped on purpose
                                         (float)pose.orientation[1],
                                         (float)pose.orientation[3]);

        Quaternion axisFixedQuat = Quaternion.Euler(-quat.eulerAngles.x,
                                              -quat.eulerAngles.z,
                                              quat.eulerAngles.y);

        // FIX - should query API for depth camera extrinsics
        Quaternion extrinsics = Quaternion.Euler(-12.0f, 0, 0);

        xform.rotation = Quaternion.Euler(90.0f, 0.0f, 0.0f) * axisFixedQuat * extrinsics;
    }
开发者ID:gitunit,项目名称:project-tango-poc,代码行数:25,代码来源:CustomPointCloudListener.cs


示例17: ReadPoseFromFile

 /// <summary>
 /// Read pose from file.
 /// </summary>
 /// <returns>The pose from file.</returns>
 /// <param name="reader">File reader.</param>
 /// <param name="pose">Tango pose data.</param>
 public int ReadPoseFromFile(BinaryReader reader, ref TangoPoseData pose)
 {
     if (reader == null)
     {
         return -1;
     }
     
     string frameMarker;
     try
     {
         frameMarker = reader.ReadString();
     }
     catch (EndOfStreamException x) 
     {
         reader.BaseStream.Position = 0;
         Reset();
         print("Restarting log file: " + x.ToString());
         frameMarker = reader.ReadString();
     }
     
     if (frameMarker.CompareTo("poseframe\n") != 0)
     {
         m_debugText = "Failed to read pose";
         return -1;
     }
     
     pose.timestamp = double.Parse(reader.ReadString());
     
     TangoCoordinateFramePair pair = new TangoCoordinateFramePair();
     pair.baseFrame = (Tango.TangoEnums.TangoCoordinateFrameType)reader.ReadInt32();
     pair.targetFrame = (Tango.TangoEnums.TangoCoordinateFrameType)reader.ReadInt32();
     pose.framePair = pair;
     
     pose.status_code = (Tango.TangoEnums.TangoPoseStatusType)reader.ReadInt32();
     pose.translation[0] = reader.ReadDouble();
     pose.translation[1] = reader.ReadDouble();
     pose.translation[2] = reader.ReadDouble();
     pose.orientation[0] = reader.ReadDouble();
     pose.orientation[1] = reader.ReadDouble();
     pose.orientation[2] = reader.ReadDouble();
     pose.orientation[3] = reader.ReadDouble();
     return 0;
 }
开发者ID:gitunit,项目名称:project-tango-poc,代码行数:49,代码来源:CustomPointCloudListener.cs


示例18: _OnPoseAvailable

        /// <summary>
        /// Handle the callback sent by the Tango Service when a new pose is sampled.
        /// </summary>
        /// <param name="callbackContext">Callback context.</param>
        /// <param name="pose">Pose.</param>
        private void _OnPoseAvailable(IntPtr callbackContext, TangoPoseData pose)
        {
            if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE &&
                pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
            {
                // MotionTracking
                lock (m_lockObject)
                {
                    // Only set new pose once the previous pose has been returned.
                    if (m_motionTrackingData == null)
                    {
                        TangoPoseData currentPose = m_poseDataPool.Pop();
                        currentPose.DeepCopy(pose);
                        m_motionTrackingData = currentPose;
                    }
                }
            }
            else if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION &&
                     pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE)
            {
                // ADF Localized
                lock (m_lockObject)
                {
                    // Only set new pose once the previous pose has been returned.
                    if (m_areaLearningData == null)
                    {
                        TangoPoseData currentPose = m_poseDataPool.Pop();
                        currentPose.DeepCopy(pose);
                        m_areaLearningData = currentPose;
                    }
                }
            }
            else if (pose.framePair.baseFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION &&
                     pose.framePair.targetFrame == TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE)
            {
                // Relocalized against ADF
                lock (m_lockObject)
                {
                    // Only set new pose once the previous pose has been returned.
                    if (m_relocalizationData == null)
                    {
                        TangoPoseData currentPose = m_poseDataPool.Pop();
                        currentPose.DeepCopy(pose);
                        m_relocalizationData = currentPose;
                    }
                }
            }

            m_isDirty = true;
        }
开发者ID:reactivestudios,项目名称:MarcoTango,代码行数:55,代码来源:PoseListener.cs


示例19: OnTangoDepthAvailable

    /// <summary>
    /// Callback that gets called when depth is available from the Tango Service.
    /// </summary>
    /// <param name="tangoDepth">Depth information from Tango.</param>
    public void OnTangoDepthAvailable(TangoUnityDepth tangoDepth)
    {
        // Calculate the time since the last successful depth data
        // collection.
        if (m_previousDepthDeltaTime == 0.0)
        {
            m_previousDepthDeltaTime = tangoDepth.m_timestamp;
        }
        else
        {
            m_depthDeltaTime = (float)((tangoDepth.m_timestamp - m_previousDepthDeltaTime) * 1000.0);
            m_previousDepthDeltaTime = tangoDepth.m_timestamp;
        }

        // Fill in the data to draw the point cloud.
        if (tangoDepth != null && tangoDepth.m_points != null)
        {
            m_pointsCount = tangoDepth.m_pointCount;
            if (m_pointsCount > 0)
            {
                _SetUpCameraData();
                TangoCoordinateFramePair pair;
                TangoPoseData poseData = new TangoPoseData();

                // Query pose to transform point cloud to world coordinates, here we are using the timestamp
                // that we get from depth.
                pair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE;
                pair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE;
                PoseProvider.GetPoseAtTime(poseData, m_previousDepthDeltaTime, pair);
                if (poseData.status_code != TangoEnums.TangoPoseStatusType.TANGO_POSE_VALID)
                {
                    return;
                }

                Vector3 position = new Vector3((float)poseData.translation[0],
                                               (float)poseData.translation[1],
                                               (float)poseData.translation[2]);
                Quaternion quat = new Quaternion((float)poseData.orientation[0],
                                                 (float)poseData.orientation[1],
                                                 (float)poseData.orientation[2],
                                                 (float)poseData.orientation[3]);
                m_startServiceTDevice = Matrix4x4.TRS(position, quat, Vector3.one);

                // The transformation matrix that represents the pointcloud's pose.
                // Explanation:
                // The pointcloud which is in Depth camera's frame, is put in unity world's
                // coordinate system(wrt unity world).
                // Then we are extracting the position and rotation from uwTuc matrix and applying it to
                // the PointCloud's transform.
                Matrix4x4 unityWorldTDepthCamera = m_unityWorldTStartService * m_startServiceTDevice * Matrix4x4.Inverse(m_imuTDevice) * m_imuTDepthCamera;
                transform.position = Vector3.zero;
                transform.rotation = Quaternion.identity;

                // Addoffset to the pointcloud depending on the offset from TangoDeltaPoseController
                Matrix4x4 unityWorldOffsetTDepthCamera;
                if (m_tangoDeltaPoseController != null)
                {
                    unityWorldOffsetTDepthCamera = m_tangoDeltaPoseController.UnityWorldOffset * unityWorldTDepthCamera;
                }
                else
                {
                    unityWorldOffsetTDepthCamera = unityWorldTDepthCamera;
                }

                // Converting points array to world space.
                m_overallZ = 0;
                for (int i = 0; i < m_pointsCount; ++i)
                {
                    float x = tangoDepth.m_points[(i * 3) + 0];
                    float y = tangoDepth.m_points[(i * 3) + 1];
                    float z = tangoDepth.m_points[(i * 3) + 2];

                    m_points[i] = unityWorldOffsetTDepthCamera.MultiplyPoint(new Vector3(x, y, z));
                    m_overallZ += z;
                }
                m_overallZ = m_overallZ / m_pointsCount;
                m_pointsTimestamp = tangoDepth.m_timestamp;

                VoxelExtractionPointCloud.Instance.addAndRender(this);

                /*
                if (m_updatePointsMesh)
                {
                    // Need to update indicies too!
                    int[] indice 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UriTemplates.UriTemplate类代码示例发布时间:2022-05-26
下一篇:
C# Tango.TangoApplication类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap