第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在指紋傳感器 PYTHON 上沒有輸入 15 秒后退出指紋程序

在指紋傳感器 PYTHON 上沒有輸入 15 秒后退出指紋程序

至尊寶的傳說 2021-10-19 16:51:32
我有一個我自己無法解決的問題(我嘗試了很多,time.time()但我從來沒有解決我的問題)。如果 15 秒過去了,我希望我的程序退出并停止等待手指。如果有人知道如何在 python 中做到這一點,我會非常高興和感激!非常感謝!問我是否有任何問題!代碼在下面!import sysimport ossys.path.insert(0, '/home/pi/scripts')import subprocessimport lcddriverfrom time import *lcd = lcddriver.lcd()lcd.lcd_clear()import hashlibfrom pyfingerprint.pyfingerprint import PyFingerprint## Tries to initialize the sensortry:f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000)if ( f.verifyPassword() == False ):    raise ValueError('The given fingerprint sensor password is wrong!')except Exception as e:lcd.lcd_display_string('Initialization failed!', 2)print('Exception message: ' + str(e))exit(1)## Gets some sensor informationprint('Currently used templates: ' + str(f.getTemplateCount()) +'/'+ str(f.getStorageCapacity()))## Tries to search the finger and calculate hashtry: f = PyFingerprint('/dev/ttyUSB0', 57600, 0xFFFFFFFF, 0x00000000)if ( f.verifyPassword() == False ):    raise ValueError('The given fingerprint sensor password is wrong!')except Exception as e:lcd.lcd_display_string('Initialization failed!', 2)print('Exception message: ' + str(e))exit(1)## Gets some sensor informationprint('Currently used templates: ' + str(f.getTemplateCount()) +'/'+ str(f.getStorageCapacity()))## Tries to search the finger and calculate hashtry:lcd.lcd_display_string(' Waiting for finger', 2)## Wait that finger is readwhile ( f.readImage() == False ):    pass## Converts read image to characteristics and stores it in charbuffer 1f.convertImage(0x01)## Searchs templateresult = f.searchTemplate()positionNumber = result[0]accuracyScore = result[1] if ( positionNumber == -1 ):    os.system('python access_denied.py')    exit(0) else:    lcd.lcd_clear()    lcd.lcd_display_string("  Finger accepted!", 2)    sleep(1.5)    lcd.lcd_clear()    os.system('python keypad.py')
查看完整描述

2 回答

?
GCT1015

TA貢獻1827條經(jīng)驗 獲得超4個贊

你可以試試這個:


timeout = time.time() + 15 # 15s from now

while True:

   # do stuff

    end_time = time.time()

    if end_time > timeout or f.readImage():

        break

    else:

        time.sleep(0.25) # sleep to reduce CPU usage


查看完整回答
反對 回復(fù) 2021-10-19
  • 2 回答
  • 0 關(guān)注
  • 225 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號