public void Grab()
    {
        if (zedCamera != null)
        {
            if (tracking)
            {
                UpdateTracking();
            }

            if (videoOverlay)
            {
                zedCamera.UpdateTextures();
            }

//			print ("Distance is approx.:" + (get_depth())+ " in");


            if (zedSVOManager != null)
            {
                if (zedSVOManager.record)
                {
                    zedCamera.Record();
                }
                if (zedSVOManager.read)
                {
                    zedSVOManager.CurrentFrame = zedCamera.GetSVOPosition();
                }
                if (zedSVOManager.read && zedSVOManager.loop)
                {
                    if (zedCamera.GetSVOPosition() >= zedCamera.GetSVONumberOfFrames() - 2)
                    {
                        zedCamera.SetSVOPosition(0);


                        if (tracking)
                        {
                            zedCamera.DisableTracking();
                            Quaternion quat = Quaternion.identity;
                            Vector3    vec  = new Vector3(0, 0, 0);
                            if (!(tracking = (zedCamera.EnableTracking(ref quat, ref vec, spatialMemory) == sl.ERROR_CODE.SUCCESS)))
                            {
                                throw new Exception("Error, tracking not available");
                            }
                            transform.localPosition = positionInit;
                            transform.localRotation = rotationInit;
                        }
                    }
                }
            }
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (zedCamera != null)
        {
            if (isThreaded || zedCamera.Grab() == 0)
            {
                if (tracking)
                {
                    UpdateTracking();
                }


                if (videoOverlay)
                {
                    zedCamera.UpdateTextures();
                }


                if (ZedSVOManager != null)
                {
                    if (ZedSVOManager.record)
                    {
                        zedCamera.Record();
                    }

                    if (ZedSVOManager.read && ZedSVOManager.loop)
                    {
                        if (zedCamera.GetSVOPosition() >= zedCamera.GetSVONumberOfFrames() - 2)
                        {
                            zedCamera.SetSVOPosition(0);

                            if (tracking)
                            {
                                zedCamera.DisableTracking();
                                Quaternion quat = Quaternion.identity;
                                Vector3    vec  = new Vector3(0, 0, 0);
                                if (!(tracking = (zedCamera.EnableTracking(ref quat, ref vec, spatialMemory) == sl.ERROR_CODE.SUCCESS)))
                                {
                                    throw new Exception("Error, tracking not available");
                                }
                                transform.localPosition = positionInit;
                                transform.localRotation = rotationInit;
                            }
                        }
                    }
                }
            }
        }
    }
Exemple #3
0
    void OnValidate()
    {
        if (zedCamera != null)
        {
            if (!isTrackingEnable && enableTracking)
            {
                //Enables the tracking and initializes the first position of the camera
                enablePoseSmoothing = enableSpatialMemory;
                if (!(enableTracking = (zedCamera.EnableTracking(ref zedOrientation, ref zedPosition, enableSpatialMemory, enablePoseSmoothing, pathSpatialMemory) == sl.ERROR_CODE.SUCCESS)))
                {
                    isZEDTracked = false;
                    throw new Exception(ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.TRACKING_NOT_INITIALIZED));
                }
                else
                {
                    isZEDTracked     = true;
                    isTrackingEnable = true;
                }
            }


            if (isTrackingEnable && !enableTracking)
            {
                isZEDTracked = false;
                lock (grabLock)
                {
                    zedCamera.DisableTracking();
                }
                isTrackingEnable = false;
            }


            setRenderingSettings();
        }
    }
    void OnValidate()
    {
        if (zedCamera != null)
        {
            if (!isTrackingEnable && enableTracking)
            {
                //Enables the tracking and initializes the first position of the camera
                Quaternion quat = Quaternion.identity;
                Vector3    vec  = new Vector3(0, 0, 0);
                enablePoseSmoothing = enableSpatialMemory;
                if (!(enableTracking = (zedCamera.EnableTracking(ref quat, ref vec, enableSpatialMemory, enablePoseSmoothing, pathSpatialMemory) == sl.ERROR_CODE.SUCCESS)))
                {
                    isZEDTracked = false;
                    throw new Exception(ZEDLogMessage.Error2Str(ZEDLogMessage.ERROR.TRACKING_NOT_INITIALIZED));
                }
                else
                {
                    isZEDTracked     = true;
                    isTrackingEnable = true;
                }
            }


            if (isTrackingEnable && !enableTracking)
            {
                isZEDTracked = false;
                lock (grabLock) {
                    zedCamera.DisableTracking();
                }
                isTrackingEnable = false;
            }


            //Create ZEDTextureOverlay object to handle left images
            ZEDRenderingPlane textureLeftOverlay = GetLeftCameraTransform().GetComponent <ZEDRenderingPlane>();
            textureLeftOverlay.SetPostProcess(postProcessing);
            Shader.SetGlobalFloat("_ZEDFactorAffectReal", cameraBrightness);


            //Create ZEDTextureOverlay object to handle Right images if a right camera is present
            if (IsStereoRig)
            {
                ZEDRenderingPlane textureRightOverlay = GetRightCameraTransform().GetComponent <ZEDRenderingPlane>();
                textureRightOverlay.SetPostProcess(postProcessing);
            }

            if (renderingPath == ZEDRenderingMode.FORWARD)
            {
                if (depthOcclusion)
                {
                    textureLeftOverlay.ManageKeyWordPipe(false, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordPipe(false, "NO_DEPTH_OCC");
                    }
                }
                else
                {
                    textureLeftOverlay.ManageKeyWordPipe(true, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordPipe(true, "NO_DEPTH_OCC");
                    }
                }
            }
            else if (renderingPath == ZEDRenderingMode.DEFERRED)
            {
                if (depthOcclusion)
                {
                    textureLeftOverlay.ManageKeyWordDefferedMat(false, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordDefferedMat(false, "NO_DEPTH_OCC");
                    }
                }
                else
                {
                    textureLeftOverlay.ManageKeyWordDefferedMat(true, "NO_DEPTH_OCC");
                    if (IsStereoRig)
                    {
                        textureLeftOverlay.ManageKeyWordDefferedMat(true, "NO_DEPTH_OCC");
                    }
                }
            }
        }
    }