public bool OneShot() { try { bGrabDone = false; if (m_imageProvider.IsOpen) { m_imageProvider.OneShot(); } DateTime st_time = DateTime.Now; TimeSpan time_span; while (!bGrabDone) { Thread.Sleep(5); Application.DoEvents(); time_span = DateTime.Now - st_time; if (time_span.TotalMilliseconds > 800) { bGrabDone = true; return(false); } } return(true); } catch (Exception) { //ShowException(e, m_imageProvider.GetLastErrorMessage()); } return(true); }
/* Starts the grabbing of one image and handles exceptions. */ private void OneShot() { try { m_imageProvider.OneShot(); /* Starts the grabbing of one image. */ } catch (Exception e) { ShowException(e, m_imageProvider.GetLastErrorMessage()); } }
/// <summary> /// Grabs a single image from ImageProvider. /// </summary> public void OneShot() { try { ImageProvider.OneShot(); } catch (Exception ex) { log.Fatal("ERROR while single shotting on device with Index " + Index); log.Fatal("Device Info: " + FullName); log.Fatal("Exception: " + ex.ToString()); OnErrorReceived?.Invoke(this, ex); } }
/// <summary> /// Start the device for a frame grab, wait a bit and then return the result. /// This method MUST raise a CameraThumbnailProduced event, even in case of error. /// </summary> public void Run(object data) { log.DebugFormat("Starting {0} for thumbnail.", summary.Alias); if (!imageProvider.IsOpen) { Thread.Sleep(timeoutOpening); } if (!imageProvider.IsOpen) { if (CameraThumbnailProduced != null) { CameraThumbnailProduced(this, new CameraThumbnailProducedEventArgs(summary, null, imageDescriptor, true, false)); } return; } try { imageProvider.OneShot(); //imageProvider.ContinuousShot(); } catch (Exception e) { LogError(e, imageProvider.GetLastErrorMessage()); } waitHandle.WaitOne(timeoutGrabbing, false); lock (locker) { if (!cancelled) { imageProvider.GrabErrorEvent -= imageProvider_GrabErrorEvent; imageProvider.DeviceRemovedEvent -= imageProvider_DeviceRemovedEvent; imageProvider.ImageReadyEvent -= imageProvider_ImageReadyEvent; Stop(); Close(); } } if (CameraThumbnailProduced != null) { CameraThumbnailProduced(this, new CameraThumbnailProducedEventArgs(summary, image, imageDescriptor, hadError, cancelled)); } }
//拍摄单张图片 public void OneShot() { Finish = false; m_imageProvider.OneShot(); /* Starts the grabbing of one image. */ }