Skip to content

Instantly share code, notes, and snippets.

@wermarter
Created January 22, 2017 09:24
Show Gist options
  • Save wermarter/883a05c1b423d043ec230756548c5a39 to your computer and use it in GitHub Desktop.
Save wermarter/883a05c1b423d043ec230756548c5a39 to your computer and use it in GitHub Desktop.
putText, cvtColor, font, random and more...
import cv2, time, sys
from random import *
import numpy as np
font = cv2.FONT_HERSHEY_SIMPLEX
cap = cv2.VideoCapture(0)
width, height = cap.get(3), cap.get(4)
print(width, height)
ck = 0
start = time.time()
while True:
ck += 1
ret, frame = cap.read()
for i in range(50):
pos = (randint(0, width), randint(0, height))
cv2.putText(frame, str(randint(0, 100)), pos, font, 2, (randint(0, 255), randint(0, 255), randint(0, 255)), 2, cv2.LINE_AA)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('Me', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
end = time.time()
break
cap.release()
cv2.destroyAllWindows()
print(ck/(end-start), 'fps')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment