forked from amartya-k/vision
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWebsiteVidCaptureCopy.py
47 lines (35 loc) · 1.01 KB
/
WebsiteVidCaptureCopy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from selenium import webdriver
from PIL import Image
#from moviepy.editor import *
import time
import cv2
import os
driver = webdriver.Chrome(executable_path='/Users/paulyp123/Desktop/chromedriver')
driver.get('https://nyctmc.org/google_popup.php?cid=1148')
#driver.get('https://www.youtube.com/')
image_folder = '/Users/paulyp123/Desktop/vision-master/' + str(time.time())
os.mkdir(image_folder)
os.chdir(image_folder)
for x in range(20):
time.sleep(.1)
driver.save_screenshot(str(time.time()) + ".png")
driver.close()
video_name = 'video.avi'
images = [img for img in os.listdir(image_folder) if img.endswith(".png")]
images.sort()
left = 848
top = 127
right = 1552
down = 541
width = right - left
height = down - top
video = cv2.VideoWriter(video_name, 0, 1, (width, height))
for image in images:
im = Image.open(image)
crop = im.crop((left, top, right, down))
crop.save(image)
video.write(cv2.imread(os.path.join(image_folder, image)))
cv2.destroyAllWindows()
video.release()
for image in images:
os.remove(image)