/// <summary> /// Requests and attempts to read an image for a barcode /// </summary> private void imgCap() { if (!run) { return; } // Do allow multiple reads at the same time from timer interrupts if (mu.WaitOne(1)) { try { Bitmap curBarCode = (Bitmap)cam.AcquireImage(); pb_barcode.Image = Bitmapper.Resize(curBarCode, pb_barcode.Width, pb_barcode.Height); curBarCode = PrepImage(curBarCode); Bitmap temp = new Bitmap(curBarCode); Bitmapper.ThresholdImage(temp, Barcode.threshold); temp = (Bitmap)Bitmapper.Resize(temp, pb_barcode.Width, temp.Height); pb_threshold.Image = temp; if (curBarCode != null) { Barcode code = new Barcode(curBarCode); if (code.uncertainty > (Int32)nud_uncertainty.Value) { throw new BarcodeException("Uncertainty to high:" + code.uncertainty); } DisplayBarcode(code.barcode); lastBarcode = code; lb_uncertainty.Text = code.uncertainty.ToString(); stop(); } } catch (Exception ex) { tb_errors.Text = ex.Message; } finally { mu.ReleaseMutex(); } } }
protected Bitmap GetCapture() { Bitmap img = null; if (CallerControl != null) { if (CallerControl.InvokeRequired) { CallerControl.Invoke(new Action(() => img = Camera.AcquireImage())); } else { img = Camera.AcquireImage(); } } return(img); }