private bool ChangeCameraStatus(CameraStatus newStatus)
        {
            bool valueChanged = false;

            lock (_cameraStatusLock)
            {
                if (_cameraStatus != newStatus)
                {
                    bool canChange = false;
                    switch (newStatus)
                    {
                    case CameraStatus.Capture:
                        canChange = _cameraStatus == CameraStatus.Pause || _cameraStatus == CameraStatus.Stop;
                        break;

                    case CameraStatus.Pause:
                        canChange = _cameraStatus == CameraStatus.Capture;
                        break;

                    case CameraStatus.Stop:
                        canChange = _cameraStatus == CameraStatus.Capture || _cameraStatus == CameraStatus.Pause;
                        break;
                    }
                    if (canChange)
                    {
                        _cameraStatus = newStatus;
                        valueChanged  = true;
                    }
                }
            }
            return(valueChanged);
        }
Example #2
0
        /// <summary>
        /// Takes a picture using the <see cref="Camera"/> object.
        /// </summary>
        /// <remarks>
        /// Taking picture involves start streaming which might take several seconds to stabilize. Camera driver keeps the stream on then it stops streaming internally if it was idle for more than 1 minute by default. This time out can be changed through <see cref="TakePictureStreamTimeout"/>
        /// </remarks>
        public void TakePicture()
        {
            lock (this.cameraLock) {
                if (this._cameraStatus == CameraStatus.Disconnected)
                {
                    ErrorPrint("Unable to take picture. Camera is not ready. Is the Camera connected?");
                }
                else if (this._cameraStatus == CameraStatus.TakePicture)
                {
                    ErrorPrint("Unable to take picture. The camera is already busy taking a picture.");
                }
                else if (this._cameraStatus == CameraStatus.StreamBitmap)
                {
                    ErrorPrint("Unable to start streaming. The camera is already busy streaming a bitmap. Call StopStreamingBitmaps to cancel that process.");
                }
                else if (this._cameraStatus == CameraStatus.Ready)
                {
                    if (!_TakePictureFlag)
                    {
                        _camera.StartStreaming(GetImageFormat(CurrentPictureResolution));
                    }

                    _LastTimeStreamStart = DateTime.Now;
                    this._cameraStatus   = CameraStatus.TakePicture;
                }
            }
        }
Example #3
0
        private void CameraManager_CameraBound(object sender, CameraStatus e)
        {
            string message = null;

            switch (e)
            {
            case CameraStatus.BuildNotFound:
                message = $"Unimplemented client build ({ProcessManager.Build}) found.";
                break;

            case CameraStatus.CameraNotFound:
                message = "Unable to read the Camera object.\nPlease ensure you are in game.";
                break;

            case CameraStatus.MemoryAccess:
                message = $"Unable to access client memory.\nTry running {GetType().Namespace} as Administrator.";
                break;

            case CameraStatus.PatternNotFound:
                message = "Unable to find the Camera movement pattern.";
                break;

            case CameraStatus.OK:
                SetFormState(true);
                return;
            }

            if (!string.IsNullOrEmpty(message))
            {
                MessageBox.Show(message, "Load Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #4
0
 public void Dispose()
 {
     m_cameraStatus = CameraStatus.None;
     m_showList.Clear();
     m_hideList.Clear();
     Destroy(circleRotateHelper);
 }
Example #5
0
 private void SortCapabilityCandidates(CameraStatus status)
 {
     if (status.ExposureMode?.Candidates != null)
     {
         status.ExposureMode.Candidates.Sort(ExposureModeComparer.INSTANCE);
     }
 }
Example #6
0
 public void UpdateCameraStatus(ref CameraStatus status)
 {
     if (changeCameraStatus && !triggered)
     {
         status.UpdateFromConverter(cameraStatusConverter);
     }
 }
Example #7
0
        /// <summary>Starts streaming pictures into the provided bitmap.</summary>
        /// <param name="bitmap">The bitmap to stream into. Its size must patch the selected resolution.</param>
        public void StartStreaming(Bitmap bitmap)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException("bitmap");
            }

            lock (this.syncRoot) {
                if (this.status == CameraStatus.Disconnected)
                {
                    throw new InvalidOperationException("No camera is connected.");
                }
                if (this.status == CameraStatus.TakePicture)
                {
                    throw new InvalidOperationException("The camera is already busy taking a picture.");
                }
                if (this.CurrentPictureResolution.Height != bitmap.Height || this.CurrentPictureResolution.Width != bitmap.Width)
                {
                    throw new ArgumentException("The camera is already busy streaming a bitmap.");
                }

                if (this.status == CameraStatus.StreamBitmap)
                {
                    this.StopStreaming();
                }

                this.takePictureFlag    = false;
                this.lastStreamingStart = DateTime.Now;
                this.targetBitmap       = bitmap;
                this.status             = CameraStatus.StreamBitmap;
                this.camera.StartStreaming(this.GetImageFormat(this.CurrentPictureResolution));
            }
        }
Example #8
0
        private void OnCameraStatusChanged(CameraStatus status)
        {
            if (status.Status == EventParam.Idle)
            {
                // When recording is stopped, clear recording time.
                status.RecordingTimeSec = 0;
            }
            if (status.IsRecording() ^ recording)
            {
                recording = !recording;
                UpdateShutterButton(status);
                ControlPanel.SetChildrenControlHitTest(!status.IsRecording());
                ControlPanel.SetChildrenControlTabStop(!status.IsRecording());

                if ((ScreenViewData?.IsAudioMode ?? false) && recording)
                {
                    CenterMicIcon.ContentTemplate = (DataTemplate)Application.Current.Resources["RecordingMicIcon"];
                    heartbeatStory = AnimationHelper.CreateHeartBeatAnimation(new AnimationRequest
                    {
                        Target = CenterMicIcon
                    }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(500));
                    heartbeatStory.Begin();
                }
                else
                {
                    CenterMicIcon.ContentTemplate = (DataTemplate)Application.Current.Resources["MicIcon"];
                    heartbeatStory?.Stop();
                }
            }
        }
 private void cbUseCases_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cameraDevice != null)
     {
         CameraStatus stat = cameraDevice.SetUseCase(cbUseCases.SelectedValue.ToString());
     }
 }
Example #10
0
        /// <summary>Takes a single picture using.</summary>
        public void TakePicture()
        {
            lock (this.syncRoot) {
                if (this.status == CameraStatus.Disconnected)
                {
                    throw new InvalidOperationException("No camera is connected.");
                }
                if (this.status == CameraStatus.TakePicture)
                {
                    throw new InvalidOperationException("The camera is already busy taking a picture.");
                }
                if (this.status == CameraStatus.StreamBitmap)
                {
                    throw new InvalidOperationException("The camera is already busy streaming a bitmap.");
                }

                if (!this.takePictureFlag)
                {
                    this.camera.StartStreaming(this.GetImageFormat(this.CurrentPictureResolution));
                }

                this.lastStreamingStart = DateTime.Now;
                this.status             = CameraStatus.TakePicture;
            }
        }
Example #11
0
 void Awake()
 {
     CameraList    = GameObject.FindGameObjectsWithTag("Camera");
     current_index = 0;
     stop_number   = 0;
     m_status      = CameraStatus.Normal;
 }
Example #12
0
    void Update()
    {
        secondsLeft -= Time.deltaTime;
        if (secondsLeft < 0)
        {
            secondsLeft = Random.Range(0.2f, 2f) * Random.Range(0.2f, 2f);

            if (status == CameraStatus.rotating)
            {
                status       = CameraStatus.waiting;
                secondsLeft /= 2f;
            }
            else
            {
                status           = CameraStatus.rotating;
                rotateMultiplier = Random.Range(20f, 80f);
                if (Random.Range(0, 2) < 1)
                {
                    rotateMultiplier *= -1;
                }
            }
        }

        if (status == CameraStatus.rotating && rover != null)
        {
            transform.RotateAround(transform.position, rover.transform.up, Time.deltaTime * rotateMultiplier);
        }
    }
Example #13
0
        public IHttpActionResult PostCameraStatus([FromBody] CameraStatusModel model)
        {
            using (var dbContext = new DataContext())
            {
                var camera = dbContext.Cameras.Find(model.DeviceID);
                if (camera == null)
                {
                    return(this.BadRequestEx(Error.DeviceNotFound));
                }

                camera.CameraStatusType  = (Core.Data.Enums.CameraStatusType)model.CameraStatusType;
                camera.ModifiedTimeStamp = DateTime.Now;

                var cameraStatus = new CameraStatus();
                cameraStatus.Camera           = camera;
                cameraStatus.CameraStatusType = (Core.Data.Enums.CameraStatusType)model.CameraStatusType;
                cameraStatus.CreatedTimeStamp = camera.ModifiedTimeStamp.Value;

                dbContext.DeviceStatuses.Add(cameraStatus);
                dbContext.SaveChanges();

                model.CreatedTimeStamp = cameraStatus.CreatedTimeStamp;

                return(Ok(model));
            }
        }
Example #14
0
        /// <summary>
        /// Starts streaming the bitmap identified by the bitmap parameter.
        /// </summary>
        /// <param name="bitmap">Bitmap of the same dimensions as the <see cref="CurrentPictureResolution"/> property.</param>
        public void StartStreamingBitmaps(Bitmap bitmap)
        {
            lock (this.cameraLock) {
                if (this._cameraStatus == CameraStatus.Disconnected)
                {
                    ErrorPrint("Unable to take picture. Camera is not ready. Is the Camera connected?");
                }
                else if (this._cameraStatus == CameraStatus.TakePicture)
                {
                    ErrorPrint("Unable to take picture. The camera is already busy taking a picture.");
                }
                else if (this._cameraStatus == CameraStatus.StreamBitmap)
                {
                    StopStreamingBitmaps();
                }

                if (CurrentPictureResolution.Height != bitmap.Height || CurrentPictureResolution.Width != bitmap.Width)
                {
                    throw new ArgumentException("Bitmap is not the same size as the current PictureResoltion", "bitmap");
                }

                if (this._cameraStatus == CameraStatus.Ready)
                {
                    _TakePictureFlag     = false;
                    _LastTimeStreamStart = DateTime.Now;
                    _targetBitmap        = bitmap;
                    _camera.StartStreaming(GetImageFormat(CurrentPictureResolution));
                    this._cameraStatus = CameraStatus.StreamBitmap;
                }
            }
        }
Example #15
0
 /// <summary>
 /// Must be called when the status of the camera has changed
 /// </summary>
 public void OnCameraStatusChanged(CameraStatus newStatus)
 {
     if (CameraStatusChanged != null)
     {
         CameraStatusChanged(this, new CameraStatusChangedEventArgs(newStatus));
     }
 }
Example #16
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public Camera(string no, string name, CameraStatus state = CameraStatus.Online)
 {
     this.No      = no;
     this.Name    = name;
     this.Status  = state;
     this.IsMute  = true;
     this.IsQuiet = true;
 }
 public void StartCapture()
 {
     if (Status == CameraStatus.Running)
     {
         throw new Exception("A camera can't be started if it is already running.");
     }
     Status = CameraStatus.Running;
 }
Example #18
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public Camera(string no, string name,CameraStatus state = CameraStatus.Online)
 {
     this.No = no;
     this.Name = name;
     this.Status = state;
     this.IsMute = true;
     this.IsQuiet = true;
 }
 public void StopCapture()
 {
     if (Status == CameraStatus.Stopped)
     {
         throw new Exception("A camera can't be stopped if it is already stopped.");
     }
     Status = CameraStatus.Stopped;
 }
Example #20
0
 public void CloseToPoint(Vector3 pos, float dis, int frameNumber)
 {
     CameraList[current_index].transform.LookAt(pos);
     init_pos       = CameraList[current_index].transform.position;
     target_pos     = Vector3.Lerp(init_pos, pos, dis / Vector3.Distance(init_pos, pos));
     stop_number    = frameNumber;
     current_number = 0;
     m_status       = CameraStatus.Moving;
 }
Example #21
0
 void cam1_CameraStatusChanged(object sender, Interface.CameraStatusChangedEventArgs e)
 {
     if (e.CurrentStatus == Interface.CameraStatus.Online)
     {
         status = e.CurrentStatus;
         cam1.Start();
     }
     Console.WriteLine(e.ToString());
 }
        Mmind.CameraStatus getCameraStatus()
        {
            Mmind.Response reply         = sendRequest(GetCameraStatus, 0.0, "");
            string         StatusUnicode = reply.CameraStatus;

            byte[]             StatusBytes = Encoding.UTF8.GetBytes(StatusUnicode);
            Mmind.CameraStatus cmstatus    = new CameraStatus();
            cmstatus = Mmind.CameraStatus.Parser.ParseFrom(StatusBytes);
            return(cmstatus);
        }
Example #23
0
 public TargetDevice(SonyCameraDeviceInfo info, HostName local)
 {
     Udn          = info.UDN;
     DeviceName   = info.ModelName;
     FriendlyName = info.FriendlyName;
     LocalAddress = local;
     _Api         = new DeviceApiHolder(info);
     _Status      = new CameraStatus();
     _Observer    = new StatusObserver(this);
 }
Example #24
0
    public void LockOff()
    {
        //退出时保持视角
        xMove = transform.rotation.eulerAngles.y;
        yMove = transform.rotation.eulerAngles.x;

        //取消锁定
        lockOnTarget    = null;
        cameraStatus    = CameraStatus.FOLLOW;
        lockDot.enabled = false;
    }
Example #25
0
 public void UpCamera()
 {
     status = CameraStatus.Moving;
     // カメラの視点をあわせる
     mainCamera.transform.rotation = playerCamera.transform.rotation;
     mainCamera.SetActive(true);
     mcm = mainCamera.GetComponent <MainCameraManager> ();
     playerCamera.SetActive(false);
     mcm.PlayUpAnimation();
     isUp = true;
 }
Example #26
0
 /// <summary>
 /// Stops streaming of bitmaps by the <see cref="Camera"/> object.
 /// </summary>
 public void StopStreamingBitmaps()
 {
     lock (this.cameraLock) {
         if (_cameraStatus == CameraStatus.StreamBitmap)
         {
             _TakePictureFlag = false;
             _camera.StopStreaming();
             _cameraStatus = CameraStatus.Ready;
         }
     }
 }
Example #27
0
        private void OnDeviceConnected(object sender, Webcam camera)
        {
            this.camera = camera;
            this.camera.Disconnected += this.OnDeviceDisconnected;

            this.status       = CameraStatus.Ready;
            this.running      = true;
            this.workerThread = new Thread(this.DoWork);
            this.workerThread.Start();

            this.OnCameraConnected(this, null);
        }
Example #28
0
        private void DoWork()
        {
            while (this.running)
            {
                lock (this.syncRoot) {
                    if (this.status == CameraStatus.TakePicture || this.status == CameraStatus.StreamBitmap)
                    {
                        if (this.camera.IsNewImageAvailable())
                        {
                            this.lastStreamingStart = DateTime.Now;

                            if (status == CameraStatus.TakePicture)
                            {
                                this.targetBitmap = new Bitmap(this.camera.CurrentStreamingFormat.Width, this.camera.CurrentStreamingFormat.Height);
                            }

                            this.camera.GetImage(this.targetBitmap);

                            if (this.status == CameraStatus.StreamBitmap)
                            {
                                this.OnBitmapStreamed(this, this.targetBitmap);
                            }
                            else
                            {
                                this.takePictureFlag       = true;
                                this.takePictureLastCalled = DateTime.Now;

                                byte[] bmp = GHI.Utilities.Bitmaps.ConvertToFile(this.targetBitmap);
                                this.OnPictureCaptured(this, new Picture(bmp, Picture.PictureEncoding.BMP));
                                this.status = CameraStatus.Ready;
                            }
                        }
                        else
                        {
                            if ((DateTime.Now - this.lastStreamingStart) > this.RestartStreamingTrigger)
                            {
                                this.camera.StopStreaming();
                                this.camera.StartStreaming(this.GetImageFormat(this.CurrentPictureResolution));
                                this.lastStreamingStart = DateTime.Now;
                            }
                        }
                    }
                    if (takePictureFlag && (status != CameraStatus.TakePicture) && ((DateTime.Now - takePictureLastCalled) > this.TakePictureStreamTimeout))
                    {
                        this.takePictureFlag = false;
                        this.camera.StopStreaming();
                    }
                }

                Thread.Sleep(100);
            }
        }
Example #29
0
        public CameraManager(int cameraID, WOZManager wozManager, Grid holder, int height = 240, int width = 320)
        {
            mWOZManager = wozManager;
            mCameraID = cameraID;  
            MyHolder = holder;

            ChangeViewTo(VIEWTYPE.SETTINGS);

            InitCamera(height, width);

            mCameraStatus = CameraStatus.IDLE;
 
        }
Example #30
0
 private void RevaluateLiveviewState(CameraStatus status)
 {
     if (liveviewDisabledByAudioMode && status.ShootMode?.Current != ShootModeParam.Audio && liveview?.ConnectionState == ConnectionState.Closed)
     {
         SequentialOperation.OpenLiveviewStream(target.Api, liveview).IgnoreExceptions();
         liveviewDisabledByAudioMode = false;
     }
     else if (!liveviewDisabledByAudioMode && status.ShootMode?.Current == ShootModeParam.Audio)
     {
         SequentialOperation.CloseLiveviewStream(target.Api, liveview).IgnoreExceptions();
         liveviewDisabledByAudioMode = true;
     }
 }
Example #31
0
    public void SaveCameraProgress(CameraStatus status, GameObject camera)
    {
        if (!willSaveProgress)
        {
            return;
        }
//        var triggers = GameObject.FindGameObjectsWithTag("Trigger");
//        foreach (var trigger in triggers) {
//            trigger.GetComponent<TriggerController>().ResetSaving();
//        }

        saveInfo.SaveCamera(status, camera);
    }
Example #32
0
        /// <summary>Stops streaming the bitmaps.</summary>
        public void StopStreaming()
        {
            lock (this.syncRoot) {
                if (status != CameraStatus.StreamBitmap)
                {
                    return;
                }

                this.takePictureFlag = false;
                this.camera.StopStreaming();
                this.status = CameraStatus.Ready;
            }
        }
Example #33
0
        /* */
        public void StartCamera()
        {

            try
            {
                cameraView.WebCamCtrl.StartCapture();
            }
            catch (Exception e)
            {
                SetMessage("Camera failed to Start");
            }


            mCameraStatus = CameraStatus.READY;
        }
Example #34
0
 public void StopCapture()
 {
     StopRecording();
     cameraView.WebCamCtrl.StopCapture();
     mCameraStatus = CameraStatus.OFF;
 }
Example #35
0
        public void StartRecording()
        {
            SetMessage("Recording!");

            try
            {
                cameraView.WebCamCtrl.StartRecording();
            }
            catch (Exception e)
            {
                SetMessage("Camera failed to Record!");
            }


            mCameraStatus = CameraStatus.RECORDING;
        }
Example #36
0
        public void StopRecording()
        {
            if (mCameraStatus == CameraStatus.RECORDING)
            {
                cameraView.WebCamCtrl.StopRecording();
                mCameraStatus = CameraStatus.READY;

                //string tempPath = @"C:\tempvideo" + mCameraID;
                string finalPath = "C:\\WOZInterface\\" + mWOZManager.mparticipantDetails.mID + "\\Video\\";   //@"C:\videos\";
                string searchPattern = "W*";

                DirectoryInfo di = new DirectoryInfo(mTempPath);
                FileInfo[] files = di.GetFiles(searchPattern, SearchOption.TopDirectoryOnly);
                
                // If the folder folder doesn't exist create it
                Directory.CreateDirectory(finalPath);
                
                foreach (FileInfo file in files)
                {
                    if (File.Exists(finalPath))
                    {
                        System.IO.File.Delete(finalPath);
                    }
                    if (File.Exists(finalPath + mCameraID + "_PName_" + mWOZManager.mparticipantDetails.mName + "_PID_" + mWOZManager.mparticipantDetails.mID + ".wmv"))
                    {
                        System.IO.File.Delete(finalPath + mCameraID + "_PName_" + mWOZManager.mparticipantDetails.mName + "_PID_" + mWOZManager.mparticipantDetails.mID + ".wmv");
                    }

                    file.MoveTo(finalPath + mCameraID + "_PName_" + mWOZManager.mparticipantDetails.mName + "_PID_" + mWOZManager.mparticipantDetails.mID + ".wmv");

                } 
            }

        }