diff --git a/bnpm/video.py b/bnpm/video.py index 5f833e3..63eba65 100644 --- a/bnpm/video.py +++ b/bnpm/video.py @@ -17,17 +17,25 @@ ## systems that do not support cv2.imshow like servers. ## Also be sure to import BNPM before importing most other ## modules. -try: +def prepare_cv2_imshow(): + """ + This function is necessary because cv2.imshow() + can crash the kernel if called after importing + av and decord. + RH 2022 + """ + import numpy as np + import cv2 test = np.zeros((1,300,400,3)) for frame in test: - cv2.putText(frame, "Prepping CV2", (10,50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255,255,255), 2) - cv2.putText(frame, "Calling this figure allows cv2.imshow ", (10,100), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1) - cv2.putText(frame, "to run after importing av and decord", (10,120), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1) + cv2.putText(frame, "WELCOME TO FACE RHYTHM!", (10,50), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255,255,255), 2) + cv2.putText(frame, "Prepping CV2", (10,100), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255,255,255), 2) + cv2.putText(frame, "Calling this figure allows cv2.imshow ", (10,150), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1) + cv2.putText(frame, "to work without crashing if this function", (10,170), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1) + cv2.putText(frame, "is called before importing av and decord", (10,190), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1) cv2.imshow('startup', frame) cv2.waitKey(100) cv2.destroyWindow('startup') -except: - pass ###############################################################################