public ARFaceGeometry.Label[] GetTriangleLabels(IntPtr geometryHandle) { int count = 0; NDKAPI.HwArFaceGeometry_getTriangleLabelsSize(m_ndkSession.SessionHandle, geometryHandle, ref count); if (!ValueLegalityChecker.CheckInt("GetTriangleLabels: count", count, 0)) { return(new ARFaceGeometry.Label[0]); } ARFaceGeometry.Label[] ret = new ARFaceGeometry.Label[count]; IntPtr triangleLabelHandle = IntPtr.Zero; NDKAPI.HwArFaceGeometry_acquireTriangleLabels(m_ndkSession.SessionHandle, geometryHandle, ref triangleLabelHandle); for (int i = 0; i < count; i++) { int val = MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(triangleLabelHandle, i); if (!ValueLegalityChecker.CheckInt("GetTriangleLabels: value", val, AdapterConstants.Enum_FaceLabel_MinIntValue, AdapterConstants.Enum_FaceLabel_MaxIntValue - 1)) { ret[i] = ARFaceGeometry.Label.Label_Non_Face; } else { ret[i] = (ARFaceGeometry.Label)val; } } return(ret); }
public int[] GetTriangleIndex(IntPtr geometryHandle) { int count = 0; NDKAPI.HwArFaceGeometry_getTriangleIndicesSize(m_ndkSession.SessionHandle, geometryHandle, ref count); if (!ValueLegalityChecker.CheckInt("GetTriangleIndex", count, 0)) { return(new int[0]); } IntPtr triangleIndexHandle = IntPtr.Zero; NDKAPI.HwArFaceGeometry_acquireTriangleIndices(m_ndkSession.SessionHandle, geometryHandle, ref triangleIndexHandle); //int[] ret = new int[count]; //for (int i = 0; i < count; i++) //{ // ret[i] = MarshalingHelper.GetValueOfUnmanagedArrayElement<int>(triangleIndexHandle, i) / 3; //} int[] ret = new int[count]; for (int i = 0; i < count; i += 3) { ret[i] = MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(triangleIndexHandle, i + 2); ret[i + 1] = MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(triangleIndexHandle, i + 1); ret[i + 2] = MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(triangleIndexHandle, i); } return(ret); }
public Vector3[] GetHandSkeletonData(IntPtr handHandle) { int skeletonCount = GetHandSkeletonCount(handHandle); IntPtr skeletonHandle = IntPtr.Zero; NDKAPI.HwArHand_getHandSkeletonArray(m_ndkSession.SessionHandle, handHandle, ref skeletonHandle); //if native returned camera coordinate, do not negative z, //since the camera coordinate in opengl and unity are the same, which is right hand if (ARCoordinateSystemType.COORDINATE_SYSTEM_TYPE_3D_CAMERA == GetSkeletonCoordinateSystemType(handHandle)) { return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <Vector3>(skeletonHandle, skeletonCount)); } //otherwise negative z, //since the world and model coordinate in opengl and unity are converse //and z value in image coordinate is useless else { Vector3[] ret = new Vector3[skeletonCount]; for (int i = 0; i < skeletonCount; i++) { Vector3 vector = new Vector3(); vector.x = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(skeletonHandle, 3 * i); vector.y = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(skeletonHandle, 3 * i + 1); vector.z = -MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(skeletonHandle, 3 * i + 2); ret[i] = vector; } return(ret); } }
public Vector4 GetGestureOrientation(IntPtr handHandle) { IntPtr data = IntPtr.Zero; NDKAPI.HwArHand_getGestureOrientation(m_ndkSession.SessionHandle, handHandle, ref data); return(MarshalingHelper.GetValueOfUnmanagedArrayElement <Vector4>(data, 0)); }
public Dictionary <ARFace.BlendShapeLocation, float> GetBlendShapeData(IntPtr blendShapesHandle) { IntPtr dataHandle = IntPtr.Zero; IntPtr shapeTypeHandle = IntPtr.Zero; int dataSize = 0; Dictionary <ARFace.BlendShapeLocation, float> ret = new Dictionary <ARFace.BlendShapeLocation, float>(); NDKAPI.HwArFaceBlendShapes_getCount(m_ndkSession.SessionHandle, blendShapesHandle, ref dataSize); if (dataSize < 0 || dataSize > AdapterConstants.Enum_FaceBlendShapeLocation_MaxIntValue) { ARDebug.LogWarning("HwArFaceBlendShapes_getCount return value:{0}, while the legal max value is {1}", dataSize, AdapterConstants.Enum_FaceBlendShapeLocation_MaxIntValue); return(ret); } NDKAPI.HwArFaceBlendShapes_acquireTypes(m_ndkSession.SessionHandle, blendShapesHandle, ref shapeTypeHandle); NDKAPI.HwArFaceBlendShapes_acquireData(m_ndkSession.SessionHandle, blendShapesHandle, ref dataHandle); for (int i = 0; i < dataSize; i++) { int location = MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(shapeTypeHandle, i); if (!ValueLegalityChecker.CheckInt("GetBlendShapeData", location, AdapterConstants.Enum_FaceBlendShapeLocation_MinIntValue, AdapterConstants.Enum_FaceBlendShapeLocation_MaxIntValue - 1)) { continue; } float val = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(dataHandle, i); ret.Add((ARFace.BlendShapeLocation)location, val); } return(ret); }
public void GetValues(IntPtr cameraMetadataHandle, ARCameraMetadataTag tag, List <ARCameraMetadataValue> resultList) { IntPtr ndkMetadataHandle = IntPtr.Zero; NDKAPI.HwArImageMetadata_getNdkCameraMetadata(m_ndkSession.SessionHandle, cameraMetadataHandle, ref ndkMetadataHandle); resultList.Clear(); NdkCameraMetadata entry = new NdkCameraMetadata(); NdkCameraStatus status = NDKAPI.ACameraMetadata_getConstEntry(ndkMetadataHandle, tag, ref entry); if (status != NdkCameraStatus.Ok) { ARDebug.LogError("ACameraMetadata_getConstEntry error with native camera error code: {0}", status); return; } for (int i = 0; i < entry.Count; i++) { switch (entry.Type) { case NdkCameraMetadataType.Byte: sbyte byteValue = MarshalingHelper.GetValueOfUnmanagedArrayElement <sbyte>(entry.Value, i); resultList.Add(new ARCameraMetadataValue(byteValue)); break; case NdkCameraMetadataType.Int32: int intValue = MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(entry.Value, i); resultList.Add(new ARCameraMetadataValue(intValue)); break; case NdkCameraMetadataType.Float: float floatValue = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(entry.Value, i); resultList.Add(new ARCameraMetadataValue(floatValue)); break; case NdkCameraMetadataType.Int64: long longValue = MarshalingHelper.GetValueOfUnmanagedArrayElement <long>(entry.Value, i); resultList.Add(new ARCameraMetadataValue(longValue)); break; case NdkCameraMetadataType.Double: double doubleValue = MarshalingHelper.GetValueOfUnmanagedArrayElement <double>(entry.Value, i); resultList.Add(new ARCameraMetadataValue(doubleValue)); break; case NdkCameraMetadataType.Rational: ARCameraMetadataRational rationalValue = MarshalingHelper.GetValueOfUnmanagedArrayElement < ARCameraMetadataRational>(entry.Value, i); resultList.Add(new ARCameraMetadataValue(rationalValue)); break; default: return; } } }
public int[] GetHandSkeletonType(IntPtr handHandle) { int skeletonCount = GetHandSkeletonCount(handHandle); IntPtr typeHandle = IntPtr.Zero; NDKAPI.HwArHand_getHandSkeletonType(m_ndkSession.SessionHandle, handHandle, ref typeHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <int>(typeHandle, skeletonCount)); }
public int[] GetSkeletonType(IntPtr bodyHandle) { int skeletonCnt = GetSkeletonPointCount(bodyHandle); IntPtr typeHandle = IntPtr.Zero; NDKAPI.HwArBody_getSkeletonTypes(m_ndkSession.SessionHandle, bodyHandle, ref typeHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <int>(typeHandle, skeletonCnt)); }
public float[] GetSkeletonConfidence(IntPtr bodyHandle) { int skeletonCnt = GetSkeletonPointCount(bodyHandle); IntPtr skeletonConfidenceHandle = IntPtr.Zero; NDKAPI.HwArBody_getSkeletonConfidence(m_ndkSession.SessionHandle, bodyHandle, ref skeletonConfidenceHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <float>(skeletonConfidenceHandle, skeletonCnt)); }
public Vector3[] GetSkeletonPoint2D(IntPtr bodyHandle) { int skeletonCnt = GetSkeletonPointCount(bodyHandle); IntPtr skeleton2DHandle = IntPtr.Zero; NDKAPI.HwArBody_getSkeletonPoint2D(m_ndkSession.SessionHandle, bodyHandle, ref skeleton2DHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <Vector3>(skeleton2DHandle, skeletonCnt)); }
public float[] GetParameterValueArray(IntPtr trackableHandle) { int count = 0; NDKAPI.HwArTrackable_getParameterCount(m_ndkSession.SessionHandle, trackableHandle, ref count); IntPtr data = IntPtr.Zero; NDKAPI.HwArTrackable_getParameterValueArray(m_ndkSession.SessionHandle, trackableHandle, ref data); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <float>(data, count)); }
public int[] GetGestureAction(IntPtr handHandle) { int actionCount = 0; NDKAPI.HwArHand_getGestureActionSize(m_ndkSession.SessionHandle, handHandle, ref actionCount); IntPtr actionDataHandle = IntPtr.Zero; NDKAPI.HwArHand_getGestureAction(m_ndkSession.SessionHandle, handHandle, ref actionDataHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <int>(actionDataHandle, actionCount)); }
private List <Vector4> _GetPointsInPointCloud(IntPtr pointCloudHandle) { IntPtr pointsArrayNativeHandle = IntPtr.Zero; int pointCloudSize = GetNumberOfPoints(pointCloudHandle); NDKAPI.HwArPointCloud_getData(m_ndkSession.SessionHandle, pointCloudHandle, ref pointsArrayNativeHandle); List <Vector4> tmpPoints = new List <Vector4>(); MarshalingHelper.AppendUnManagedArray2List <Vector4>(pointsArrayNativeHandle, pointCloudSize, tmpPoints); return(tmpPoints); }
public Vector2Int[] GetSkeletonConnection(IntPtr handHandle) { int connectionArraySize = 0; IntPtr connectionHandle = IntPtr.Zero; NDKAPI.HwArHand_getHandSkeletonConnectionSize(m_ndkSession.SessionHandle, handHandle, ref connectionArraySize); if (!ValueLegalityChecker.CheckInt("GetSkeletonConnection", connectionArraySize, 0)) { return(new Vector2Int[0]); } NDKAPI.HwArHand_getHandSkeletonConnection(m_ndkSession.SessionHandle, handHandle, ref connectionHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <Vector2Int>(connectionHandle, connectionArraySize / 2)); }
public Vector2[] GetTexCoord(IntPtr geometryHandle) { int count = 0; NDKAPI.HwArFaceGeometry_getTexCoordSize(m_ndkSession.SessionHandle, geometryHandle, ref count); if (!ValueLegalityChecker.CheckInt("GetTexCoord", count, 0)) { return(new Vector2[0]); } IntPtr texcoordHandle = IntPtr.Zero; NDKAPI.HwArFaceGeometry_acquireTexCoord(m_ndkSession.SessionHandle, geometryHandle, ref texcoordHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <Vector2>(texcoordHandle, count / 2)); }
public bool[] GetSkeletonPointIsExist_3D(IntPtr bodyHandle) { int skeletonCnt = GetSkeletonPointCount(bodyHandle); IntPtr existHandle = IntPtr.Zero; bool[] ret = new bool[skeletonCnt]; NDKAPI.HwArBody_getSkeletonPointIsExist3D(m_ndkSession.SessionHandle, bodyHandle, ref existHandle); for (int i = 0; i < skeletonCnt; i++) { ret[i] = MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(existHandle, i) == 1 ? true : false; } return(ret); }
public int[] GetSkeletonConnection(IntPtr bodyHandle) { int connectionArraySize = 0; NDKAPI.HwArBody_getSkeletonConnectionSize(m_ndkSession.SessionHandle, bodyHandle, ref connectionArraySize); if (!ValueLegalityChecker.CheckInt("GetSkeletonConnection", connectionArraySize, 0)) { return(new int[0]); } IntPtr connectionHandle = IntPtr.Zero; NDKAPI.HwArBody_getSkeletonConnection(m_ndkSession.SessionHandle, bodyHandle, ref connectionHandle); return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <int>(connectionHandle, connectionArraySize)); }
public Vector3[] GetHandBox(IntPtr handHandle) { int count = 2; IntPtr data = IntPtr.Zero; NDKAPI.HwArHand_getGestureHandBox(m_ndkSession.SessionHandle, handHandle, ref data); Vector3[] ret = new Vector3[count]; for (int i = 0; i < count; i++) { Vector3 vector = new Vector3(); vector.x = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(data, 3 * i); vector.y = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(data, 3 * i + 1); vector.z = -MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(data, 3 * i + 2); ret[i] = vector; } return(ret); }
public int[] GetParameterTypeArray(IntPtr trackableHandle) { int count = 0; NDKAPI.HwArTrackable_getParameterCount(m_ndkSession.SessionHandle, trackableHandle, ref count); IntPtr types = IntPtr.Zero; NDKAPI.HwArTrackable_getParameterTypeArray(m_ndkSession.SessionHandle, trackableHandle, ref types); int[] dataArray = new int[count]; if (types == null) { return(dataArray); } if (dataArray == null) { return(dataArray); } return(MarshalingHelper.GetArrayOfUnmanagedArrayElement <int>(types, count)); }
public Vector3[] GetVertexNormals(IntPtr sceneMeshHandle) { int count = 0; NDKAPI.HwArSceneMesh_getVerticesSize(m_ndkSession.SessionHandle, sceneMeshHandle, ref count); if (!ValueLegalityChecker.CheckInt("GetVertices", count, 0)) { return(new Vector3[0]); } IntPtr vertexNormalsHandle = IntPtr.Zero; NDKAPI.HwArSceneMesh_acquireVertexNormals(m_ndkSession.SessionHandle, sceneMeshHandle, ref vertexNormalsHandle); Vector3[] ret = new Vector3[count / 3]; for (int i = 0; i < count / 3; i++) { ret[i] = new Vector3(); ret[i].x = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(vertexNormalsHandle, 3 * i); ret[i].y = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(vertexNormalsHandle, 3 * i + 1); ret[i].z = MarshalingHelper.GetValueOfUnmanagedArrayElement <float>(vertexNormalsHandle, 3 * i + 2); } return(ret); }
public void GetAllCameraMetadataTags(IntPtr cameraMetadataHandle, List <ARCameraMetadataTag> resultList) { IntPtr metadataHandle = IntPtr.Zero; NDKAPI.HwArImageMetadata_getNdkCameraMetadata(m_ndkSession.SessionHandle, cameraMetadataHandle, ref metadataHandle); IntPtr tagsHandle = IntPtr.Zero; int tagsCount = 0; NdkCameraStatus status = NDKAPI.ACameraMetadata_getAllTags(metadataHandle, ref tagsCount, ref tagsHandle); if (status != NdkCameraStatus.Ok) { ARDebug.LogError("ACameraMetadata_getAllTags error with native camera error code: {0}", status); return; } for (int i = 0; i < tagsCount; i++) { resultList.Add((ARCameraMetadataTag)MarshalingHelper.GetValueOfUnmanagedArrayElement <int>(tagsHandle, i)); } }