QR Code

A QR code consists of black squares arranged in a square grid on a white background, which can be read by an imaging device such as a camera, and processed using Reed–Solomon error correction until the image can be appropriately interpreted. The required data is then extracted from patterns that are present in both horizontal and vertical components of the image.

A QR code consists of black squares arranged in a square grid on a white background, which can be read by an imaging device such as a camera, and processed using Reed–Solomon error correction until the image can be appropriately interpreted. The required data is then extracted from patterns that are present in both horizontal and vertical components of the image.

The QR code system was invented in 1994 by Denso Wave. Its purpose was to track vehicles during manufacturing; it was designed to allow high-speed component scanning. QR codes are now used in a much broader context, including both commercial tracking applications and convenience-oriented applications aimed at mobile-phone users (termed mobile tagging). QR codes may be used to display text to the user, to add a vCard contact to the user's device, to open a Uniform Resource Identifier (URI), or to compose an email or text message. There are a great many QR code generators available as software or as online tools. The QR code has become one of the most-used types of two-dimensional code.

QR codes can be used on various mobile device operating systems. These devices support URL redirection, which allows QR codes to send metadata to existing applications on the device. Many paid or free apps are available with the ability to scan the codes and hard-link to an external URL.

URLs aided marketing conversion rates even in the pre-smartphone era, but during those years faced several limitations: ad viewers usually had to type the URL and often did not have a web browser in front of them when they first viewed the ad. The chances were high that they would forget to visit the site later, not bother to type a URL, or forget what URL to type. Semantic URLs decreased these risks but did not eliminate them. Some of these disadvantages to URL conversion rates are fading away now that smartphones are putting web access and voice recognition in constant reach, with QR code providing the URL for instant access.

During the month of June 2011, according to one study, 14 million mobile users scanned a QR code or a barcode. Some 58% of those users scanned a QR or barcode from their homes, while 39% scanned from retail stores; 53% of the 14 million users were men between the ages of 18 and 34.  The use of QR codes for "virtual store" formats started in South Korea,   and Argentina,  but is currently expanding globally.  Walmart, Procter & Gamble and Woolworths have already adopted the Virtual Store concept. 

This document has been composed with the free HTML edior which can be accessed here. Use it every time for document editing.

  • The name of a pet, child, family member, or significant other
  • TAnniversary dates and birthdays
  • TBirthplace
  • TName of a favorite holiday
  • TSomething related to a favorite sports team
  • TThe word "password"
  • Integrating the ZXing library directly into my Android application

    I've managed to figure it out :) And down below you can read step-by-step guide so it hopefully can help others with the same problem as I had ;)

    1. Install Apache Ant - (See this YouTube video for config help)
    2. Download the ZXing source from ZXing homepage and extract it
    3. With the use of Windows Commandline (Run->CMD) navigate to the root directory of the downloaded zxing src.
    4. In the commandline window - Type ant -f core/build.xml press enter and let Apache work it's magic [having issues?]
    5. Enter Eclipse -> new Android Project, based on the android folder in the directory you just extracted
    6. Right-click project folder -> Properties -> Java Build Path -> Library -> Add External JARs...
    7. Navigate to the newly extracted folder and open the core directory and select core.jar ... hit enter!

    Now you just have to correct a few errors in the translations and the AndroidManifest.xml file :) Now you can happily compile, and you will now have a working standalone barcode scanner app, based on the ZXing source ;)

    Happy coding guys - I hope it can help others :)

    Having issues building with ANT? Keep reading

    If ant -f core/build.xml says something like:

    Unable to locate tools.jar. Expected to find it in
    C:\Program Files\Java\jre6\lib\tools.jar

    then set your JAVA_HOME environment variable to the proper java folder. I found tools.jar in my (for Windows):

    C:\Program Files\Java\jdk1.6.0_21\lib

    so I set my JAVA_HOME to:

    C:\Progra~1\Java\jdk1.6.0_25

    the reason for the shorter syntax I found at some site which says:

    "It is strongly advised that you choose an installation directory that does not include spaces in the path name (e.g., do NOT install in C:\Program Files). If Java is installed in such a directory, it is critical to set the JAVA_HOME environment variable to a path that does not include spaces (e.g., C:\Progra~1); failure to do this will result in exceptions thrown by some programs that depend on the value of JAVA_HOME."

    I then relaunched cmd (important because DOS shell only reads env vars upon launching, so changing an env var will require you to use a new shell to get the updated value)

    and finally the ant -f core/build.xml worked.

    integrating barcode scanner into php application?

    PHP can be easily utilized for reading bar codes printed on paper documents. Connecting manual barcode reader to the computer via USB significantly extends usability of PHP (or any other web programming language) into tasks involving document and product management, like finding a book records in the database or listing all bills for a particular customer.

    Following sections briefly describe process of connecting and using manual bar code reader with PHP.

    The usage of bar code scanners described in this article are in the same way applicable to any web programming language, such as ASP, Python or Perl. This article uses only PHP since all tests have been done with PHP applications.

    What is a bar code reader (scanner)

    Bar code reader is a hardware pluggable into computer that sends decoded bar code strings into computer. The trick is to know how to catch that received string. With PHP (and any other web programming language) the string will be placed into focused input HTML element in browser. Thus to catch received bar code string, following must be done:

    just before reading the bar code, proper input element, such as INPUT TEXT FIELD must be focused (mouse cursor is inside of the input field). once focused, start reading the code when the code is recognized (bar code reader usually shortly beeps), it is send to the focused input field. By default, most of bar code readers will append extra special character to decoded bar code string called CRLF (ENTER). For example, if decoded bar code is "12345AB", then computer will receive "12345AB". Appended character (or ) emulates pressing the key ENTER causing instant submission of the HTML form:

    <form action="search.php" method="post">
     <input name="documentID" onmouseover="this.focus();" type="text">
    </form>

    Choosing the right bar code scanner

    When choosing bar code reader, one should consider what types of bar codes will be read with it. Some bar codes allow only numbers, others will not have checksum, some bar codes are difficult to print with inkjet printers, some barcode readers have narrow reading pane and cannot read for example barcodes with length over 10 cm. Most of barcode readers support common barcodes, such as EAN8, EAN13, CODE 39, Interleaved 2/5, Code 128 etc.

    For office purposes, the most suitable barcodes seem to be those supporting full range of alphanumeric characters, which might be:

    Other important things to note:

    Installing scanner drivers

    Installing manual bar code reader requires installing drivers for your particular operating system and should be normally supplied with purchased bar code reader.

    Once installed and ready, bar code reader turns on signal LED light. Reading the barcode starts with pressing button for reading.

    Scanning the barcode - how does it work?

    STEP 1 - Focused input field ready for receiving character stream from bar code scanner:

    step 1

    STEP 2 - Received barcode string from bar code scanner is immediatelly submitted for search into database, which creates nice "automated" effect:

    step 2

    STEP 3 - Results returned after searching the database with submitted bar code:

    step 3

    Conclusion

    It seems, that utilization of PHP (and actually any web programming language) for scanning the bar codes has been quite overlooked so far. However, with natural support of emulated keypress (ENTER/CRLF) it is very easy to automate collecting & processing recognized bar code strings via simple HTML (GUI) fomular.

    The key is to understand, that recognized bar code string is instantly sent to the focused HTML element, such as INPUT text field with appended trailing character ASCII 13 (=ENTER/CRLF, configurable option), which instantly sends input text field with populated received barcode as a HTML formular to any other script for further processing.

    Reference: http://www.synet.sk/php/en/280-barcode-reader-scanner-in-php

    Hope this helps you :)

    How to decode a QR-code image in (preferably pure) Python?

    TL;DR: I need a way to decode a QR-code from an image file using (preferable pure) Python.

    I've got a jpg file with a QR-code which I want to decode using Python. I've found a couple libraries which claim to do this:

    PyQRCode (website here) which supposedly can decode qr codes from images by simply providing a path like this:

    import sys, qrcode
    d = qrcode.Decoder()
    if d.decode('out.png'):
     print 'result: ' + d.result
    else:
     print 'error: ' + d.error

    So I simply installed it using sudo pip install pyqrcode. The thing I find strange about the example code above however, is that it only imports qrcode (and not pyqrcode though) Since I think qrcode refers to this library which can only generate qr-code images it kind of confused me. So I tried the code above with both pyqrcode and qrcode, but both fail at the second line saying AttributeError: 'module' object has no attribute 'Decoder'. Furthermore, the website refers to Ubuntu 8.10 (which came out more than 6 years ago) and I can't find a public (git or other) repository of it to check the latest commit. So I moved on to the next library:

    ZBar (website here) claims to be "an open source software suite for reading bar codes from various sources, such as image files." So I tried installing it on Mac OSX running sudo pip install zbar. This fails with error: command 'cc' failed with exit status 1. I tried to suggestions in the answers to this SO question, but I can't seem to solve it. So I decided to move on again:

    QRTools, which according to this blogpost can decode images easily by using the following code:

    from qrtools import QR
    myCode = QR(filename=u"/home/psutton/Documents/Python/qrcodes/qrcode.png")
    if myCode.decode():
     print myCode.data
     print myCode.data_type
     print myCode.data_to_string()

    So I tried installing it using sudo pip install qrtools, which can't find anything. I also tried it with python-qrtoolsqr-toolspython-qrtools and a couple more combinations, but unfortunately to no avail. I suppose it refers to this repo which says it is based on ZBar (see above). Although I want to run my code on Heroku (and thus prefer a pure Python solution) I successfully installed it on a Linux box (with sudo apt-get install python-qrtools) and tried running it:

    from qrtools import QR
    c = QR(filename='/home/kramer65/qrcode.jpg')
    c.data # prints u'NULL'
    c.data_type # prints u'text'
    c.data_to_string() # prints '\xef\xbb\xbfNULL' where I expect an int (being `1234567890`)

    Although this seems to decode it, It doesn't seem to do it correctly. It furthermore needs ZBar and is thus not pure Python. So I decided to find yet another library.

    PyXing (website here) is supposedly a Python port of the popular Java ZXing library, but the initial and only commit is 6 years old and the project has no readme or documentation whatsoever.

    For the rest I found a couple qr-encoders (not decoders) and some API endpoints which can decode for you. Since I don't like this service to be dependent on other API endpoints I would want to keep the decoding local though.

    So to conclude; would anybody know how I can decode QR-codes from images in (preferable pure) Python? All tips are welcome!

    How to generate a QR Code for an Android application? 

    I need to create a qrcode in my android application, and I need a library or source code that lets me create a QR Code in an Android app.

    The library I need must:

    1. not leave a watermark (like onbarcode library)
    2. not use web service API to create the qrcode (like Google's library zxing)
    3. not need 3rd party installers (like QR Droid)

    I already created such code for iPhone (Objective-C) but I need a quick fix for Android until I have time to make a QR Code generator of my own. It's my first android project so any help will be appreciated.

    Have you looked into ZXING? I've been using it successfully to create barcodes. You can see a full working example in the bitcoin application src

    // this is a small sample use of the QRCodeEncoder class from zxing
    try {
     // generate a 150x150 QR code
     Bitmap bm = encodeAsBitmap(barcode_content, BarcodeFormat.QR_CODE, 150, 150);
     if(bm != null) {
     image_view.setImageBitmap(bm);
     }
    } catch (WriterException e) { //eek }

    How to decode a QR-code image in (preferably pure) Python?

    I've got a jpg file with a QR-code which I want to decode using Python. I've found a couple libraries which claim to do this:

    PyQRCode (website here) which supposedly can decode qr codes from images by simply providing a path like this:

    import sys, qrcode
    d = qrcode.Decoder()
    if d.decode('out.png'):
     print 'result: ' + d.result
    else:
     print 'error: ' + d.error

    So I simply installed it using sudo pip install pyqrcode. The thing I find strange about the example code above however, is that it only imports qrcode (and not pyqrcode though) Since I think qrcode refers to this library which can only generate qr-code images it kind of confused me. So I tried the code above with both pyqrcode and qrcode, but both fail at the second line saying AttributeError: 'module' object has no attribute 'Decoder'. Furthermore, the website refers to Ubuntu 8.10 (which came out more than 6 years ago) and I can't find a public (git or other) repository of it to check the latest commit. So I moved on to the next library:

    ZBar (website here) claims to be "an open source software suite for reading bar codes from various sources, such as image files." So I tried installing it on Mac OSX running sudo pip install zbar. This fails with error: command 'cc' failed with exit status 1. I tried to suggestions in the answers to this SO question, but I can't seem to solve it. So I decided to move on again:

    QRTools, which according to this blogpost can decode images easily by using the following code:

    from qrtools import QR
    myCode = QR(filename=u"/home/psutton/Documents/Python/qrcodes/qrcode.png")
    if myCode.decode():
     print myCode.data
     print myCode.data_type
     print myCode.data_to_string()

    So I tried installing it using sudo pip install qrtools, which can't find anything. I also tried it with python-qrtoolsqr-toolspython-qrtools and a couple more combinations, but unfortunately to no avail. I suppose it refers to this repo which says it is based on ZBar (see above). Although I want to run my code on Heroku (and thus prefer a pure Python solution) I successfully installed it on a Linux box (with sudo apt-get install python-qrtools) and tried running it:

    from qrtools import QR
    c = QR(filename='/home/kramer65/qrcode.jpg')
    c.data # prints u'NULL'
    c.data_type # prints u'text'
    c.data_to_string() # prints '\xef\xbb\xbfNULL' where I expect an int (being `1234567890`)

    Although this seems to decode it, It doesn't seem to do it correctly. It furthermore needs ZBar and is thus not pure Python. So I decided to find yet another library.

    PyXing (website here) is supposedly a Python port of the popular Java ZXing library, but the initial and only commit is 6 years old and the project has no readme or documentation whatsoever.

    For the rest I found a couple qr-encoders (not decoders) and some API endpoints which can decode for you. Since I don't like this service to be dependent on other API endpoints I would want to keep the decoding local though.

    So to conclude; would anybody know how I can decode QR-codes from images in (preferable pure) Python? All tips are welcome!

    Undefined symbols for architecture armv7 when using ZXing library in XCode 4.5

    Well, at last I got it working.. For anyone who encounters this in the future..

    1. Rename the main.m file to main.mm.

      ZXing's README states why we need this

      It can happen that when trying to build your own project with ZXingWidgetController you get linker errors like "undefined reference to". If this error looks like a c++ undefined reference, then renaming main.m into main.mm (Objective-C++ source suffix) may fix the problem

    2. Rename the file (ViewController/View) which uses ZXing libray functions so that it also has .mm extension.

    3. Check architecture settings across project. Give architecture and valid architecture as armv7 armv7s in your project settings, target settings, and ZXing project (which you added to your main project) and target settings.

    4. In main project -> Build Settings scroll and find out the options, C++ Language Dialect and C++ Standard Library. Select options "Compiler Default" for both of them. (This is the step I missed, It is needed because newest XCode template has compiler default settings different to what they were in older versions).

    5. You also might have to set ZXingWidget's "Build Valid Architecture Only" flag set as NO. In my case, this field was already NO

    These fixed the issue for me..

    Update

    On December 2013, Google has retired ZXing iOS/Objective C port. So Zxing project for iOS is no longer maintained and updated for new iOS versions. Also Zxing doesn't have support for Arm64 architecture which is one of the standard architecture as per new XCode versions.

    So developers are encouraged to move over to the native Apple framework to read barcode which is available from iOS7 onwards. See this for a step by step tutorial.

    Integrate Zxing, QR code reader framework, in my iPhone project. I checked out ZXing sdk from here. I ran the sample project coming with ZXing, named ScanTest, without any issues. But when I try to integrate the library with my project I am getting the error mentioned.

    Project specification

    Problem

    When I build, after doing every integration steps in ZXing readme file, I am getting build errors like

    Undefined symbols for architecture armv7:
     "std::basic_ostream<char, std::char_traits<char> >& std::operator<<<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)", referenced from:
     zxing::qrcode::Detector::computeDimension(zxing::Ref<zxing::ResultPoint>, zxing::Ref<zxing::ResultPoint>, zxing::Ref<zxing::ResultPoint>, float) in libZXingWidget.a(Detector-B8B28E953F840D47.o)
    Undefined symbols for architecture armv7:
    "std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
     zxing::Exception::Exception(char const*) in libZXingWidget.a(Exception.o)
     zxing::common::StringUtils::guessEncoding(unsigned char*, int, std::map<unsigned int, std::string, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, std::string> > >

    There are 27 errors like that.. I only copied the first two.

    What did I found out

    Well, I went through this, this ,this ,this, this, this,this threads in stackoverflow, all with the same error message. None of the solutions worked for me.

    Then I found this closed thread in ZXing forums discussing the same issue. From that discussion, some possible solutions are (worked for some)

    The first error is (probably) because you haven't renamed main.m to main.mm. The second error is (probably) because you're not linking against the widget library

    I also renamed my main.m, cross checked whether I have added the library only to find I surely had. So this is not the case.

    After I changed the Architectures of the library to "Standard (armv7, armv7s)" to match my main project I was able to successfully compile the app.

    My project, target, library project (for debug, distribution, release) architecture is given as Standard (armv7, armv7s). So no luck there either.

    Then they closed the issue saying this,

    The zxing projects have been updated to add the armv7s arch and remove the armv6 arch. These changes are required (1) to build for the iPhone 5 which is armv7s and (2) to build at all since Xcode 4.5 does not include support for armv6. If you have your own project files, you'll need to make these changes yourself. These are general changes not specific to zxing so if you have trouble, you make get more/quicker help in a general forum like StackOverflow.

    So here I am, in StackOverflow.

    One more point

    In ZXing integration README file , the first step in integration is,

    1) Locate the "ZXingWidget.xcodeproj" file under "zxing/iphone/ZXingWidget/". Drag ZXingWidget.xcodeproj and drop it onto the root of your Xcode project's "Groups and Files" sidebar. A dialog will appear -- make sure "Copy items" is unchecked and "Reference Type" is "Relative to Project" before clicking "Add". Alternatively you can right-click on you project navigator and select 'Add files to "MyProject"'.

    When I dragged the ZXingWidget.xcodeproj file to my project, there was no dialog. The project directly added to the project and I could not set, "copy items" and "Reference Type" properties. I don't know it is a new feature of xcode 4.5 or a bug. That is the only step I couldn't correctly follow as per the README file.

    How much data / information can we save / store in a QR code?

    QR codes have three parameters: Datatype, size (number of 'pixels') and error correction level. How many information can be stored there also depends on these parameters. For example the lower the error correction level, the more information can be stored, but the harder the code is to recognize for readers.

    The maximum size and the lowest error correction give the following values:
    Numeric only Max. 7,089 characters
    Alphanumeric Max. 4,296 characters
    Binary/byte Max. 2,953 characters (8-bit bytes)

    How to run a maven created jar file using just the command line

    I am not sure in your case. But as I know to run any jar file from cmd we can use following command:

    Go up to the directory where your jar file is saved:

    java -jar <jarfilename>.jar

    But you can check following links. I hope it'll help you:

    Run Netbeans maven project from command-line?

    http://www.sonatype.com/books/mvnref-book/reference/running-sect-options.html

    Embed Zxing library without using Barcode Scanner app

    It's really easier to just integrate via Intent. More reliable, and you get updates automatically. While I don't advise it...

    The complete source code is available from the ZXing project. You want to build core.jar from core/ and put it in your Android lib/ folder to include the core decoder in your app. You do not want to include javase. You can look to the code in android/ as it is the source to Barcode Scanner, but as the authors we'd suggest you not just copy and paste it.

    It is Apache licensed which means you can use it freely, as long as you essentially give the user access to the license terms.

    QR CODE max char length

    A summary of the specification is here:

     * http://en.wikipedia.org/wiki/QR_code
     Numeric only Max. 7,089 characters (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
     Alphanumeric Max. 4,296 characters (0–9, A–Z [upper-case only], space, $, %, *, +, -, ., /, :)
     Binary/byte Max. 2,953 characters (8-bit bytes) (23624 bits)
     Kanji/Kana Max. 1,817 characters
    

    The specification itself is here:

    As far as "more space", you should think of the QR code as a "link", or a "shortcut" to your URL. Clicking the QR code brings the user to web site; once they're there, you have as much space as you want.

    How to draw a QR code with Qt in native C/C++

    If you feel that Fukuchi's library is too large[0] for you, consider looking at Nayuki's C++ QR Code generator library[1]: https://github.com/nayuki/QR-Code-generator/tree/master/cpp

    Nayuki's library requires C++11, and is portable without needing Autotools. Sample usage:

    #include <string>
    #include <vector>
    #include "QrCode.hpp"
    using namespace qrcodegen;
    // Create the QR Code object
    QrCode qr = QrCode::encodeText("Hello, world!", QrCode::Ecc::MEDIUM);
    // Read the black & white pixels
    for (int y = 0; y < qr.size; y++) {
     for (int x = 0; x < qr.size; x++) {
     int color = qr.getModule(x, y); // 0 for white, 1 for black
     // You need to modify this part
     draw_pixel_onto_QT(x, y, color);
     }
    }

    [0]: Fukuchi: 20 files, ~7200 lines among the main .c and .h files (excluding build and test code).
    [1]: Nayuki: 6 files, ~1400 lines among the main .cpp and .hpp files (excluding demo code).


    EDIT 2016-12-08 by OP I decided, with permission, to add my own adaption to Qt. This code compiles and runs fine on my system, And I think it should be independent enough to work elsewhere without too many tweaks as well.

    #include "QrCode.hpp"
    void paintQR(QPainter &painter, const QSize sz, const QString &data, QColor fg)
    {
     char *str=data.toUtf8().data();
     // NOTE: At this point you will use the API to get the encoding and format you want, instead of my hardcoded stuff:
     qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(str, qrcodegen::QrCode::Ecc::LOW);
     const int s=qr.getSize()>0?qr.getSize():1;
     const double w=sz.width();
     const double h=sz.height();
     const double aspect=w/h;
     const double size=((aspect>1.0)?h:w);
     const double scale=size/(s+2);
     // NOTE: For performance reasons my implementation only draws the foreground parts in supplied color.
     // It expects background to be prepared already (in white or whatever is preferred).
     painter.setPen(Qt::NoPen);
     painter.setBrush(fg);
     for(int y=0; y<s; y++) {
     for(int x=0; x<s; x++) {
     const int color=qr.getModule(x, y); // 0 for white, 1 for black
     if(0!=color) {
     const double rx1=(x+1)*scale, ry1=(y+1)*scale;
     QRectF r(rx1, ry1, scale, scale);
     painter.drawRects(&r,1);
     }
     }
     }
    }

    QR code reader for iPhone

    ZBarSDK is another option. A very capable library.

    UPDATE January 2014

    Beginning in iOS7, AVCaptureDevice now includes the ability to read barcodes (of all kinds) and return a human readable value. If you're targeting iOS7+, this is the way to go. ZBarSDK is still great for pre-iOS7 support, of course.

    Why does the fragment's onCreateView, onCreate, onActivityCreated are called.

    I would change your architecture for this one on the android developer documentation:

    http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html

    but I would change some things...

    1-I would change this method:

    /**
     * The Fragment's UI is just a simple text view showing its
     * instance number.
     */
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
     Bundle savedInstanceState) {
     View v = inflater.inflate(R.layout.fragment_pager_list, container, false);
     View tv = v.findViewById(R.id.text);
     ((TextView)tv).setText("Fragment #" + mNum);
     return v;
     }

    For something like this where we decide which fragment you populate depending the position of the viewPager:

    Can associated values and raw values coexist in Swift enumeration?

    Yes this is possible. An enum may contain both associated values and raw values. (Swift 4 & 3)

    Shorthand notation

    The issue with your code is that you are using the shorthand notation for RawRepresentable anddefining associated types.

    Let's look at how to define these separately:

    1) RawRepresentable (shorthand notation):

    enum Barcode: String {
     case UPCA = "order 1"
     case QRCode = "order 2"
    }

    2) Associated types:

    enum Barcode {
     case UPCA(Int, Int, Int)
     case QRCode(String)
    }

    Each of these is great, but what if you need both as your code snippet shows.

    Solution

    Define the enum with associated values and then implement conformance to RawRepresentableseparately in an extension (i.e. not using shorthand notation).

    Example:

    enum Barcode {
     case UPCA(Int, Int, Int)
     case QRCode(String)
    }
    extension Barcode: RawRepresentable {
     public typealias RawValue = String
     /// Failable Initalizer
     public init?(rawValue: RawValue) {
     switch rawValue {
     case "Order 1": self = .UPCA(1,1,1)
     case "Order 2": self = .QRCode("foo")
     default:
     return nil
     }
     }
     /// Backing raw value
     public var rawValue: RawValue {
     switch self {
     case .UPCA: return "Order 1"
     case .QRCode: return "Order 2"
     }
     }
    }

    Minor Detail

    In this solution, defaults for the associated values, e.g. .UPCA(1,1,1) must be supplied when constructing the enum from the rawValue argument. You can get fancy and use the associated types as part of the backing raw value — which is more powerful, but adds some complexity.

    References

    For more info on the topic see Ole Begemann's excellent write up.

    sample code to detect QRCode in an image

    I use this code in C# to decode (not detect) a QRCode and it works:

    LuminanceSource ls = new RGBLuminanceSource(image, image.Width, image.Height);
    Result result = new QRCodeReader().decode(new BinaryBitmap(new HybridBinarizer(ls)));

    Now I would like to detect a QRCode in a more complex image with a lot of other stuffs such images and text. I'm not able to understand how to accomplish this because I cannot find any sample and transforming Bitmap (C#) to Bitmatrix for Detector (zxing) is not so direct.

    Does anyone have a piece of code to give me?

    Free c# QR-Code generator

    ZXing is an open source project that can detect and parse a number of different barcodes. It can also generate QR-codes. (Only QR-codes, though).

    There are a number of variants for different languages: ActionScript, Android (java), C++, C#, IPhone (Obj C), Java ME, Java SE, JRuby, JSP. Support for generating QR-codes comes with some of those: ActionScript, Android, C# and the Java variants.

    Unable to run odoo properly in Mac OS X

    I just went through the setup on two systems, one is Mac OS X El Capitan 10.11.2 and another one is my primary OS - Ubuntu 15.04 (where things went much easier, but maybe it is just because I use Ubuntu on daily basis).

    Below are installation steps for both systems. Make sure that every command finishes successfully (at least doesn't report any errors).

    Mac OS X El Capitan 10.11.2

    Prerequisites: I already had git and python 2.7.10.

    1) Clone odoo repository:

    git clone https://github.com/odoo/odoo.git

    2) Download and install Postgresapp

    Now add to ~/.bash_profile:

    export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin

    And just execute the command above it if you already have the open terminal.

    3) Install pip

    sudo easy_install pip

    4) Install nodejs

    5) Install less and less-plugin-clean-css

    sudo npm install -g less less-plugin-clean-css

    Should show output like this:

    /usr/local/bin/lessc -> /usr/local/lib/node_modules/less/bin/lessc
    less-plugin-clean-css@1.5.1 /usr/local/lib/node_modules/less-plugin-clean-css
    └── clean-css@3.4.9 (source-map@0.4.4, commander@2.8.1)
    less@2.6.0 /usr/local/lib/node_modules/less
    ├── mime@1.3.4
    ├── graceful-fs@3.0.8
    ├── image-size@0.3.5
    ├── errno@0.1.4 (prr@0.0.0)
    ├── promise@6.1.0 (asap@1.0.0)
    ├── source-map@0.4.4 (amdefine@1.0.0)
    ├── mkdirp@0.5.1 (minimist@0.0.8)
    └── request@2.69.0 (aws-sign2@0.6.0, forever-agent@0.6.1, tunnel-agent@0.4.2, oauth-sign@0.8.1, is-typedarray@1.0.0, caseless@0.11.0, stringstream@0.0.5, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, tough-cookie@2.2.1, node-uuid@1.4.7, qs@6.0.2, combined-stream@1.0.5, mime-types@2.1.9, form-data@1.0.0-rc3, aws4@1.2.1, hawk@3.1.3, bl@1.0.2, har-validator@2.0.6, http-signature@1.1.1)

    6) Install binary dependencies

    I think not all the steps below are really necessary, but I performed them, so include just for the case they actually were needed.

    Once you have brew, run the following in the terminal:

    brew install autoconf automake libtool
    brew install libxml2 libxslt libevent

    7) Install python dependencies

    sudo easy_install -U setuptools
    pip install --user -r requirements.txt

    It should show something like this at the end:

    Successfully installed Babel-1.3 Jinja2-2.7.3 Mako-1.0.1 MarkupSafe-0.23 Pillow-2.7.0 PyYAML-3.11 Python-Chart-1.39 Werkzeug-0.9.6 argparse-1.2.1 beautifulsoup4-4.4.1 decorator-3.4.0 docutils-0.12 feedparser-5.1.3 gdata-2.0.18 gevent-1.0.2 greenlet-0.4.7 jcconv-0.2.3 lxml-3.4.1 mock-1.0.1 ofxparse-0.14 passlib-1.6.2 psutil-2.2.0 psycogreen-1.0 psycopg2-2.5.4 pyPdf-1.13 pydot-1.0.2 pyparsing-2.0.1 pyserial-2.7 python-dateutil-1.5 python-ldap-2.4.19 python-openid-2.2.5 python-stdnum-1.2 pytz-2013.7 pyusb-1.0.0b2 qrcode-5.1 reportlab-3.1.44 requests-2.6.0 six-1.4.1 suds-jurko-0.6 vatnumber-1.2 vobject-0.6.6 xlwt-0.7.5

    8) Run odoo

    cd odoo # change dir to the folder you cloned odoo to
    export LC_ALL=en_US.UTF-8
    export LANG=en_US.UTF-8
    # Re-check parameters, it looks like addons path you used is incorrect
    ./odoo.py --addons-path=addons --db-filter=mydb

    Now you should see the output like this:

    INFO ? openerp: OpenERP version 9.0c
    INFO ? openerp: addons paths: ['/Users/dev/Library/Application Support/Odoo/addons/9.0', u'/Users/dev/projects/odoo/addons', '/Users/dev/projects/odoo/openerp/addons']
    INFO ? openerp: database: default@default:default
    INFO ? openerp.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069

    9) Open odoo in your browser

    Done!

    The online Windows XP simulator runs in a web browser and its operation imitates the operating system. You can use it to prank someone.