Beispiel #1
0
def generate(codes = range(20), width=2.0, cols = 5):
  width_str = '%fcm' % width

  tex_figs = ''

  c_strs = []
  f_strs = []

  for c in codes:
    c_str = '%06d' % c
    qr = QR(data = url_fmt % c)
    img_filename = img_dir + '/%s.png' % c_str 
    qr.encode(img_filename)
    c_strs.append(c_str)
    f_strs.append(figure_fmt % (width_str, img_filename))

  elts = []
  for i in range(0,len(codes),cols):
    elts.append(c_strs[i:i+cols])
    elts.append(f_strs[i:i+cols])

  tex_file = open(tex_filename, 'w')
  tex_file.write(tex_fmt % list_to_table(elts))
  tex_file.close()

  subprocess.check_call(['pdflatex',tex_filename],cwd=tex_dir)
Beispiel #2
0
def Authentication(self, l):

    count = 0
    myCode = QR(filename=u"/home/pi/Desktop/image.png")
    myCode.decode()
    n = myCode.data_to_string()
    print n
Beispiel #3
0
    def qrencode(self):
        text = [
            unicode(self.textEdit.toPlainText()),
            unicode(self.urlEdit.text()),
            ( unicode(self.emailEdit.text()), unicode(self.emailSubjectEdit.text()), unicode(self.emailBodyEdit.toPlainText()) ),
            ( unicode(self.smsNumberEdit.text()), unicode(self.smsBodyEdit.toPlainText()) ),
            unicode(self.telephoneEdit.text()),
        ]
        level = (u'L',u'M',u'Q',u'H')
        data_type = (u'text',u'url',u'emailmessage',u'sms',u'telephone')

        if text[self.tabs.currentIndex()]:
            qr = QR(pixel_size = unicode(self.pixelSize.value()),
                    data=text[self.tabs.currentIndex()],
                    level=unicode(level[self.ecLevel.currentIndex()]),
                    margin_size=unicode(self.marginSize.value()),
                    data_type=unicode(data_type[self.tabs.currentIndex()]),
                    )
            if qr.encode() == 0:
                self.qrcode.setPixmap(QtGui.QPixmap(qr.filename))
                self.saveButton.setEnabled(True)
            else:
                print >>sys.stderr, u"ERROR: Something went wrong while trying to generate de qrcode."
        else:
            self.saveButton.setEnabled(False)
Beispiel #4
0
def scanadd(name):

    myCode = QR(filename=name)
    if myCode.decode():
        if myCode.data_type == "text":
            print "worked"
            retval=""
            add = False
            start = True
            for x in myCode.data:
                if x in "13" and start:
                    add = True
                    start = False
                    retval+=x
                elif add and x in "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ":
                    retval+=x
                else:
                    add=False
            print "raw",myCode.data
            return retval
            #aystit(retval, amt)
        else:
            print "That isn't text you tricky trickster"
    else:
        print "I can't decode that.  Sorry."
Beispiel #5
0
 def decodeFile(self, fn=None):
     if not fn:
         fn = unicode(QtGui.QFileDialog.getOpenFileName(
             self, 
             u'Open QRCode',
             filter=u'Images (*.png *.jpg);; All Files (*.*)'
             )
         )
     if os.path.isfile(fn):
         qr = QR(filename=fn)
         if qr.decode():
             self.showInfo(qr)
         else:
             QtGui.QMessageBox.information(
                 self,
                 u'Decode File',
                 u'No QRCode could be found in file: <b>%s</b>.' % fn
             )
     else:
         QtGui.QMessageBox.information(
             self,
             u"Decode from file",
             u"The file <b>%s</b> doesn't exist." %
             os.path.abspath(fn),
             QtGui.QMessageBox.Ok
         )
 def StartScan(self):
     #Reading the file "EmployeeList.csv" as a dataframe
     data = pd.read_csv("EmployeeList.csv")
     #Defining global variables so other functions can access them
     global name
     option = 0
     name = 0
     ID_found = False
     count = 0
     #Setting the variable "myCode" to access the function QR and Decode webcam images
     myCode = QR()
     myCode.decode_webcam()
     global ID
     global manager
     #Setting variable "ID" to equal the scanned code
     ID = myCode.data
     #Searching the file "EmployeeList.csv" to see if the ID exists, then grabbing the fullname and role
     #Also changing the label name say "Successfully Scanned" for 3 seconds when the ID is found
     for i in range((len(data["ID"]))):
         if data["ID"][i] == ID:
             name = (data["Name"][i])
             ID_found = True
             manager = (data["Role"][i])
             self.label.setStyleSheet('color: rgb(0, 183, 0)')
             self.label.setText("Successfully Scanned")
             QtCore.QTimer.singleShot(
                 3000, lambda: self.label.setText('Welcome ' + name))
             QtCore.QTimer.singleShot(
                 3000, lambda: self.label.setStyleSheet('color: white'))
             break
         else:
             count = count + 1
     #If the ID cannot be found within the file the label changes
     if ID_found == False:
         self.label.setText("ID Not Found, Please Try Again")
Beispiel #7
0
    def qrencode(self):
        text = [
            unicode(self.textEdit.toPlainText()),
            unicode(self.urlEdit.text()),
            (unicode(self.emailEdit.text()),
             unicode(self.emailSubjectEdit.text()),
             unicode(self.emailBodyEdit.toPlainText())),
            (unicode(self.smsNumberEdit.text()),
             unicode(self.smsBodyEdit.toPlainText())),
            unicode(self.telephoneEdit.text()),
        ]
        level = (u'L', u'M', u'Q', u'H')
        data_type = (u'text', u'url', u'emailmessage', u'sms', u'telephone')

        if text[self.tabs.currentIndex()]:
            qr = QR(
                pixel_size=unicode(self.pixelSize.value()),
                data=text[self.tabs.currentIndex()],
                level=unicode(level[self.ecLevel.currentIndex()]),
                margin_size=unicode(self.marginSize.value()),
                data_type=unicode(data_type[self.tabs.currentIndex()]),
            )
            if qr.encode() == 0:
                self.qrcode.setPixmap(QtGui.QPixmap(qr.filename))
                self.saveButton.setEnabled(True)
            else:
                print >> sys.stderr, u"ERROR: Something went wrong while trying to generate de qrcode."
        else:
            self.saveButton.setEnabled(False)
Beispiel #8
0
def qr_encode(option, opt_str, value, parser):
    text = sys.argv[2]
    img = QR(data=text, pixel_size=10)
    img.encode()
    os.system("mv " + img.filename + " ~/Desktop/qr_" +
              datetime.datetime.now().strftime("%d%m%Y_%H%M%S") + ".png")
    print("File is saved in Desktop")
Beispiel #9
0
def check_qr(file):
    qr = QR()
    if qr.decode(file):
        print qr.data
        return True

    return False
Beispiel #10
0
    def create_qr_image(self, amount_total):
        url = "https://verificacfdi.facturaelectronica.sat.gob.mx/default.aspx"
        UUID = self.cfdi_folio_fiscal

        qr_emisor = self.partner_id.vat_split
        qr_receptor = self.company_id.vat_split
        total = "%.6f" % (amount_total or 0.0)
        total_qr = ""
        qr_total_split = total.split('.')
        decimales = qr_total_split[1]
        index_zero = self.return_index_floats(decimales)
        decimales_res = decimales[0:index_zero + 1]
        if decimales_res == '0':
            total_qr = qr_total_split[0]
        else:
            total_qr = qr_total_split[0] + "." + decimales_res

        last_8_digits_sello = ""


        cfdi_sello = self.cfdi_sello

        last_8_digits_sello = cfdi_sello[len(cfdi_sello) - 8:]

        qr_string = '%s&id=%s&re=%s&rr=%s&tt=%s&fe=%s' % (
        url, UUID, qr_emisor, qr_receptor, total_qr, last_8_digits_sello)

        qr_code = QR(data=qr_string.encode('utf-8'))
        try:
            qr_code.encode()
        except Exception, e:
            raise UserError(_('Advertencia !!!\nNo se pudo crear el Código Bidimensional. Error %s') % e)
Beispiel #11
0
 def takein(self):
     self.turn_red()
     ''' capture image'''
     os.system('fswebcam -r 1024x786  --jpeg 500 qw.jpeg')
     
     '''sleep to recover image'''
     time.sleep(5)
     
     '''extract qrcode'''
     myCode = QR(filename="/home/pi/Desktop/project/ikart/qw.jpeg")
     if myCode.decode():
         print myCode.data
         print myCode.data_type
         print myCode.data_to_string()
         
          '''send product'''
          self.send_product()
          
          
          '''update xml '''
          self.update_xml()
          
          
          '''display details on lED'''
          self.displaydetails()
Beispiel #12
0
    def qrencode(self, fileName=None):
        #Functions to get the correct data
        data_fields = {
            "text": unicode(self.textEdit.toPlainText()),
            "url": unicode(self.urlEdit.text()),
            "bookmark": ( unicode(self.bookmarkTitleEdit.text()), unicode(self.bookmarkUrlEdit.text()) ),
            "email": unicode(self.emailEdit.text()),
            "emailmessage": ( unicode(self.emailEdit.text()), unicode(self.emailSubjectEdit.text()), unicode(self.emailBodyEdit.toPlainText()) ),
            "telephone": unicode(self.telephoneEdit.text()),
            "phonebook": (('N',unicode(self.phonebookNameEdit.text())),
                          ('TEL', unicode(self.phonebookTelEdit.text())),
                          ('EMAIL',unicode(self.phonebookEMailEdit.text())),
                          ('NOTE', unicode(self.phonebookNoteEdit.text())),
                          ('BDAY', unicode(self.phonebookBirthdayEdit.date().toString("yyyyMMdd")) if self.phonebookBirthdayLabel.isChecked() else ""), #YYYYMMDD
                          ('ADR', unicode(self.phonebookAddressEdit.text())),  #The fields divided by commas (,) denote PO box, room number, house number, city, prefecture, zip code and country, in order.
                          ('URL', unicode(self.phonebookUrlEdit.text())),
                          # ('NICKNAME', ''),
                        ),
            "sms": ( unicode(self.smsNumberEdit.text()), unicode(self.smsBodyEdit.toPlainText()) ),
            "mms": ( unicode(self.mmsNumberEdit.text()), unicode(self.mmsBodyEdit.toPlainText()) ),
            "geo": ( unicode(self.geoLatEdit.text()), unicode(self.geoLongEdit.text()) ),
            "wifi": ( unicode(self.wifiSSIDEdit.text()), (u"WEP",u"WPA",u"nopass")[self.wifiEncriptionType.currentIndex()], unicode(self.wifiPasswordEdit.text()))
        }

        data_type = unicode(self.templates[unicode(self.selector.currentText())])
        data = data_fields[data_type]
        
        level = (u'L',u'M',u'Q',u'H')

        if data:
            if data_type == 'emailmessage' and data[1] == '' and data[2] == '':
                data_type = 'email'
                data = data_fields[data_type]
            qr = QR(pixel_size = unicode(self.pixelSize.value()),
                    data = data,
                    level = unicode(level[self.ecLevel.currentIndex()]),
                    margin_size = unicode(self.marginSize.value()),
                    data_type = data_type,
                    )
            error = 1
            if type(fileName) is not unicode:
                error = qr.encode()
            else:
                error = qr.encode(fileName)
            if error == 0:
                self.qrcode.setPixmap(QtGui.QPixmap(qr.filename))
                self.saveButton.setEnabled(True)
            else:
                if NOTIFY:
                    n = pynotify.Notification(
                        "QtQR",
                        unicode(self.trUtf8("ERROR: Something went wrong while trying to generate the QR Code.")),
                        "qtqr"
                        )
                    n.show()
                else:
                    print "Something went wrong while trying to generate the QR Code"
            qr.destroy()
        else:
            self.saveButton.setEnabled(False)
Beispiel #13
0
def decode_qr(img_name):
    qr = QR()

    if qr.decode(img_name):
        return qr.data.split(' ')[-1].encode('utf-8')
    else:
        return False
Beispiel #14
0
 def read(self):
     myCode = QR()
     print(myCode.decode_webcam())
     #print(myCode.data)
     #print(myCode.data_type)
     #print(myCode.data_to_string())
     return myCode.data_to_string
Beispiel #15
0
 def read(self):
     myCode = QR()
     print(myCode.decode_webcam())
     #print(myCode.data)
     #print(myCode.data_type)
     #print(myCode.data_to_string())
     return myCode.data_to_string
Beispiel #16
0
def allocate_qrcode(tag, prefix):
    qr = QR(data=tag, pixel_size=4)
    qr.encode()

    path = qr.filename
    f = get_qrcode_filename(tag, prefix)
    os.system("mkdir -p qrcodes; cp {} qrcodes/{}".format(path, f))
    return (f)
Beispiel #17
0
def decode_image(filename="default.png"):
    """default.png is a sample image. for more qr code images, see http://qrcode.kaywa.com/"""
    my_code = QR(filename=os.path.dirname(os.path.abspath(__file__)) + "/" + filename)
    if my_code.decode():
        print my_code.data
        return my_code.data
    else:
        return None
Beispiel #18
0
def decodeKey(file):
    decCode = QR(filename=file)
    if decCode.decode():
        key = decCode.data
        int_key = []
        for b in key.split('/'):
            int_key.append(int(b))
        return int_key
Beispiel #19
0
	def get(self, path):
		home_url = options.home_url
		if home_url.startswith("http://"):
			home_url = home_url[7:]
		q=QR(u""+home_url+"/auth/"+path)
		q.encode()
		self.set_header("Content-Type", "image/gif")
		self.write(open(q.filename).read())
Beispiel #20
0
def decodeKey(file):
	decCode = QR(filename=file)
	if decCode.decode():
		key = decCode.data
		int_key = []
		for b in key.split('/'):
			int_key.append(int(b))
		return int_key 
Beispiel #21
0
def decodeAES(key, file):
	if isinstance(key, str):
		int_key = hexToKey(key)
	elif isinstance(key, list):
		int_key = key[:]
	AESqr = QR(filename=file)
	if AESqr.decode():
		plaintext = dAES.decrypt(AESqr.data, int_key)
	return plaintext
Beispiel #22
0
def decodeAES(key, file):
    if isinstance(key, str):
        int_key = hexToKey(key)
    elif isinstance(key, list):
        int_key = key[:]
    AESqr = QR(filename=file)
    if AESqr.decode():
        plaintext = dAES.decrypt(AESqr.data, int_key)
    return plaintext
Beispiel #23
0
def __init__(
self, data=u'NULL', pixel_size=3, level='L', margin_size=4, data_type=u'text', filename=None
):

	from qrtools import QR
	myCode = QR(data=u"Simpledata", pixel_size=10)
	myCode.encode()
	print myCode.filename
	print myCode
def write(building, washer):
    string = building + " : " + washer
    u = unicode(string, "utf-8")

    my_QR = QR(data=u, pixel_size=10)
    my_QR.encode()

    # command to move the QR code to the desktop
    os.system("sudo mv " + my_QR.filename + " ~/Desktop")
Beispiel #25
0
def decodeQRCode(fileName, path=""):
    """expects fileName is .jpg"""
    myCode = QR(filename = path + fileName)
    if myCode.decode():
        print "decoderen qr gelukt"
        return myCode.data
    else:
        print "decoderen qr gefaald"
        return False
Beispiel #26
0
def qr_read(request):
    data_value=json.loads(request.body)
    print(data_value)
    my_QR = QR(filename = "/opt/lampp/htdocs/qrcodes/"+data_value['name'])

    # decodes the QR code and returns True if successful
    my_QR.decode()

    # prints the data
    return HttpResponse(my_QR.data)
Beispiel #27
0
def get_qr_code(image_filename):
    """ Return True if the given image is a front page (based on a QR code)
    or false otherwise. The QR code must contain FRONT_PAGE_CODE to indicate
    that the page is a front page. """
    scanner = QR(filename=image_filename)
    if scanner.decode():
        data = scanner.data
        return data
    else:
        return None
Beispiel #28
0
	def extract(self):
		pnr=raw_input("Enter PNR no.:\t")
		# Python 2.x program to Scan and Read a QR code
		my_QR = QR(filename = pnr+".png")
		 
		# decodes the QR code and returns True if successful
		my_QR.decode()
		 
		# prints the data
		print my_QR.data
Beispiel #29
0
def uploaded(file):
		from qrtools import QR
		myCode = QR(filename=file)
		if myCode.decode():
			print myCode.data
			g.db.execute('insert into vehicle (p_num,dataa) values(?,?)',[session.get('id'),myCode.data])
			g.db.commit()
			return redirect(url_for('landing'))
		
		return 'Something went wrong'
Beispiel #30
0
def get_qr_code(image_filename):
    """ Return True if the given image is a front page (based on a QR code)
    or false otherwise. The QR code must contain FRONT_PAGE_CODE to indicate
    that the page is a front page. """
    scanner = QR(filename=image_filename)
    if scanner.decode():
        data = scanner.data
        return data
    else:
        return None
Beispiel #31
0
def read_qrcode_and_open_the_web():
	print "\n\nDecoding QR Code ..."

	qr = QR(filename = "qr-code.png")
	qr.decode()

	print "Decoded data: "
	print qr.data

	return qr.data
def read():
    # Python 2.x program to Scan and Read a QR code
    my_QR = QR(filename="/home/jumana/Desktop/second.png")

    # decodes the QR code and returns True if successful
    my_QR.decode()

    val = my_QR.data

    # prints the data
    print val
Beispiel #33
0
def readtextfromQR():
    try :
        from qrtools import QR
        from codecs import BOM_UTF8
    except ImportError :
        print('Module qrtools missing! No QR-code import possible!')
        raise 
    myCode = QR()
    myCode.decode_webcam()
    key = myCode.data_to_string().strip()
    return key[len(BOM_UTF8):] # fixes zbar!
Beispiel #34
0
def readQR():
    future = time.time() + 10
    ret = 'NULL'
    while time.time() < future and ret == 'NULL':
        myCode = QR()
        myCode.decode_webcam()
        ret = myCode.data

    if ret == 'NULL':
        return -1
    return ret
Beispiel #35
0
def readQR():
    future = time.time() + 10
    ret = "NULL"
    while time.time() < future and ret == "NULL":
        myCode = QR()
        myCode.decode_webcam()
        ret = myCode.data

    if ret == "NULL":
        return -1
    return ret
Beispiel #36
0
    def Authentication(self,l):
        
        count =0
        myCode=QR(filename=u"/home/pi/Desktop/image.png")
        myCode.decode()
	n=myCode.data_to_string() 
        for a in l:
            for y in a:
		x=y.encode("utf-8")
                if x == n[3:]:
                    count+=1
        return count
Beispiel #37
0
 def decodeWebcam(self):
     QtGui.QMessageBox.information(
         self, u"Decode from webcam",
         u"You are about to decode from your webcam. Please put the code in front of your webcam with a good light source and keep it steady. Once you see a green rectangle you can close the window by pressing any key.",
         QtGui.QMessageBox.Ok)
     qr = QR()
     qr.decode_webcam()
     if qr.data_decode[qr.data_type](qr.data) == 'NULL':
         QtGui.QMessageBox.warning(
             self, u"Decoding Failed", u"<p>Oops! no code was found.<br /> \
             Maybe your webcam didn't focus.</p>", QtGui.QMessageBox.Ok)
     else:
         self.showInfo(qr)
def decode():
    """
    Decodes the QR code and returns a list of information
    """
    my_code = QR()
    result = my_code.decode_webcam()
    if result:
        if result[0]:
            now = datetime.now()
            return [result[1], now]
        else:
            return [None, result[1]]
    else:
        return [None, "Failed to initialise webcam"]
Beispiel #39
0
 def decodeWebcam(self):
     vdDialog = VideoDevices()
     if vdDialog.exec_():
         device = vdDialog.videoDevices[
             vdDialog.videoDevice.currentIndex()][1]
         qr = QR()
         qr.decode_webcam(device=device)
         if qr.data_decode[qr.data_type](qr.data) == 'NULL':
             QtWidgets.QMessageBox.warning(
                 self, "Decoding Failed",
                 "<p>Oops! no code was found.<br /> Maybe your webcam didn't focus.</p>",
                 QtWidgets.QMessageBox.Ok)
         else:
             self.showInfo(qr)
Beispiel #40
0
 def decodeWebcam(self):
     vdDialog = VideoDevices()
     if vdDialog.exec_():
         device = vdDialog.videoDevices[vdDialog.videoDevice.currentIndex()][1]
         qr = QR()
         qr.decode_webcam(device=device)
         if qr.data_decode[qr.data_type](qr.data) == "NULL":
             QtGui.QMessageBox.warning(
                 self,
                 self.trUtf8("Decoding Failed"),
                 self.trUtf8("<p>Oops! no code was found.<br /> Maybe your webcam didn't focus.</p>"),
                 QtGui.QMessageBox.Ok,
             )
         else:
             self.showInfo(qr)
Beispiel #41
0
	def get(self, path):
		try:
			if(str(int(path))!=path):
				self.write("Incorect ID")
				return
		except:
			self.write("Incorect ID")
			return
		home_url = options.home_url
		if home_url.startswith("http://"):
			home_url = home_url[7:]
		q=QR(u""+home_url+"/o/"+path)
		q.encode()
		self.set_header("Content-Type", "image/gif")
		self.write(open(q.filename).read())
def read_qr():
    myCode = QR()
    myCode.decode_webcam()
    global search_element
    search_element = myCode.data
    global df
    try:
        df = pd.read_csv('input_data.csv')
    except:
        print('There was an error opening the file!')
        sys.exit()
    global selected_row
    selected_row = df.loc[df['unique_id'] == search_element]
    global adf
    adf = df.drop(df[df.unique_id == search_element].index)
Beispiel #43
0
def get_qr_code(image_name):

    scans_dir = u"scans/"
    codes_dir = u"codes/"

    input_scan_path = scans_dir + image_name + u"-result.jpg"

    qr_code = QR(filename=input_scan_path)

    if qr_code.decode():

        return qr_code.data

    else:

        return None
Beispiel #44
0
 def decodeFile(self, fn=None):
     if not fn:
         fn = unicode(
             QtGui.QFileDialog.getOpenFileName(
                 self, self.trUtf8("Open QRCode"), filter=self.trUtf8("Images (*.png *.jpg);; All Files (*.*)")
             )
         )
     if os.path.isfile(fn):
         qr = QR(filename=fn)
         if qr.decode():
             self.showInfo(qr)
         else:
             QtGui.QMessageBox.information(
                 self,
                 self.trUtf8("Decode File"),
                 unicode(self.trUtf8("No QRCode could be found in file: <b>%s</b>.")) % fn,
             )
def qrimg(lines,filename):
    lines = unicode(lines, "utf-8")
    img=Image.new("RGBA", (380,380),(255,255,255))
    draw = ImageDraw.Draw(img)
    y_text =8 
    for line in lines.splitlines():
        width, height = font.getsize(line)
        draw.text((10,y_text),line,(0,0,0), font=font)
        y_text +=height
        draw = ImageDraw.Draw(img)
    #img = img.resize((380,420))
    img.save(filename)
    thedata = QR(filename=filename)
    if thedata.decode():
        return thedata.data
    else:
        return "Error: " + filename + " "
Beispiel #46
0
def decodificar():
       
    global status
    global decoded
    noint = False
    code = QR()
    code.decode_webcam()
    pre_decoded = code.data
    decoded_vector = pre_decoded.split('#')
    decoded = decoded_vector[0]
    generarid(archlibros) 
    try:
        int(decoded)
    except ValueError:
        noint = True
    if (decoded != "NULL") and (decoded <= countstr) and (noint != True):
        status = 1
Beispiel #47
0
def qrimg(lines, filename):
    lines = unicode(lines, "utf-8")
    img = Image.new("RGBA", (380, 380), (255, 255, 255))
    draw = ImageDraw.Draw(img)
    y_text = 8
    for line in lines.splitlines():
        width, height = font.getsize(line)
        draw.text((10, y_text), line, (0, 0, 0), font=font)
        y_text += height
        draw = ImageDraw.Draw(img)
    #img = img.resize((380,420))
    img.save(filename)
    thedata = QR(filename=filename)
    if thedata.decode():
        return thedata.data
    else:
        return "Error: " + filename + " "
Beispiel #48
0
def _qr_code(qr_code_data):
    """
        Create QR code.
        @type qr_code_data: string
        @param qr_code_data: Data to encode in the qr code
    """
    if not qr_code_data:
        return "/static/images/default.png"

    qr_code_data = "\n".join(qr_code_data)
    qr_code_data = "mecard:" + qr_code_data
    qr_code = QR(qr_code_data)
    qr_code.encode()
    with open(qr_code.filename) as filename:
        data = filename.read()
        return "data:image/png;base64," + data.encode('base64')
    qr_code.destroy()
Beispiel #49
0
def solve(filename):
    (_, tmp) = tempfile.mkstemp()

    while True:
        qrpic = QR(margin_size=0, filename=filename)
        if qrpic.decode():
            data = qrpic.data
            if len(data) < 32:
                print(data)
                break

            qr_data_to_qr(data, tmp)
            filename = tmp
        else:
            print('Unable to solve', file=sys.stderr)
            break

    os.unlink(tmp)
Beispiel #50
0
    def btnTakePhotoClick(self, event):
        qr = QR()
        i = 0
        while qr.data == "NULL":
        #while i == 0:
            _filename = '/home/pi/cpi/camera' + str(i) + '.jpg'
            camera = picamera.PiCamera()
            camera.resolution = (300, 300)
            camera.capture(_filename)
            print "gecaptured: " + _filename
            z = qr.decode(_filename)
            print z


            
            bm = wx.Image(_filename, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
            
            #bitmap = wx.Bitmap(QR_IMAGE_FILE)
            #bitmap = self.scale_bitmap(bitmap, 300, 300)    
            #control = wx.StaticBitmap(self, -1, bitmap)
            #control.SetPosition((10, 10))
		
            self.imgQROutgoing.SetBitmap(bm)
            self.textImageWhatToDo.Label="Message: " + qr.data
            #self.Refresh()
            self.Update()
            print "refreshed" 
            #im = Image.open('/home/pi/cpi/camera' + str(i) + '.jpg')
            #pho = ImageTk.PhotoImage(im)
            #label = Label(image = pho)
            #label.image = pho
            #label.pack()
            ##root.update()
            ###frame.update()
            #self.ph.image = pho
            
            
            print "bild camera" + str(i) + ".jpg angezeigt"
            time.sleep(1)
            camera.close()
                #qr.destroy()
            i = i + 1
            print "i ist jetzt: " + str(i)
            print "--------------------------------------"
Beispiel #51
0
def encodeKey(key):
    if isinstance(key, str):
        int_key = hexToKey(key)
        myCode = QR(data="/".join(map(str, int_key)), data_type="text")
        myCode.encode()
        return myCode.filename
    elif isinstance(key, list):
        str_key = "/".join(map(str, key))
        myIntCode = QR(data=str_key, data_type="text")
        myIntCode.encode()
        return myIntCode.filename
Beispiel #52
0
 def decodeWebcam(self):
     QtGui.QMessageBox.information(
         self,
         u"Decode from webcam",
         u"You are about to decode from your webcam. Please put the code in front of your webcam with a good light source and keep it steady. Once you see a green rectangle you can close the window by pressing any key.",
         QtGui.QMessageBox.Ok
     )
     qr = QR()
     qr.decode_webcam()
     if qr.data_decode[qr.data_type](qr.data) == 'NULL':
         QtGui.QMessageBox.warning(
             self,
             u"Decoding Failed",
             u"<p>Oops! no code was found.<br /> \
             Maybe your webcam didn't focus.</p>",
             QtGui.QMessageBox.Ok
         )
     else:
         self.showInfo(qr)
Beispiel #53
0
def readqr(data):
        filename = "%s%s.bmp" %(imgpath,str(uuid.uuid4()))
        ##qr mappings
        cmap = {'0': (255,255,255),
                '1': (0,0,0)}

        ## clean up the data
	length = len(data.split("\n"))
        data = data.replace("\n","")

        ##build image
        rawdata = [cmap[letter] for letter in data]
        img = Image.new('RGB', (length, len(data)//length), "white")
        img.putdata(rawdata)
        img.save(filename, 'BMP')

        ##decode image
        myCode = QR(filename=filename)
        if myCode.decode():
                text=myCode.data
                return text.lower()
        else:
                return False
Beispiel #54
0
def main():
    if len(sys.argv) != 2:
        print "FAIL"
        return -1
    qr = QR()
    qr.decode_webcam()
    if qr.data == "NULL":
        print "FAIL"
        return -1
    data = qr.data.split(":", 1)
    if len(data) != 2:
        print "FAIL"
        return -1
    if data[0] != "seed":
        print "NOTSEED"
        return -1
    password = sys.argv[1]
    seed = call("echo \"%s\" | base64 -d | ccat -K %s" % (data[1], password))
    if len(seed) != 32:
        print "BADSEED"
        return -1
    print seed
    return 0
Beispiel #55
0
    def check_image_qr(self, path):
        myCode = QR(filename=path)
        if myCode.decode():
            self.qr_link = myCode.data_to_string()
            self.copy_link.set_sensitive(True)
            alert = NotifyAlert(10)
            alert.props.title = _("Code found")
            alert.props.msg = _("Click on toolbar button for "
                "copy link to clipboard.")
            alert.connect("response", lambda x,
                y: self.activity.remove_alert(x))
            self.activity.add_alert(alert)
        else:
            self.qr_link = None
            self.copy_link.set_sensitive(False)
            alert = NotifyAlert(10)
            alert.props.title = _("Code not found")
            alert.props.msg = _("Try again, please focus the Qr "
                "Code in the camera.")
            alert.connect("response", lambda x,
                y: self.activity.remove_alert(x))
            self.activity.add_alert(alert)

        self.stop_play.set_sensitive(False)
Beispiel #56
0
def encodeAES(key, plain, level='L'):
	if isinstance(key, str):
		int_key = hexToKey(key)
	elif isinstance(key, list):
		int_key = key[:]
	ciphertext = dAES.encrypt(plain, int_key)
	if len(ciphertext) > 2952:
		print(colors.FAIL+"resulting cipher text is too long ("+str(len(ciphertext))+" characters) to fit in QR code (Even at error correction level L, max length: 2952)"+colors.ENDC)
		exit(0)
	if not level == 'L':
		if level == 'M' and len(ciphertext) > 2330:
			print(colors.FAIL+"resulting cipher text is too long ("+str(len(ciphertext))+" characters) to fit in QR code at error correction level M (max length: 2330)"+colors.ENDC)
			exit(0)
		elif level == 'Q' and len(ciphertext) > 1662:
			print(colors.FAIL+"resulting cipher text is too long ("+str(len(ciphertext))+" characters) to fit in QR code at error correction level Q (max length: 1662)"+colors.ENDC)
			exit(0)
		elif level == 'H' and len(ciphertext) > 1272:
			print(colors.FAIL+"resulting cipher text is too long ("+str(len(ciphertext))+" characters) to fit in QR code at error correction level Q (max length: 1662)"+colors.ENDC)
			exit(0)
	AESqr = QR(data=ciphertext, data_type="text", level=level)
	if AESqr.encode() == 0:
		return AESqr.filename
	else:
		print(colors.FAIL+"um..."+colors.ENDC)
Beispiel #57
0
def encodeKey(key):
	if isinstance(key, str):
		int_key = hexToKey(key)
		myCode = QR(data="/".join(map(str, int_key)),data_type="text")
		myCode.encode()
		return myCode.filename
	elif isinstance(key, list):
		str_key = "/".join(map(str, key))
		myIntCode = QR(data=str_key,data_type="text")
		myIntCode.encode()
		return myIntCode.filename
Beispiel #58
-1
def main():
    qr = QR()
    qr.decode_webcam()
    if qr.data == "NULL":
        print "FAIL"
        return -1
    data = qr.data.split(":")
    if len(data) != 2:
        print "FAIL"
        return -1
    if data[0] != "bitcoin":
        print "NOTADDR"
        return -1
    print data[1]
    return 0