Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 8
0
        public void LoadSharedData(ARSharedData sharedData)
        {
            NDKARStatus status = NDKAPI.HwArSession_load(m_ndkSession.SessionHandle, sharedData.RawData.m_pinAddr,
                                                         sharedData.RawData.DataSize);

            ARExceptionAdapter.ExtractException(status);
        }
Exemplo n.º 9
0
        public void Stop()
        {
            NDKARStatus status = NDKAPI.HwArSession_stop(m_ndkSession.SessionHandle);

            ARDebug.LogInfo("native stop end with value:{0}", status);
            ARExceptionAdapter.ExtractException(status);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        //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);
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        public float GetExtentZ(IntPtr planeHandle)
        {
            float f = 0f;

            NDKAPI.HwArPlane_getExtentZ(m_ndkSession.SessionHandle, planeHandle, ref f);
            return(f);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 22
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);
            }
        }
Exemplo n.º 23
0
        //trackable list

        public IntPtr CreateList()
        {
            IntPtr handle = IntPtr.Zero;

            NDKAPI.HwArTrackableList_create(m_ndkSession.SessionHandle, ref handle);
            return(handle);
        }
Exemplo n.º 24
0
        public Vector4 GetGestureOrientation(IntPtr handHandle)
        {
            IntPtr data = IntPtr.Zero;

            NDKAPI.HwArHand_getGestureOrientation(m_ndkSession.SessionHandle, handHandle, ref data);
            return(MarshalingHelper.GetValueOfUnmanagedArrayElement <Vector4>(data, 0));
        }
Exemplo n.º 25
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));
        }
Exemplo n.º 27
0
        public int GetParameterCount(IntPtr trackableHandle)
        {
            int count = 0;

            NDKAPI.HwArTrackable_getParameterCount(m_ndkSession.SessionHandle, trackableHandle, ref count);
            return(count);
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 30
0
        public long GetTimestamp()
        {
            long timestamp = 0;

            NDKAPI.HwArFrame_getTimestamp(m_ndkSession.SessionHandle, m_ndkSession.FrameHandle, ref timestamp);
            return(timestamp);
        }