i have tried reinstalling opencv andimporting cv2 as from cv2 import cv2
and all other solutions listed here[1]: Python 3 Opencv set up problem: "cannot find reference 'VideoCapture' in __init__.py" on Pycharm IDE. other functions like cv2.imwrite and cv2.destroyAllWindows. i am open to solutions to this problem or alternative packages
import cv2
import os
cam = cv2.VideoCapture("C:example.mp4")
try:
if not os.path.exists('data'):
os.makedirs('data')
except OSError:
print('Error: Creating directory of data')
currentframe = 0
while (True):
ret, frame = cam.read()
if ret:
name = './data/frame' + str(currentframe) + '.jpg'
print('Creating...' + name)
cv2.imwrite(name, frame)
currentframe += 1
else:
break
cam.release()
cv2.destroyAllWindows()
the code is supposed to grab frames from a video and save them to individual files. if someone has a solution to my problem or an alternative way of getting frames from a video without using opencv i would really apreciate it