async Task <WriteableBitmap> GetImageFromCamera() { try { CurrentStatus = "Checking for laser."; //TODO: temporary code bool isLaserAvailable = await _lasers.GetEnabled(0); if (isLaserAvailable) { CurrentStatus = "Starting Laser"; await _lasers.SetLaserState(0, IsLaserChecked); } //Start taking image. [shutterState = open, exposureType = light] CurrentStatus = "Starting exposure."; var image = await _camera.AcquireImageAsync(new AcquireParams { ExposureTime = ExposureTime * 1000, AnalogGain = 10, MaxGain = 29, MinGain = 0, ExposureType = false }, new System.Threading.CancellationToken()); if (image != null) { var currentTime = DateTime.Now; //Await the exposure time. //await Funcs.PutTaskDelay(1000); //Just let it wait a second before a //Make sure image is ready. CurrentStatus = $"Checking for exposure, elapsed {DateTime.Now.Subtract(currentTime).Seconds} seconds."; //Get the image. CurrentStatus = "Exposure available, now getting image."; ushort[,] img = image.Image; //Now stop the laser if (isLaserAvailable && IsLaserChecked) { CurrentStatus = "Stoping Laser."; //TODO: temporary commented await _lasers.SetLaserState(0, false); } if (img == null) { CurrentStatus = "Can't obtain image from camera"; return(null); } //Now convert the image and return. CurrentStatus = "Done"; _lastImageArray = img; return(Imaging.GetImageFromUShort(img, IsScaledChecked, false)); } }catch (Exception ex) { CurrentStatus = ex.Message; } return(null); }