Lecture 8
Lecture 8
Lecture 8
Install pyautogui
Installed
Numpy Already Installed
#Screen Recorder
import cv2 as c
import pyautogui as p
import numpy as np
#Creat resolution
rs = p.size()
#file name in which we store recording
fn = input("please enter any file name and path")
#fix the frame rate
fps = 60.0
fourcc = c.VideoWriter_fourcc(*"XVID")
output = c.VideoWriter(fn, fourcc, fps, rs)
#Creating Recording Module
c.namedWindow("Live_Recording",c.WINDOW_NORMAL)
c.resizeWindow("Live_Recording", (600,400))
while True:
img = p.screenshot()
f = np.array(img)
f = c.cvtColor(f, c.COLOR_BGR2RGB)
output.write(f)
c.imshow("Live_Recording",f)
if c.waitKey(1) ==ord("q"):
break
output.release()
c.destroyAllWindows()
Project 2
vidcap = cv2.VideoCapture("F:\screen_again.mp4")
ret,image = vidcap.read()#READ THE VIDEO
count = 0
while True:
if ret == True:
cv2.imwrite("F:\\frames\\imgN%d.jpg" % count, image) # save frame as JPEG file
vidcap.set(cv2.CAP_PROP_POS_MSEC,(count**100)) #used to hold speed of frane generation
ret,image = vidcap.read()
cv2.imshow("res",image)
print ('Read a new frame:',count ,ret)
count += 1
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cv2.destroyAllWindows()
else:
break
vidcap.release()
cv2.destroyAllWindows()
import cv2
count = 0
while True:
if ret == True:
cv2.imwrite("F:\\frames\\imgN%d.jpg" % count, image) # save frame as JPEG file
vidcap.set(cv2.CAP_PROP_POS_MSEC,(count**100)) #used to hold speed of frane generation
ret,image = vidcap.read()
cv2.imshow("res",image)
print ('Read a new frame:',count ,ret)
count += 1
if cv2.waitKey(1) & 0xFF == ord("q"):
break
cv2.destroyAllWindows()
else:
break
vidcap.release()
cv2.destroyAllWindows()