I need to take screenshots from webcam to save on my computer. But the webcam is very low quality Please can anyone tell me what should I change to use another webcam I put in a USB port on my laptop, rather than the integrated camera?
import cv2
cam = cv2.VideoCapture(0)
cv2.namedWindow("Python Webcam Screenshot App")
img_counter = 0
while True:
ret, frame = cam.read()
if not ret:
print("failed to grab frame")
break
cv2.imshow("test",frame)
k = cv2.waitKey()
if k%256 == 27:
print("Escape hit, closing the app")
break
elif k%256 == 32:
img_name = "opencv_frame{}.png".format(img_counter)
cv2.imwrite(img_name,frame)
print("Screenshot taken")
img_counter+=1
cam.release()
cam.destroyAllWindows()