trying to safe a simple image from a stream and save it but the apiPreference cant be found on line 7. already tried several things and read the openCV information on the writer function but i cant find anything on the apiPreferences.
import cv2
import numpy as np
# Open the device at the ID 0
cap = cv2.VideoCapture(1)
#fcc = cv2.VideoWriter_foucc(*"JPG")
out = cv2.VideoWriter("newImage.jpg", fourcc=0, fps=0)#line7
#Check whether user selected camera is opened successfully.
if not (cap.isOpened()):
print("Could not open video device")
#To set the resolution
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
while(True):
# Returns true and capture frame-by-frame and
ret, frame = cap.read()
snapShot = frame
# Display the resulting frame
cv2.imshow('preview', frame)
out.write(snapShot)
#Waits for a user input to quit the applicatio or save an image
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
just to get the fault:
Traceback (most recent call last):
File"home/pi/Dokuments/cameraStream.py", line 7, in <module>
out = cv2.VideoWriter("newImage.jpg", fourcc=0, fps=0)
TypeError: Required argument 'apiPreference' (pos 2) not found
any idea on how to fix that would be great as im running out of ideas.
question from:https://stackoverflow.com/questions/65849618/get-image-from-cam-stream-with-python-and-opencv