ios - ZXingObjc - Cannot read Code128 when the barcode area is short -
i'm using zxingobjc
read barcode images in swift
app. works fine in situations. when height of code128 short, "a barcode not found in image".
i try add kbarcodeformatcode128
possibleformat
of zxdecodehints
no luck.
is limits of zxingobjc
, or did miss else? appreciated.
here code:
import foundation import zxingobjc let zxingreader = zxingreader.shared class zxingreader { static let shared = zxingreader() lazy var decodehints: zxdecodehints = { let hints = zxdecodehints() return hints }() func readcodefromimage(image: uiimage) throws -> zxresult { let source = zxcgimageluminancesource(cgimage: image.cgimage!) let binazer = zxhybridbinarizer(source: source) let bitmap = zxbinarybitmap(binarizer: binazer) let reader = zxmultiformatreader() { let result = try reader.decode(bitmap, hints: decodehints) return result } catch let error nserror { throw error } } func readcodefromimage(image: uiimage, completion: (zxresult) -> void, failure: ((nserror) -> void)?) { { let result = try readcodefromimage(image) completion(result) } catch let error nserror { guard let failure = failure else { return } failure(error) } } }
here images use: zxingobjc
works fine on left image, return nil on right image.
Comments
Post a Comment