'''下面是我试图运行的代码。我收到了 AttributeError。我有 python 3.6.6,但无法导入 cv2。我会得到一个错误:“AttributeError:部分初始化的模块‘cv2’没有属性‘VideoCapture’(很可能是由于循环导入)”。
路径是否正确? 它正在从用户/“用户目录名”/.spyder-py3/cv2.py'''
执行#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import cv2
#print(cv2._file_)
# open import video
video_capture=cv2.VideoCapture('video.mp4')
# webcam: video_capture=cv2.VideoCapture(0)
#read first frame
_, current_frame= video_capture.read()
cv2.imshow('app', current_frame)
cv2.waitKey(0)
video_capture.release()
cv2.destroyAllWindows()