ต้องลง OpenCv ตาม python version
import cv2
cap = cv2.VideoCapture(1)
# Check if the webcam is opened correctly
if not cap.isOpened():
raise IOError("Cannot open webcam")
while True:
ret, frame = cap.read()
frame = cv2.resize(frame, None, fx=0.25, fy=0.25, interpolation=cv2.INTER_AREA)
sky = frame[0:200, 70:270]
sky = cv2.flip(sky,1)
cv2.namedWindow('Thanaphan',cv2.WINDOW_NORMAL)
cv2.imshow('Thanaphan', sky)
cv2.setWindowProperty('Thanaphan', cv2.WND_PROP_TOPMOST, 1)
c = cv2.waitKey(1)
if c == 27:
break
cap.release()
cv2.destroyAllWindows()