all you need to know to barcodes in your apps › files › mobiconf-barcodes.pdf · qr pdf417 2d...

48
All you need to know to leverage barcodes in your apps

Upload: others

Post on 03-Jul-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

All you need to know to leverage barcodes

in your apps

Page 2: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Oliver Drobnik iOS Development & Consulting

@cocoaneticscocoanetics.com

Full-time iOS developer and blogger since January 2010

Page 3: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

44% off all books at manning.com through Dec 3rd with promo code mobicftw

Tweet about my talk with #barcodes_iOS for chance to win one free copy

Page 4: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Barcode Basics

Page 5: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

40th AnniversaryWhat do these have in common?

July 24, 1974 June 26, 1974?Oliver

UPC

Page 6: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Advantages of Barcodes

• “tried and true” technology

• inexpensive to add to packaging

• reliable (check digits, redundancy)

• passive: no privacy “leakage”

• scanning technology widely available

Page 7: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

UPC

EAN

JAN

1973

1977

1978

2009

Page 8: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Trade

TGlobal

GItem

INumber

N

Page 9: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

GTIN• Standard maintained by GS1 International

• GTIN is the number/symbol

• UPC = GTIN-12

• EAN, JAN = GTIN-13

• GTIN-12 plus leading zero = GTIN-13

• GTIN-8 needs special permission

Page 10: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

GS1 International• Big renaming of organizations in 2005:

• Universal Product Code Council became GS1 US

• European EAN Association became GS1 International

• 4 years later UPC, EAN and JAN were unified to GTIN

• Most countries have national GS1 office with 3-digit prefix

• Manufacturer code assigned by national office

• Product number chosen by manufacturer

Page 11: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric
Page 12: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Universal Product Code as GTIN-12 (aka UPC-A)

Page 13: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Model Name as Code39

Page 14: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Top Assembly (?) Number as Code39

Page 15: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Serial Number as Code39

Page 16: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric
Page 17: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Universal Product Code as GTIN-12

Page 18: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Part Number as Code128

Page 19: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Serial Number as Code128

Page 20: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

1D Barcodes• Bars and Spaces

• Longer lines: Marker bars

• Can be scanned with laser that touches all lines

• CCD simulates the scan line

• Numeric or alpha-numeric

• Caption: human-readable text

Page 21: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

2D Barcodes

• No bars, but 2D squares

• Smallest element: Module

• Cannot be read with laser

• Requires CCD camera

• Arbitrary data

Page 22: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

Page 23: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

1973

Page 24: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

1974

Page 25: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

1981

Page 26: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

1982

Page 27: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

1991

Page 28: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

1994

Page 29: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Aztec

QR

PDF417

2D

Shortened

1D

EAN-13EAN-8

UPC-AUPC-E

Standard

GTIN Family

Numbers Alpha-Numeric Arbitrary Data

Stacked Lines SquaresCode 39

Code 39 mod 43

Code 93

Code 93 (Full ASCII)

Code 39 (Full ASCII)

Code 39 mod 43 (Full ASCII)

Code 128

Barcodes supported by iOS

1995

Page 30: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Barcode Scanning

Page 31: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

AV Foundation

AV Foundation

Core Audio Core AnimationCore Media

Obj-C

C

Page 32: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

AVCaptureDevice

Camera!

AVCaptureDeviceInput ports AVCaptureInputPortVideo

AVCaptureInputPortMeta

initWithDevice:

AVCaptureSession

inputs

outputs

addInput:

I'm the manager!

AVCaptureStillImageOutput

connections

AVCaptureConnection

inputPorts

output

addOutput:

AVCaptureConnection

inputPorts

AVCaptureVideoPreviewLayer

session connection

Preview

Book Chapter 2 Sample App: Camera

Page 33: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Camera Authorization• since iOS 7, but only for device sold in China

• since iOS 8 for all devices

• not determined - request authorization authorized - all is finedenied - user’s choicerestricted - higher power’s choice

• deal gracefully with loss of functionality

Page 34: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

AVCaptureDevice

Camera!

AVCaptureDeviceInput ports AVCaptureInputPortVideo

AVCaptureInputPortMeta

initWithDevice:

AVCaptureSession

inputs

outputs

addInput:

I'm the manager!

AVCaptureStillImageOutput

connections

AVCaptureConnection

inputPorts

output

addOutput:

AVCaptureConnection

inputPorts

AVCaptureVideoPreviewLayer

session connection

Preview

Book Chapter 2 Sample App: Camera

Page 35: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

AVCaptureDevice

Camera!

AVCaptureDeviceInput ports AVCaptureInputPortVideo

AVCaptureInputPortMeta

initWithDevice:

AVCaptureSession

inputs

outputs

addInput:

I'm the manager!

AVCaptureConnection

inputPorts

AVCaptureVideoPreviewLayer

session connection

Preview

AVCaptureMetadataOutput

connections

AVCaptureConnection

inputPorts

output

addOutput:

Your delegate

Gets informed about all detected metadata objects

metadataObjectsDelegate

Book Chapter 3 Sample App: QRScanner

Page 36: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Metadata Objects

2D Barcode 1D BarcodeFace

Page 37: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Scanning Takeaways• Delegate called separately for faces and barcodes

• Use background queue if doing CPU-intense work

• 1D codes use multiple scan lines, max. 1 recognized

• 2D codes can be detected anywhere in video frames, up to 4 recognized (except for PDF417)

• Performance better scanning for fewer types

• Optimize the UI for 1D or 2D: “Rect of Interest”

Page 38: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Barcode Generation

Page 39: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Why would you…?• Nice version of an item’s GTIN (instead of photo)

• Data transfer: show dynamic 2D code for other phone to scan it (like Passbook)

• AirPrint QR Codes to A4 sticker sheet

• AirPrint single serial number sticker(e.g. for a hardware inventory tracking app)

• Extend the scannable universe

Page 40: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

2D Barcode Generation• Generate with Core Image

• Only CIQRCodeGenerator documented

• creates CIImage, need to render into CGImage and scale afterwards

• Aztec or PDF417 “private API”

Book Chapter 5 Sample App: QRBuilder

Page 41: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

1D Barcode Generation• BarCodeKit creates:

• Codabar

• Code 11

• Code 39 (plain, modulo 43, full ASCII)

• Code 93

• Code 128

• Facing Identification Mark (FIM)

• GTIN family: EAN-8, EAN-13, UPC-A, UPC-E, EAN-2, EAN-5

• Interleaved 2 of 5

• MSI

• Pharmacode One Track

• Standard 2 of 5

Book Chapter 5 Sample App: SerialSticker

• No public APIs in iOS

• Generate with BarCodeKit

• Free for owners of my book

• Draws to bitmap or PDF context

Page 42: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Label Printers• Inexpensive, ideal for single stickers

• Roll-fed: Endless or Die-Cut

• Endless: calculate cut-off length

• Beware of thermal bleeding

• Paper sensors report size via AirPrint

• Label printers are endless fun!

Page 43: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

Product Information

Page 44: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

GTIN is just a number…• Devices have mobile internet

• Query web services, e.g. Discogs

• No normalization of GTINs

• No reliable source of product info

• GS1 only has manufacturer info

• amazon.com - guess again…

Book Chapter 6 Sample App: MusicCollection

Page 45: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

"§4: (e) You will not, without our express prior written approval, use any Product Advertising Content on or in connection with any site or application designed or intended for use with a mobile phone or other handheld device, or any television set-top box or Internet-enabled television"

Amazon.com Product Advertising API

License Agreement

Page 46: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

productlayer

Page 47: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

• Free JSON+RESTful web service

• iOS SDK on GitHub (Open Source)

• 1.7 Mio products so far

• Standard categories from GS1 + additional sub-categories

• Build any app you like with it, we’ll help you promote it

• Your app users contribute back via SDK (missing details, photos, etc.)

• User’s lists of products accessible via API

• Go to developer.productlayer.com to sign up for free account

productlayer

Page 48: All you need to know to barcodes in your apps › files › Mobiconf-Barcodes.pdf · QR PDF417 2D Shortened 1D EAN-8 EAN-13 UPC-E UPC-A Standard GTIN Family Numbers Alpha-Numeric

@cocoanetics @productlayer

Thanks for watching!