import os
import cv
import cv2
videos_src_path = 'C://Users//Zhu Yunpeng//Downloads//UT'
videos_save_path = 'C://Users//Zhu Yunpeng//Downloads//UT//frames'
videos = os.listdir(videos_src_path)
videos = filter(lambda x: x.endswith('avi'), videos)
for each_video in videos:
print (each_video)
# get the name of each video, and make the directory to save frames
each_video_name, _ = each_video.split('.')
os.mkdir(videos_save_path + '/' + each_video_name)
each_video_save_full_path = os.path.join(videos_save_path, each_video_name) + '/'
# get the full path of each video, which will open the video tp extract frames
each_video_full_path = os.path.join(videos_src_path, each_video)
cap = cv2.VideoCapture(each_video_full_path)
frame_count = 1
success = True
while(success):
success, frame = cap.read()
print ('Read a new frame: '), success
params = []
params.append(cv2.imwrite(cv.CV_IMWRITE_PXM_BINARY)
params.append(1)
cv2.imwrite(each_video_save_full_path + each_video_name + "_%d.ppm" % frame_count, frame, params)
frame_count = frame_count + 1
cap.release()
ModuleNotFoundError: No module named 'cv'
尝试了import cv2.cv as cv,也不好使ModuleNotFoundError: No module named 'cv2.cv'
但是cv2又没有这个模块cv.CV_IMWRITE_PXM_BINARY
是不是新版python里面没有cv模块了?
我不是通过anac。。来安装的啊。我发现python3.6就是没有cv这个模块了,坑爹。这个模块cv.CV_IMWRITE_PXM_BINARY,被cv2哪个功能代替了?有人知道么
怎么import cv啊?用哪个包?