Barcode Scanning / iOS

[quote=154896:@Jason King]Here is an implementation using CoreImage. From what I was reading, it will only function on a physical device and my tests indicate the same since a CIDetector cannot be created in the simulator. If someone can test it and let me know if it works since I don’t yet have an iOS license that would be great.
https://www.dropbox.com/s/nnpb8gphiq2c7bk/QRReader.zip?dl=0

Edit: Link was wrong.[/quote]

It seems to work and says “Hello world”.

I simply had to modify the button Action to

Label1.Text = QRReader.Read(qr_code_without_logo)

Yeah that and the image not being found by the project was the problem with the original link.

Thanks for testing! That’s exactly what was supposed to be displayed by that code.

So now using the Camera class I posted above and the QRReader module you should be able read a QR code using the iPhone/iPad camera. Enjoy!

Great Christmas gift from Jason. :slight_smile:
Thank you again for helping us here !

Strange the iOSEmulator cannot use the camera from a MBP. :slight_smile: That would make debugging much easier. :slight_smile:

Yeah I agree, I expected it to use the iSight camera but it doesn’t. Maybe an oversight by Apple, or maybe there is something which prevents it from working. We will probably never know.

I just combined the camera project and QR Reader from Jason King into one project I called QRCamera. It allows to take a picture of a QR code, then read the content of it.

That is the base for what the OP was asking :slight_smile:

QRCamera.xojo_binary_project

:slight_smile: Thanks Michel and Jason

Hi, The QRCode Reader works great, but I see from docs you can only use TypeQRCode or TypeRectangle. Would reading Code3of9 be completely different or even possible?

Thanks

Yes, reading Code 3of9 would be completely different and is currently not possible with declares. It would require the use of several AVFoundation classes which cannot be used in Xojo because Xojo uses a cooperative threading model and the callbacks from AVFoundation are invoked on unmanaged threads which leads to exceptions in Xojo. You would have to implement reading Code3of9 in code yourself :frowning: Maybe using TypeRectangle will allow you to identify the barcode and you could then extract the image to process?

Thanks very much Jason. Question answered :slight_smile:

3of9 is not terribly complex : http://www.barcodeisland.com/code39.phtml

If you use the camera to get the picture of the barcode, then you can analyse it by fetching the black or white pixels from left to right. The start character will provide the synchronization data (the width or an elementary bar in pixels), then you can analyze the whole picture.

I would suggest starting with an impeccable representation such as what you can find at images.google.com, and when your deciphering code is done, test with camera pictures. Since the camera pictures can be blurry or lack contrast, you will probably need to check the coherence of the extracted data.

I have never done it that way, but I designed bar code fonts, and code 39 is one of the simplest ones.

Thanks very much Michel. I was doing some investigation on it after Jason’s reply - I knew it must be manageable since it’s possible to print 3 of 9 from a font. Your suggestions and links will help a lot.

Cheers

Chris

Stupid spammer…

@Chris O’Brien the new version of iOSKit (v1.2) has the classes necessary for reading Code 3 of 9 codes. There is a demo view which shows you how to use them. The values of metadataObjectTypes which can be used are all strings and you just have to specify the proper key(s) to read the barcodes:

"org.gs1.UPC-E", "org.iso.Code39", "org.iso.Code39Mod43", "org.gs1.EAN-13", "org.gs1.EAN-8", "com.intermec.Code93", "org.iso.Code128", "org.iso.PDF417", "org.iso.QRCode", "org.iso.Aztec"
If you have any questions please ask.

FWIW, we used Jason’s AVFoundation barcode scanning classes for scanning Passbook passes at XDC this year and they performed outstandingly.

[quote=152282:@Jason King]
Demo project:
https://www.dropbox.com/s/ib3xswbydnjrm5c/Camera.xojo_binary_project?dl=0[/quote]

Thanks for sharing.
I was trying to modify your code to make the final code more like a single class you can drop in a view, to make it accessible from within whatever view it was dragged in.

The PresentInView method wants to have the view set passed though. Something I can’t really figure out yet.
Any ideas?

Hi Edwin, that class has been updated in iOSKit. Please download the latest version there which also includes an example view of how to pass the view to the camera object.

https://github.com/kingj5/iOSKit

Jason

Thanks Jason! I am trying to figure out how to drag the components in my project. I guess just slapping everything in a folder will be a neat solution?
By the way: Is there a change that CoreLocation will be added? (to use GPS etc)