internal string readQR(string fileName, int page) { BarcodeReader reader = null; try { reader = new BarcodeReader(); if (tbrCode != 0) reader.TbrCode = tbrCode;// ClearImage V9 and later. Otherwise use: reader.Read(tbrCode.ToString(), 456780); // for faster reading specify only required direction reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.QR = true; Barcode[] barcodes = reader.Read(fileName, page); mBarcodes = sortBarcode(barcodes); string s = ""; int cnt = 0; foreach (Barcode bc in mBarcodes) { cnt++; AddBarcode(ref s, cnt, bc); } if (cnt == 0) { s = "NO BARCODES"; } return s; } catch (Exception ex) { return ex.Message; } finally { if (reader != null) reader.Dispose(); // ClearImage V9 and later. Immediately free memory } }
internal string readWithEvents(string fileName) { BarcodeReader reader = null; try { reader = new BarcodeReader(); if (tbrCode != 0) reader.TbrCode = tbrCode;// ClearImage V9 and later. Otherwise use: reader.Read(tbrCode.ToString(), 456780); // for faster reading specify only required direction reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.Code128 = true; reader.Code39 = true; // Configure events reader.BarcodeFoundEvent += new BarcodeReader.BarcodeFoundEventHandler(_OnBarcodeFound); // Read reader.Read(fileName); if ((txtRslt.Text == "")) { txtRslt.Text = "NO BARCODES"; } return ""; // txtRslt.Text is already updated; } catch (Exception ex) { return ex.Message; } finally { if (reader != null) reader.Dispose(); // ClearImage V9 and later. Immediately free memory } }
internal string readFromStream(string fileName) { BarcodeReader reader = null; try { reader = new BarcodeReader(); if (tbrCode != 0) reader.TbrCode = tbrCode;// ClearImage V9 and later. Otherwise use: reader.Read(tbrCode.ToString(), 456780); // for faster reading specify only required direction reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.Code128 = true; reader.Code39 = true; string s = ""; using (MemoryStream ms = Utility.FileToStream(fileName)) { Barcode[] barcodes = reader.Read(ms); 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; } catch (Exception ex) { return ex.Message; } finally { if (reader != null) reader.Dispose(); // ClearImage V9 and later. Immediately free memory } }
private void readFileOnThread() { BarcodeReader reader = null; try { reader = new BarcodeReader(); if (tbrCode != 0) reader.TbrCode = tbrCode;// ClearImage V9 and later. Otherwise use: reader.Read(tbrCode.ToString(), 456780); // configure directions reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.Code128 = true; reader.Code39 = true; // 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(); } } } } catch (Exception ex) { string s = txtRslt.Text + ">>>>>>>> ERROR processing '" + Environment.NewLine + ex.Message + Environment.NewLine; lock (_lockObject) { SetControlPropertyThreadSafe(txtRslt, "Text", s); System.Windows.Forms.Application.DoEvents(); } } finally { if (reader != null) reader.Dispose(); // ClearImage V9 and later. Immediately free memory } }
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!! }
public override void Cleanup() { Messenger.Default.Unregister <SettingsSavedMessage>(this); Messenger.Default.Unregister <BusyMessage>(this); Messenger.Default.Unregister <ScaleWeightReportMessage>(this); Messenger.Default.Unregister <KeyDownMessage>(this); Messenger.Default.Unregister <List <TagItem> >(this); Messenger.Default.Unregister <BarcodeScannedMessage>(this); timer.Enabled = false; TagDataProvider.Disconnect(); if (_scaleReader != null) { _scaleReader.Dispose(); } if (_barCodeReader != null) { _barCodeReader.Dispose(); } base.Cleanup(); }
public void Dispose() { if (_reader != null) { try { _reader.ScannerEnable = false; } catch { } _reader.Dispose(); _reader = null; } }
private void mnuExit_Click(object sender, EventArgs e) { try { m_Symbologies.EnableAll(); m_BCreader.ScannerEnable = true; m_BCreader.Dispose(); m_Reader.Close(); HighBeep.Dispose(); LowBeep.Dispose(); this.Dispose(); } catch { } Application.Exit(); }
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 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.BarcodeRead -= bcr_BarcodeRead; bcr.BarcodeReadCanceled -= bcr_BarcodeReadCanceled; bcr.BarcodeReadError -= bcr_BarcodeReadError; try { bcr.NoBarcodeRead -= bcr_NoBarcodeRead; bcr.EnableNoBarcodeReadEvent = false; } catch (Exception) { addLog("Unable to unset bcr.EnableNoBarcodeReadEvent. Old DLL?"); } bcr.ThreadedRead(false); 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> /// Closes the selected scanner device. /// </summary> async void CloseBarcodeScanner() { myLog.doLog("CloseBarcodeScanner..."); if (mBarcodeReader != null && mBarcodeReader.IsReaderOpened) { //settings.Clear(); BarcodeReader.Result result = await mBarcodeReader.CloseAsync(); if (result.Code == BarcodeReader.Result.Codes.SUCCESS) { mBarcodeReader.BarcodeDataReady -= MBarcodeReader_BarcodeDataReady; mBarcodeReader.Dispose(); mBarcodeReader = null; } else { myLog.doLog("Error", "CloseAsync failed, Code:" + result.Code + " Message:" + result.Message); } } }
internal string readWithZones(string fileName, int page) { BarcodeReader reader = null; try { reader = new BarcodeReader(); if (tbrCode != 0) reader.TbrCode = tbrCode;// ClearImage V9 and later. Otherwise use: reader.Read(tbrCode.ToString(), 456780); // for faster reading specify only required direction reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.Code128 = true; reader.Code39 = true; ImageIO io = new ImageIO(); ImageInfo info = io.Info(fileName, page); string s = "======= Barcode in ZONE (upper half of the image) ===========" + Environment.NewLine; // Set zone to top half of the image reader.Zone = new Rectangle(0, 0, info.Width, info.Height / 2); Barcode[] barcodes = reader.Read(fileName, page); 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; s = s + "======= Barcode in IMAGE ===========" + Environment.NewLine; // Disable zone reader.Zone = new Rectangle(); barcodes = reader.Read(fileName, page); cnt = 0; foreach (Barcode bc in barcodes) { cnt++; AddBarcode(ref s, cnt, bc); } if (cnt == 0) { s = s + "NO BARCODES"; } return s; } catch (Exception ex) { return ex.Message; } finally { if (reader != null) reader.Dispose(); // ClearImage V9 and later. Immediately free memory } }
void ReadBarcodes1D(string fileName, int page) { BarcodeReader reader = null; try { reader = new BarcodeReader(); // Create and configure reader reader.Code39 = true; reader.Code128 = true; Barcode[] barcodes = reader.Read(fileName, page); // Read barcodes foreach (Barcode barcode in barcodes) // Process results { Console.WriteLine("Barcode type: " + barcode.Type.ToString() + " Text: " + Environment.NewLine + barcode.Text); } } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } finally { if (reader != null) { reader.Dispose(); } } // ClearImage 9 and latter. Free image memory. }
internal string readDriverLicense(string fileName, int page) { BarcodeReader reader = null; try { reader = new BarcodeReader(); if (tbrCode != 0) reader.TbrCode = tbrCode;// ClearImage V9 and later. Otherwise use: reader.Read(tbrCode.ToString(), 456780); // for faster reading specify only required direction reader.Horizontal = true; reader.Vertical = true; reader.Diagonal = true; //configure types reader.DrvLicID = true; Barcode[] barcodes = reader.Read(fileName, page); string s = ""; int cnt = 0; foreach (Barcode bc in barcodes) { cnt++; if (bc.Type == BarcodeType.Pdf417) { // Decode and display AAMVA data as XML string aamva = bc.Decode(BarcodeDecoding.aamva); if (aamva != "") s = s + "Driver License / ID Data: " + Environment.NewLine + aamva + Environment.NewLine; } AddBarcode(ref s, cnt, bc); } if (cnt == 0) { s = "NO BARCODES"; } return s; } catch (Exception ex) { return ex.Message; } finally { if (reader != null) reader.Dispose(); // ClearImage V9 and later. Immediately free memory } }
public ProcessedDataEntry ProcessSheet(ConfigurationBase configuration, Mat sheet, Action <RectangleF, bool> OnOptionProcessed = null, string originalSheetPath = "") { OBRConfiguration obrConfiguration = (OBRConfiguration)configuration; RectangleF barcodeRegion = obrConfiguration.GetConfigArea.ConfigRect; // Configure reader //CiServer ciServer = Server.GetThreadServer(); //CiBarcodePro barcodeReader = ciServer.CreateBarcodePro(); barcodeReader.Auto1D = obrConfiguration.AutoDetect1DBarcode; // Enable automatic detection of barcode type (Slower processing) if (!obrConfiguration.AutoDetect1DBarcode) { // Select barcode types to read barcodeReader.Code128 = obrConfiguration.Code128; barcodeReader.Code93 = obrConfiguration.Code93; barcodeReader.Code39 = obrConfiguration.Code39; } if (obrConfiguration.CheckAll) // Limit barcode search direction (Faster processing) { barcodeReader.Horizontal = true; barcodeReader.Vertical = true; barcodeReader.Diagonal = true; } else { barcodeReader.Horizontal = obrConfiguration.CheckHorizontal; barcodeReader.Vertical = obrConfiguration.CheckVertical; barcodeReader.Diagonal = obrConfiguration.CheckDiagonal; } //barcodeReader.Algorithm = obrConfiguration.AlgorithmPreference; string output = "-"; Barcode[] barcodes = null; using (Bitmap region = sheet.Bitmap.Clone(barcodeRegion, System.Drawing.Imaging.PixelFormat.Format8bppIndexed)) { try { barcodes = barcodeReader.Read(region); // Read barcodes } catch (Exception ex) { Console.WriteLine("Exception: " + ex.ToString()); } finally { if (barcodeReader != null) { barcodeReader.Dispose(); } } //Free image memory. if (barcodes.Length == 0 && obrConfiguration.SearchFullIfNull) { using (Mat orignalSheet = CvInvoke.Imread(originalSheetPath)) { barcodes = barcodeReader.Read(orignalSheet.Bitmap); // Read barcodes } } output = barcodes.Length > 0 ? barcodes[0].Text : "-"; } return(new ProcessedDataEntry(configuration.Title, output.ToCharArray(), new ProcessedDataType[] { ProcessedDataType.NORMAL }, new byte[0, 0], barcodes)); }