Skip to content

Commit

Permalink
wrap prepare_cv2_imshow in a function
Browse files Browse the repository at this point in the history
  • Loading branch information
RichieHakim committed Jan 30, 2024
1 parent 180e824 commit 7e30801
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions bnpm/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
###############################################################################


Expand Down

0 comments on commit 7e30801

Please sign in to comment.