Пример #1
0
 public void SwitchCameraDirection(CameraDevice.CameraDirection direction) //改变摄像机的前后摄像头
 {
     CameraDevice.Instance.Stop();                                         //先关闭当前后置摄像头
     CameraDevice.Instance.Deinit();
     CameraDevice.Instance.Init(direction);                                //改为前置摄像头
     CameraDevice.Instance.Start();
 }
Пример #2
0
    private void StopQCAR()
    {
        Debug.Log("StopQCAR");
        MarkerTracker tracker = TrackerManager.Instance.GetTracker <MarkerTracker>();

        if (tracker != null)
        {
            tracker.Stop();
        }
        ImageTracker tracker2 = TrackerManager.Instance.GetTracker <ImageTracker>();

        if (tracker2 != null)
        {
            tracker2.Stop();
        }
        TextTracker tracker3 = TrackerManager.Instance.GetTracker <TextTracker>();

        if (tracker3 != null)
        {
            tracker3.Stop();
        }
        this.CameraDirection = CameraDevice.Instance.GetCameraDirection();
        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();
        QCARRenderer.Instance.ClearVideoBackgroundConfig();
    }
Пример #3
0
    private bool ChangeCameraDirection(CameraDevice.CameraDirection direction)
    {
        // This takes care of stopping and starting the targetFinder internally upon switching the camera
        CloudRecoBehaviour cloudRecoBehaviour = GameObject.FindObjectOfType(typeof(CloudRecoBehaviour)) as CloudRecoBehaviour;

        cloudRecoBehaviour.CloudRecoEnabled = false;

        bool directionSupported = false;

        bool needsObjectTrackerRestart = stopRunningObjectTracker();

        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();
        if (CameraDevice.Instance.Init(direction))
        {
            directionSupported = true;
        }
        CameraDevice.Instance.Start();

        if (needsObjectTrackerRestart)
        {
            restartRunningObjectTracker();
        }

        cloudRecoBehaviour.CloudRecoEnabled = true;

        return(directionSupported);
    }
Пример #4
0
 private void RestartCamera(CameraDevice.CameraDirection direction)
 {
     CameraDevice.Instance.Stop();
     CameraDevice.Instance.Deinit();
     CameraDevice.Instance.Init(direction);
     CameraDevice.Instance.Start();
 }
Пример #5
0
    private bool RestartCamera(CameraDevice.CameraDirection direction)
    {
        ObjectTracker tracker = TrackerManager.Instance.GetTracker <ObjectTracker>();

        if (tracker != null)
        {
            tracker.Stop();
        }

        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();

        if (!CameraDevice.Instance.Init(direction))
        {
            Debug.Log("Failed to init camera for direction: " + direction.ToString());
            return(false);
        }
        if (!CameraDevice.Instance.Start())
        {
            Debug.Log("Failed to start camera for direction: " + direction.ToString());
            return(false);
        }

        if (tracker != null)
        {
            if (!tracker.Start())
            {
                Debug.Log("Failed to restart the Tracker.");
                return(false);
            }
        }

        return(true);
    }
Пример #6
0
        public void Switchthecamera()
        {
            CameraDevice.CameraDirection camdirection = CameraDevice.Instance.GetCameraDirection();
            switch (camdirection)
            {
            case CameraDevice.CameraDirection.CAMERA_DEFAULT:
            case CameraDevice.CameraDirection.CAMERA_BACK:
                CameraDevice.Instance.Stop();
                CameraDevice.Instance.Deinit();

                CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_FRONT);
                CameraDevice.Instance.Start();
                break;

            case CameraDevice.CameraDirection.CAMERA_FRONT:
                CameraDevice.Instance.Stop();
                CameraDevice.Instance.Deinit();

                CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_DEFAULT);
                CameraDevice.Instance.Start();
                break;
            }
            if (oncameraswitched != null)
            {
                oncameraswitched.Invoke(camdirection);
            }
        }
Пример #7
0
 private void SetUpCameraDirection(CameraDevice.CameraDirection dir)
 {
     CameraDevice.Instance.Stop();
     CameraDevice.Instance.Deinit();
     VuforiaConfiguration.Instance.Vuforia.CameraDirection = dir;
     CameraDevice.Instance.Init(VuforiaConfiguration.Instance.Vuforia.CameraDirection);
     CameraDevice.Instance.Start();
 }
Пример #8
0
    public void SwitchCameraDirection(CameraDevice.CameraDirection dir)
    {
        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();

        CameraDevice.Instance.Init(dir);
        CameraDevice.Instance.Start();
    }
Пример #9
0
    public void SelectCamera(CameraDevice.CameraDirection camDir)
    {
        if (RestartCamera(camDir))
        {
            mActiveDirection = camDir;

            // Upon camera restart, flash is turned off
            mFlashTorchEnabled = false;
        }
    }
Пример #10
0
 private void RestartCamera(CameraDevice.CameraDirection newDir)
 {
     CameraDevice.Instance.Stop();
     CameraDevice.Instance.Deinit();
     CameraDevice.Instance.Init(newDir);
     CameraDevice.Instance.Start();
     // Periodically check to see if still needed
     VuforiaUnity.OnPause();
     VuforiaUnity.OnResume();
 }
Пример #11
0
 private void RestartCamera(CameraDevice.CameraDirection newDir)
 {
     CameraDevice.Instance.Stop();
     CameraDevice.Instance.Deinit();
     CameraDevice.Instance.Init(newDir);
     CameraDevice.Instance.Start();
     // These are to fight the bug the will otherwise flip the selfie cam upside down on iOS
     // Periodically check to see if still needed
     VuforiaUnity.OnPause();
     VuforiaUnity.OnResume();
 }
Пример #12
0
 public void SwapCamera()
 {
     CameraDevice.CameraDirection currentDir = CameraDevice.Instance.GetCameraDirection();
     if (currentDir == CameraDevice.CameraDirection.CAMERA_BACK || currentDir == CameraDevice.CameraDirection.CAMERA_DEFAULT)
     {
         RestartCamera(CameraDevice.CameraDirection.CAMERA_FRONT, true);
     }
     else
     {
         RestartCamera(CameraDevice.CameraDirection.CAMERA_BACK, false);
     }
 }
Пример #13
0
//	void checkCamera(){
//		CameraDevice.Instance.Stop ();
//		CameraDevice.Instance.Deinit ();
//		Debug.Log ("  CAMERA OFF NOW ");
//		bool dualCamera = CameraDevice.Instance.Init (CameraDevice.CameraDirection.CAMERA_FRONT);
//		Debug.Log (" CAMERA SHOULD HAVE RESTARTED NOW - VALUE OF BOOL = "+dualCamera);
//		if (!dualCamera) {
//			Debug.Log ("DAMN, CAMERA IS A WEBCAMERA !");
//		}
//	}

    public void toggleCamera()
    {
        CameraDevice.CameraDirection cam_direc = CameraDevice.Instance.GetCameraDirection();
        if (cam_direc == CameraDevice.CameraDirection.CAMERA_DEFAULT || cam_direc == CameraDevice.CameraDirection.CAMERA_BACK)
        {
            restartCamera(CameraDevice.CameraDirection.CAMERA_FRONT);
        }
        else
        {
            restartCamera(CameraDevice.CameraDirection.CAMERA_BACK);
        }
    }
Пример #14
0
    private bool ChangeCameraDirection(CameraDevice.CameraDirection direction)
    {
        bool directionSupported = false;

        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();
        if (CameraDevice.Instance.Init(direction))
        {
            directionSupported = true;
        }
        CameraDevice.Instance.Start();

        return(directionSupported);
    }
Пример #15
0
    private void RestartCamera(CameraDevice.CameraDirection newDir, bool mirror)
    {
        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();

        CameraDevice.Instance.Init(newDir);

        // Set mirroring
        var config = VuforiaRenderer.Instance.GetVideoBackgroundConfig();

        config.reflection = mirror ? VuforiaRenderer.VideoBackgroundReflection.ON : VuforiaRenderer.VideoBackgroundReflection.OFF;
        VuforiaRenderer.Instance.SetVideoBackgroundConfig(config);

        CameraDevice.Instance.Start();
    }
 private void SetViewerActive(bool isActive, bool deinitCam, bool initCam, CameraDevice.CameraDirection camDirection, CameraDevice.CameraDeviceMode mode)
 {
     if (deinitCam)
     {
         CameraDevice.Instance.Stop();
         CameraDevice.Instance.Deinit();
     }
     Device.Instance.SetViewerActive(isActive);
     if (initCam)
     {
         CameraDevice.Instance.Init(camDirection);
         CameraDevice.Instance.SelectVideoMode(mode);
         CameraDevice.Instance.Start();
     }
     this.ConfigureView();
 }
Пример #17
0
    public void SwitchCameraMode()
    {
        if (activeCameraDirection == CameraDevice.CameraDirection.CAMERA_BACK)
        {
            activeCameraDirection = CameraDevice.CameraDirection.CAMERA_FRONT;
        }

        else if (activeCameraDirection == CameraDevice.CameraDirection.CAMERA_FRONT)
        {
            activeCameraDirection = CameraDevice.CameraDirection.CAMERA_BACK;
        }

        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();
        CameraDevice.Instance.Init(activeCameraDirection);
        CameraDevice.Instance.Start();
    }
Пример #18
0
 public void ChangeCameraDirection()
 {
     if (device.GetCameraDirection() == CameraDevice.CameraDirection.CAMERA_BACK)
     {
         direction = CameraDevice.CameraDirection.CAMERA_FRONT;
     }
     else
     {
         direction = CameraDevice.CameraDirection.CAMERA_BACK;
     }
     StopTracker();
     StopCamera();
     DeInitCamera();
     SetDirectionCamera(direction);
     StartCamera();
     StartTracker();
 }
 protected override void Awake()
 {
     VuforiaAbstractConfiguration.GenericVuforiaConfiguration vuforia = VuforiaAbstractConfiguration.Instance.Vuforia;
     this.CameraDeviceModeSetting        = vuforia.CameraDeviceMode;
     this.MaxSimultaneousImageTargets    = vuforia.MaxSimultaneousImageTargets;
     this.MaxSimultaneousObjectTargets   = vuforia.MaxSimultaneousObjectTargets;
     this.UseDelayedLoadingObjectTargets = vuforia.UseDelayedLoadingObjectTargets;
     this.CameraDirection       = vuforia.CameraDirection;
     this.MirrorVideoBackground = vuforia.MirrorVideoBackground;
     this.mWorldCenterMode      = base.VuforiaBehaviour.WorldCenterMode;
     this.mWorldCenter          = base.VuforiaBehaviour.WorldCenter;
     this.mEyewearBehaviour     = DigitalEyewearARController.Instance;
     if (this.mEyewearBehaviour == null)
     {
         Debug.LogError("Failed to get an instance of DigitalEyewearBehaviour");
     }
     this.mVideoBackgroundMgr = VideoBackgroundManager.Instance;
     this.mVideoBackgroundMgr.Initialize();
 }
Пример #20
0
    private bool ChangeCameraDirection(CameraDevice.CameraDirection direction)
    {
        bool directionSupported = false;

        bool needsObjectTrackerRestart = stopRunningObjectTracker();

        CameraDevice.Instance.Stop();
        CameraDevice.Instance.Deinit();

        if(CameraDevice.Instance.Init(direction)) {
            directionSupported = true;
        }
        CameraDevice.Instance.Start();

        if (needsObjectTrackerRestart)
            restartRunningObjectTracker();

        return directionSupported;
    }
Пример #21
0
    void OnPreCull()
    {
        if (CameraDevice.Instance != null)
        {
            direction = CameraDevice.Instance.GetCameraDirection();
            switch (direction)
            {
            case CameraDevice.CameraDirection.CAMERA_FRONT:
                if (firstRun)
                {
                    backgroundPlane.localScale = planeFrontCam;
                    firstRun = false;
                }
                break;

            case CameraDevice.CameraDirection.CAMERA_BACK:
                backgroundPlane.localScale = planeRearCam;
                mFlipped   = false;
                mFirstCall = true;
                break;
            }
        }
        else
        {
            Debug.Log("<color=cyan>CameraDevice.Instance = null</color>");
            return;
        }

        if (!mFlipped && direction == CameraDevice.CameraDirection.CAMERA_FRONT)
        {
            if (!mFirstCall)
            {  // don't flip on first call to OnPreCull()
                Camera    cam       = this.GetComponent <Camera>();
                Vector3   flipScale = new Vector3(mFlipHorizontal ? -1 : 1, mFlipVertical ? -1 : 1, 1);
                Matrix4x4 projMat   = cam.projectionMatrix * Matrix4x4.Scale(flipScale);
                cam.projectionMatrix = projMat;
                mFlipped             = true;
            }
            mFirstCall = false;
        }
    }
Пример #22
0
 public void SwitchCamera()
 {
     CountDown._instance.ResetTime();
     switchCameraNum++;
     if (switchCameraNum == 1)
     {
         CameraDevice.CameraDirection cameraDirection = CameraDevice.CameraDirection.CAMERA_FRONT;
         CameraDevice.Instance.Stop();
         CameraDevice.Instance.Deinit();
         CameraDevice.Instance.Init(cameraDirection);
         CameraDevice.Instance.Start();
     }
     if (switchCameraNum == 2)
     {
         CameraDevice.CameraDirection cameraDirection = CameraDevice.CameraDirection.CAMERA_BACK;
         CameraDevice.Instance.Stop();
         CameraDevice.Instance.Deinit();
         CameraDevice.Instance.Init(cameraDirection);
         CameraDevice.Instance.Start();
         switchCameraNum = 0;
     }
 }
 public override bool Init(CameraDevice.CameraDirection cameraDirection)
 {
     if (QCARRuntimeUtilities.IsPlayMode())
     {
         cameraDirection = CameraDevice.CameraDirection.CAMERA_BACK;
     }
     if (this.InitCameraDevice((int)cameraDirection) == 0)
     {
         return(false);
     }
     this.mCameraDirection = cameraDirection;
     this.mCameraReady     = true;
     if (this.CameraReady)
     {
         QCARAbstractBehaviour behaviour = (QCARAbstractBehaviour)UnityEngine.Object.FindObjectOfType(typeof(QCARAbstractBehaviour));
         if (behaviour != null)
         {
             behaviour.ResetClearBuffers();
             behaviour.ConfigureVideoBackground(true);
         }
     }
     return(true);
 }
Пример #24
0
 public void switchCamera()
 {
     if (direction == CameraDevice.CameraDirection.CAMERA_BACK)
     {
         CameraDevice.Instance.Stop();
         CameraDevice.Instance.Deinit();
         TrackerManager.Instance.GetTracker <ObjectTracker>().Stop();
         CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_FRONT);
         CameraDevice.Instance.Start();
         TrackerManager.Instance.GetTracker <ObjectTracker>().Start();
         direction = CameraDevice.CameraDirection.CAMERA_FRONT;
     }
     else
     {
         CameraDevice.Instance.Stop();
         CameraDevice.Instance.Deinit();
         TrackerManager.Instance.GetTracker <ObjectTracker>().Stop();
         CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_BACK);
         CameraDevice.Instance.Start();
         TrackerManager.Instance.GetTracker <ObjectTracker>().Start();
         direction = CameraDevice.CameraDirection.CAMERA_BACK;
     }
 }
 public override bool Init(CameraDevice.CameraDirection cameraDirection)
 {
     if (this.InitCameraDevice((int)cameraDirection) == 0)
     {
         return(false);
     }
     this.mSelectedCameraDirection = cameraDirection;
     if (VuforiaRuntimeUtilities.IsPlayMode())
     {
         this.mActualCameraDirection = CameraDevice.CameraDirection.CAMERA_BACK;
     }
     else
     {
         int num = VuforiaWrapper.Instance.CameraDeviceGetCameraDirection();
         if (num != 1)
         {
             if (num != 2)
             {
                 this.mActualCameraDirection = CameraDevice.CameraDirection.CAMERA_DEFAULT;
             }
             else
             {
                 this.mActualCameraDirection = CameraDevice.CameraDirection.CAMERA_FRONT;
             }
         }
         else
         {
             this.mActualCameraDirection = CameraDevice.CameraDirection.CAMERA_BACK;
         }
     }
     this.mCameraReady = true;
     if (this.CameraReady)
     {
         VuforiaARController.Instance.ResetBackgroundPlane(true);
     }
     return(true);
 }
 public override bool GetSelectedCameraDirection(out CameraDevice.CameraDirection cameraDirection)
 {
     cameraDirection = this.mSelectedCameraDirection;
     return(this.mHasCameraDeviceModeBeenSet);
 }
Пример #27
0
 public abstract bool GetSelectedCameraDirection(out CameraDevice.CameraDirection cameraDirection);
Пример #28
0
 public abstract bool Init(CameraDevice.CameraDirection cameraDirection);
Пример #29
0
 public void SetDirectionCamera(CameraDevice.CameraDirection direction)
 {
     device.Init(direction);
 }