Add permission to the application which run this code. In this case, the code is running under the Code (Visual Studio code), and the Code has to be checked for capturing screens as follows.
Code
from PIL import ImageGrab
import os
import time
def screenGrab():
box = (0, 0, 1920, 1080)
im = ImageGrab.grab(box)
im.save(os.getcwd() + '\\screenshot_' + str(int(time.time())) + '.png', 'PNG')
def main():
screenGrab()
if __name__ == '__main__':
main()
import cv2
import pafy
# Tokyo Station
url = 'https://youtu.be/6YRUWrkV2R4'
video = pafy.new(url)
streams = video.streams
for i in streams:
print(i)
# get best resolution regardless of format
best = video.getbest()
# start the video
cap = cv2.VideoCapture(best.url)
while (True):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(20) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Chichibu is also famous for the animation “Anohana: The Flower We Saw That Day“. It was on air in 2011, but still may anime fans are visiting Chichibu, the place of anime scenes.