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")
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
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!
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
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 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)
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)
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
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
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 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
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"]
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...'
def decode_from_webcam(): my_code = QR() decoded = my_code.decode_webcam() return decoded
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
from qrtools import QR import webbrowser import time myCode = QR() myCode.decode_webcam(lambda data: webbrowser.open(data),device='/dev/video0')
def decode_qr_code(self): qr_reader = QR() qr_reader.decode_webcam(None, "http://192.168.0.20/video.cgi")
from qrtools import QR myCode = QR() print (myCode.decode_webcam())
def scan_qr(self): """Scans a QR-Code and returns the data as a string""" qr = QR() qr.decode_webcam() return str(qr.data)
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 + "~")
def decodeWebcam(self): qr = QR() qr.decode_webcam() if qr.data_to_string() != 'NULL':
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