/// <summary> /// Initializes a new instance of the Meta.PointCloudData class. /// </summary> /// <param name="maxSize"> The maximum size of the point cloud data. </param> /// <param name="metadata"> Information describing the point cloud data. </param> public PointCloudData(int maxSize, PointCloudMetaData metadata = null) { points = new TPoint[maxSize]; for (int i = 0; i < maxSize; i++) { points[i] = new TPoint(); } height = 0; width = 0; size = 0; frameId = 0; valid = false; metaData = metadata; arrivalOfCleanSensorDataTimeStamp = 0; completionOfPointCloudGenerationTimeStamp = 0; }
/// <summary> Gets point cloud meta data. </summary> /// /// <param name="pointCloudMetaData"> Information describing the point cloud meta. </param> /// /// <returns> true if it succeeds, false if it fails. </returns> public bool GetPointCloudMetaData(ref PointCloudMetaData pointCloudMetaData) { lock (_cloudDataLock) { if (_pointCloudMetaData == null) { return(false); } if (pointCloudMetaData == null) { pointCloudMetaData = new PointCloudMetaData(_pointCloudMetaData); } _pointCloudMetaData.CopyTo(ref pointCloudMetaData); return(true); } }
public void Start() { if (m_logInRecordSesnorDataFolder) { _sensorDataRecorder = GameObject.Find("MetaCameraRig").GetComponent <RecordSensorData>(); if (_sensorDataRecorder != null) { UnityEngine.Debug.LogError("cant find RecordsensorData"); } m_loggingFolder = _sensorDataRecorder.GetRecordingPath(); } if (m_loggingFolder == null) { UnityEngine.Debug.LogError("Logging Folder is null"); return; } _pointCloudMetaData = new PointCloudMetaData(); _pointCloudDataLogging = new PointCloudDataLogging(m_loggingFolder); _interactionEngine = metaContext.Get <InteractionEngine>(); }
/// <summary> Convert from interop data. </summary> /// <param name="pointCloudData"> Information describing the point cloud. </param> /// <param name="pointCloudMetaData_"> Information describing the point cloud meta. </param> /// <param name="pointCloudInteropData"> Information describing the point cloud interop. </param> /// <param name="pointCloudRawData"> Information describing the point cloud raw. </param> public static void ConvertFromInteropData(ref PointCloudData <TPoint> pointCloudData, PointCloudMetaData pointCloudMetaData_, PointCloudInteropData pointCloudInteropData, float[] pointCloudRawData) { if (pointCloudData != null) { pointCloudData.valid = pointCloudInteropData.valid; pointCloudData.size = pointCloudInteropData.size; pointCloudData.height = pointCloudInteropData.height; pointCloudData.width = pointCloudInteropData.width; pointCloudData.frameId = pointCloudInteropData.frameID; pointCloudData.arrivalOfCleanSensorDataTimeStamp = pointCloudInteropData.arrivalOfCleanSensorDataTimeStamp; pointCloudData.completionOfPointCloudGenerationTimeStamp = pointCloudInteropData.completionOfPointCloudGenerationTimeStamp; for (int cloudIndex = 0; cloudIndex < pointCloudData.size; cloudIndex++) { pointCloudData.points[cloudIndex].SetDataFromRawBytes(pointCloudRawData, cloudIndex, 4); } } }
/// <summary> Handler, called when the new point cloud meta data. </summary> public void GetPointCloudMetaData() { if (!HandKernelInterop.GetPointCloudMetaData(ref _pointCloudInteropMetaData)) { return; } lock (_cloudDataLock) { _pointCloudMetaData = new PointCloudMetaData(_pointCloudInteropMetaData); //todo: make this be able to handle data other than XYZConfidence //hack _pointCloudMetaData.field = PointCloudDataType.XYZCONFIDENCE; //todo: not do this. _pointCloudVertices = new float[_pointCloudMetaData.maxSize * 4]; // better way to do this _pointCloudRawData = new char[_pointCloudMetaData.maxSize * _pointCloudMetaData.pointSize]; _pointCloudDataHandle = GCHandle.Alloc(_pointCloudRawData, GCHandleType.Pinned); _pointCloudInteropData.data = _pointCloudDataHandle.AddrOfPinnedObject(); _pointCloudDataHandle.Free(); _pointCloudInteropData.valid = false; _pointCloudData = new PointCloudData <TPoint>(_pointCloudMetaData.maxSize); //end hack } }
/// <summary> Copies to described by pointCloudMetaData. </summary> /// <param name="pointCloudMetaData"> Information describing the point cloud meta. </param> public void CopyTo(ref PointCloudMetaData pointCloudMetaData) { pointCloudMetaData.maxSize = maxSize; pointCloudMetaData.pointSize = pointSize; pointCloudMetaData.field = field; pointCloudMetaData.height = height; pointCloudMetaData.width = width; // This should be the number of points in the file pointCloudMetaData.numFields = numFields; pointCloudMetaData.field = field; if (pointCloudMetaData.fieldCount == null) { pointCloudMetaData.InitializeDataFields(); //todo: fix this scenario. These field should never be un initialized (or should be initializer more elegantly) //Removed warning thrown - YG //UnityEngine.Debug.LogWarning("This data is not initialized."); } Array.Copy(fieldType, pointCloudMetaData.fieldType, numFields); Array.Copy(fieldSize, pointCloudMetaData.fieldSize, numFields); Array.Copy(fieldCount, pointCloudMetaData.fieldCount, numFields); Array.Copy(fieldName, pointCloudMetaData.fieldName, numFields); }
/// <summary> /// Gets a deep copy of the point cloud data. Used for persisting point cloud data after the frame it is played. /// </summary> /// <param name="pcd">The point cloud object to store the data in.</param> /// <param name="metadata">The metadata object to store the data in.</param> internal void GetDeepCopyOfPointData(ref PointCloudData <PointXYZConfidence> pcd, ref PointCloudMetaData metadata) { _pointCloudSource.SetPointCloudDataFromInteropData(pcd, metadata); }
/// <summary> Initializes a new instance of the Meta.PointCloudMetaData class. </summary> /// <param name="pointCloudMetaData"> Information describing the point cloud meta. </param> public PointCloudMetaData(PointCloudMetaData pointCloudMetaData) { ResetFields(); numFields = pointCloudMetaData.numFields; InitializeDataFields(); }