ascii-webcam
ascii-webcam copied to clipboard
Fermer proprement le programme
D'après le code la touche échappe permet de quitter le programme, mais ce n'est pas le cas. Ou alors c'est dû à mon environnement ?
OS : Debian 10 Buster
Par contre en affichant le résultat dans une fenêtre comme sur ma branche inwindow cela fonctionne.
Pour ma part j'ai le même problème.
Le terminal affiche ce caractère brièvement
ˆ[
Je suis sur macOS Catalina 10.15.5
J'ai un problème également avec la fermeture du programme. Donc j'ai fait appel au saint help() et on y apprend que le cv2.waitKey() ne fonctionne que si une fenêtre de l'interface graphique cv2 tourne en fond. J'ai donc testé de mettre un petit cv2.namedWindow('leave', cv2.WINDOW_NORMAL)
juste avant la boucle if, ça me crée une fenêtre et la touche quitter fonctionne (à noter qu'il faut que la fenêtre de cv2 ait le focus). Donc je dirais que ce pb est normal et qu'il suffit de créer une fenêtre cv2 pour le résoudre. Mais sachant qu'il lui faut le focus pour se fermer, on ne peut pas dire que ce soit une solution ergonomique.
`>>> import cv2
help(cv2.waitKey) Help on built-in function waitKey:
waitKey(...) waitKey([, delay]) -> retval . @brief Waits for a pressed key. . . The function waitKey waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay . milliseconds, when it is positive. Since the OS has a minimum time between switching threads, the . function will not wait exactly delay ms, it will wait at least delay ms, depending on what else is . running on your computer at that time. It returns the code of the pressed key or -1 if no key was . pressed before the specified time had elapsed. . . @note . . This function is the only method in HighGUI that can fetch and handle events, so it needs to be . called periodically for normal event processing unless HighGUI is used within an environment that . takes care of event processing. . . @note . . The function only works if there is at least one HighGUI window created and the window is active. . If there are several HighGUI windows, any of them can be active. . . @param delay Delay in milliseconds. 0 is the special value that means "forever".`