title: Cannot scan QR code using zbar
body: <p><a href="http://i.stack.imgur.com/zclcr.png" rel="nofollow">My QR code</a></p>
  
  <p>When I run my code I´m always getting "[]" as output, which means that Zbar can´t read the QR... There is something wrong with my image format? I can´t figure out why this is not working.</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>import numpy as np
  import cv2
  import zbar
  import sys
  
  class ImageSource(object):
      def __init__(self,source):
          self.is_camera = type(source)==int
          if self.is_camera:
              self.source = cv2.VideoCapture(source)
          else:
              self.source = cv2.imread(source,1)
  
      def get_size(self):
          if self.is_camera:
              return (int(self.source.get(3)),int(self.source.get(4)))
          else:
              return (self.source.shape[1],self.source.shape[0])
  
      def get_next(self):
          if self.is_camera:
              return self.source.read()[1]
          else:
              return self.source
  
      def release(self):
          if self.is_camera:
              self.source.release()
  
  class QRScanner(object):
      def __init__(self, width, height):
          self.scanner = zbar.ImageScanner()
          self.scanner.parse_config('enable')
          self.width = width
          self.height = height
  
      def get_qrcodes(self, image):
          zbar_img = self.cv2_to_zbar_image(image)
          self.scanner.scan(zbar_img)
          result=[]
          for symbol in zbar_img:
              if symbol.type!=zbar.Symbol.QRCODE: continue
              fixed_data = symbol.data.decode("utf8").encode("shift_jis").decode("utf8")
  
              result.append(QRCode(fixed_data,symbol.location))
          del(zbar_img)
          return result
  
      def cv2_to_zbar_image(self, cv2_image):
          return zbar.Image(self.width, self.height, 'Y800',cv2_image.tostring())
  
  
  cap = ImageSource("1.png")
  frame = cap.get_next()
  scanner = QRScanner(cap.get_size()[0],cap.get_size()[1])
  print scanner.get_qrcodes(frame)
  </code></pre>