Пример #1
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")
Пример #2
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
Пример #3
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!
Пример #4
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
Пример #5
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)
Пример #6
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)
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)
Пример #8
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)
Пример #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 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
Пример #11
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
Пример #12
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)
Пример #13
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
Пример #14
0
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"]
Пример #15
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
Пример #16
0
            resultColor = color
            #print 'new result: ',resultColor #debug print

    return resultColor


# main code:

myCode = QR()
myCode.set_timeOut(5)
maxTimeoutCount = 3
timeoutCount = 0

list = []
while not list:
    myCode.decode_webcam()
    list = myCode.get_symList()
    if not list:
        print 'failed to read a code, trying again...'
        timeoutCount += 1
        if timeoutCount >= maxTimeoutCount:
            print 'max timouts exceeded. now exiting'
            break
        else:
            continue
    print 'successful read'
    print 'Raw List: ', list
    filterColors(list)
    print 'Filtered List: ', list
    if not list:
        print 'Filtered list is empty, retrying...'
Пример #17
0
def decode_from_webcam():
    my_code = QR()
    decoded = my_code.decode_webcam()
    return decoded
Пример #18
0
def get_qr_content(with_gui=False, manual_detect=False):

    detected = False
    camera.init()
    if not len(camera.list_cameras()):
        print("No camera detected!")
        sys.exit(-1)
    cam = camera.Camera(camera.list_cameras()[config.camera_number - 1])
    size = cam.get_size()
    width, height = size

    if not manual_detect:
        sys.stdout.write("QR detection started, wait several seconds...")
        sys.stdout.flush()
        cam.start()

        if with_gui:
            screen = pygame.display.set_mode(cam.get_size())
            pygame.display.set_caption("Check QR recognize")
    else:
        with_gui = True
        print("QR detection through GUI, press any key when green line flash")

    data = 0
    while not detected:
        try:

            if manual_detect:
                qr = QR()
                qr.decode_webcam()
                data = qr.data

            else:
                img = cam.get_image()

                # we can use file buffer for recognition
                # pygame.image.save(img, "file.jpg")
                # pil_string_image = Image.open("file.jpg").convert('L').tostring()

                pygame_img = pygame.image.tostring(img, 'RGB', False)
                pil_string_image = Image.fromstring(
                    'RGB', size, pygame_img).convert('L').tostring()

                if with_gui:
                    screen.blit(img, (0, 0))
                    pygame.display.flip()  # display update

                zbar_image = zbar.Image(width, height, 'Y800',
                                        pil_string_image)

                scanner = zbar.ImageScanner()
                scanner.parse_config('enable')
                data = scanner.scan(zbar_image)

                sys.stdout.write('.')
                sys.stdout.flush()

                for qr in zbar_image:
                    if data:
                        "Additional QR recognized!"
                    data = qr.data

            if data:
                print("\nRecognized: `{}`".format(data))
                detected = True

        except Exception as e:
            print("Error! " + str(e))
            pass
        finally:
            time.sleep(config.qr_scan_waiting)

    if not manual_detect:
        pygame.display.quit()
        cam.stop()

    return 0 if data == "NULL" else data
Пример #19
0
from qrtools import QR
import webbrowser
import time
myCode = QR()
myCode.decode_webcam(lambda data: webbrowser.open(data),device='/dev/video0')


    





Пример #20
0
 def decode_qr_code(self):
     qr_reader = QR()
     qr_reader.decode_webcam(None, "http://192.168.0.20/video.cgi")
Пример #21
0
from qrtools import QR


myCode = QR()
print (myCode.decode_webcam())
Пример #22
0
 def scan_qr(self):
     """Scans a QR-Code and returns the data as a string"""
     qr = QR()
     qr.decode_webcam()
     return str(qr.data)         
Пример #23
0
import qrtools
from qrtools import QR
myCode = QR()
print myCode.decode_webcam()
print myCode.data
print myCode.data_type
print myCode.data_to_string()
from email.MIMEBase import MIMEBase
from email import encoders

data = pd.read_csv("EmployeeList.csv")

option = 0
name = 0
ID_found = False
manager = False

while ID_found == False:
    count = 0
    global myCode
    global scanner
    myCode = QR()
    scanner = myCode.decode_webcam()
    ID = myCode.data
    for i in range((len(data["ID"]))):
        if data["ID"][i] == ID:
            name = (data["Name"][i])
            ID_found = True
            manager = (data["Role"][i])
            break
        else:
            count = count + 1

    if ID_found == False:
        print("ID Not Found, Please Input Again")

print("~" + 'Welcome' + " " + name + "~")
Пример #25
0
def decodeWebcam(self):
        qr = QR()
        qr.decode_webcam()
        if qr.data_to_string() != 'NULL':
Пример #26
-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