Пример #1
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
Пример #2
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()
Пример #3
0
def check_qr(file):
    qr = QR()
    if qr.decode(file):
        print qr.data
        return True

    return False
Пример #4
0
def decode_qr(img_name):
    qr = QR()

    if qr.decode(img_name):
        return qr.data.split(' ')[-1].encode('utf-8')
    else:
        return False
Пример #5
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)
Пример #6
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")
Пример #7
0
 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")
Пример #8
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
Пример #9
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
Пример #10
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)
Пример #11
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)
Пример #12
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
Пример #13
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
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")
Пример #15
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)
Пример #16
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
Пример #17
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
Пример #18
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'
Пример #19
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
Пример #21
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
Пример #22
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!
Пример #23
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
Пример #24
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)
Пример #25
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)
Пример #26
0
    def takein(self):

        self.update_xml('')
        return




        self.turn_red()

        '''try:
            find=os.remove("/home/pi/Desktop/project/ikart/qw.jpeg")
        except OSError:
            pass'''

        ''' capture image'''
        try :
            '''fswebcam -d /dev/video0  -S 2 -s brightness=60% -s Contrast=15%  -s Gamma=50%  -p YUYV -r 1280x720 --jpeg 80 -s Sharpness=40% -s Saturation=15%   --title "New Zealand - Wellington - Tawa"  $DIR/$filename'''
            os.system('fswebcam -r 100x100  --jpeg 1000 qw.jpeg')

        except IOError:
            time.sleep(1)
            os.system('fswebcam -r 300x300 --jpeg 500 kqrcode.jpeg')

        '''sleep to recover image'''
        time.sleep(4)

        '''extract qrcode'''
        try :
            myCode = QR(filename="/home/pi/Desktop/project/ikart/kqrcode.jpeg")
            if myCode.decode():
                print myCode.data
                print myCode.data_type
                print myCode.data_to_string()

                m=myCode.data_to_string()
                print (m)

                '''update xml '''
                self.update_xml(m)



                '''display details on lED'''
                self.displaydetails()
        except IOError as e:
            print(e,'sfhgdfhsdhdsh',myCode,str(myCode))
            return 0
        pass
Пример #27
0
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)
Пример #28
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
Пример #29
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 + " "
Пример #30
-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