asciicam.py
The snippet can be accessed without any authentication.
Authored by
defnull
Edited
asciicam.py 488 B
import cv2
import os
import sys
cap = cv2.VideoCapture(0)
height, width = map(int, os.popen('stty size', 'r').read().split())
write = sys.stdout.write
try:
while(True):
ret, frame = cap.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = cv2.resize(frame, (width, height))
write('\u001b[1;1H' + '\n'.join(''.join(" .',:;clxokXdO0KN"[c//16] for c in row) for row in frame))
except KeyboardInterrupt:
pass
finally:
cap.release()
cv2.destroyAllWindows()
Please register or sign in to comment