tjwoon / csZBar

Cordova plugin to integrate with the ZBar barcode scanning library.
Other
143 stars 181 forks source link

Only scan specific barcode types #46

Open ghost opened 8 years ago

ghost commented 8 years ago

To do so, add the following to the scan method in CsZbar.m:

        ZBarImageScanner *scanner = self.scanReader.scanner;

        [scanner setSymbology:0 config:ZBAR_CFG_ENABLE to:0];

        [scanner setSymbology: ZBAR_QRCODE
                       config: ZBAR_CFG_ENABLE
                           to: 1];

(under self.scanReader = [AlmaZBarReaderViewController new];)

Now only QR codes area able to be scanned..

(PS:Sorry for not using pull requests.. hope you can still integrate these features) (with some more configuration of course).

Codes:

ZBAR_NONE = 0, /**< no symbol decoded */ ZBAR_PARTIAL = 1, /**< intermediate status */ ZBAR_EAN2 = 2, /**< GS1 2-digit add-on */ ZBAR_EAN5 = 5, /**< GS1 5-digit add-on */ ZBAR_EAN8 = 8, /**< EAN-8 */ ZBAR_UPCE = 9, /**< UPC-E */ ZBAR_ISBN10 = 10, /**< ISBN-10 (from EAN-13). @since 0.4 */ ZBAR_UPCA = 12, /**< UPC-A */ ZBAR_EAN13 = 13, /**< EAN-13 */ ZBAR_ISBN13 = 14, /**< ISBN-13 (from EAN-13). @since 0.4 */ ZBAR_COMPOSITE = 15, /**< EAN/UPC composite */ ZBAR_I25 = 25, /**< Interleaved 2 of 5. @since 0.4 */ ZBAR_DATABAR = 34, /**< GS1 DataBar (RSS). @since 0.11 */ ZBAR_DATABAR_EXP = 35, /**< GS1 DataBar Expanded. @since 0.11 */ ZBAR_CODE39 = 39, /**< Code 39. @since 0.4 */ ZBAR_PDF417 = 57, /**< PDF417. @since 0.6 */ ZBAR_QRCODE = 64, /**< QR Code. @since 0.10 */ ZBAR_CODE93 = 93, /**< Code 93. @since 0.11 */ ZBAR_CODE128 = 128, /**< Code 128 */

dannygunawan commented 8 years ago

it would be great if we could set the barcode types as a parameter.

{
    text_title: "OPTIONAL Title Text - default = 'Scan QR Code'", // Android only
    text_instructions: "OPTIONAL Instruction Text - default = 'Please point your camera at the QR code.'", // Android only
    camera: "front" || "back" // defaults to "back"
    flash: "on" || "off" || "auto" // defaults to "auto". See Quirks
    drawSight: true || false, //defaults to true, create a red sight/line in the center of the scanner view.
    barcodeTypes: ["EAN8","EAN13","UPC-E"]
}

Thank you

dcousens commented 8 years ago

@wesleywesley is this just an attempt at an optimization?

ghost commented 8 years ago

Not an attempt at optimization, if one is to scan a document that contains both a barcode and a QR code, i only want the QR code read. Right now user has to make sure not to scan the barcode. With above code, (probably should be done via parameters), we have control of what to allow to scan.

dcousens commented 8 years ago

Good point! Could you make a PR for this with your existing solution? I'll clean it up if needed, would just save a lot of the initial footwork.