8

Data Matrix barcode support was added to iOS 8 and I'm able to use it to read Data Matrix barcodes if they are black on white (dark on light). However, it never reads a white on black (light on dark) barcode.

Reads this fine:

enter image description here

Unable to read this:

enter image description here

Per Data Matrix ECC 200, light on dark should be supported.

Anyone have an idea how to get iOS 8 to read a light on dark Data Matrix barcode?

bobnoble
  • 5,794
  • 3
  • 25
  • 32
  • May I know which API you use? – gabbler Dec 20 '14 at 14:41
  • @gabbler I'm using the native iOS barcode capability (`AVCaptureMetadataOutput`) and associated delegate (`AVCaptureMetadatOutputObjectsDelegate`). – bobnoble Dec 20 '14 at 14:58
  • Did you use your camera to scan the picture, or just pass in the picture for decoding? – gabbler Dec 20 '14 at 15:02
  • I'm using the camera - iOS does not (currently) support passing in a picture for decoding. – bobnoble Dec 20 '14 at 15:03
  • I see the same result, don't know the reason though. – gabbler Dec 20 '14 at 15:08
  • Do you expect decoded result of the second image to be the same as the first image? If so, you can invert the image colour of the second image, the resulting image looks like the first image. – gabbler Dec 21 '14 at 04:00
  • There are other commercial barcode APIs that can help you decoding inverted barcodes (if this is an option at all). – ssasa Dec 22 '14 at 15:21
  • 1
    @ssasa I am really hoping to use the native iOS capability. Seems silly to have to resort to another library when (almost) everything I need is part if iOS. – bobnoble Dec 22 '14 at 22:26
  • @bobnoble Did you find anything i mean solution? please share! – Buntylm Apr 14 '16 at 18:15
  • @BuntyMadan Unfortunately, no, have never found a solution to this. Currently looking at a couple of commercial libraries - Scandit and Manatee. In our testing for barcode types Code 29, Code 128, QR code and DataMatrix, Scandit performs slightly better than Manatee. – bobnoble Apr 15 '16 at 11:48
  • @bobnoble ok, thanks a lot for your response. – Buntylm Apr 15 '16 at 12:19
  • @bobnoble tried with https://manateeworks.com iOS SDK and working fine for me. – Buntylm Apr 19 '16 at 06:25

1 Answers1

0

You can invert the colors of your AVCaptureSession in real time, allowing you to read the Data Matrix code.

You can use GPUImage to invert the colors. It's fast and plugs in easily. Just invert and let AVFoundation find it as normal.

Ryan Kreager
  • 3,571
  • 1
  • 20
  • 35
  • `AVCaptureVideoPreviewLayer` is for presenting the video as it is captured. Applying an invert filter would only invert what the user sees, not to the input of the `AVCaptureSession`, so don't see how that would help. Are you thinking of something else? – bobnoble Dec 20 '14 at 17:22
  • #facepalm - Yes, I'm thinking of something else :) What system are you using to capture the QR image? Before I edit my answer, are you processing a static image or using a live preview to capture the QR code? – Ryan Kreager Dec 20 '14 at 17:32
  • It's Data Matrix (not QR Code). I'm using the native iOS barcode scanning and using live video. – bobnoble Dec 20 '14 at 17:42
  • Fixed my answer - see above :) – Ryan Kreager Dec 20 '14 at 18:01
  • 1
    I don't think the output from GPUImage can be an input to an `AVCaptureSession` which is required to use the iOS barcode scanning on it. – bobnoble Dec 20 '14 at 18:30
  • 1
    Did anyone get this to work? I'm looking for a solution as well. ZXing on iOS doesn't seem to work either. – Uniphonic Feb 23 '17 at 17:11
  • 2
    @Uniphonic The answer is to get the frames from the capture session, use CIFilter's to invert the image and use the new Vision framework on iOS11+ to detect barcodes from the inverted image. – Kaan Dedeoglu Nov 29 '17 at 10:29