public ARPlane AcquireSubsumedBy(IntPtr planeHandle) { IntPtr parentHandle = IntPtr.Zero; NDKAPI.HwArPlane_acquireSubsumedBy(m_ndkSession.SessionHandle, planeHandle, ref parentHandle); return(m_ndkSession.TrackableManager.ARTrackableFactory(parentHandle, false) as ARPlane); }
public ARTrackable.TrackingState GetTrackingState(IntPtr trackableHandle) { ARTrackable.TrackingState state = ARTrackable.TrackingState.STOPPED; NDKAPI.HwArTrackable_getTrackingState(m_ndkSession.SessionHandle, trackableHandle, ref state); return(state); }
public IntPtr AcquireGeometry(IntPtr faceHandle) { IntPtr geometry = IntPtr.Zero; NDKAPI.HwArFace_acquireGeometry(m_ndkSession.SessionHandle, faceHandle, ref geometry); return(geometry); }
public void GetAnchors(IntPtr trackableHandle, List <ARAnchor> anchors) { IntPtr anchorListHandle = m_ndkSession.AnchorAdapter.CreateList(); NDKAPI.HwArTrackable_getAnchors(m_ndkSession.SessionHandle, trackableHandle, anchorListHandle); anchors.Clear(); int cntOfAnchor = m_ndkSession.AnchorAdapter.GetListSize(anchorListHandle); for (int i = 0; i < cntOfAnchor; i++) { IntPtr anchorHandle = m_ndkSession.AnchorAdapter.AcquireListItem(anchorListHandle, i); ARAnchor anchor = m_ndkSession.AnchorManager.ARAnchorFactory(anchorHandle, false); if (anchorHandle == IntPtr.Zero) { Debug.LogFormat("anchor {0} is not valid", anchorHandle); } else { anchors.Add(anchor); } } m_ndkSession.AnchorAdapter.DestroyList(anchorListHandle); }
public int GetListSize(IntPtr listHandle) { int count = 0; NDKAPI.HwArTrackableList_getSize(m_ndkSession.SessionHandle, listHandle, ref count); return(count); }
public IntPtr AcquireListItem(IntPtr listHandle, int index) { IntPtr hitResultHandle = m_ndkSession.HitResultAdapter.Create(); NDKAPI.HwArHitResultList_getItem(m_ndkSession.SessionHandle, listHandle, index, hitResultHandle); return(hitResultHandle); }
public float GetDistance(IntPtr hitResultHandle) { float f = 0f; NDKAPI.HwArHitResult_getDistance(m_ndkSession.SessionHandle, hitResultHandle, ref f); return(f); }
public void LoadSharedData(ARSharedData sharedData) { NDKARStatus status = NDKAPI.HwArSession_load(m_ndkSession.SessionHandle, sharedData.RawData.m_pinAddr, sharedData.RawData.DataSize); ARExceptionAdapter.ExtractException(status); }
public void Stop() { NDKARStatus status = NDKAPI.HwArSession_stop(m_ndkSession.SessionHandle); ARDebug.LogInfo("native stop end with value:{0}", status); ARExceptionAdapter.ExtractException(status); }
public void SetDisplayGeometry(ScreenOrientation orientation, int width, int height) { const int androidRotation0 = 0; const int androidRotation90 = 1; const int androidRotation180 = 2; const int androidRotation270 = 3; int androidOrientation = 0; switch (orientation) { case ScreenOrientation.LandscapeLeft: androidOrientation = androidRotation90; break; case ScreenOrientation.LandscapeRight: androidOrientation = androidRotation270; break; case ScreenOrientation.Portrait: androidOrientation = androidRotation0; break; case ScreenOrientation.PortraitUpsideDown: androidOrientation = androidRotation180; break; } ARDebug.LogInfo("native set display geometry begin with android oritentation:{0}, width={1}, height={2}", androidOrientation, width, height); NDKAPI.HwArSession_setDisplayGeometry(m_ndkSession.SessionHandle, androidOrientation, width, height); }
//this function will add newly trackable into trackableManager public void GetAllTrackables(List <ARTrackable> trackableList) { trackableList.Clear(); IntPtr trackableListHandle = m_ndkSession.TrackableAdapter.CreateList(); NDKAPI.HwArSession_getAllTrackables(m_ndkSession.SessionHandle, NDKARTrackableType.BaseTrackable, trackableListHandle); int cntOfTrackable = m_ndkSession.TrackableAdapter.GetListSize(trackableListHandle); for (int i = 0; i < cntOfTrackable; i++) { IntPtr trackableHandle = m_ndkSession.TrackableAdapter.AcquireListItem(trackableListHandle, i); //todo the following code is to mask 0x41520105 in arcore NDKARTrackableType type = m_ndkSession.TrackableAdapter.GetType(trackableHandle); if ((int)type == 0x41520105) { m_ndkSession.TrackableAdapter.Release(trackableHandle); continue; } trackableList.Add(m_ndkSession.TrackableManager.ARTrackableFactory(trackableHandle, true)); } m_ndkSession.TrackableAdapter.DestroyList(trackableListHandle); }
public void UpdateNDKConfigWithUnityConfig(IntPtr configHandle, ARConfigBase arConfig) { NDKAPI.HwArConfig_setArType(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetARType()); NDKAPI.HwArConfig_setCameraLensFacing(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetCameraLensFacing()); NDKAPI.HwArConfig_setLightEstimationMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetLightingMode()); NDKAPI.HwArConfig_setPlaneFindingMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetPlaneFindingMode()); NDKAPI.HwArConfig_setUpdateMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetUpdateMode()); NDKAPI.HwArConfig_setImageInputMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetImageInputMode()); //this interface only support by HUAWEI_AR_ENGINE if (AREnginesSelector.Instance.GetCreatedEngine() == AREnginesType.HUAWEI_AR_ENGINE) { NDKAPI.HwArConfig_setPowerMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetPowerMode()); NDKAPI.HwArConfig_setFocusMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetFocusMode()); NDKAPI.HwArConfig_setEnableItem(m_ndkSession.SessionHandle, configHandle, arConfig.GetConfigEnableItem()); NDKAPI.HwArConfig_setSemanticMode(m_ndkSession.SessionHandle, configHandle, arConfig.GetConfigSemanticMode()); } //the following code is used to forward compatable if ((arConfig.GetARType() & (int)NDKARType.HAND_AR) != 0) { NDKAPI.HwArConfig_setHandFindingMode(m_ndkSession.SessionHandle, configHandle, (int)arConfig.GetHandFindingMode()); } if (arConfig.GetAugImgDataBaseHandle() != null) { byte[] RawData = arConfig.GetAugImgDataBaseHandle().GetRawData(); IntPtr AugImgDatabaseHandle = m_ndkSession.AugmentedImageDatabaseAdapter.CreateAugImgDatabaseFromBytes(RawData); NDKAPI.HwArConfig_setAugmentedImageDatabase(m_ndkSession.SessionHandle, configHandle, AugImgDatabaseHandle); } }
public float GetExtentZ(IntPtr planeHandle) { float f = 0f; NDKAPI.HwArPlane_getExtentZ(m_ndkSession.SessionHandle, planeHandle, ref f); return(f); }
public ARPlane.PlaneType.Type GetPlaneType(IntPtr planeHandle) { int planeType = 0; NDKAPI.HwArPlane_getType(m_ndkSession.SessionHandle, planeHandle, ref planeType); return((ARPlane.PlaneType.Type)planeType); }
public IntPtr CreateList() { IntPtr listHandle = IntPtr.Zero; NDKAPI.HwArHitResultList_create(m_ndkSession.SessionHandle, ref listHandle); return(listHandle); }
public IntPtr Create() { IntPtr lightEstimateHandle = IntPtr.Zero; NDKAPI.HwArLightEstimate_create(m_ndkSession.SessionHandle, ref lightEstimateHandle); return(lightEstimateHandle); }
public int GetListSize(IntPtr listHandle) { int size = 0; NDKAPI.HwArHitResultList_getSize(m_ndkSession.SessionHandle, listHandle, ref size); return(size); }
public bool GetState(IntPtr lightEstimateHandle) { int state = 0; NDKAPI.HwArLightEstimate_getState(m_ndkSession.SessionHandle, lightEstimateHandle, ref state); return(state == 1 ? true : false); }
public IntPtr Create() { IntPtr hitResultHandle = IntPtr.Zero; NDKAPI.HwArHitResult_create(m_ndkSession.SessionHandle, ref hitResultHandle); return(hitResultHandle); }
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); }
internal IntPtr GetTrackbaleHandle(IntPtr hitResultHandle) { IntPtr trackableHandle = IntPtr.Zero; NDKAPI.HwArHitResult_acquireTrackable(m_ndkSession.SessionHandle, hitResultHandle, ref trackableHandle); return(trackableHandle); }
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); } }
//trackable list public IntPtr CreateList() { IntPtr handle = IntPtr.Zero; NDKAPI.HwArTrackableList_create(m_ndkSession.SessionHandle, ref handle); return(handle); }
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 NDKARTrackableType GetType(IntPtr trackableHandle) { NDKARTrackableType type = NDKARTrackableType.BaseTrackable; NDKAPI.HwArTrackable_getType(m_ndkSession.SessionHandle, trackableHandle, ref type); return(type); }
private ARCameraIntrinsics GetARCameraIntrinsicsFromeHandle(IntPtr intrinsicsHandle) { float focalX = 0; float focalY = 0; float principalX = 0; float principalY = 0; int imageWidth = 0; int imageHeight = 0; float[] outDistortion = new float[5]; NDKAPI.HwArCameraIntrinsics_getFocalLength(m_ndkSession.SessionHandle, intrinsicsHandle, ref focalX, ref focalY); NDKAPI.HwArCameraIntrinsics_getPrincipalPoint(m_ndkSession.SessionHandle, intrinsicsHandle, ref principalX, ref principalY); NDKAPI.HwArCameraIntrinsics_getImageDimensions(m_ndkSession.SessionHandle, intrinsicsHandle, ref imageWidth, ref imageHeight); NDKAPI.HwArCameraIntrinsics_getDistortion(m_ndkSession.SessionHandle, intrinsicsHandle, outDistortion); return(new ARCameraIntrinsics(new Vector2(focalX, focalY), new Vector2(principalX, principalY), new Vector2Int(imageWidth, imageHeight), outDistortion)); }
public int GetParameterCount(IntPtr trackableHandle) { int count = 0; NDKAPI.HwArTrackable_getParameterCount(m_ndkSession.SessionHandle, trackableHandle, ref count); return(count); }
public IntPtr Create() { IntPtr cameraConfigHandle = IntPtr.Zero; NDKAPI.HwArCameraConfig_create(m_ndkSession.SessionHandle, ref cameraConfigHandle); return(cameraConfigHandle); }
public IntPtr AcquireBlendShape(IntPtr faceHandle) { IntPtr blendshape = IntPtr.Zero; NDKAPI.HwArFace_acquireBlendShapes(m_ndkSession.SessionHandle, faceHandle, ref blendshape); return(blendshape); }
public long GetTimestamp() { long timestamp = 0; NDKAPI.HwArFrame_getTimestamp(m_ndkSession.SessionHandle, m_ndkSession.FrameHandle, ref timestamp); return(timestamp); }