def interactWebsite(message): if message in morse_code.inverseMorseAlphabet.keys(): message = morse_code.decrypt(message) # print(message) if message == '@': return 'quit' interactElement(getCurrentElement(), word=message)
def test_decrypt(): """Decrypt method. Function test_decrypt() compares given morse code with string. """ assert morse_code.decrypt('- -... ..- .. ... --. .-. ' '. .- - ..- -. .. ...- . .-. ' '... .. - -.-- .-.-.-') \ == 'TBU IS GREAT UNIVERSITY.' assert morse_code.decrypt('...-- ...-- -....- .---- ' '----- -...- ..--- ...--') \ == '33 - 10 = 23' assert morse_code.decrypt('-..-. .-.-. -....- ---... ' '.-.-.- .-.-.-') \ == '/+-: . .' assert morse_code.decrypt('.---- ..--- ...-- ....- ..... ' '-.... --... ---.. ----. -----') \ == '1234567890'
cv2.putText(frame, " EAR: {:.2f}".format(ear), (300, 30), # ear aspect ratio cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2) cv2.putText(frame, " m_EAR: {:.2f}".format(mouthEar), (280, 50), # ear aspect ratio cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2) # show the frame cv2.imshow("Frame", frame) key = cv2.waitKey(1) & 0xFF if (pattern_list and pattern_list[-1]=='/') or len(pattern_list) > 6: RAISE_TOTAL,BLINK_TOTAL=0,0 message = "".join(pattern_list)[:-1] # to exclude the backslash print(message) if message in morse_code.inverseMorseAlphabet.keys(): message = morse_code.decrypt(message) if message !=' ': currentWord+=message else: print('WORD: '+''.join(currentWord)) currentWord=[] print(message) # interactElement(getCurrentElement(), word = message) pattern_list=[] if (TIME > 10): sendEmail(user) sendWechatMessage(user) # cv2.putText(frame, message, (50, 150), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0,0,255), 2) # if the `q` key was pressed, break from the loop