Computer Vision : Show Date and Time on Videos using OpenCV Python
import cv2
import datetime
cap = cv2.VideoCapture(0)
#print(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
#print(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
cap.set(3, 3000)
cap.set(4, 3000)
print(cap.get(3))
print(cap.get(4))
while(cap.isOpened()):#open camera
ret, frame = cap.read() #read frames
if ret == True:#if there is a frame
font = cv2.FONT_HERSHEY_SIMPLEX
text = 'Width: '+ str(cap.get(3)) + ' Height:' + str(cap.get(4))
datet = str(datetime.datetime.now())
frame = cv2.putText(frame, text, (10, 50), font, 1,
(0, 255, 255), 2)
frame = cv2.putText(frame, datet, (10, 100), font, 1,
(0, 255, 255), 2)
cv2.imshow('frame', frame)
if cv2.waitKey(1)== ord('q'): #wait key from keyboard
break
else: #if ret =false
break
cap.release()# close camera
cv2.destroyAllWindows() #close window
#====================================================#
if you faced any issue contact me via
what's app : +201210894349
or facebook
Comments
Post a Comment
I hope you have benefited from this blog, and if you have any question, feel free to leave it here.