We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13
Lecture 6 “
Video Capture From Different
Sources Access camera in browser using IP JavaScript Camera Accessed Camera Accessed # How to use android device camera as webcam in Opencv import cv2 camera = "http://192.168.98.137:8080/video" #Connect your labtop and android device with same network either wifi or cap = cv2.VideoCapture(0)# here is 0 is path of any video cap.open(camera) print("check===", cap.isOpened()) #it is 4 byte code which is use to specify the cideo codec fourcc = cv2.VideoWriter_fourcc(*"XVID")# *"XVID" #it contains 4 parameter , name, codec, fps, resolution output = cv2.VideoWriter("hero.avi",fourcc,20.0,(640,480),0) while(cap.isOpened()): ret, frame = cap.read() #here read the frame if ret == True: cv2.imshow('Colorframe', frame) if cv2.waitKey() & 0xFF == ord('q'): #press to exit break
#Release everything if job is finished
cap.release() output.release() cv2.destroyAllWindows() Frame Resized # How to use android device camera as webcam in Opencv import cv2 camera = "http://192.168.98.137:8080/video" #Connect your labtop and android device with same network either wifi or cap = cv2.VideoCapture(0)# here is 0 is path of any video cap.open(camera) print("check===", cap.isOpened()) #it is 4 byte code which is use to specify the cideo codec fourcc = cv2.VideoWriter_fourcc(*"XVID")# *"XVID" #it contains 4 parameter , name, codec, fps, resolution output = cv2.VideoWriter("hero.avi",fourcc,20.0,(640,480),0) while(cap.isOpened()): ret, frame = cap.read() #here read the frame if ret == True: frame = cv2.resize(frame, (700,450)) cv2.imshow('Colorframe', frame) if cv2.waitKey() & 0xFF == ord('q'): #press to exit break
#Release everything if job is finished
cap.release() output.release() cv2.destroyAllWindows() To Save File # How to use android device camera as webcam in Opencv import cv2 camera = "http://192.168.98.137:8080/video" #Connect your labtop and android device with same network either wifi or cap = cv2.VideoCapture(0)# here is 0 is path of any video cap.open(camera) print("check===", cap.isOpened()) #it is 4 byte code which is use to specify the cideo codec fourcc = cv2.VideoWriter_fourcc(*"XVID")# *"XVID" #it contains 4 parameter , name, codec, fps, resolution output = cv2.VideoWriter("F:\hero.mp4",fourcc,20.0,(640,480)) while(cap.isOpened()): ret, frame = cap.read() #here read the frame if ret == True: frame = cv2.resize(frame, (700,450)) cv2.imshow('Colorframe', frame) output.write(frame) if cv2.waitKey() & 0xFF == ord('q'): #press to exit break
#Release everything if job is finished
cap.release() output.release() cv2.destroyAllWindows() Flip & Grayscale Frame Resized import cv2 camera = "http://192.168.98.137:8080/video" #Now capture video from webcam and save it to memeory cap = cv2.VideoCapture(0,cv2.CAP_DSHOW) cap.open(camera) #DIVX, XVID, MJPG, X264, WMV1, WMV2 fourcc = cv2.VideoWriter_fourcc(*"XVID") # "XVID" # It contain four parameter, name, codec, fps, resolution output = cv2.VideoWriter("F:\First Semester 2024\Computer Vision\output.avi", fourcc,20.0, (640,480),0) print(cap) while cap.isOpened(): ret,frame = cap.read() if ret == True: frame = cv2.resize(frame,(700,700)) gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) frame = cv2.flip(gray,0) cv2.imshow('frame',frame) cv2.imshow("gray", gray) output.write(gray) if cv2.waitKey(1) & 0xFF == ord('q'): #Press to exit break cap.release() output.release() cv2.destroyAllWindows()