def identify(ldev): fps.SetLED(True) ctime = time.time() print 'Place finger on sensor for identification, please' #wait for the user to place their finger on the scanner while fps.IsPressFinger()==False: newtime = time.time()-ctime FPS.delay(.5) if (newtime) > 5.0: print '5 seconds' USB.writebuf(ldev,'$FPIDEN,ENDED') fps.SetLED(False) return USB.writebuf(ldev,'$FPIDEN,WORKING') #capture an image and check if it is in the database fps.CaptureFinger(False) ID=fps.Identify1_N()#Verify1_1(0) #time.sleep(2) #print 'ERR %d' % ID #if the user exists and the ID# does not exceed 200, welcome. else, enroll if ID<200: print 'ID:'+ str(ID) print 'Welcome, User #%d'% (queue.returnfileID(ID)) #return queue.phalangelist[ID].fileID USB.writebuf(ldev,('$FPIDEN,SUCC,'+str(queue.returnfileID(ID)))) else: print 'User not found' USB.writebuf(ldev,'$FPIDEN,ERR,NOTFOUND') time.sleep(1) fps.SetLED(False) return
def DeleteEverything(fps): lcd.clear() lcd.message("Wiping all Data.") FPS.delay(0.5) fps.DeleteAll() lcd.clear() lcd.message("All Users' Data\nDeleted.")
def identify(fps, mode, num): print 'Place finger on sensor for identification, please' #wait for the user to place their finger on the scanner while fps.IsPressFinger() == False: FPS.delay(1) if mode == 0: #capture an image and check if it is in the database fps.CaptureFinger(False) ID = fps.Identify1_N() #Verify1_1(0) #time.sleep(2) #print 'ERR %d' % ID #if the user exists and the ID# does not exceed 200, welcome. else, enroll if ID < 200: print 'Welcome, User #%d' % (ID + 1) else: print 'User not found' time.sleep(1) enroll(fps) elif mode == 1: #capture an image and check if it is in the database fps.CaptureFinger(False) ID = fps.Verify1_1(num) #time.sleep(2) #print 'ERR %d'% ID #if the user exists and the ID# does not exceed 200, welcome. else, enroll if ID == 0: print 'Welcome, User #%d' % (num + 1) else: print 'User mismatch, check database for a match' time.sleep(1) identify(fps, 0, 0)
def fps_init(): print 'initializing fingerpirnt scanner' fps = FPS.FPS_GT511C3(device_name='/dev/ttyAMA0',baud=9600,timeout=2,is_com=False) fps.UseSerialDebug = True fps.SetLED(False) FPS.delay(1) fps.DeleteAll() print 'done.' return fps
def Verify(fps,id): imgRaw = GetRawImg(fps) if imgRaw.__len__()>0: FPS.delay(3) img = processImage('fingerprint_verify_'+id+'.raw',imgRaw) savedImg1 = SavedImg('fingerprint'+id+'.raw') return 'Verified is: %s' % (str(matchBif(img, savedImg1))) else: return 'Not Verified'
def LegacyEnroll(fps): ''' Enroll test ''' enrollid = SlotFinder() if enrollid < 3000: #press finger to Enroll enrollid tkMessageBox.showinfo("", "PLACE YOUR FINGER TO ENROLL") print 'Press finger to Enroll %s' % str(enrollid) fps.EnrollStart(enrollid) while not fps.IsPressFinger(): FPS.delay(3) iret = 0 if fps.CaptureFinger(True): #remove finger print 'remove finger' fps.Enroll1() while not fps.IsPressFinger(): FPS.delay(3) #Press same finger again print 'Press same finger again' while not fps.IsPressFinger(): FPS.delay(3) if fps.CaptureFinger(True): #remove finger print 'remove finger' fps.Enroll2() while not fps.IsPressFinger(): FPS.delay(3) #Press same finger again print 'press same finger yet again' while not fps.IsPressFinger(): FPS.delay(3) if fps.CaptureFinger(True): #remove finger iret = fps.Enroll3() if iret == 0: tkMessageBox.showinfo("", "ENROLLING SUCCESSFUL") print 'Enrolling Successfull' addrprivate = RSA.generate(1024) addrpublic = addrprivate.publickey() PrivKey = addrprivate.exportKey() PublKey = addrpublic.exportKey() dBaseSync(enrollid, PrivKey, PublKey) else: tkMessageBox.showinfo("", "ENROLLING FAILED") print 'Enrolling Failed with error code: %s' % str( iret) else: print 'Failed to capture third finger' else: print 'Failed to capture second finger' else: print 'Failed to capture first finger' else: print 'Failed: enroll storage is full'
def LegacyEnroll(): ''' Enroll test ''' enrollid = 0 okid = False #search for a free enrollid, you have max 200 while not okid and enrollid < 200: okid = fps.CheckEnrolled(enrollid) if not okid: enrollid += 1 if enrollid < 200: #press finger to Enroll enrollid print 'Press finger to Enroll %s' % str(enrollid) fps.EnrollStart(enrollid) while not fps.IsPressFinger(): FPS.delay(1) iret = 0 if fps.CaptureFinger(True): #remove finger print 'remove finger' fps.Enroll1() while not fps.IsPressFinger(): FPS.delay(1) #Press same finger again print 'Press same finger again' while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): #remove finger print 'remove finger' fps.Enroll2() while not fps.IsPressFinger(): FPS.delay(1) #Press same finger again print 'press same finger yet again' while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): #remove finger iret = fps.Enroll3() if iret == 0: print 'Enrolling Successfull' else: print 'Enrolling Failed with error code: %s' % str( iret) else: print 'Failed to capture third finger' else: print 'Failed to capture second finger' else: print 'Failed to capture first finger' else: print 'Failed: enroll storage is full'
def GetRawImg(fps): ret = bytes() if fps.SetLED(True) and fps.IsPressFinger(): if fps.GetRawImage(): response = fps._lastResponse.RawBytes[16:] print fps.serializeToSend(response) print u'Size %s' % str(response.__len__()) ret = bytes(response) FPS.delay(0.1) fps.SetLED(False) return ret
def LegacyEnroll(fps): ''' Enroll test ''' enrollid=0 okid=False #search for a free enrollid, you have max 200 while not okid and enrollid < 200: okid = fps.CheckEnrolled(enrollid) if not okid: enrollid+=1 if enrollid <200: #press finger to Enroll enrollid print 'Press finger to Enroll %s' % str(enrollid) fps.EnrollStart(enrollid) while not fps.IsPressFinger(): FPS.delay(1) iret = 0 if fps.CaptureFinger(True): #remove finger print 'remove finger' fps.Enroll1() while not fps.IsPressFinger(): FPS.delay(1) #Press same finger again print 'Press same finger again' while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): #remove finger print 'remove finger' fps.Enroll2() while not fps.IsPressFinger(): FPS.delay(1) #Press same finger again print 'press same finger yet again' while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): #remove finger iret = fps.Enroll3() if iret == 0: print 'Enrolling Successfull' else: print 'Enrolling Failed with error code: %s' % str(iret) else: print 'Failed to capture third finger' else: print 'Failed to capture second finger' else: print 'Failed to capture first finger' else: print 'Failed: enroll storage is full'
def identify1_n(fps): fps.SetLED(True) sock.sendall('Press finger\n') while not fps.IsPressFinger(): FPS.delay(0.1) print 'Press finger' if fps.CaptureFinger(True): time.sleep(0.1) print"remove finger" sock.sendall('Remove finger\n') id_identify=fps.Identify1_N() print "id is",id_identify sock.sendall('id is :'+str(id_identify)) fps.SetLED(True)
def __init__(self): pygame.init() self.screen = pygame.display.set_mode([640, 480]) self.sysfont = pygame.font.SysFont(None, 60) self.life_image = pygame.image.load("image/heart.png") self.start() self.running = True fps = FPS() while self.running: fps.start() for event in pygame.event.get(): if event.type == pygame.QUIT or (event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE): self.running = False self.update() pygame.display.update() fps.end() delay = int(FRAME_RATE - fps.get_time() * 1000) if delay < 0: delay = 0 pygame.time.delay(delay) # 60 FPS pygame.quit()
def Loggin(fps): ''' Log in and retrieve ID ''' enrollid = SlotFinder() while not fps.IsPressFinger(): FPS.delay(3) iret = 0 if fps.CaptureFinger(True): tkMessageBox.showinfo("", "PLACE YOUR FINGER") #remove finger print 'remove finger' iret = fps.Identify1_N() print(iret) vs = str(iret) idkey = open('/home/pi/python-GT511c3/Session.idk', 'w') idkey.write(vs) idkey.close()
def Verify1_1(fps): fps.SetLED(True) id=sock.recv(1024) id=int(id[0]) sock.sendall('Press finger\n') while not fps.IsPressFinger(): FPS.delay(0.1) print 'Press finger' if fps.CaptureFinger(True): time.sleep(0.1) if fps.Verify1_1(id)==0: print"yes!!id and fingerprint matched." sock.sendall("yes!!id and fingerprint matched.") else: print"oops!!id and fingerprint not matched." sock.sendall("oops!!id and fingerprint not matched.") fps.SetLED(True)
def Delete(fps): lcd.clear() lcd.message("Press Finger\nTo Remove") while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): lcd.clear() lcd.message("Indentifying..") UserID = fps.Identify1_N() if UserID < 200 and UserID >= 0: FPS.delay(1) fps.DeleteID(UserID) lcd.clear() lcd.message("Identity #%s\nRemoved." % str(UserID)) print "Identity %s Removed." % str(UserID) else: lcd.clear() lcd.message("Fingerprint\nnot found.")
def Verify(fps): lcd.clear() lcd.message("Press Finger\nTo Verify") # Verify Test Function ID = -1 print "Press Finger to Scanner." while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): lcd.clear() lcd.message("Identifying..") FPS.delay(0.5) ID = fps.Identify1_N() if ID < 200 and ID >= 0: print "Welcome, User #%s" % str(ID) lcd.clear() lcd.message("Welcome,\nUser #%s" % str(ID)) else: lcd.clear() lcd.message("Fingerprint\nnot found.") print "Fingerprint not found. \n"
def Finger_PrintSM(msg): fps = FPS.FPS_GT511C3(device_name='/dev/ttyAMA0',baud=9600,timeout=2,is_com=False) fps.UseSerialDebug = True fps.SetLED(True) # Turns ON the CMOS LED FPS.delay(1) # wait 1 second print 'Put your finger in the scan' if not hasattr(Finger_PrintSM,"state"): #Declare intial state Finger_PrintSM.state = IDLE print Finger_PrintSM.state print 'CurState:[' + Finger_PrintSM+']' print 'Cmd:[' + msg + ']' if(Finger_PrintSM.state == IDLE): if(msg == 'First'): Finger_PrintSM.state = GET_FIRST elif(Finger_PrintSM.state == GET_FIRST): if(msg == 'Second'): Finger_PrintSM.state = GET_SECOND elif(Finger_PrintSM.state is GET_SECOND): if(msg == 'Third'): Finger_PrintSM.state = GET_THIRD elif(Finger_PrintSM.state is GET_THIRD): if(msg == 'Finish'): Finger_PrintSM.state = STORE_FINGER elif(Finger_PrintSM.state is STORE_FINGER): print 'About to store finger' Finger_PrintSM.state = IDLE elif(Finger_PrintSM.state is WARNING): print 'Warning' else: print 'unknown state'
def initialize(self): print('Begin') fps = FPS.FPS_GT511C3(device_name='/dev/ttyAMA0', baud=9600, timeout=2, is_com=False) print('Scanner connected') counter = 1 while counter < 5: fps.SetLED(True) time.sleep(2) print('On') fps.SetLED(False) time.sleep(2) print('Off') counter = counter + 1
def LoopCaptureFinger(scanner): while not fps.IsPressFinger(): #verify if the finger is in the scan print 'Place your finger on scanner' FPS.delay(1) print 'Your finger is in the scan' print 'Capture Finger' fingerFLAG = False for i in range(3): print 'Keep Finger Pressed' if fps.CaptureFinger(False): fingerFLAG = True print 'Remove Finger' while fps.IsPressFinger(): FPS.delay(1) break FPS.delay(1) if fingerFLAG: print 'Finger successfully captured' else: print 'Finger was not captured'
def waitUntilPress(fps): while fps.IsPressFinger() == False: FPS.delay(FPS.INTERVAL + 0.03)
# print 'Failed to capture second finger' msg = {'msg': 'Failed to capture second finger'} socketIO.emit('fps_com', msg) else: # print 'Failed to capture first finger' msg = {'msg': 'Failed to capture first finger'} socketIO.emit('fps_com', msg) else: # print 'Failed: enroll storage is full' msg = {'msg': 'Failed: enroll storage is full'} socketIO.emit('fps_com', msg) if __name__ == '__main__': fps = FPS.FPS_GT511C3(device_name=DEVICE_GPIO, baud=9600, timeout=2, is_com=False) fps.UseSerialDebug = False GPIO.setmode( GPIO.BCM ) # programming the GPIO by BOARD pin numbers, GPIO21 is called as PIN21 # Set the LED GPIO number LED = 21 # Set the LED GPIO pin as an output GPIO.setup(LED, GPIO.OUT) # initialize digital pin21 as an output. # fps.UseSerialDebug = True #fps.SetLED(True) # Turns ON the CMOS LED FPS.delay(1) # wait 1 second for initialize finish fps.SetLED(True) # Turns ON the CMOS LED
def enroll(fps): ID = 0 count = 0 unavail = True prevcount = fps.GetEnrollCount() #increment through IDs in chronological order until one is available while unavail == True: unavail = fps.CheckEnrolled(ID) if (unavail == True): ID += 1 fps.EnrollStart(ID) print 'Enrollment takes three scans.' print 'Place finger on sensor, please, user # %d' % (ID + 1) #wait for finger to be present on device while fps.IsPressFinger() == False: FPS.delay(1) capt = fps.CaptureFinger(False) captErr = 0 #if capture was successful, proceed to enroll1 if capt == True: print 'Please remove finger' captErr = fps.Enroll1() #print 'Err Status: %d' % captErr captErr = 0 #wait for finger to be removed from device while fps.IsPressFinger() == True: FPS.delay(1) print 'Place the same finger a second time' #wait for finger to be present again while fps.IsPressFinger() == False: FPS.delay(1) capt = fps.CaptureFinger(False) if capt == True: print 'Please remove finger' captErr = fps.Enroll2() #print 'Err Status: %d' % captErr captErr = 0 while fps.IsPressFinger() == True: FPS.delay(1) print 'Place the same finger a third time' while fps.IsPressFinger() == False: FPS.delay(1) capt = fps.CaptureFinger(False) if capt == True: print 'Please remove finger' captErr = fps.Enroll3() #print 'Err Status: %d' % captErr currcount = fps.GetEnrollCount() if captErr == 0: if currcount != prevcount: print 'You have successfully been enrolled' else: print 'Enrollment unsuccessful. Error code: 2' else: print 'Enrollment unsuccessful. Error code: %d' % captErr #enroll(fps) else: print 'Enrollment unsuccessful, did not capture third finger.' else: print 'Enrollment unsuccessful, did not capture second finger.' else: print 'Enrollment unsuccessful, did not capture first finger.'
#Press same finger again print 'press same finger yet again' while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): #remove finger iret = fps.Enroll3() if iret == 0: print 'Enrolling Successfull' else: print 'Enrolling Failed with error code: %s' % str( iret) else: print 'Failed to capture third finger' else: print 'Failed to capture second finger' else: print 'Failed to capture first finger' else: print 'Failed: enroll storage is full' if __name__ == '__main__': FPS.FPS_GT511C3(device_name='/dev/ttyAMA0', baud=9600, timeout=2, is_com=False) #settings for raspberry pi GPIO fps.Open() if fps.SetLED(True): LegacyEnroll()
Step 3: Connect the VCC pin of the fingerprint GTC511C3 to VCC 3,3 in GPIO Step 4: Connect the Ground pin of fingerprint GT511C3 to ground pin in GPIO This may be works fine, if don't, try to change the fingerprint baud rate with baud_to_115200.py sample code ''' import FPS, sys if __name__ == '__main__': fps = FPS.FPS_GT511C3(device_name='/dev/ttyAMA0',baud=9600,timeout=2,is_com=False) fps.UseSerialDebug = True fps.SetLED(True) # Turns ON the CMOS LED FPS.delay(1) # wait 1 second print 'Put your finger in the scan' counter = 0 # simple counter for wait 10 seconds while counter < 10: if fps.IsPressFinger(): #verify if the finger is in the scan print 'Your finger is in the scan' fps.SetLED(False) # Turns OFF the CMOS LED break else: FPS.delay(1) #wait 1 second counter = counter + 1 fps.Close() # Closes serial connection
def __init__(self, vid_path, src=0, src2=1, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) ########################################################### ########################################################### ########################################################### #Camera params self.counter = 0 self.fps = FPS() self.sp = vid_path self.stream = cv2.VideoCapture(src) self.stream2 = cv2.VideoCapture(src2) self.default_fps = self.stream.get(cv2.CAP_PROP_FPS) self.default_fps2 = self.stream2.get(cv2.CAP_PROP_FPS) self.cam_size = (int(self.stream.get(cv2.CAP_PROP_FRAME_WIDTH)), int(self.stream.get(cv2.CAP_PROP_FRAME_HEIGHT))) self.cam_size2 = (int(self.stream2.get(cv2.CAP_PROP_FRAME_WIDTH)), int(self.stream2.get(cv2.CAP_PROP_FRAME_HEIGHT))) self.writer = cv2.VideoWriter(self.sp + 'outputVid.avi', cv2.VideoWriter_fourcc(*'XVID'), self.default_fps, self.cam_size) self.writer2 = cv2.VideoWriter(self.sp + 'outputVid2.avi', cv2.VideoWriter_fourcc(*'XVID'), self.default_fps2, self.cam_size2) self.cam_ind = src self.cam_ind2 = src2 self.stopped = False ########################################################### ########################################################### ########################################################### #GUI configuration self.disply_width = 500 self.display_height = 350 self.setWindowTitle("Qt live label demo") self.layout_base = QVBoxLayout() self.layout_h = QHBoxLayout() self.camera1 = QLabel("webcam1") self.camera2 = QLabel("webcam2") start_b = QPushButton("Start Video") stop_b = QPushButton("Stop Video") start_b.pressed.connect(self.start_record) stop_b.pressed.connect(self.stop_record) self.layout_h.addWidget(self.camera1) self.layout_h.addWidget(self.camera2) self.layout_base.addWidget(start_b) self.layout_base.addWidget(stop_b) self.layout_base.addLayout(self.layout_h) self.layout_h.setSpacing(15) self.widget = QWidget() self.widget.setLayout(self.layout_base) self.setCentralWidget(self.widget) self.camera1.resize(self.disply_width, self.display_height) self.camera2.resize(self.disply_width, self.display_height) self.show() self.threadpool = QThreadPool() print("Multithreading with maximum %d threads" % self.threadpool.maxThreadCount()) print("Cam 1 fps&size:", self.default_fps, self.cam_size) print("Cam 2 fps&size:", self.default_fps2, self.cam_size2) self.worker = Worker() self.timer = QTimer() self.timer.setInterval(1000) self.timer.timeout.connect(self.recurring_timer) self.timer.start()
def main(): fps = FPS.FPS_GT511C3( device_name="/dev/ttyAMA0", baud=9600, timeout=2, is_com=False ) # settings for raspberry pi GPIO fps.Open() kp = keypad() digit = None # Loop while waiting for a keypress WelcomeMessage() digit = kp.getKey() if digit == 1: if fps.SetLED(True): Verify(fps) FPS.delay(2) elif digit == 2: if fps.SetLED(True): Enroll(fps) FPS.delay(2) elif digit == 3: if fps.SetLED(True): Delete(fps) FPS.delay(2) elif digit == 4: UserStats(fps) elif digit == 0: lcd.clear() lcd.message("Don't just\npress buttons.") FPS.delay(0.5) digit = kp.getKey() if digit == 8: lcd.clear() lcd.message("Seriously, stop\ndoing that.") FPS.delay(0.5) digit = kp.getKey() if digit == 5: lcd.clear() lcd.message("I'm Serious! Not\none more button!") FPS.delay(0.5) digit = kp.getKey() if digit == 2: lcd.clear() lcd.message("NO! That button\ndeletes all the-") time.sleep(2) DeleteEverything(fps) elif digit == 0: lcd.clear() lcd.message("~~~~~~~~~~~~~~~~") FPS.delay(0.5) digit = kp.getKey() if digit == 0: lcd.clear() lcd.message("\n~~~~~~~~~~~~~~~~") FPS.delay(0.5) digit = kp.getKey() if digit == 0: lcd.clear() lcd.message("POWER OPTIONS\nOFF=1 | RSET=2") FPS.delay(0.5) digit = kp.getKey() POWERFUNC(digit) else: lcd.clear() lcd.message("Invalid Input\nTry Again") time.sleep(1.5) print digit # return digit fps.SetLED(False) FPS.delay(1) fps.Close()
# do a bit of cleanup cv2.destroyAllWindows() stream.close() rawCapture.close() camera.close() """ # created a *threaded *video stream, allow the camera sensor to warmup, # and start the FPS counter print("[INFO] sampling THREADED frames from `picamera` module...") vs = PiVideoStream().start() time.sleep(2.0) fps = FPS.FPS().start() # loop over some frames...this time using the threaded stream while fps._numFrames < args["num_frames"]: # grab the frame from the threaded video stream and resize it # to have a maximum width of 400 pixels frame = vs.read() #frame = imutils.resize(frame, width=400) # check to see if the frame should be displayed to our screen if args["display"] > 0: cv2.imshow("Frame", frame) key = cv2.waitKey(1) & 0xFF # update the FPS counter fps.update()
def waitUntilRelease(fps): while fps.IsPressFinger() == True: FPS.delay(FPS.INTERVAL + 0.03)
def Enroll(fps,id): imgRaw = GetRawImg(fps) if imgRaw.__len__()>0: FPS.delay(3) SaveImage('fingerprint'+id+'.raw', imgRaw) """
''' Created on 08/04/2014 @author: jeanmachuca SAMPLE CODE: This is for to change the fingerprint baud rate to 9600 Executes this script only once ''' import FPS, sys DEVICE_GPIO = '/dev/ttyAMA0' DEVICE_LINUX = '/dev/cu.usbserial-A601EQ14' DEVICE_MAC = '/dev/cu.usbserial-A601EQ14' DEVICE_WINDOWS = 'COM3' FPS.BAUD = 115200 #initial baud rate FPS.DEVICE_NAME = DEVICE_MAC if __name__ == '__main__': fps = FPS.FPS_GT511C3(device_name=DEVICE_MAC, is_com=True) fps.UseSerialDebug = True fps.ChangeBaudRate(9600) fps.Close() pass
def enroll_ID(fileID,ldev): ## if queue.returnscannerID(fileID) == -1: ## print 'already exists' ## return ctime = 0 ID=0;count=0 unavail=True prevcount=fps.GetEnrollCount() #increment through IDs in chronological order until one is available while unavail==True: unavail=fps.CheckEnrolled(ID) if(unavail==True): ID+=1 fps.EnrollStart(ID) #wait for finger to be present on device FPS.delay(1) print 'Enrollment takes three scans.' print 'Place finger on sensor, please, user # %d' % (ID+1) USB.writebuf(ldev,'$FPENROLL,EN1') fps.SetLED(True) ctime = time.time() if fps.IsPressFinger(): FPS.delay(.5) while fps.IsPressFinger()==False: newtime = time.time()-ctime FPS.delay(.5) if (newtime) > 5.0: print '5 seconds' USB.writebuf(ldev,'$FPENROLL,EN1,TIMEOUT') fps.SetLED(False) return capt=fps.CaptureFinger(True) captErr=0 #if capture was successful, proceed to enroll1 if capt==True: print 'Please remove finger' USB.writebuf(ldev,'$FPENROLL,RM1') captErr=fps.Enroll1() #print 'Err Status: %d' % captErr captErr=0 #wait for finger to be removed from device while fps.IsPressFinger()==True: FPS.delay(1) print 'Place the same finger a second time' USB.writebuf(ldev,'$FPENROLL,EN2') #wait for finger to be present again ctime = time.time() while fps.IsPressFinger()==False: newtime = time.time()-ctime FPS.delay(.5) if (newtime) > 5.0: print '5 seconds' USB.writebuf(ldev,'$FPENROLL,EN2,TIMEOUT') fps.SetLED(False) return capt=fps.CaptureFinger(True) if capt==True: print 'Please remove finger' USB.writebuf(ldev,'$FPENROLL,RM2') captErr=fps.Enroll2() #print 'Err Status: %d' % captErr captErr=0 while fps.IsPressFinger()==True: FPS.delay(1) print 'Place the same finger a third time' USB.writebuf(ldev,'$FPENROLL,EN3') ctime = time.time() while fps.IsPressFinger()==False: newtime = time.time()-ctime FPS.delay(1) if (newtime) > 5.0: print '5 seconds' USB.writebuf(ldev,'$FPENROLL,EN3,TIMEOUT') fps.SetLED(False) return capt=fps.CaptureFinger(True) if capt==True: print 'Please remove finger' USB.writebuf(ldev,'$FPENROLL,RM3') captErr=fps.Enroll3() #print 'Err Status: %d' % captErr currcount=fps.GetEnrollCount() if captErr==0: if currcount!=prevcount: print 'You have successfully been enrolled' #queue.assign_scannerID(fileID, currcount) save_template(fileID, ID) if queue.assign_scannerID(fileID,ID) == -1: fps.DeleteID(ID) stng = ',NOTINQ' else: stng = ',ADDEDTOQ' fps.SetLED(False) return '$FPENROLL,SUCC,' + str(fileID) + stng else: print 'Enrollment unsuccessful. Error code: 2' fps.SetLED(False) return '$FPENROLL,ERR,2' else: print 'Enrollment unsuccessful. Error code: %d' % captErr #enroll(fps) fps.SetLED(False) return '$FPENROLL,ERR.' + str(captErr) else: print 'Enrollment unsuccessful, did not capture third finger.' fps.SetLED(False) return '$FPENROLL,ERR,3' else: print 'Enrollment unsuccessful, did not capture second finger.' fps.SetLED(False) return '$FPENROLL,ERR,2' else: print 'Enrollment unsuccessful, did not capture first finger.' fps.SetLED(False) return '$FPENROLL,ERR,1'
This may be works fine, if don't, try to change the fingerprint baud rate with baud_to_115200.py sample code ''' import FPS, sys DEVICE_GPIO = '/dev/ttyAMA0' DEVICE_LINUX = '/dev/cu.usbserial-A601EQ14' DEVICE_MAC = '/dev/cu.usbserial-A601EQ14' DEVICE_WINDOWS = 'COM3' FPS.BAUD = 115200 FPS.DEVICE_NAME = DEVICE_MAC if __name__ == '__main__': fps = FPS.FPS_GT511C3(device_name=DEVICE_MAC,baud=115200,timeout=2,is_com=False) fps.UseSerialDebug = True fps.SetLED(True) # Turns ON the CMOS LED FPS.delay(1) # wait 1 second print 'Put your finger in the scan' counter = 0 # simple counter for wait 10 seconds while counter < 10: if fps.IsPressFinger(): #verify if the finger is in the scan print 'Your finger is in the scan' fps.SetLED(False) # Turns OFF the CMOS LED break else: FPS.delay(1) #wait 1 second counter = counter + 1 fps.Close() # Closes serial connection
"--num-frames", type=int, default=100, help="# of frames to loop over for FPS test") ap.add_argument("-d", "--display", type=int, default=-1, help="Whether or not frames should be displayed") args = vars(ap.parse_args()) #Baseline # grab a pointer to the video stream and initialize the FPS counter print("[INFO] sampling frames from webcam...") stream = cv2.VideoCapture(1) fps = FPS().start() # loop over some frames while fps._numFrames < args["num_frames"]: # grab the frame from the stream (grabbed, frame) = stream.read() #r = 150.0 / frame.shape[1] # dim = (150, int(frame.shape[0] * (150.0 / frame.shape[1]) ) ) # frame = cv2.resize(frame, dim, interpolation=cv2.INTER_AREA) # check to see if the frame should be displayed to our screen if args["display"] > 0: cv2.imshow("Frame", frame) key = cv2.waitKey(1) & 0xFF # update the FPS counter fps.update() # stop the timer and display FPS information fps.stop()
#!/usr/bin/env python #-*- coding: utf- -*- import FPS """ Change baudrate from 9600 to 115200 """ fps = FPS.FPS_GT511C3(device_name='/dev/ttyAMA0', baud=9600, timeout=2, is_com=False) fps.ChangeBaudRate(115200) fps.Close()
def Enroll(fps): lcd.clear() lcd.message("Finding open\nID Number.") enrollid = 0 okid = False iret = 5 while not okid and enrollid < 200: okid = fps.CheckEnrolled(enrollid) if not okid: enrollid += 1 if enrollid < 200: lcd.clear() lcd.message("Press Finger\nTo Enroll") fps.EnrollStart(enrollid) while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): lcd.clear() lcd.message("Enrolling 1..") FPS.delay(0.5) iret = fps.Enroll1() lcd.clear() lcd.message("Remove Finger.") while fps.IsPressFinger(): FPS.delay(1) lcd.clear() lcd.message("Press same\nfinger again.") while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): FPS.delay(0.5) lcd.clear() lcd.message("Enrolling 2..") iret = fps.Enroll2() lcd.clear() lcd.message("Remove Finger.") while fps.IsPressFinger(): FPS.delay(1) lcd.clear() lcd.message("Press same\nfinger again.") while not fps.IsPressFinger(): FPS.delay(1) if fps.CaptureFinger(True): FPS.delay(0.5) lcd.clear() lcd.message("Enrolling 3..") iret = fps.Enroll3() FPS.delay(1) print "----------------------------> iret value: %s" % str(iret) if iret == 0: print "Enrolling Successful" print "Stored as ID #%s" % str(enrollid) lcd.clear() lcd.message("Success!\nID #%s enrolled" % str(enrollid)) FPS.delay(3) else: print "Enrolling Failed with error code: %s" % str(iret) FPS.delay(1.5) else: print "Failed to capture third finger" print "Enrolling Failed with error code: %s" % str(iret) lcd.clear() lcd.message("Third Capture\nFailed") FPS.delay(3) else: print "Failed to capture second finger" print "Enrolling Failed with error code: %s" % str(iret) lcd.clear() lcd.message("Second Capture\nFailed") FPS.delay(3) else: print "Failed to capture first finger" print "Enrolling Failed with error code: %s" % str(iret) lcd.clear() lcd.message("First Capture\nFailed") FPS.delay(3) else: print "Failed: enroll storage is full" lcd.clear() lcd.message("Enroll Failed\nStorage Full") FPS.delay(3) if iret == 1: lcd.clear() lcd.message("Enroll Failed") FPS.delay(2) elif iret == 2: lcd.clear() lcd.message("Enroll Failed\nBad Finger") FPS.delay(2) elif iret == 3: lcd.clear() lcd.message("Enroll Failed\nPrint in Use") FPS.delay(2) else: pass
eid = 0 eAlready = True while eAlready is True and eid < 3000: eAlready = fps.CheckEnrolled(eid) if eAlready == True: eid += 1 print('slot available is ' + str(eid)) return eid def dBaseSync(kid, key1, key2): conn = sqlite3.connect("/home/pi/python-GT511c3/finger.db") row = [kid, key1, key2] print(row) c = conn.cursor() c.execute("INSERT INTO codes VALUES(?, ?, ?)", row) conn.commit() conn.close if __name__ == '__main__': fps = FPS.FPS_GT511C3(device_name=DEVICE_LINUX, baud=9600, timeout=2, is_com=False) #settings for raspberry pi GPIO fps.Open() if fps.SetLED(True): LegacyEnroll(fps) fps.SetLED(False) fps.Close()
def Enroll(fps): ''' Enroll test ''' fps.SetLED(True) enrollid=0 okid=True #search for a free enrollid, you have max 200 message="wait until the id no. is allotted\n" sock.sendall(message) while okid and enrollid < 200: okid = fps.CheckEnrolled(enrollid) print"alloting id no." if okid: enrollid+=1 #print enrollid,okid #print 'this is the enroll id' if enrollid <200: #press finger to Enroll enrollid print 'Press finger to Enroll for first capture %s' % str(enrollid) message1="id. allocated is "+str(enrollid)+"\nPress finger to start enrollment\n" sock.sendall(message1) time.sleep(0.2) fps.EnrollStart(enrollid) while not fps.IsPressFinger(): print'Press finger' sock.send("press finger\n") FPS.delay(0.2) iret = 0 if fps.CaptureFinger(True): time.sleep(0.2) #remove finger print 'remove finger' sock.sendall("remove finger\n") fps.Enroll1() fps.SetLED(False) time.sleep(0.2) #print 'Enrollment 1 successfull' fps.SetLED(True) while not fps.IsPressFinger(): FPS.delay(0.2) #Press same finger again print 'Press same finger again' sock.sendall("press same finger again\n") while not fps.IsPressFinger(): FPS.delay(0.1) if fps.CaptureFinger(True): #remove finger time.sleep(0.1) print 'remove finger' sock.sendall('remove finger\n') fps.Enroll2() fps.SetLED(False) time.sleep(0.1) #print 'Enrollment 2 successfull' fps.SetLED(True) while not fps.IsPressFinger(): FPS.delay(0.1) #Press same finger again print 'press same finger yet again' sock.sendall('press same finger yet again\n') while not fps.IsPressFinger(): FPS.delay(0.1) if fps.CaptureFinger(True): #remove finger iret = fps.Enroll3() time.sleep(0.1) fps.SetLED(False) #print 'Enrollment successfull' if iret == 0: print 'Enrolling Successfull' sock.sendall('Enrolling Successful\n') else: print 'Enrolling Failed with error code: %s' % str(iret) sock.sendall('Enrolling Failed with error code:'+str(iret)+'\n') else: print 'Failed to capture third finger' sock.sendall('Failed to capture third finger\n') else: print 'Failed to capture second finger' sock.sendall('Failed to capture second finger\n') else: print 'Failed to capture first finger' sock.sendall('Failed to capture first finger\n') else: print 'Failed: enroll storage is full' sock.sendall('Failed: enroll storage is full\n')
''' Created on 08/04/2014 @author: jeanmachuca ''' import FPS, sys from test_raw import * if __name__ == '__main__': fps = FPS.FPS_GT511C3() fps.UseSerialDebug = True print Verify(fps, sys.argv[1]) fps.Close() pass
arduino.write(command.encode()) # start the capture (on camera channel 0) thread cap = WebcamVideoStream(src=0).start() # wait one second for everything to settle before reading first frame time.sleep(1) # create a video of the tracking timestamp = "{:%Y_%m_%d_%H_%M}".format(datetime.now()) fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v') out = cv2.VideoWriter('recordings/video' + timestamp + '.mov', fourcc, 30, (612, 425), True) # start FPS counter fps = FPS() fps.start() # record time timerStart = datetime.now() while True: # capture a frame frame = cap.read() # undistort and crop the frame # cv2.undistort() is slow so we use a remapping # undistorted = cv2.undistort(frame, mtx, dist, None, newcameramtx) undistorted = cv2.remap(frame, map1, map2, cv2.INTER_LINEAR) x, y, w, h = roi cropped = undistorted[y:y + h, x:x + w]
class MainWindow(QMainWindow): ########################################################### ########################################################### ########################################################### #Constructor def __init__(self, vid_path, src=0, src2=1, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) ########################################################### ########################################################### ########################################################### #Camera params self.counter = 0 self.fps = FPS() self.sp = vid_path self.stream = cv2.VideoCapture(src) self.stream2 = cv2.VideoCapture(src2) self.default_fps = self.stream.get(cv2.CAP_PROP_FPS) self.default_fps2 = self.stream2.get(cv2.CAP_PROP_FPS) self.cam_size = (int(self.stream.get(cv2.CAP_PROP_FRAME_WIDTH)), int(self.stream.get(cv2.CAP_PROP_FRAME_HEIGHT))) self.cam_size2 = (int(self.stream2.get(cv2.CAP_PROP_FRAME_WIDTH)), int(self.stream2.get(cv2.CAP_PROP_FRAME_HEIGHT))) self.writer = cv2.VideoWriter(self.sp + 'outputVid.avi', cv2.VideoWriter_fourcc(*'XVID'), self.default_fps, self.cam_size) self.writer2 = cv2.VideoWriter(self.sp + 'outputVid2.avi', cv2.VideoWriter_fourcc(*'XVID'), self.default_fps2, self.cam_size2) self.cam_ind = src self.cam_ind2 = src2 self.stopped = False ########################################################### ########################################################### ########################################################### #GUI configuration self.disply_width = 500 self.display_height = 350 self.setWindowTitle("Qt live label demo") self.layout_base = QVBoxLayout() self.layout_h = QHBoxLayout() self.camera1 = QLabel("webcam1") self.camera2 = QLabel("webcam2") start_b = QPushButton("Start Video") stop_b = QPushButton("Stop Video") start_b.pressed.connect(self.start_record) stop_b.pressed.connect(self.stop_record) self.layout_h.addWidget(self.camera1) self.layout_h.addWidget(self.camera2) self.layout_base.addWidget(start_b) self.layout_base.addWidget(stop_b) self.layout_base.addLayout(self.layout_h) self.layout_h.setSpacing(15) self.widget = QWidget() self.widget.setLayout(self.layout_base) self.setCentralWidget(self.widget) self.camera1.resize(self.disply_width, self.display_height) self.camera2.resize(self.disply_width, self.display_height) self.show() self.threadpool = QThreadPool() print("Multithreading with maximum %d threads" % self.threadpool.maxThreadCount()) print("Cam 1 fps&size:", self.default_fps, self.cam_size) print("Cam 2 fps&size:", self.default_fps2, self.cam_size2) self.worker = Worker() self.timer = QTimer() self.timer.setInterval(1000) self.timer.timeout.connect(self.recurring_timer) self.timer.start() def progress_fn(self, n): print("%d%% done" % n) def thread_fc(self): while True: # if the thread indicator variable is set, stop the thread if self.stopped == True: print("[Record-Info] elasped time: {:.2f}".format( self.fps.elapsed())) print("[Record-Info] approx. FPS: {:.2f}".format( self.fps.fps())) self.stream.release() self.stream2.release() self.writer.release() self.writer2.release() cv2.destroyAllWindows() return "Done" # otherwise, read the next frame from the stream (self.success, self.frame) = self.stream.read() (self.success2, self.frame2) = self.stream2.read() self.fps.update() if self.success: self.writer.write(self.frame) if self.success2: self.writer2.write(self.frame2) self.worker.signals.change_pixmap_signal.emit( [self.frame, self.frame2]) def print_output(self, s): print("output", s) def thread_complete(self): print("Thread complete") def convert_cv_qt(self, cv_img): """Convert from an opencv image to QPixmap""" rgb_image = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB) h, w, ch = rgb_image.shape bytes_per_line = ch * w convert_to_Qt_format = QImage(rgb_image.data, w, h, bytes_per_line, QImage.Format_RGB888) p = convert_to_Qt_format.scaled(self.disply_width, self.display_height, Qt.KeepAspectRatio) return QPixmap.fromImage(p) @pyqtSlot(np.ndarray) def update_image(self, cv_img): """Updates the image_label with a new opencv image""" qt_img = self.convert_cv_qt(cv_img[0]) qt_img2 = self.convert_cv_qt(cv_img[1]) self.camera1.setPixmap(qt_img) self.camera2.setPixmap(qt_img2) def execute_thread(self): # Pass the function to execute self.worker.begin_job( self.thread_fc ) # Any other args, kwargs are passed to the run function self.worker.signals.change_pixmap_signal.connect(self.update_image) self.worker.signals.result.connect(self.print_output) self.worker.signals.finished.connect(self.thread_complete) self.worker.signals.progress.connect(self.progress_fn) # Execute self.threadpool.start(self.worker) return self def start_record(self): print('start recording!', self.stopped) self.fps.start() if self.stopped == True: self.worker = Worker() self.stream = cv2.VideoCapture(self.cam_ind) self.stream2 = cv2.VideoCapture(self.cam_ind2) self.writer = cv2.VideoWriter(self.sp + 'outputVid.avi', cv2.VideoWriter_fourcc(*'XVID'), self.default_fps, self.cam_size) self.writer2 = cv2.VideoWriter(self.sp + 'outputVid2.avi', cv2.VideoWriter_fourcc(*'XVID'), self.default_fps2, self.cam_size2) self.stopped = False self.worker.open_record_loop() self.execute_thread() def stop_record(self): # indicate that the thread should be stopped print("Stop recording!") self.stopped = True self.worker.close_record_loop() self.fps.stop() self.execute_thread() def recurring_timer(self): self.counter += 1