import cv2
cap = [Link](0)
print("Check===", [Link]())
fourcc = cv2.VideoWriter_fourcc(*"XVID")
output = [Link]("[Link]",fourcc,20.0,(640,480),0)
while([Link]()):
ret, frame = [Link]()
if ret == True:
[Link]('Colorframes', frame)
if [Link](1) & 0xFF == ord('q'):
break
[Link]()
[Link]()
[Link]()
Lec 7
IP Webcam
• Download & Install it from Play Store in your
mobile
• Install, click on the Start Server
• Connect the mobile with same WIFI or
Hotspot
• Access the camera in the browser and write
the IP address in browser address bar.
import cv2
camera = "[Link] Ip of the Camera
cap = [Link](0) #Here Parameter 0 is a path of any video
[Link](camera)
print("check===",[Link]())
fourcc = cv2.VideoWriter_fourcc(*"XVID") #It contain four parameters: Name, Codec,
fps, Resolution
output = [Link]("[Link]",fourcc,20.0,(640,480),0)
while([Link]()):
ret, frame = [Link]() # Read the frame
if ret == True:
[Link]('ColorFrame', frame)
if [Link]() & 0xFF == ord('q'): #Press to Exit
break
#Release Everything if job is finished
[Link]()
[Link]()
[Link]()
import cv2
Resize
camera = "[Link] ca
cap = [Link](0,cv2.CAP_DSHOW) #Here Parameter 0 is a path of any video
[Link](camera)
print("check===",[Link]())
fourcc = cv2.VideoWriter_fourcc(*"XVID") #It contain four parameters: Name, Codec, fps,
Resolution
output = [Link]("[Link]",fourcc,20.0,(640,480),0)
while([Link]()):
ret, frame = [Link]() # Read the frame
if ret == True:
[Link](frame,(350,700))
[Link]('ColorFrame', frame)
if [Link]() & 0xFF == ord('q'): #Press to Exit
break
#Release Everything if job is finished
[Link]()
[Link]()
[Link]()
import cv2
camera = "[Link] ca
cap = [Link](0,cv2.CAP_DSHOW) #Here Parameter 0 is a path of any video
[Link](camera)
print("check===",[Link]())
fourcc = cv2.VideoWriter_fourcc(*"XVID") #It contain four parameters: Name, Codec, fps,
Resolution
output = [Link]("[Link]",fourcc,20.0,(640,480),0)
while([Link]()):
ret, frame = [Link]() # Read the frame
if ret == True:
[Link](frame,(175,175))
[Link]('ColorFrame', frame)
if [Link]() & 0xFF == ord('q'): #Press to Exit
break
#Release Everything if job is finished
[Link]()
[Link]()
[Link]()
YouTube Video Without Downloading
import pafy
Pip install pafy in anaconda prompt
Installed
# Capture Video From Youtube
import cv2
import pafy
url = "[Link]
data = [Link](url)
data = [Link](preftype="mp4")
cap = [Link](0)# here parameter 0 is a path of any video
[Link]([Link])
print("check===", [Link]())
while([Link]()):
ret, frame = [Link]() #here read the frame
if ret == True:
frame = [Link](frame,(700,700))
gray = [Link](frame, cv2.COLOR_BGR2GRAY)
[Link]('Colorframe', frame)
[Link]('gray', gray)
if [Link](1) & 0xFF ==ord('q'): #press to exit
break
[Link]()
[Link]()
Error
import cv2
from pytube import YouTube
# YouTube video URL GPT Code
video_url = '[Link]
# Downloading the video
yt = YouTube(video_url)
stream = [Link](progressive=True, file_extension='mp4').first()
[Link](filename='video')
# Playing the downloaded video using OpenCV
cap = [Link]('video.mp4')
while True:
ret, frame = [Link]()
if not ret:
break
# Display original video
[Link]('Original Video', frame)
# Convert frame to grayscale
gray_frame = [Link](frame, cv2.COLOR_BGR2GRAY)
# Display grayscale video
[Link]('Grayscale Video', gray_frame)
if [Link](25) & 0xFF == ord('q'):
break
[Link]()
[Link]()
Assignment