public MainForm(Type startProcessType, bool test) { this.startProcessType = startProcessType; IsTest = test; InitializeComponent(); Height = 320; Width = 240; if (!IsTest) { try { IntermecBarcodeReader = new BarcodeReader(); IntermecBarcodeReader.BarcodeRead += OnBarcodeRead; IntermecBarcodeReader.ThreadedRead(true); } catch (Exception exc) { Console.Write(exc.Message); } } HotKeyAgent = new HotKeyProcessing(this); Client = new WMSClient(this, startProcessType); Client.Start(); if ( File.Exists( Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\update")) { Client.NeedToUpdate = true; } }
protected override void OnClosing(CancelEventArgs e) { if (_reader != null) { _reader.Dispose(); _reader = null; } base.OnClosing(e); }
public static BarcodeResult[] GetBarcode(Bitmap bitmap, Int64 format, string strSessionID) { BarcodeReader reader = new BarcodeReader(); ReaderOptions options = new ReaderOptions(); options.MaxBarcodesToReadPerPage = 100; options.BarcodeFormats = (BarcodeFormat)format; reader.ReaderOptions = options; reader.LicenseKeys = "<input barcode reader license here>"; return reader.DecodeBitmap(bitmap); }
public MainForm(bool test) { IsTest = test; InitializeComponent(); Height = 320; Width = 240; //SqlCeEngine engine = new SqlCeEngine("Data Source='SD-MMCard\\DCIM\\Test333.sdf';"); //if (!(File.Exists(@"SD-MMCard\DCIM\Test333.sdf"))) // engine.CreateDatabase(); //SqlCeConnection connection = new SqlCeConnection(engine.LocalConnectionString); //connection.Open(); //SqlCeCommand command = connection.CreateCommand(); //command.CommandText = "SELECT * FROM dar"; //SqlCeDataReader result = command.ExecuteReader(); //while (result.Read()) //{ // MessageBox.Show(result[0].ToString()); //} if (!IsTest) { try { IntermecBarcodeReader = new BarcodeReader(); IntermecBarcodeReader.BarcodeRead += OnBarcodeRead; IntermecBarcodeReader.ThreadedRead(true); } catch (Exception exc) { Console.Write(exc.Message); } } HotKeyAgent = new HotKeyProcessing(this); Client = new WMSClient(this); Client.Start(); if ( File.Exists( Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\update")) { Client.NeedToUpdate = true; } }
public void DecodeBarcode() { // create a barcode reader instance BarcodeReader reader = new BarcodeReader(); // load a bitmap var barcodeBitmap = (Bitmap)Image.FromFile("E:\\Ecep\\Toko\\SSCC-Pallet-Barcode.jpg"); // detect and decode the barcode inside the bitmap var result = reader.Decode(barcodeBitmap); // do something with the result if (result != null) { //txtDecoderType.Text = result.BarcodeFormat.ToString(); //kdBarang = result.Text; //this.StateHasChanged(); } }
public string ReadBarCodeText(byte[] b) { using (var stream = new MemoryStream(b)) { using (var bm = new Bitmap(stream)) { var reader = new BarcodeReader(); reader.Options = new DecodingOptions() { CharacterSet = this.Charset, TryHarder = true }; var res = reader.Decode(bm); return(res.Text); } } }
private string decode(Bitmap bitmap) { IBarcodeReader reader = new BarcodeReader(); // detect and decode the barcode inside the bitmap var result = reader.Decode(bitmap); // do something with the result if (result != null) { return(result.Text); } else { return(""); } }
public void BtnCheckOnClick() { WebCamDevice[] devices = WebCamTexture.devices; foreach (var item in devices) { if (!item.isFrontFacing) { mWebCamTexture = new WebCamTexture(item.name, Screen.width, Screen.height); rawImage.texture = mWebCamTexture; rawImage.gameObject.SetActive(true); mWebCamTexture.Play(); mReader = new BarcodeReader(); isCheck = true; break; } } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog() { Filter = "Imagen png|*.png", InitialDirectory = @"C:\Users\ivanc\Desktop\codigos" }; if (ofd.ShowDialog() == DialogResult.OK) { pictureBox2.Image = Image.FromFile(ofd.FileName); BarcodeReader br = new BarcodeReader(); texto = br.Decode((Bitmap)pictureBox2.Image).ToString(); } dato(); this.Close(); }
/// <summary> /// Verifies if the document conatins barcode or not. /// </summary> /// <param name="filePath">The image's path that should be verified.</param> /// <returns>Retuns true if the image conatins barcodem and false if not.</returns> public static bool IsLastPage(string filePath) { if (!IsBitmapImage(filePath)) { return(false); } var barcodeReader = new BarcodeReader(); Result barcodeResult; using (var barcodeBitmap = (Bitmap)Image.FromFile(filePath)) { barcodeResult = barcodeReader.Decode(barcodeBitmap); } return(barcodeResult != null); }
public new void Dispose() { addLog("IntermecScanControl Dispose()..."); //dispose BarcodeReader if (bcr != null) { // addLog("IntermecScanControl Dispose(): Calling CancelRead(true)..."); // bcr.CancelRead(true); addLog("IntermecScanControl Dispose(): Disposing BarcodeReader..."); bcr.ThreadedRead(false); bcr.BarcodeRead -= bcr_BarcodeRead; //bcr.BarcodeReadCanceled -= bcr_BarcodeReadCanceled; //bcr.BarcodeReadError -= bcr_BarcodeReadError; bcr.Dispose(); bcr = null; } }
public string findQRCodeInImage(Texture2D image) { if (barcodeReader == null) { barcodeReader = new BarcodeReader(); } string o = "No Qr Code Found"; var data = barcodeReader.Decode(image.GetRawTextureData(), image.width, image.height, RGBLuminanceSource.BitmapFormat.RGB24); if (data != null) { // QRCode detected. Debug.Log(data.Text); o = data.Text; } return(o); }
static string DecodeBarcode(BarcodeReader barcodeReader, Mat barcodeImage) { if (barcodeImage.Width == 0 || barcodeImage.Height == 0) { return(null); } var barcodeBitmap = new Bitmap(barcodeImage.ToMemoryStream()); var barcodeResult = barcodeReader.Decode(barcodeBitmap); if (barcodeResult != null && barcodeResult.Text.Length == 8) { return(barcodeResult.Text); } return(null); }
private void button1_Click(object sender, EventArgs e) { BarcodeReader barcodeReader = new BarcodeReader(); barcodeReader.Options.CharacterSet = "UTF-8"; Result result = barcodeReader.Decode((Bitmap)pictureBoxImage.Image); if (result != null) { textBox2.Text = result.Text; } else { MessageBox.Show("无法识别的条码!"); textBox2.Text = ""; } }
private void decodeQR() { try { Bitmap bitmap = new Bitmap(pictureBox1.Image); BarcodeReader reader = new BarcodeReader { AutoRotate = true, TryInverted = true }; Result result = reader.Decode(bitmap); string decoded = result.ToString().Trim(); scantb1.Text = decoded; } catch (Exception) { MessageBox.Show("Image not found", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Дешифрование QR кода /// </summary> /// <param name="webTexture"> Текстура QR для дешифрования </param> /// <returns> Возвращает зашифрованное сообщение </returns> public string ReGenerateQR(WebCamTexture webTexture) { IBarcodeReader barcodeReader = new BarcodeReader(); var result = barcodeReader.Decode(webTexture.GetPixels32(), webTexture.width, webTexture.height); if (result != null) { Debug.Log("Decoded text from QR: " + result.Text); return(result.Text); } else { Debug.Log("Not found QR code"); return(null); } }
private void OnGUI() { try { if (camTexture.isPlaying) { GUI.DrawTexture(screenRect, camTexture, ScaleMode.ScaleToFit); IBarcodeReader barcodeReader = new BarcodeReader(); var result = barcodeReader.Decode(camTexture.GetPixels32(), camTexture.width, camTexture.height); if (result != null) { if (result.Text == "Dog") { if (currentModel == null) { animal = animals.Where(a => a.name == "Dog").First(); currentModel = Instantiate(models[0], new Vector3(0, 0, 0), transform.rotation) as GameObject; enableButtons(); } else { camTexture.Stop(); } } else if (result.Text == "Cat") { if (currentModel == null) { animal = animals.Where(a => a.name == "Cat").First(); currentModel = Instantiate(models[1], new Vector3(0, 0, 0), transform.rotation) as GameObject; enableButtons(); } else { camTexture.Stop(); } } } } } catch (Exception ex) { Debug.LogWarning(ex.Message); } }
public async void CloseScanner(BarcodeReader mSelectedReader) { try { BarcodeReader.Result result = await mSelectedReader.CloseAsync(); if (result.Code == BarcodeReader.Result.Codes.SUCCESS || result.Code == BarcodeReader.Result.Codes.NO_ACTIVE_CONNECTION) { Debug.WriteLine("Scanner closed"); } } catch (Exception e) { Analytics.TrackEvent("Error al cerrar el scanner: " + e.Message + "\n Escaner: " + Preferences.Get("LECTOR", "N/A")); } }
private void timer1_Tick(object sender, EventArgs e) { BarcodeReader Reader = new BarcodeReader(); Result result = Reader.Decode((Bitmap)pictureBox2.Image); try { String decoded = result.ToString().Trim(); if (decoded != null) { timer1.Stop(); MessageBox.Show(decoded); } }catch (Exception ex) { } }
void Update() { try { IBarcodeReader barcodeReader = new BarcodeReader(); // decode the current frame var result = barcodeReader.Decode(webCam.GetPixels32(), webCam.width, webCam.height); if (result != null) { Debug.Log("DECODED TEXT FROM QR: " + result.Text); ClientNetworkManager.ConnectClient(result.Text); this.enabled = false; } } catch (Exception ex) { Debug.LogWarning(ex.Message); } }
void webCamTimer_Tick(object sender, EventArgs e) { var bitmap = wCam.GetCurrentImage(); if (bitmap == null) { return; } var reader = new BarcodeReader(); var result = reader.Decode(bitmap); if (result != null) { txtTypeWebCam.Text = result.BarcodeFormat.ToString(); txtContentWebCam.Text = result.Text; } }
void OnGUI() { // drawing the camera on screen GUI.DrawTexture(screenRect, backCam, ScaleMode.ScaleToFit); // do the reading — you might want to attempt to read less often than you draw on the screen for performance sake try { IBarcodeReader barcodeReader = new BarcodeReader(); // decode the current frame var result = barcodeReader.Decode(backCam.GetPixels32(), backCam.width, backCam.height); if (result != null) { text.text = result.Text; } } catch (Exception ex) { Debug.LogWarning(ex.Message); } }
private void VideoUpdater_Tick(object sender, EventArgs e) { BarcodeReader reader = new BarcodeReader(); if (QrScreen.Image != null) { Result DecodedCode = reader.Decode((Bitmap)QrScreen.Image); try { MessageBox.Show(DecodedCode.ToString().Trim()); VideoUpdater.Enabled = false; } catch (Exception) { } } }
//private Symbol.Barcode.Reader MyReader = null; //private Symbol.Barcode.ReaderData MyReaderData = null; //private System.EventHandler MyEventHandler = null; private void EnableReader(object sender, EventArgs e) { try { bcr = new BarcodeReader("AllScanners"); bcr.ScannerEnable = true; bcr.BarcodeRead += new BarcodeReadEventHandler(HandleData); bcr.ThreadedRead(true); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
private void CloseReader(object sender, CancelEventArgs e) { try { if (bcr != null) { bcr.ScannerEnable = false; bcr.Dispose(); bcr = null; } } catch (Exception exp) { MessageBox.Show(exp.Message); } }
protected void btnSave_Click(object sender, EventArgs e) { Bitmap bt = new Bitmap(@"D:\Devlop\Test\C#二维码生成\二维码识别\jiashizheng.png"); BarcodeReader reader = new BarcodeReader(); reader.Options.CharacterSet = "UTF-8"; reader.Options.TryHarder = true; reader.Options.PureBarcode = true; var result = reader.Decode(bt); //return (result == null) ? null : result.Text; if (result != null) { this.txbModelName.Text = result.Text; } }
public WindowsFormsDemoForm() { InitializeComponent(); barcodeReader = new BarcodeReader { AutoRotate = true, TryInverted = true, Options = new DecodingOptions { TryHarder = true } }; barcodeReader.ResultPointFound += point => { if (point == null) { resultPoints.Clear(); } else { resultPoints.Add(point); } }; barcodeReader.ResultFound += result => { txtType.Text = result.BarcodeFormat.ToString(); txtContent.Text += result.Text + Environment.NewLine; if (result.ResultMetadata.ContainsKey(ResultMetadataType.UPC_EAN_EXTENSION)) { txtContent.Text += " UPC/EAN Extension: " + result.ResultMetadata[ResultMetadataType.UPC_EAN_EXTENSION].ToString(); } lastResults.Add(result); var parsedResult = ResultParser.parseResult(result); if (parsedResult != null) { btnExtendedResult.Visible = !(parsedResult is TextParsedResult); txtContent.Text += "\r\n\r\nParsed result:\r\n" + parsedResult.DisplayResult + Environment.NewLine + Environment.NewLine; } else { btnExtendedResult.Visible = false; } }; resultPoints = new List <ResultPoint>(); lastResults = new List <Result>(); Renderer = typeof(BitmapRenderer); }
private void timer2_Tick(object sender, EventArgs e) { BarcodeReader read = new BarcodeReader(); if (pictureBox1.Image != null) { Result res = read.Decode((Bitmap)pictureBox1.Image); try { lblSNum.Text = res.ToString(); } catch (Exception ex) { //MessageBox.Show(ex.Message); } } }
private void timer1_Tick(object sender, EventArgs e) { if (pictureBox.Image != null) { BarcodeReader barcodeReader = new BarcodeReader(); Result result = barcodeReader.Decode((Bitmap)pictureBox.Image); if (result != null) { txtQRCode.Text = result.ToString(); timer1.Stop(); if (captureDevice.IsRunning) { captureDevice.Stop(); } } } }
protected void ReadBarcode(string imagePath) { BarcodeReader reader = new BarcodeReader(ConfigurationManager.AppSettings["BarcodeScannerAPIKey"]); TextResult[] result = reader.DecodeFile(imagePath, ""); if (result.Length > 0) { lblResult.Text = "Number of barcodes found in image: " + result.Length; CreateResultsTable(result); } else { lblResult.Text = "No barcodes found in image"; } }
void check() { try { Invoke(new MethodInvoker(backgroundchange2)); IBarcodeReader reader = new BarcodeReader(); Bitmap cloneBitmap = (Bitmap)video.Clone(); var result = reader.Decode(cloneBitmap); if (result != null) { bool send = false; if (lastString.Equals(result.Text)) { Int32 t = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; if (t > lastTime) { send = true; } } else { send = true; } if (send) { lastString = result.Text; lastTime = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + 5; SendKeys.SendWait(lastString); SendKeys.SendWait("{ENTER}"); Console.WriteLine("GetStarted was a success. Read Value: " + lastString); System.Media.SoundPlayer player = new System.Media.SoundPlayer(System.IO.Directory.GetCurrentDirectory() + "\\beep-07.wav"); player.Play(); Invoke(new MethodInvoker(backgroundchange)); } } } catch (Exception e) { Console.WriteLine("errore: " + e.ToString()); } }
static public string Read(WebCamTexture tex) { BarcodeReader reader = new BarcodeReader(); int w = tex.width; int h = tex.height; var pixel32s = tex.GetPixels32(); var r = reader.Decode(pixel32s, w, h); if (r != null) { return(r.Text); } else { return("error"); } }
/// <summary> /// Tries to read barcode into an image. Rotates the image untill it reads successfull /// </summary> /// <param name="reader"></param> /// <param name="bmp"></param> /// <param name="data"></param> /// <returns></returns> public static Barcode[] ReadFromBitmapRotateAll(this BarcodeReader reader, ref Bitmap bmp, Voucher data) { Barcode[] results = reader.ReadFromBitmap(bmp); for (int count = 0; count < 4 && (results == null || results.Length == 0); count++) { bmp = bmp.RotateEx(90); results = reader.ReadFromBitmap(bmp); } if (results != null && results.Length > 0) { data.BarCodeArea = Rectangle.FromLTRB(results[0].Left, results[0].Top, results[0].Right, results[0].Bottom); data.BarCodeImage = bmp.CopyNoFree(data.BarCodeArea); } return(results); }
public string Read1DPro_File(string fileName) { BarcodeReader reader = new BarcodeReader(); // configure directions reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.Code39 = true; reader.Code128= true; // Read Code39 and Code128 barcodes in file Barcode[] barcodes = reader.Read(fileName); string s = "";int cnt = 0; foreach (Barcode bc in barcodes) { cnt++; AddBarcode(ref s, cnt, bc); } if (cnt == 0) { s = s + "NO BARCODES"; } s = s + Environment.NewLine; return s; }
private void dispatcherTimer_Tick(object sender, EventArgs e) { BarcodeReader reader = new BarcodeReader(); Result result = new Result("", null, null, BarcodeFormat.All_1D); if (pictureBox1.Image != null) { result = reader.Decode((System.Drawing.Bitmap)pictureBox1.Image); } try { string decode = result.ToString().Trim(); if (decode != "") { int i = CoderDecoder.CoderDecoder.processOrWorker(decode); if (i == 2) { fullInfoFromQRCode.Text = CoderDecoder.CoderDecoder.getFullInfoAboutProccess(CoderDecoder.CoderDecoder.decode(decode)); id_procces.Content = decode.Split(' ')[0]; ClassForAudio.playScan(); } else { string str = CoderDecoder.CoderDecoder.getInfoAboutWorker(decode); InfoAboutWorker.Content = str.Split('_')[0]; id_worker.Content = str.Split('_')[1]; ClassForAudio.playScan(); } } } catch (Exception ex) { if (ex.Message == "not found process") { fullInfoFromQRCode.Text = "Такого Завдання не знайдено!!!"; ClassForAudio.playNoScan(); } if (ex.Message == "not found worker") { InfoAboutWorker.Content = "Такого працівника не знайдено!!!"; ClassForAudio.playNoScan(); } } }
public string[] ReadBarcode_Auto(Mat frame) { string[] data = new string[2] { "NoRead", "" }; IBarcodeReader reader = new BarcodeReader(); var grayFrame = frame.ToImage <Gray, byte>();//frame.Convert<Gray, byte>(); reader.Options.TryHarder = true; reader.Options.PossibleFormats = new List <BarcodeFormat> { BarcodeFormat.CODE_39, BarcodeFormat.CODE_128, BarcodeFormat.EAN_8, BarcodeFormat.EAN_13, BarcodeFormat.ITF }; reader.Options.UseCode39ExtendedMode = true; reader.Options.UseCode39RelaxedExtendedMode = true; //BarcodeReadImage = null; int i = 64; int try_ = 0; while (i < 257) { grayFrame = frame.ToImage <Gray, byte>(); grayFrame = grayFrame.ThresholdBinary(new Gray(i), new Gray(maxValue)); var result = reader.Decode(grayFrame.ToBitmap()); if (result != null) { data[0] = result.Text; data[1] = result.BarcodeFormat.ToString(); ExtractedImage = grayFrame.Mat; i = 999; } i += 16; try_++; } if (i != 999) { grayFrame = frame.ToImage <Gray, byte>(); grayFrame = grayFrame.ThresholdBinary(new Gray(128), new Gray(255)); ExtractedImage = grayFrame.Mat; } return(data); }
public BarcodeReader BuildBarcodeReader() { var reader = new BarcodeReader(); if (this.TryHarder.HasValue) { reader.Options.TryHarder = this.TryHarder.Value; } if (this.PureBarcode.HasValue) { reader.Options.PureBarcode = this.PureBarcode.Value; } if (this.AutoRotate.HasValue) { reader.AutoRotate = this.AutoRotate.Value; } if (this.UseCode39ExtendedMode.HasValue) { reader.Options.UseCode39ExtendedMode = this.UseCode39ExtendedMode.Value; } if (!string.IsNullOrEmpty(this.CharacterSet)) { reader.Options.CharacterSet = this.CharacterSet; } if (this.TryInverted.HasValue) { reader.TryInverted = this.TryInverted.Value; } if (this.AssumeGS1.HasValue) { reader.Options.AssumeGS1 = this.AssumeGS1.Value; } if (this.PossibleFormats != null && this.PossibleFormats.Count > 0) { reader.Options.PossibleFormats = new List <BarcodeFormat>(); foreach (var pf in this.PossibleFormats) { reader.Options.PossibleFormats.Add(pf); } } return(reader); }
private async void DecodeBarCode() { var reader = new BarcodeReader { AutoRotate = true, Options = new DecodingOptions { TryHarder = true, } }; var result = await Task.Run(() => reader.Decode(Image)); Debug.WriteLine(result != null ? "Barcode text : " + result.Text + "\nFormat : " + result.BarcodeFormat : "Barcode not found!"); }
public string ReadQR_Page(Bitmap btPic) { BarcodeReader reader = new BarcodeReader(); // for faster reading specify only required direction reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; // specify type reader.QR = true; string s = ""; using (MemoryStream stream = new MemoryStream()) { btPic.Save(stream, ImageFormat.Bmp); stream.Position = 0; Barcode[] barcodes = reader.Read(stream); int cnt = 0; foreach (Barcode bc in barcodes) { cnt++; AddBarcode(ref s, cnt, bc); } if (cnt == 0) { s = "NO BARCODES"; } } return s; }
public string ReadPdf417_Page(string fileName, int page) { BarcodeReader reader = new BarcodeReader(); // for faster reading specify only required direction reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; // specify type reader.Pdf417 = true; Barcode[] barcodes = reader.Read (fileName, page); string s = ""; int cnt = 0; foreach (Barcode bc in barcodes) {cnt++; AddBarcode(ref s, cnt, bc); } if (cnt == 0) { s = "NO BARCODES"; } return s; }
public new void Dispose() { addLog("IntermecScanControl Dispose()..."); _continueWait = false; //signal threads to stop SystemEvent waitEvent = new SystemEvent("EndWaitLoop52", false, false); waitEvent.PulseEvent(); System.Threading.Thread.Sleep(100); int iTry = 0; while (_bWaitLoopRunning && iTry < 5) { System.Threading.Thread.Sleep(300); iTry++; } addLog("IntermecScanControl Dispose(): ending Threads..."); //is the waitThread (waitLoop) still running? if (waitThread != null) { addLog("IntermecScanControl Dispose(): ending event watch thread ..."); waitThread.Abort(); } //is there still a readThread running? if (readThread != null) { addLog("IntermecScanControl Dispose(): ending Barcode reading thread ..."); readThread.Abort(); } if (bcr != null) { addLog("IntermecScanControl Dispose(): Calling ScannerOnOff(false)..."); scannerOnOff(false); addLog("IntermecScanControl Dispose(): Disposing BarcodeReader..."); //bcr.ThreadedRead(false); bcr.BarcodeRead -= bcr_BarcodeRead; bcr.Dispose(); bcr = null; addLog("IntermecScanControl Dispose(): BarcodeReader disposed"); } try { addLog("IntermecScanControl Dispose(): enabling HardwareTrigger..."); //replaced this call as ADCComInterface made problems //S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); YetAnotherHelperClass.setHWTrigger(true); YetAnotherHelperClass.setNumberOfGoodReadBeeps(1); } catch (Exception ex) { addLog("IntermecScanControl Dispose(), Exception: enabling HardwareTrigger: "+ex.Message); } addLog("IntermecScanControl Dispose(): restoring Scan Button Key..."); ITCTools.KeyBoard.restoreKey(); addLog("...IntermecScanControl Dispose(): end."); //base.Dispose(); do not use!! }
/// <summary> /// enables event handler for barcode read /// </summary> public void Connect() { addLog("Connect()..."); try { if (bcr == null) { addLog("create new barcoderader"); bcr = new BarcodeReader(); } else addLog("using existing barcodereader"); } catch (BarcodeReaderException ex) { addLog("BarcodeReaderException in Connect(): " + ex.Message); } catch (Exception ex) { addLog("Exception in Connect(): " + ex.Message); } if (bcr != null) { addLog("attach barcode read event"); bcr.BarcodeRead += new BarcodeReadEventHandler(bcr_BarcodeRead); } else addLog("no BarcodeReader!"); addLog("Connect() end"); }
public void OnPreviewFrame (byte [] bytes, Android.Hardware.Camera camera) { if ((DateTime.Now - lastPreviewAnalysis).TotalMilliseconds < options.DelayBetweenAnalyzingFrames) return; try { var cameraParameters = camera.GetParameters(); var img = new YuvImage(bytes, ImageFormatType.Nv21, cameraParameters.PreviewSize.Width, cameraParameters.PreviewSize.Height, null); if (barcodeReader == null) { barcodeReader = new BarcodeReader(null, null, null, (p, w, h, f) => new PlanarYUVLuminanceSource(p, w, h, 0, 0, w, h, false)); //new PlanarYUVLuminanceSource(p, w, h, dataRect.Left, dataRect.Top, dataRect.Width(), dataRect.Height(), false)) if (this.options.TryHarder.HasValue) barcodeReader.Options.TryHarder = this.options.TryHarder.Value; if (this.options.PureBarcode.HasValue) barcodeReader.Options.PureBarcode = this.options.PureBarcode.Value; if (!string.IsNullOrEmpty (this.options.CharacterSet)) barcodeReader.Options.CharacterSet = this.options.CharacterSet; if (this.options.TryInverted.HasValue) barcodeReader.TryInverted = this.options.TryInverted.Value; if (this.options.PossibleFormats != null && this.options.PossibleFormats.Count > 0) { barcodeReader.Options.PossibleFormats = new List<BarcodeFormat>(); foreach (var pf in this.options.PossibleFormats) barcodeReader.Options.PossibleFormats.Add(pf); } //Always autorotate on android barcodeReader.AutoRotate = true; } //Try and decode the result var result = barcodeReader.Decode(img.GetYuvData(), img.Width, img.Height, RGBLuminanceSource.BitmapFormat.Unknown); lastPreviewAnalysis = DateTime.Now; if (result == null || string.IsNullOrEmpty (result.Text)) return; Android.Util.Log.Debug("ZXing.Mobile", "Barcode Found: " + result.Text); ShutdownCamera(); callback(result); } catch (ReaderException) { Android.Util.Log.Debug("ZXing.Mobile", "No barcode Found"); // ignore this exception; it happens every time there is a failed scan } catch (Exception) { // TODO: this one is unexpected.. log or otherwise handle it throw; } }
/// <summary> /// stop timer, disconnect barcode event handler /// and cancel pending barcode reads /// </summary> public void Disconnect() { addLog("Disconnect..."); if (timer1 != null) { try { addLog("disable timer1"); timer1.Change(Timeout.Infinite, m_iTimeout); } catch (Exception) { } } else addLog("no timer1"); try { if (bcr != null) { addLog("removing event handler"); bcr.BarcodeRead -= bcr_BarcodeRead; addLog("cancel pending read"); bcr.CancelRead(true); addLog("Disposing barcodereader"); bcr.Dispose(); addLog("set barcodereader=null"); bcr = null; } else { addLog("no barcodereader!"); } } catch (Exception ex) { addLog("Exception in Disconnect(): " + ex.Message); } }
public void Dispose() { addLog("Dispose()..."); if (timer1 != null) timer1.Dispose(); if (bcr != null) { Disconnect(); bcr = null; } addLog("Dispose() end"); }
public IntermecBarcodescanControl5() { InitializeComponent(); try { addLog("IntermecBarcodescanControl5: setHWTrigger(true)..."); //enable HW trigger, a workaround as HW trigger is sometimes disabled on BarcodeReader.Dispose() //if (!S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true)) //{ // addLog("IntermecBarcodescanControl5: setHWTrigger(true)...FAILED. Trying again"); // Thread.Sleep(50); // S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); //try again //} //replaced above code with the following, there were problems with load/unload the ADCComInterface inside S9CConfig YetAnotherHelperClass.setHWTrigger(true); //change number of good read beeps to zero YetAnotherHelperClass.setNumberOfGoodReadBeeps(0); addLog("IntermecBarcodescanControl5: mapKey()..."); //we use the standard scan key assignement: addLog("IntermecBarcodescanControl5: restoreScanKeyDefault()..."); ITCTools.KeyBoard.restoreScanKeyDefault(); } catch (Exception ex) { addLog("Exception in IntermecBarcodescanControl5: setHWTrigger(true)..." + ex.Message); } try { //Cannot use Keydown etc within a usercontrol, we will not get the events!!!!! ITCTools.KeyBoard.createMultiKey2Events(); #if USEWAITLOOP addLog("IntermecBarcodescanControl2: starting named event watch thread..."); waitThread = new System.Threading.Thread(waitLoop); //waitThread.Priority = ThreadPriority.Lowest; //does not help waitThread.Start(); #endif addLog("IntermecBarcodescanControl5: new BarcodeReader()..."); //create a new BarcodeReader instance bcr = new BarcodeReader(this, "default");// (); addLog("IntermecBarcodescanControl5: BarcodeReader adding event handlers..."); bcr.BarcodeRead += new BarcodeReadEventHandler(bcr_BarcodeRead); bcr.BarcodeReadCanceled += new BarcodeReadCancelEventHandler(bcr_BarcodeReadCanceled); bcr.BarcodeReadError += new BarcodeReadErrorEventHandler(bcr_BarcodeReadError); addLog("IntermecBarcodescanControl5: enabling Scanner..."); bcr.ScannerEnable = true; addLog("IntermecBarcodescanControl5: ScannerOn=false..."); bcr.ScannerOn = false; addLog("Enabling event driver scanning"); bcr.ThreadedRead(true); } catch (BarcodeReaderException ex) { bcr = null; System.Diagnostics.Debug.WriteLine("BarcodeReaderException in IntermecScanControl(): " + ex.Message); } catch (Exception ex) { bcr = null; System.Diagnostics.Debug.WriteLine("Exception in IntermecScanControl(): " + ex.Message); } if (bcr == null) { addLog("IntermecBarcodescanControl5: BarcodeReader init FAILED"); throw new System.IO.FileNotFoundException("Intermec.Datacollection.dll or ITCScan.DLL missing"); } #if TESTMODE //testcodes = new string[8]; testCodeCount = testcodes.Length; testCodePos = 0; #endif }
private void InicializarLeitor() { _reader = new BarcodeReader(); _reader.Start(); _reader.ListChanged += (sender, args) => { if (args.ListChangedType == ListChangedType.ItemAdded) { var readertext = ((BarcodeReader)sender).ReaderData.Text; try { ValidaLocalizacao(readertext); } catch { } } }; }
public mainFrm() { InitializeComponent(); #if ASYNCHRONOUS try { mySensor = new Sensor(this, Sensor.SensorsEnabled.AccelerometerEnabled, true); } catch (Exception) { MessageBox.Show("No sensor available. Did you install SensorCab runtime? Exit"); Application.Exit(); } //call mySensor_AccelerationEvent for Acceleration events from sensor mySensor.AccelerationMinimumNotifyDelta = 0; mySensor.SensorDataUpdateInterval = 10; mySensor.AccelerationEvent += new AccelerationEventHandler(mySensor_AccelerationEvent); #else //mySensor = new Sensor(this, Sensor.SensorsEnabled.AccelerometerEnabled, false); #endif cbSensity.SelectedIndex = 3; //default is 0.01, 0 means all events trackBar1.Value = 100; //mySensor.SensorDataUpdateInterval = 50; // shaker1 = new ShakeDetection.ShakeClass1("shake1"); shaker1.shakeTreshold = 8.0; //shaker1.logEnabled = true; //better implementation shaker1.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker1_ShakeDetected); // shaker2 = new ShakeDetection.ShakeClass2("shake2"); //shaker2.logEnabled = true; shaker2.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker2_ShakeDetected); // shaker3 = new ShakeDetection.ShakeClass3("shake3"); //shaker3.logEnabled = true; shaker3.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker3_ShakeDetected); // shaker4 = new ShakeDetection.ShakeClass4("shake4"); //shaker4.logEnabled = true; shaker4.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker4_ShakeDetected); // shaker5 = new ShakeDetection.ShakeClass5("shake5"); trackBar5.Value = 8; trackBar1_ValueChanged(this, null); //shaker5.logEnabled = true; shaker5.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker5_ShakeDetected); // shaker6 = new ShakeDetection.ShakeClass6("shake6"); //shaker6.logEnabled = true; shaker6.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker6_ShakeDetected); trackBar6.Value = 120; // shaker7 = new ShakeDetection.ShakeClass7("shake7"); //shaker7.logEnabled = true; shaker7.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker7_ShakeDetected); // shaker8 = new ShakeDetection.ShakeClass8("shake8"); //shaker8.logEnabled = true; shaker8.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker8_ShakeDetected); // shaker9 = new ShakeDetection.ShakeClass9("shake9"); //shaker8.logEnabled = true; shaker9.ShakeDetected += new ShakeDetection.ShakeClass.ShakeDetectedEventHandler(shaker9_ShakeDetected); // move1 = new Movedetection.MovementClass1("move1"); move1.logEnabled = true; move1.MoveDetected += new Movedetection.MovementClass.MoveDetectedEventHandler(move1_MoveDetected); move1.IdleDetected += new Movedetection.MovementClass.IdleDetectedEventHandler(move1_IdleDetected); #if !ASYNCHRONOUS //myTimer.Interval = 50; //approx 20 events per second //myTimer.Tick += new EventHandler(myTimer_Tick); //myTimer.Enabled = true; //do not enable timer before assigning the shaker/move classes //myTimer.Enabled = true; myThread = new bgThread(); myThread.bgThreadEvent += new bgThread.bgThreadEventHandler(myThread_bgThreadEvent); #endif //perfChart1.maxDecimal = 1500; perfChart1._SymmetricDisplay= true; perfChart1._ScaleMode = SpPerfChart.ScaleMode.Relative; //perfChart2.maxDecimal = 1500; perfChart2._SymmetricDisplay = true; perfChart2._ScaleMode = SpPerfChart.ScaleMode.Relative; //perfChart3.maxDecimal = 1500; perfChart3._SymmetricDisplay = true; perfChart3._ScaleMode = SpPerfChart.ScaleMode.Relative; perfChart4._SymmetricDisplay = true; perfChart4._ScaleMode = SpPerfChart.ScaleMode.Relative; starting = false; #if USE_SCANNER scanEvents = new ScanEvents(); try { bcr = new BarcodeReader(); bcr.ContinuesScan = true; scanTimer = new Timer(); scanTimer.Interval = 1000; //fire every second scanTimer.Tick += new EventHandler(scanTimer_Tick); scanTimer.Enabled = true; } catch (Exception) { //scanner not available } #endif }
private void ActivateBCR(object sender, EventArgs e) { if (!NoBRC_Test) { try { bcr = new BarcodeReader("AllScanners"); bcr.ScannerEnable = true; bcr.BarcodeRead += new BarcodeReadEventHandler(bcr_BarcodeRead); bcr.ThreadedRead(true); } catch (Exception exp) { MessageBox.Show(exp.Message); } } }
private void InitBarcodeReaderIfNeeded() { if (_barcodeReader != null) return; _barcodeReader = new BarcodeReader(null, null, null, (p, w, h, f) => new PlanarYUVLuminanceSource(p, w, h, 0, 0, w, h, false)); //new PlanarYUVLuminanceSource(p, w, h, dataRect.Left, dataRect.Top, dataRect.Width(), dataRect.Height(), false)) if (_scanningOptions.TryHarder.HasValue) _barcodeReader.Options.TryHarder = _scanningOptions.TryHarder.Value; if (_scanningOptions.PureBarcode.HasValue) _barcodeReader.Options.PureBarcode = _scanningOptions.PureBarcode.Value; if (!string.IsNullOrEmpty(_scanningOptions.CharacterSet)) _barcodeReader.Options.CharacterSet = _scanningOptions.CharacterSet; if (_scanningOptions.TryInverted.HasValue) _barcodeReader.TryInverted = _scanningOptions.TryInverted.Value; if (_scanningOptions.PossibleFormats != null && _scanningOptions.PossibleFormats.Count > 0) { _barcodeReader.Options.PossibleFormats = new List<BarcodeFormat>(); foreach (var pf in _scanningOptions.PossibleFormats) _barcodeReader.Options.PossibleFormats.Add(pf); } }
private void DeactivateBCR(object sender, EventArgs e) { if (!NoBRC_Test) { try { if (bcr != null) { bcr.ScannerEnable = false; bcr.Dispose(); bcr = null; } } catch (Exception exp) { MessageBox.Show(exp.Message); } } }
bool SetupCaptureSession () { // configure the capture session for low resolution, change this if your code // can cope with more data or volume session = new AVCaptureSession () { SessionPreset = AVCaptureSession.Preset640x480 }; // create a device input and attach it to the session var captureDevice = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video); if (captureDevice == null){ Console.WriteLine ("No captureDevice - this won't work on the simulator, try a physical device"); return false; } var input = AVCaptureDeviceInput.FromDevice (captureDevice); if (input == null){ Console.WriteLine ("No input - this won't work on the simulator, try a physical device"); return false; } else session.AddInput (input); previewLayer = new AVCaptureVideoPreviewLayer(session); //Framerate set here (15 fps) if (previewLayer.RespondsToSelector(new Selector("connection"))) previewLayer.Connection.VideoMinFrameDuration = new CMTime(1, 10); previewLayer.LayerVideoGravity = AVLayerVideoGravity.ResizeAspectFill; previewLayer.Frame = this.Frame; previewLayer.Position = new PointF(this.Layer.Bounds.Width / 2, (this.Layer.Bounds.Height / 2)); layerView = new UIView(this.Frame); layerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; layerView.Layer.AddSublayer(previewLayer); this.AddSubview(layerView); ResizePreview(UIApplication.SharedApplication.StatusBarOrientation); if (overlayView != null) { this.AddSubview (overlayView); this.BringSubviewToFront (overlayView); //overlayView.LayoutSubviews (); } session.StartRunning (); Console.WriteLine ("RUNNING!!!"); // create a VideoDataOutput and add it to the sesion output = new AVCaptureVideoDataOutput () { //videoSettings VideoSettings = new AVVideoSettings (CVPixelFormatType.CV32BGRA), }; // configure the output queue = new MonoTouch.CoreFoundation.DispatchQueue("ZxingScannerView"); // (Guid.NewGuid().ToString()); var barcodeReader = new BarcodeReader(null, (img) => { var src = new RGBLuminanceSource(img); //, bmp.Width, bmp.Height); //Don't try and rotate properly if we're autorotating anyway if (options.AutoRotate.HasValue && options.AutoRotate.Value) return src; switch (UIDevice.CurrentDevice.Orientation) { case UIDeviceOrientation.Portrait: return src.rotateCounterClockwise().rotateCounterClockwise().rotateCounterClockwise(); case UIDeviceOrientation.PortraitUpsideDown: return src.rotateCounterClockwise().rotateCounterClockwise().rotateCounterClockwise(); case UIDeviceOrientation.LandscapeLeft: return src; case UIDeviceOrientation.LandscapeRight: return src; } return src; }, null, null); //(p, w, h, f) => new RGBLuminanceSource(p, w, h, RGBLuminanceSource.BitmapFormat.Unknown)); if (this.options.TryHarder.HasValue) { Console.WriteLine("TRY_HARDER: " + this.options.TryHarder.Value); barcodeReader.Options.TryHarder = this.options.TryHarder.Value; } if (this.options.PureBarcode.HasValue) barcodeReader.Options.PureBarcode = this.options.PureBarcode.Value; if (this.options.AutoRotate.HasValue) { Console.WriteLine("AUTO_ROTATE: " + this.options.AutoRotate.Value); barcodeReader.AutoRotate = this.options.AutoRotate.Value; } if (!string.IsNullOrEmpty (this.options.CharacterSet)) barcodeReader.Options.CharacterSet = this.options.CharacterSet; if (this.options.TryInverted.HasValue) barcodeReader.TryInverted = this.options.TryInverted.Value; if (this.options.PossibleFormats != null && this.options.PossibleFormats.Count > 0) { barcodeReader.Options.PossibleFormats = new List<BarcodeFormat>(); foreach (var pf in this.options.PossibleFormats) barcodeReader.Options.PossibleFormats.Add(pf); } outputRecorder = new OutputRecorder (this.options, img => { try { var started = DateTime.Now; var rs = barcodeReader.Decode(img); var total = DateTime.Now - started; Console.WriteLine("Decode Time: " + total.TotalMilliseconds + " ms"); if (rs != null) resultCallback(rs); } catch (Exception ex) { Console.WriteLine("DECODE FAILED: " + ex); } }); output.AlwaysDiscardsLateVideoFrames = true; output.SetSampleBufferDelegate (outputRecorder, queue); Console.WriteLine("SetupCamera Finished"); session.AddOutput (output); //session.StartRunning (); if (captureDevice.IsFocusModeSupported(AVCaptureFocusMode.ModeContinuousAutoFocus)) { NSError err = null; if (captureDevice.LockForConfiguration(out err)) { captureDevice.FocusMode = AVCaptureFocusMode.ModeContinuousAutoFocus; if (captureDevice.FocusPointOfInterestSupported) captureDevice.FocusPointOfInterest = new PointF(0.5f, 0.5f); captureDevice.UnlockForConfiguration(); } else Console.WriteLine("Failed to Lock for Config: " + err.Description); } return true; }
public void OnPreviewFrame (byte [] bytes, Android.Hardware.Camera camera) { //Check and see if we're still processing a previous frame if (processingTask != null && !processingTask.IsCompleted) return; if ((DateTime.UtcNow - lastPreviewAnalysis).TotalMilliseconds < options.DelayBetweenAnalyzingFrames) return; var cameraParameters = camera.GetParameters(); var width = cameraParameters.PreviewSize.Width; var height = cameraParameters.PreviewSize.Height; //var img = new YuvImage(bytes, ImageFormatType.Nv21, cameraParameters.PreviewSize.Width, cameraParameters.PreviewSize.Height, null); lastPreviewAnalysis = DateTime.UtcNow; processingTask = Task.Factory.StartNew (() => { try { if (barcodeReader == null) { barcodeReader = new BarcodeReader (null, null, null, (p, w, h, f) => new PlanarYUVLuminanceSource (p, w, h, 0, 0, w, h, false)); //new PlanarYUVLuminanceSource(p, w, h, dataRect.Left, dataRect.Top, dataRect.Width(), dataRect.Height(), false)) if (this.options.TryHarder.HasValue) barcodeReader.Options.TryHarder = this.options.TryHarder.Value; if (this.options.PureBarcode.HasValue) barcodeReader.Options.PureBarcode = this.options.PureBarcode.Value; if (!string.IsNullOrEmpty (this.options.CharacterSet)) barcodeReader.Options.CharacterSet = this.options.CharacterSet; if (this.options.TryInverted.HasValue) barcodeReader.TryInverted = this.options.TryInverted.Value; if (this.options.PossibleFormats != null && this.options.PossibleFormats.Count > 0) { barcodeReader.Options.PossibleFormats = new List<BarcodeFormat> (); foreach (var pf in this.options.PossibleFormats) barcodeReader.Options.PossibleFormats.Add (pf); } } bool rotate = false; int newWidth = width; int newHeight = height; var cDegrees = getCameraDisplayOrientation(this.activity); if (cDegrees == 90 || cDegrees == 270) { rotate = true; newWidth = height; newHeight = width; } var start = PerformanceCounter.Start(); if (rotate) bytes = rotateCounterClockwise(bytes, width, height); var result = barcodeReader.Decode (bytes, newWidth, newHeight, RGBLuminanceSource.BitmapFormat.Unknown); PerformanceCounter.Stop(start, "Decode Time: {0} ms (width: " + width + ", height: " + height + ", degrees: " + cDegrees + ", rotate: " + rotate + ")"); if (result == null || string.IsNullOrEmpty (result.Text)) return; Android.Util.Log.Debug ("ZXing.Mobile", "Barcode Found: " + result.Text); ShutdownCamera (); callback (result); } catch (ReaderException) { Android.Util.Log.Debug ("ZXing.Mobile", "No barcode Found"); // ignore this exception; it happens every time there is a failed scan } catch (Exception) { // TODO: this one is unexpected.. log or otherwise handle it throw; } }); }
private void InicializarLeitor() { _reader = new BarcodeReader(); _reader.Start(); _reader.ListChanged += (sender, args) => { if (args.ListChangedType == ListChangedType.ItemAdded) { var readertext = ((BarcodeReader)sender).ReaderData.Text; BuscaProduto(readertext); } }; }
public void OnPreviewFrame(byte [] bytes, Android.Hardware.Camera camera) { if (!isAnalyzing) return; //Check and see if we're still processing a previous frame if (processingTask != null && !processingTask.IsCompleted) return; if ((DateTime.UtcNow - lastPreviewAnalysis).TotalMilliseconds < options.DelayBetweenAnalyzingFrames) return; // Delay a minimum between scans if (wasScanned && ((DateTime.UtcNow - lastPreviewAnalysis).TotalMilliseconds < options.DelayBetweenContinuousScans)) return; wasScanned = false; var cameraParameters = camera.GetParameters(); var width = cameraParameters.PreviewSize.Width; var height = cameraParameters.PreviewSize.Height; //var img = new YuvImage(bytes, ImageFormatType.Nv21, cameraParameters.PreviewSize.Width, cameraParameters.PreviewSize.Height, null); lastPreviewAnalysis = DateTime.UtcNow; processingTask = Task.Factory.StartNew (() => { try { if (barcodeReader == null) { barcodeReader = new BarcodeReader (null, null, null, (p, w, h, f) => new PlanarYUVLuminanceSource (p, w, h, 0, 0, w, h, false)); //new PlanarYUVLuminanceSource(p, w, h, dataRect.Left, dataRect.Top, dataRect.Width(), dataRect.Height(), false)) if (this.options.TryHarder.HasValue) barcodeReader.Options.TryHarder = this.options.TryHarder.Value; if (this.options.PureBarcode.HasValue) barcodeReader.Options.PureBarcode = this.options.PureBarcode.Value; if (!string.IsNullOrEmpty (this.options.CharacterSet)) barcodeReader.Options.CharacterSet = this.options.CharacterSet; if (this.options.TryInverted.HasValue) barcodeReader.TryInverted = this.options.TryInverted.Value; if (this.options.PossibleFormats != null && this.options.PossibleFormats.Count > 0) { barcodeReader.Options.PossibleFormats = new List<BarcodeFormat> (); foreach (var pf in this.options.PossibleFormats) barcodeReader.Options.PossibleFormats.Add (pf); } } bool rotate = false; int newWidth = width; int newHeight = height; var cDegrees = getCameraDisplayOrientation(this.activity); if (cDegrees == 90 || cDegrees == 270) { rotate = true; newWidth = height; newHeight = width; } if (rotate) bytes = rotateYUV420Degree90(bytes, width, height);//rotateCounterClockwise(bytes, width, height); var result = barcodeReader.Decode (bytes, newWidth, newHeight, RGBLuminanceSource.BitmapFormat.Unknown); if (result == null || string.IsNullOrEmpty (result.Text)) return; Android.Util.Log.Debug (MobileBarcodeScanner.TAG, "Barcode Found: " + result.Text); var img = new YuvImage(bytes, cameraParameters.PreviewFormat, newWidth, newHeight, null); System.IO.MemoryStream outStream = new System.IO.MemoryStream(); bool didIt = img.CompressToJpeg(new Rect(0,0,newWidth, newHeight), 75, outStream); outStream.Seek(0, System.IO.SeekOrigin.Begin); Bitmap newBM = BitmapFactory.DecodeStream(outStream); result.CaptureImage = newBM; wasScanned = true; callback (result); } catch (ReaderException) { Android.Util.Log.Debug (MobileBarcodeScanner.TAG, "No barcode Found"); // ignore this exception; it happens every time there is a failed scan } catch (Exception) { // TODO: this one is unexpected.. log or otherwise handle it throw; } }); }
//User section for bussines logic //Your code should be inserted here protected async Task UserSection() { _screenView = Screen.CreateElement("Design.ScreenView"); _screenList = Screen.CreateElement("Design.ScreenList"); _screenInfo = Screen.CreateElement("Design.ScreenInfo"); _state = AppState.List; #region init // load Screen List controls screenList_List = _screenList.GetChildByName("MainList") as ListBox; screenList_List.Clickable = true; screenList_List.Clicked += screenList_List_Clicked; screenList_BtAdd = _screenList.GetChildByName("BtAdd") as SelectableArea; screenList_BtAdd.Clicked += screenList_BtAdd_Clicked; // load screen info controls _screenInfo_Caption = _screenInfo.GetChildByName("tbCaption") as TextBlock; _screenInfo_MainText = _screenInfo.GetChildByName("tbMainText") as TextBlock; _screenInfo_BtBack = _screenInfo.GetChildByName("BtBack") as SelectableArea; _screenInfo_BtBack.Clicked += BackToSCreenList; // load screen view controls _screenView_Image = _screenView.GetChildByName("MainImage") as ImageBlock; _screenView_CameraName = _screenView.GetChildByName("TlName") as TextBlock; _screenView_BtBack = _screenView.GetChildByName("BtBack") as SelectableArea; _screenView_BtBack.Clicked += BackToSCreenList; // qrcode reader _barcodeReader = new BarcodeReader(this); _barcodeReader.BarcodeReady += (s, be) => { if (_barcodeReader.RC == FunctionRC.OK) { AddCamera(_barcodeReader.MainData); } else { // todo error reporting //barcodeState = TPositioningState.ErrorReceived; } }; #endregion _cameras = new List<string>(); _state = AppState.List; AddCamera("100-066e23cd012e8f79afc37722e07bf694"); AddCamera("100-f0a176294a5c51a822ee6f4c0ae89a2c"); AddCamera("100-2033519638a3a4abb9b41d3a04bdb666"); #if false // можно включить AddCamera("100-2fbb74c566c49f4cfb6e2ea2ce1c9b4d"); AddCamera("100-40580f419398b68e0a18fa0fc319101b"); AddCamera("100-1bb9cf88076de6341a294182a49c6cf5"); #endif for (; ; ) { switch (_state) { case AppState.List: Screen.Content = _screenList; break; case AppState.StartingView: // start timer Schedule(1000, GetPicture); _screenInfo_Caption.Text = "Подключение"; _screenInfo_MainText.Text = "Пожалуйста, подождите. Идет подключение..."; Screen.Content = _screenInfo; break; case AppState.View: _screenView_Image.Image = _lastImage; _screenView_CameraName.Text = _cameras[_activeCamera]; Screen.Content = _screenView; break; case AppState.Error: Screen.Content = _screenInfo; break; } await Wait(); } }
public IntermecBarcodescanControl3() { InitializeComponent(); try { addLog("IntermecBarcodescanControl2: setHWTrigger(true)..."); //enable HW trigger, a workaround as HW trigger is sometimes disabled on BarcodeReader.Dispose() //if (!S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true)) //{ // addLog("IntermecBarcodescanControl2: setHWTrigger(true)...FAILED. Trying again"); // Thread.Sleep(50); // S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); //try again //} //replaced above code with the following, there were problems with load/unload the ADCComInterface inside S9CConfig YetAnotherHelperClass.setHWTrigger(true); //change number of good read beeps to zero YetAnotherHelperClass.setNumberOfGoodReadBeeps(0); addLog("IntermecBarcodescanControl2: mapKey()..."); //we need full control of scan start and end ITCTools.KeyBoard.mapKey(); } catch (Exception ex) { addLog("Exception in IntermecBarcodescanControl2: setHWTrigger(true)..." + ex.Message); } try { addLog("IntermecBarcodescanControl2: new BarcodeReader()..."); bcr = new BarcodeReader(this, "default");// (); addLog("IntermecBarcodescanControl2: BarcodeReader adding event handlers..."); bcr.BarcodeRead += new BarcodeReadEventHandler(bcr_BarcodeRead); bcr.BarcodeReadCanceled += new BarcodeReadCancelEventHandler(bcr_BarcodeReadCanceled); bcr.BarcodeReadError += new BarcodeReadErrorEventHandler(bcr_BarcodeReadError); addLog("IntermecBarcodescanControl2: starting named event watch thread..."); waitThread = new System.Threading.Thread(waitLoop); waitThread.Start(); addLog("IntermecBarcodescanControl2: enabling Scanner..."); bcr.ScannerEnable = true; addLog("IntermecBarcodescanControl2: ScannerOn=false..."); bcr.ScannerOn = false; } catch (BarcodeReaderException ex) { bcr = null; System.Diagnostics.Debug.WriteLine("BarcodeReaderException in IntermecScanControl(): " + ex.Message); } catch (Exception ex) { bcr = null; System.Diagnostics.Debug.WriteLine("Exception in IntermecScanControl(): " + ex.Message); } if (bcr == null) { addLog("IntermecBarcodescanControl2: BarcodeReader init FAILED"); throw new System.IO.FileNotFoundException("Intermec.Datacollection.dll or ITCScan.DLL missing"); } #if TESTMODE //testcodes = new string[8]; testCodeCount = testcodes.Length; testCodePos = 0; #endif }
public string Read1DPro_File_WithEvents(string fileName) { BarcodeReader reader = new BarcodeReader(); // configure directions reader.Horizontal = true; reader.Vertical = false; reader.Diagonal = false; //configure types reader.Auto1D = true; // Configure events reader.BarcodeFoundEvent += new BarcodeReader.BarcodeFoundEventHandler (_OnBarcodeFound); // Read reader.Read (fileName); if ((txtRslt.Text == "")) { txtRslt.Text = "NO BARCODES"; } return txtRslt.Text; }
public void test_Random_Encoding_Decoding_Cycles_Up_To_1000() { int bigEnough = 256; byte[] data = new byte[256]; Random random = new Random(2344); for (int i = 0; i < 1000; i++) { random.NextBytes(data); //string content = "U/QcYPdz4MTR2nD2+vv88mZVnLA9/h+EGrEu3mwRIP65DlM6vLwlAwv/Ztd5LkHsio3UEJ29C1XUl0ZGRAFYv7pxPeyowjWqL5ilPZhICutvQlTePBBg+wP+ZiR2378Jp6YcB/FVRMdXKuAEGM29i41a1gKseYKpEEHpqlwRNE/Zm5bxKwL5Gv2NhxIvXOM1QNqWGwm9XC0jcvawbJprRfaRK3w3y2CKYbwEH/FwerRds2mBehhFHD5ozbgLSa1iIkIbnjBn/XV6DLpNuD08s/hCUrgx6crdSw89z/2nfxcOov2vVNuE9rbzB25e+GQBLBq/yfb1MTh3PlMhKS530w=="; string content = Convert.ToBase64String(data); BarcodeWriter writer = new BarcodeWriter { Format = BarcodeFormat.QR_CODE, Options = new EncodingOptions { Height = bigEnough, Width = bigEnough } }; Bitmap bmp = writer.Write(content); var reader = new BarcodeReader { Options = new DecodingOptions { PureBarcode = true, PossibleFormats = new List<BarcodeFormat> {BarcodeFormat.QR_CODE} } }; var decodedResult = reader.Decode(bmp); Assert.IsNotNull(decodedResult); Assert.AreEqual(content, decodedResult.Text); } }
private void Read1DPro_OnThread() { BarcodeReader reader = new BarcodeReader(); #if false // configure directions reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.Auto1D = true; #else // configure directions reader.Horizontal = true; //configure types reader.Code39 = true; #endif // Configure events reader.BarcodeFoundEvent += new BarcodeReader.BarcodeFoundEventHandler(_OnBarcodeFoundThread); // Read while (true) { string fileName; // Obtain next file name lock (_lockObject) { if (filesScanned >= filesToScan.Length) break; fileName = filesToScan[filesScanned]; filesScanned++; } // Read images from file try { #if false reader.Read(fileName); // Read all pages #else reader.Read(fileName, 1); // Read only page 1 #endif } catch (Exception ex) { string s = txtRslt.Text + ">>>>>>>> ERROR processing '" + fileName + "'" + Environment.NewLine + ex.Message + Environment.NewLine; lock (_lockObject) {SetControlPropertyThreadSafe (txtRslt, "Text", s); System.Windows.Forms.Application.DoEvents(); } } } }