I would like to create a program which saves .jpg images taken from the webcam(frames).
What my program do for now is, opening a webcam, taking one and only one frame, and then everything stops.
What i would like to have is more than one frame
My error-code is this one:
import numpy as np
cap = cv2.VideoCapture(0)
count = 0
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imwrite("frame%d.jpg" % ret, frame) # save frame as JPEG file
# Display the resulting frame
Actually it sounds like you are always saving your image with the same name because you are concatenating ret instead of count in the imwrite method
try this :
name = "frame%d.jpg"%count cv2.imwrite(name, frame) # save frame as JPEG file