Beispiel #1
0
        private void _dslrCamera_ImageReady(object sender, ImageReadyEventArgs args)
        {
            try
            {
                tl.LogMessage("Image downloaded", args.RawFileName);
                try
                {
                    tl.LogMessage("RAW Reading", "Raw reading started");
                    PrepareCameraImageArray(args.RawFileName);
                    tl.LogMessage("RAW Reading", "Raw reading finished");
                }
                catch (Exception ex)
                {
                    LogError("RAW reading error", ex);
                    throw new NotConnectedException("Raw reading error");
                }

                _cameraState = CameraStates.cameraIdle;
                cameraImageReady = true;
            }
            finally
            {
                UnsubscribeCameraEvents();
            }
        }
Beispiel #2
0
        public void StartExposure(double Duration, bool Light)
        {
            cameraImageReady = false;
            if (Duration < 0.0)
            {
                throw new InvalidValueException("StartExposure", Duration.ToString(), "0.0 upwards");
            }

            cameraLastExposureDuration = Duration;
            exposureStart = DateTime.Now;
            _cameraState  = CameraStates.cameraExposing;
            SetCameraSettings(ApiContainer.DslrCamera, CameraSettings);
            SubscribeCameraEvents();

            try
            {
                tl.LogMessage("StartExposure", Duration.ToString() + " " + Light.ToString());
                ApiContainer.DslrCamera.StartExposure(Duration, Light);
            }
            catch (Exception ex)
            {
                LogError("Exposure failed", ex);
                throw new NotConnectedException(ErrorMessages.NotConnected);
            }
        }
Beispiel #3
0
    IEnumerator CameraDelay()
    {
        isCoroutineRunning = true;
        yield return(new WaitForSeconds(0.7f));

        if (isCoroutineRunning)
        {
            if (currentState == CameraStates.bringNear)
            {
                SoundManager.Instance.canPlayBrakeSound = true;
                currentState       = CameraStates.idle;
                isCoroutineRunning = false;
            }
            else if (currentState == CameraStates.startBringNear)
            {
                isCoroutineRunning = false;
            }
            else if (currentState == CameraStates.sendFar)
            {
                currentState       = CameraStates.idle;
                isCoroutineRunning = false;
            }
            else if (currentState == CameraStates.startSendFar)
            {
                isCoroutineRunning = false;
            }
        }
    }
Beispiel #4
0
    private void UpdateOffset()
    {
        if (isOffset)
        {
            // Update current offset based on animation curve
            position.offset = Vector3.Lerp(startOffset, endOffset, offsetCurve.Evaluate(offsetCounter / offsetDuration));

            // Update offset time counter
            offsetCounter += Time.deltaTime;

            if (offsetCounter >= offsetDuration)
            {
                // Reset offset time counter
                offsetCounter = 0f;

                // Disable offset transition state
                isOffset = false;

                // Fix current offset end value
                position.offset = endOffset;

                // Reset offset transition start and end values
                startOffset = Vector3.zero;
                endOffset   = Vector3.zero;

                // Update current camera state
                state = endState;

                // Reset lerp counter
                lerpCounter = 0f;
            }
        }
    }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LxWebcam"/> class.
        /// Must be public for COM registration.
        /// </summary>
        public Camera()
        {
            traceLogger = new TraceLogger("", "LxWebcam");
            ReadProfile(); // Read device configuration from the ASCOM Profile store

            traceLogger.LogMessage("Camera", "Starting initialisation");

            webcam  = null;
            comPort = null;

            cameraXSize      = 0;
            cameraYSize      = 0;
            numX             = 0;
            numY             = 0;
            startX           = 0;
            startY           = 0;
            exposureMin      = double.NaN;
            exposureMax      = double.NaN;
            exposureStart    = DateTime.MinValue;
            exposureAbort    = DateTime.MinValue;
            exposureDuration = double.NaN;
            imageReady       = false;
            imageArray       = null;
            cameraState      = CameraStates.cameraIdle;
            pulseGuideMin    = 0;
            pulseGuideMax    = 0;
            semaphore        = null;
            threadRunning    = false;
            thread           = null;

            traceLogger.LogMessage("Camera", "Completed initialisation");
        }
Beispiel #6
0
        public void StartExposure(double Duration, bool Light)
        {
            if (_cameraState != CameraStates.cameraIdle)
            {
                throw new InvalidOperationException("Cannot start exposure - camera is not idle");
            }

            cameraImageReady = false;
            if (Duration < 0.0)
            {
                throw new InvalidValueException("StartExposure", Duration.ToString(), "0.0 upwards");
            }
            cameraLastExposureDuration = Duration;
            exposureStart = DateTime.Now;
            _cameraState  = CameraStates.cameraExposing;

            if (ApiContainer.DslrCamera.IsLiveViewMode)
            {
                LvExposure(Duration);
            }
            else
            {
                ShutterExposure(Duration, Light);
            }
        }
    // Update is called once per frame
    void Update()
    {
        cameraStopwatch += Time.deltaTime;



        switch (currentState)
        {
        case CameraStates.CAMERA_STATIONARY:
            int playerZone = GetPlayerZone();
            if (currentZone != playerZone)
            {
                MoveCameraToZone(playerZone);
            }
            break;

        case CameraStates.CAMERA_MOVING:
            if (PushCameraTowards(GetCurrentCameraPosition()))
            {
                currentState = CameraStates.CAMERA_STATIONARY;
                currentZone  = zoneTarget;
            }
            break;

        default:
            break;
        }

        // Every frame the camera turns to look at the player
        LookAtPlayer();
    }
        /// <summary>
        /// Stops camera.
        /// </summary>
        public async void StopCameraAsync()
        {
            if (CameraState != CameraStates.Initialized || _mediaCapture == null)
            {
                Debug.WriteLine(DebugTag + "StopCameraAsync(): Camera is not initialised");
                return;
            }

            CameraState             = CameraStates.Stopping;
            CaptureButton.IsEnabled = false;

            try
            {
                Debug.WriteLine(DebugTag + "StopCameraAsync(): Stopping camera...");
                await _mediaCapture.StopPreviewAsync();

                _mediaCapture.Dispose();
                _mediaCapture = null;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(DebugTag + "StopCameraAsync(): Failed to stop camera: " + ex.ToString());
            }

            CameraState = CameraStates.NotInitialized;
        }
Beispiel #9
0
 void FrameCaptureNewFrameEvent(object sender, Bitmap newFrame)
 {
     cameraState    = CameraStates.cameraReading;
     availableImage = (Bitmap)newFrame.Clone();
     imageReady     = true;
     cameraState    = CameraStates.cameraIdle;
 }
Beispiel #10
0
        private void ExposureThread()
        {
            while (true)
            {
                bool success;

                try
                {
                    success = this.semaphore.WaitOne();
                }
                catch
                {
                    success = false;
                }

                if (!success || !this.threadRunning)
                {
                    cameraState = CameraStates.cameraIdle; break;
                }

                int startX = this.startX;
                int startY = this.startY;
                int numX   = this.numX;
                int numY   = this.numY;

                HashSet <string> states = new HashSet <string>();

                while (this.threadRunning)
                {
                    ComPort.Response response = this.comPort.State(states);
                    LogMessage("ExposureThread", response.ToString());

                    if (response != ComPort.Response.OK)
                    {
                        success = false; break;
                    }

                    if (!states.Contains(ComPort.Exposure))
                    {
                        break;
                    }

                    cameraState = CameraStates.cameraExposing; Thread.Sleep(1);
                }

                if (!this.threadRunning)
                {
                    this.cameraState = CameraStates.cameraIdle; break;
                }

                if (success && this.exposureStart > this.exposureAbort)
                {
                    this.cameraState = CameraStates.cameraReading;
                    this.imageReady  = this.webcam.Capture(out this.imageArray, startX, startY, numX, numY);
                }

                this.cameraState = CameraStates.cameraIdle;
            }
        }
Beispiel #11
0
 public void StartTransition(Vector2 newOffset)
 {
     if (currentState != CameraStates.TRANSITION || currentState != CameraStates.NEW_SPOT)
     {
         currentState = CameraStates.TRANSITION;
         offset       = newOffset;
         StartCoroutine(ChangeToState(CameraStates.NEW_SPOT));
     }
 }
Beispiel #12
0
 public void RevertBack()
 {
     if (currentState != CameraStates.REVERT)
     {
         currentState = CameraStates.REVERT;
         offset       = prevOffset;
         StartCoroutine(ChangeToState(CameraStates.TRACKING));
     }
 }
Beispiel #13
0
        private void DslrCamera_LiveViewImageReady(object sender, LiveViewImageReadyEventArgs e)
        {
            cameraImageArray = _imageDataProcessor.ReadBitmap(e.Data);
            cameraImageArray = _imageDataProcessor.CutArray(cameraImageArray, StartX, StartY, NumX, NumY, CameraXSize, CameraYSize);
            ApiContainer.DslrCamera.LiveViewImageReady -= DslrCamera_LiveViewImageReady;

            _cameraState = CameraStates.cameraIdle;
            cameraImageReady = true;
        }
Beispiel #14
0
    } // CalculateFOVAmount()

    public void TriggerLevelSuccessFinished(Transform _parent)
    {
        cameraState = CameraStates.OnSuccessFinish;

        if (useCameraRotateWhenFinish)
        {
            transform.parent = _parent;
        }
    } // TriggerLevelSuccessFinished()
Beispiel #15
0
        /// <summary>
        /// Switches state of the camera to the <paramref name="newState"/>
        /// </summary>
        /// <param name="newState">The new state of the camera to switch to.</param>
        void SwitchToState(CameraStates newState)
        {
            CameraState newStateInstance = GetStateInstance(newState);

            state.SwitchFromThis(newStateInstance);
            newStateInstance.SwitchToThis(state);

            state = newStateInstance;
        }
Beispiel #16
0
        public void StartExposure(double Duration, bool Light)
        {
            this.CheckConnected("StartExposure");

            if (Duration < this.exposureMin || this.exposureMax < Duration)
            {
                if (Duration != 0)
                {
                    throw new InvalidValueException("StartExposure", Duration.ToString(), exposureMin.ToString(), exposureMax.ToString());
                }

                Duration = exposureMin;
            }

            if (this.startX < 0 || this.cameraXSize <= this.startX)
            {
                throw new InvalidValueException("StartExposure", this.startX.ToString(), "0", (this.cameraXSize - 1).ToString());
            }

            if (this.startY < 0 || this.cameraYSize <= this.startY)
            {
                throw new InvalidValueException("StartExposure", this.startY.ToString(), "0", (this.cameraYSize - 1).ToString());
            }

            if (this.numX < 1 || this.cameraXSize - this.startX < this.numX)
            {
                throw new InvalidValueException("StartExposure", this.numX.ToString(), "1", (this.cameraXSize - this.startX).ToString());
            }

            if (this.numY < 1 || this.cameraYSize - this.startY < this.numY)
            {
                throw new InvalidValueException("StartExposure", this.numY.ToString(), "1", (this.cameraYSize - this.startY).ToString());
            }

            ComPort.Response response = this.comPort.Start((int)(Duration * 1000 + 0.5));
            LogMessage("StartExposure", response.ToString());

            if (response.Reply != "OK")
            {
                throw new InvalidOperationException("StartExposure");
            }

            this.exposureDuration = Duration;
            this.exposureStart    = DateTime.Now;

            this.imageReady  = false;
            this.imageArray  = null;
            this.cameraState = CameraStates.cameraWaiting;

            try
            {
                this.semaphore.Release();
            }
            catch
            {
            }
        }
Beispiel #17
0
 public CameraState CreateCameraState(CameraStates state)
 {
     switch (state)
     {
     case (CameraStates.CameraFollowing):
         return(_followFactory.Create());
     }
     throw ModestTree.Assert.CreateException();
 }
Beispiel #18
0
 public void Reset()
 {
     cameraState             = CameraStates.Normal;
     transform.position      = startPos;
     camera.orthographicSize = startSize;
     translationCurveTimer   = 0;
     Time.timeScale          = 1;
     slowmoTimer             = 0;
 }
Beispiel #19
0
 public void MoveCam()
 {
     if (CameraState == CameraStates.Menu)
     {
         CameraState = CameraStates.Ingame;
     }
     else if (CameraState == CameraStates.Ingame)
     {
         CameraState = CameraStates.Menu;
     }
 }
Beispiel #20
0
        public void AbortExposure()
        {
            CheckConnected("Camera not connected");
            tl.LogMessage("AbortExposure", "");
            if (_cameraState == CameraStates.cameraExposing)
            {
                _sonyCamera.AbortExposure();
            }

            _cameraState = CameraStates.cameraIdle;
        }
Beispiel #21
0
    public void ResetCamera()
    {
        if (target == null)
        {
            target = GameObject.FindGameObjectWithTag("Player").transform;
        }

        if (target != null)
        {
            currentState       = CameraStates.idle;
            isCoroutineRunning = false;
            transform.position = originalPosition;
        }
    }
Beispiel #22
0
 public void AbortExposure()
 {
     if (CameraStates.cameraReading == cameraState || CameraStates.cameraDownload == cameraState)
     {
         throw new InvalidOperationException();
     }
     StopLx();
     exposureTimer.Dispose();
     if (null != availableImage)
     {
         availableImage.Dispose();
     }
     cameraState = CameraStates.cameraIdle;
 }
Beispiel #23
0
    public void ChangeCameraState(CameraStates requestedState)
    {
        if (currentState == requestedState)
        {
            return;
        }

        else
        {
            switch (requestedState)
            {
            case CameraStates.ZoomMin:
                currentState = requestedState;
                height       = Zoom1.x;
                posZminus    = Zoom1.y;
                camRotation  = Zoom1.z;
                break;

            case CameraStates.ZoomTwo:
                currentState = requestedState;
                height       = Zoom2.x;
                posZminus    = Zoom2.y;
                camRotation  = Zoom2.z;
                break;

            case CameraStates.ZoomThree:
                currentState = requestedState;
                height       = Zoom3.x;
                posZminus    = Zoom3.x;
                camRotation  = Zoom3.z;
                break;

            case CameraStates.ZoomFour:
                currentState = requestedState;
                height       = Zoom4.x;
                posZminus    = Zoom4.y;
                camRotation  = Zoom4.z;
                break;

            case CameraStates.ZoomMax:
                currentState = requestedState;
                height       = Zoom5.x;
                posZminus    = Zoom5.y;
                camRotation  = Zoom5.z;
                break;
            }
            Debug.Log("Switched Camera to: " + currentState);
        }
    }
Beispiel #24
0
    // Update is called once per frame
    void Update()
    {
        CameraRotationYSum += CameraRotationY;

        print("CameraRotationYSum = " + CameraRotationYSum);
        print("Timer = " + Timer);

        if (CameraRotationYSum > CameraRotationLimit)
        {
            Timer--;
            if (Timer < 0)
            {
                _currentState = CameraStates.MoveLeft;
                Timer         = 200;
            }
            else
            {
                _currentState = CameraStates.StayStill;
            }
        }
        else if (CameraRotationYSum < -CameraRotationLimit)
        {
            Timer--;
            if (Timer < 0)
            {
                _currentState = CameraStates.MoveRight;
                Timer         = 200;
            }
            else
            {
                _currentState = CameraStates.StayStill;
            }
        }

        if (_currentState == CameraStates.MoveLeft)
        {
            CameraRotationY = -Time.deltaTime;
        }
        else if (_currentState == CameraStates.MoveRight)
        {
            CameraRotationY = Time.deltaTime;
        }
        else if (_currentState == CameraStates.StayStill)
        {
            CameraRotationY = 0;
        }

        transform.Rotate(0, CameraRotationY, 0, Space.World);
    }
Beispiel #25
0
    private void GetCameraStateInput()
    {
        // Update camera switch state
        canLerp = (state != CameraStates.TOOBJECTIVE && state != CameraStates.TOORBIT);

        // Check camera change input
        if (Input.GetButton(transitionInput) && canLerp && state == CameraStates.ORBIT)
        {
            // Calculate closest enemy transform reference
            objective = gameplayManager.GetClosestFocusedEnemy();

            // Get its camera target transform reference (first child)
            if (objective)
            {
                objective = objective.GetChild(0);
            }
        }

        // Check for change
        // TODO: check if there is any target
        if (Input.GetButtonUp(transitionInput) && canLerp && (gameplayManager.Characters.Count > 1))
        {
            // Update camera state based on previous state
            state = ((state == CameraStates.ORBIT) ? CameraStates.TOOBJECTIVE : CameraStates.TOORBIT);

            // Reset lerp counter
            lerpCounter = 0f;

            if (state == CameraStates.TOORBIT)
            {
                Vector3 currentEulers = Quaternion.LookRotation(objective.position - transform.position).eulerAngles;
                orbit.yRotation = currentEulers.y - 180;
            }
        }

        // Fix camera state if objective doesn't exist
        if (state == CameraStates.TOOBJECTIVE && !objective)
        {
            state = CameraStates.ORBIT;
        }
        else if (state == CameraStates.OBJECTIVE && !objective)
        {
            // Reset camera state to orbit
            state = CameraStates.TOORBIT;

            // Reset lerp counter
            lerpCounter = 0f;
        }
    }
Beispiel #26
0
 private void SlowmotionMovement()
 {
     slowmoTimer   += Time.unscaledDeltaTime * 0.5f;
     Time.timeScale = slowmoCurve.Evaluate(slowmoTimer);
     if (slowmoTimer >= slowmoTotalTime)
     {
         Time.timeScale = 1;
         slowmoTimer    = 0;
         cameraState    = CameraStates.Normal;
     }
     translationCurveTimer += Time.unscaledDeltaTime;
     endPos                  = target != null ? new Vector3(target.position.x, target.position.y, transform.position.z) : new Vector3(0, 0, -10);
     transform.position      = Vector3.Lerp(transform.position, endPos, translationCurve.Evaluate(translationCurveTimer / travelTransitionTime));
     camera.orthographicSize = target != null?Mathf.Lerp(camera.orthographicSize, endSize, translationCurve.Evaluate(translationCurveTimer / cameraSizeTransitionTime)) : camera.orthographicSize;
 }
Beispiel #27
0
 private void cameraRideIntro()
 {
     if (this.CAM1_dolly.m_PathPosition < (this.CAM1_dolly.m_Path.MaxPos))
     {
         this.CAM1_dolly.m_PathPosition += Time.deltaTime;
         this.chairController.Animate("rotate");
     }
     else
     {
         if (this.chairController.isInAnimation == false)
         {
             this.cameraState = CameraStates.waitOnChair;
         }
     }
 }
Beispiel #28
0
    void Start()
    {
        // 设置ID
        leader = GameObject.FindGameObjectWithTag(Tags.Leader).transform;
        player = GameObject.FindGameObjectWithTag(Tags.Player).transform;
        SetID((int)gameObject.GetInstanceID());


        //设置状态接口,并指向一个状态
        EntityManager.Instance().RegisterEntity(this);
        m_pStateMachine = new StateMachine <MyCamera>(this);
        States          = this.gameObject.transform.FindChild("CameraStates").GetComponent <CameraStates>();
        m_pStateMachine = new StateMachine <MyCamera>(this);
        m_pStateMachine.SetCurrentState(States.FarSceneState);
        m_pStateMachine.SetGlobalStateState(States.GlobalState);
    }
Beispiel #29
0
    public void ResetCamera()
    {
        // Reset camera state to orbit with interpolation
        state       = CameraStates.TOORBIT;
        lerpCounter = 0f;

        // Reset orbit camera state values
        if (objective)
        {
            Vector3 currentEulers = Quaternion.LookRotation(objective.position - transform.position).eulerAngles;
            orbit.yRotation = currentEulers.y - 180;

            // Reset objective reference
            objective = null;
        }
    }
Beispiel #30
0
    public void HandleScreenShake()
    {
        SmoothFollow.enabled = false;

        if (Shake > 0)
        {
            gameObject.transform.position = Random.insideUnitSphere * ShakeAmount;
            Shake -= Time.deltaTime * ShakeDecreaseRate;
        }
        else
        {
            Shake = 0.0f;
            SmoothFollow.enabled = true;
            CameraState          = LastCameraState;
        }
    }
Beispiel #31
0
    private void determineCameraState()
    {
        if (inLookAround)
        {

            cameraState = CameraStates.LookAround;
        }
        else if (inShooting)
        {

            cameraState = CameraStates.Shooting;
        }
        else if (onTeleportField)
        {

            cameraState = CameraStates.onTeleport;
        }
        else
        {

            cameraState = CameraStates.FirstPerson;
        }
    }
Beispiel #32
0
		public void ToggleViewToPointCamera()
		{
			if (CameraState == CameraStates.ViewToPoint) {

			} else {
				CameraState = CameraStates.ViewToPoint;
			} 
		}
Beispiel #33
0
        }//end getImage(...


        private object doGRIMG()
        {
            uint xbytesize = (uint)(cameraNumX * 2);               //Number of 8 bit (bytes) per row

            uint[,] image = new uint[cameraNumX, cameraNumY];     //Container for the retrieved image
            byte[] rowString = new byte[cameraNumX];               //Container for a single row from image

            int row, col, bytecol, y, x;
            for (row = 0; row < cameraNumY; row++)              //For each row
            {
                rowString = FTDIio.readio(xbytesize);               //  read a row
                y = flipY ? cameraNumY - row - 1 : row;         //  vertical flip data?
                for (col = 0; col < cameraNumX; col++)          //Now translate 2x8 bit to 16 bit (Big Endian)
                {
                    bytecol = col * 2;
                    x = flipX ? -col - 1 : col;               //  mirror data?
                    image[x, y] = (uint)((short)rowString[bytecol] << 8 | (byte)rowString[bytecol + 1]);
                }
                if (row % 30 == 0) Debug.WriteLine("row: " + row);
            }
            cameraImageReady = true;
            cameraState = CameraStates.cameraIdle;
            Debug.WriteLine("exit download" + DateTime.Now);
            return image;
        }
Beispiel #34
0
		public void ToggleTopDownCamera()
		{
			CameraState = CameraStates.TopDown;
		}
Beispiel #35
0
		public void ToggleFreeSurfaceCamera()
		{
			if (CameraState == CameraStates.FreeSurface) {
				//CameraState = CameraStates.TopDown;
			} else {
				CameraState			= CameraStates.FreeSurface;
				FreeSurfacePosition = CameraPosition;
			}
		}
Beispiel #36
0
        public void StartExposure(double Duration, bool Light)
        {
            double sec = Math.Floor(Duration);                      //Camera firmware requires exposure time
            double msec = Math.Floor((Duration - sec) * 1000);      // to be in seconds and mSec
            string cmd;                                             //EXPOSE or DEXPOSE

            
            cameraImageReady = false;
            cameraState = CameraStates.cameraExposing;

            if (Duration < 0.0) throw new InvalidValueException("StartExposure", Duration.ToString(), "0.0 upwards");
            if (cameraNumX > ccdWidth) throw new InvalidValueException("StartExposure", cameraNumX.ToString(), ccdWidth.ToString());
            if (cameraNumY > ccdHeight) throw new InvalidValueException("StartExposure", cameraNumY.ToString(), ccdHeight.ToString());
            if (cameraStartX > ccdWidth) throw new InvalidValueException("StartExposure", cameraStartX.ToString(), ccdWidth.ToString());
            if (cameraStartY > ccdHeight) throw new InvalidValueException("StartExposure", cameraStartY.ToString(), ccdHeight.ToString());

            cameraLastExposureDuration = Duration;
            exposureStart = DateTime.Now;

            tl.LogMessage("StartExposure", Duration.ToString() + " " + Light.ToString());

            CommandString(sec.ToString() + " XSEC !");      //Send the camera the exposure time
            CommandString(msec.ToString() + " XMSEC ! ");

            if (Light) cmd = "EXPOSE";
            else cmd = "DEXPOSE";                           //Dark expose (closed shutter)

            //Start a separate thread to do exposure and image capture so this can return to client
            // to show exposure time display
            FTDIio.GrabImageLock = true;
            Thread t = new Thread(() => SendExpose(cmd, Duration));
            t.Start();
            FTDIio.GrabImageLock = false;
        }
Beispiel #37
0
        // here are some useful properties and methods that can be used as required
        // to help with driver development

        private object getImage()
        {

            uint xbytesize = (uint)(cameraNumX * 2);               //Number of 8 bit (bytes) per row

            uint[,] image = new uint[cameraNumX, cameraNumY];     //Container for the retrieved image
            byte[] rowString = new byte[cameraNumX];               //Container for a single row from image

            Debug.WriteLine("enter download" + DateTime.Now);
            cameraImageReady = false;
            cameraState = CameraStates.cameraDownload;
            CommandString("PON");
            CommandString(String.Concat(cameraNumX.ToString(), " XSIZE !"));
            CommandString(String.Concat(cameraNumY.ToString(), " YSIZE !"));
            CommandString(String.Concat(binx.ToString(), " XBIN !"));
            CommandString(String.Concat(biny.ToString(), " YBIN !"));
            CommandString(String.Concat(cameraStartX.ToString(), " XOFFS !"));
            CommandString(String.Concat(cameraStartY.ToString(), " YOFFS !"));

            //Thread t = new Thread(() => doGRIMG());
            //t.Start();
            //t.Join();

            lock (FTDIio.cmdLock)
            {
                FTDIio.CommandBlind("GRIMG");                     //Requested image but don't wait for any response but echo

                int row, col, bytecol, y, x;
                for (row = 0; row < cameraNumY; row++)              //For each row
                {
                    rowString = FTDIio.readio(xbytesize);               //  read a row
                    y = flipY ? cameraNumY - row - 1 : row;         //  vertical flip data?
                    for (col = 0; col < cameraNumX; col++)          //Now translate 2x8 bit to 16 bit (Big Endian)
                    {
                        bytecol = col * 2;
                        x = flipX ? -col - 1 : col;               //  mirror data?
                        image[x, y] = (uint)((short)rowString[bytecol] << 8 | (byte)rowString[bytecol + 1]);
                    }
                    if (row % 30 == 0) Debug.WriteLine("row: " + row);
                }

                FTDIio.waitForOk();
            }
            //FTDIio.GrabImageLock = false;
            cameraImageReady = true;
            cameraState = CameraStates.cameraIdle;
            Debug.WriteLine("exit download" + DateTime.Now);


            return (object)image;
        }//end getImage(...