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 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 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 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 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 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 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 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 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)); } }
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); }