diff --git a/encrypter_decrypter_gui.py b/encrypter_decrypter_gui.py index 75d10d37839..48504895408 100644 --- a/encrypter_decrypter_gui.py +++ b/encrypter_decrypter_gui.py @@ -257,6 +257,7 @@ def backend_work(self, todo, text_coming): # ==================== Classes End Here ... ! ================= +# this code runes only in this file if __name__ == "__main__": run = Main() Notebook(run) diff --git a/webcam.py b/webcam.py index 30a89df27f4..d1aa682caac 100644 --- a/webcam.py +++ b/webcam.py @@ -6,6 +6,7 @@ # Improve this program and make it suitable for general module like use in another programs import cv2 +from colorama import Fore cap = cv2.VideoCapture(0) @@ -17,8 +18,13 @@ # FourCC is platform dependent; however, MJPG is a safe choice. fourcc = cv2.VideoWriter_fourcc(*"MJPG") -# Create video writer object. Save file to recording.avi -out = cv2.VideoWriter("recording.avi", fourcc, 20.0, (frames_width, frames_height)) +# exception Handling for captured video +try: + # 60 FPS video capture + # Create video writer object. Save file to recording.avi + out = cv2.VideoWriter("recording.avi", fourcc, 60.0, (frames_width, frames_height)) +except(Exception) as e: + print(Fore.RED, e, Fore.RESET) while True: # Capture frame-by-frame @@ -27,16 +33,18 @@ if ret == True: # Write frame to recording.avi out.write(frame) - + + # color video output # Our operations on the frame come here - gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + gray = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA) # Display the resulting frame cv2.imshow("frame", gray) - if cv2.waitKey(1) & 0xFF == ord("q"): + if cv2.waitKey(1) & 0xFF == ord(" "): break # When everything is done, release the capture and video writer cap.release() out.release() cv2.destroyAllWindows() +