23 lines
450 B
Python
23 lines
450 B
Python
import cv2
|
|
import numpy as np
|
|
|
|
def main():
|
|
capture = cv2.VideoCapture(2)
|
|
cv2.namedWindow("Camera", cv2.WINDOW_AUTOSIZE)
|
|
|
|
while True:
|
|
ret, frame = capture.read()
|
|
|
|
frame_mono = np.mean(frame, axis=2)
|
|
intensity = np.mean(frame_mono)
|
|
|
|
print(f"\033[H\033[2J{intensity:6.3f}")
|
|
|
|
cv2.imshow('Camera', frame)
|
|
|
|
if cv2.waitKey(1) == ord('q'):
|
|
break
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|