To write a python program using OpenCV to capture the image from the web camera and do the following image manipulations.
End the program and close the output video window by pressing 'q'.
import cv2
viedoCaptureObject=cv2.VideoCapture(0)
while(True):
ret,frame=viedoCaptureObject.read()
cv2.imwrite("SriVarshan.jpg",frame)
result=False
viedoCaptureObject.release()
cv2.destroyAllWindows()
import numpy as np
import cv2
cap=cv2.VideoCapture(0)
while True:
ret,frame=cap.read()
cv2.imshow('Shangai',frame)
if cv2.waitKey(1)==ord('q'):
break
cap.release()
cv2.destroyAllWindows()
import numpy as np
import cv2
cap=cv2.VideoCapture(0)
while True:
ret,frame=cap.read()
width=int(cap.get(3))
height=int(cap.get(4))
image=np.zeros(frame.shape,np.uint8)
smaller_frame=cv2.resize(frame,(0,0),fx=0.5,fy=0.5)
image[:height//2, :width//2]=smaller_frame
image[height//2:, :width//2]=smaller_frame
image[:height//2, width//2:]=smaller_frame
image[height//2:, width//2:]=smaller_frame
cv2.imshow('212222240104-PsvVarshan,image)
if cv2.waitKey(1)==ord('q'):
break
cap.release()
cv2.destroyAllWindows()
import numpy as np
import cv2
cap=cv2.VideoCapture(0)
while True:
ret,frame=cap.read()
width=int(cap.get(3))
height=int(cap.get(4))
image=np.zeros(frame.shape,np.uint8)
smaller_frame=cv2.resize(frame,(0,0),fx=0.5,fy=0.5)
image[:height//2, :width//2]=cv2.rotate(smaller_frame,cv2.ROTATE_180)
image[height//2:, :width//2]=smaller_frame
image[:height//2, width//2:]=cv2.rotate(smaller_frame,cv2.ROTATE_180)
image[height//2:, width//2:]=smaller_frame
cv2.imshow('212222240104_PsvVarshan',image)
if cv2.waitKey(1)==ord('q'):
break
cap.release()
cv2.destroyAllWindows()