omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Barcode / QR Code Camera Scanner Demo (objc_util)

    Pythonista
    7
    11
    17198
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • omz
      omz last edited by

      Someone asked me on Twitter if Pythonista had support for scanning barcodes, using the camera. While there's nothing like that built-in, I looked around a bit, and it turns out that there are APIs for this in Apple's AVFoundation framework, so I thought it might be interesting to build a wrapper around that.

      This demo shows a live camera preview, and it plays a sound when a barcode or QR code is found in the viewfinder. The scanned code (a number for EAN codes, URLs or text for QR codes...) is shown in an overlay label. When the view is closed, a list of all (unique) codes that were scanned is printed to the console.

      Here's the code: Barcode Scanner.py (Gist)

      And a screenshot:

      1 Reply Last reply Reply Quote 7
      • dgelessus
        dgelessus last edited by

        Is it also possible to read a barcode from an image file instead of the camera? (For when the QR code is so small that getting the camera to focus is almost impossible.) There are lots of apps that can scan barcodes normally, but I don't know of any that can scan existing image files.

        1 Reply Last reply Reply Quote 1
        • omz
          omz last edited by

          @dgelessus That should be possible. You'd probably use CoreImage instead of AVFoundation though – the approach would be very similar to the "Camera Scanner" demo in the bundled ObjC examples, which is using CIDetector with CIDetectorTypeRectangle. There's also CIDetectorTypeQRCode, which sounds like exactly what you're looking for.

          1 Reply Last reply Reply Quote 0
          • vcr80
            vcr80 last edited by vcr80

            How can I push the scanner as a subview to a navigation view, get the first result it scanned, close the scanner an process the number, the scanner returned?

            I already managed to load the scanner as a sub view of a navigation view but now I'm stuck.

            1 Reply Last reply Reply Quote 0
            • jbap
              jbap last edited by

              Don't we have a qrcode module?

              1 Reply Last reply Reply Quote 0
              • omz
                omz last edited by

                @jbap That's for generating QR codes (from a URL etc.), not for reading them.

                1 Reply Last reply Reply Quote 1
                • jbap
                  jbap last edited by

                  Just wondering if the qrcode module could be expanded to produce and read.

                  1 Reply Last reply Reply Quote 0
                  • jbap
                    jbap last edited by

                    I tried this, and I'm just curious how I could use the photos module to scan. When my iPad is in any other orientation than the preset in this program, the camera does not shift. My iPad will turn, but the camera won't.

                    1 Reply Last reply Reply Quote 0
                    • kareliap
                      kareliap last edited by

                      Hi! I have been working with this script and I have been trying to get the picture from which the QR code was finally scanned? Do you know if this is possible with AVFoundation?

                      1 Reply Last reply Reply Quote 0
                      • robertiii
                        robertiii last edited by

                        This works great except when my ipad is turned sideways the camera acts weird and is like the camera is in mirror mode or something.

                        1 Reply Last reply Reply Quote 0
                        • roseybrown
                          roseybrown last edited by roseybrown

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Powered by NodeBB Forums | Contributors