import numpy as np
import cv2
cap = cv2.VideoCapture(0)
fourcc = cv2.cv.CV_FOURCC(*'XVID')
out = cv2.VideoWriter('drop.avi', fourcc, 20.0, (640,480))
while cv2.VideoCaptured('drop.avi') is True:
# Captures frame x frame
ret , frame = cap.read()
#Frame operations
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
name = "frame%d.jpg"%count #saves frames and a JPEG image file
cv2.imwrite(name, frame)
#Display the resulting frame
cv2.imshow('frame', gray)
if cv2.waitKey(30):`enter code here`
break
cv.VideoCapture.release()
当我希望代码严格地从文件中读取视频而不是从我的网络摄像头。我知道我需要删除cap = cv2.VideoCpature(0)
。但是,我收到错误'module' object has no attribute 'VideoCapture'
。这段代码来自官方的OpenCV教程,所以我不确定是什么问题。我猜是有些东西不在正确的文件夹中。
答案 0 :(得分:2)
要在视频中阅读的正确代码段是:
#container {
height: 180px;
display: flex;
flex-flow: row;
align-items: stretch;
border: 1px dashed gray;
}
table {
display: flex;
flex-flow: row;
margin: 10px;
overflow: scroll;
border: 1px dashed blue;
}
tbody {
display: block; /* Disable tabular layout, and make <tbody> a flex item */
margin: auto 0; /* Push to the center (vertically) */
}
td {
height: 10px;
width: 100px;
border: 1px solid red;
}
#container div {
flex: 1;
margin: 10px;
border: 1px dashed red;
}