public override DecoderItem Decode(byte[] input, VisualDecoderSettings settings) { var image = ByteArrayToImage(input); var barcodeReader = new BarcodeReader { AutoRotate = true, PossibleFormats = list, PureBarcode = false, TryHarder = true }; var result = barcodeReader.Decode(image); // decode barcode if (result != null) { image = DrawRectangleZXing(image, result); return(new DecoderItem { BitmapWithMarkedCode = ImageToByteArray(image), CodePayload = result.Text, CodeType = result.BarcodeFormat.ToString() }); } return(null); }
public override DecoderItem Decode(byte[] input, VisualDecoderSettings settings) { var result = new DecoderItem(); var language = settings.OCRLanguage.ToString(); //use eng if the user dont know the language if (language.Equals(VisualDecoderSettings.OCRLanguages.unkown.ToString())) { language = VisualDecoderSettings.OCRLanguages.eng.ToString(); } using (var ocr = new tessnet2.Tesseract()){ try { ocr.Init(TessractData, language, settings.NumericMode); List <tessnet2.Word> r1 = ocr.DoOCR(ByteArrayToImage(input), Rectangle.Empty); //aggregate resultTest string resultText = ""; int lc = tessnet2.Tesseract.LineCount(r1); for (int i = 0; i < lc; i++) { resultText += tessnet2.Tesseract.GetLineText(r1, i) + "\n"; } //fill result result.CodePayload = resultText; result.CodeType = "none"; result.BitmapWithMarkedCode = input; ocr.Clear(); } catch (Exception) // well, the ocr lib sucks... it sometimes trows memory leaks. // But it is the best opensource lib available. { } } return(result); }
public virtual DecoderItem Decode(byte[] input, VisualDecoderSettings settings) { throw new NotImplementedException(); }