Python OpenCV避免视频源->;捕获源对话框
因此,我试图在Python2.7.5上创建一个简单的程序,其中一个窗口 为用户选择的时间显示实时视频源Python OpenCV避免视频源->;捕获源对话框,python,python-2.7,opencv,video,webcam,Python,Python 2.7,Opencv,Video,Webcam,因此,我试图在Python2.7.5上创建一个简单的程序,其中一个窗口 为用户选择的时间显示实时视频源 import numpy as np import cv2 import time def Func_VideoCapture(Float_Time = 10): Float_WantedTime = time.time() + Float_Time Float_CurentTime = time.time() cap = cv2.VideoCapture(0)
import numpy as np
import cv2
import time
def Func_VideoCapture(Float_Time = 10):
Float_WantedTime = time.time() + Float_Time
Float_CurentTime = time.time()
cap = cv2.VideoCapture(0)
while Float_CurentTime <= Float_WantedTime:
#get current time
Float_CurentTime = time.time()
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame',frame)
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
Float_Time = float(raw_input(">>> "))
Func_VideoCapture(Float_Time)
…在主功能中,但结果相同:
import numpy as np
import cv2
import time
def Func_VideoCapture(cap, Float_Time = 10):
Float_WantedTime = time.time() + Float_Time
Float_CurentTime = time.time()
while Float_CurentTime <= Float_WantedTime:
Float_CurentTime = time.time()
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame',frame)
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
def main():
cap = cv2.VideoCapture(0)
Float_Time = float(raw_input(">>> "))
Func_VideoCapture(cap, Float_Time)
if __name__ == "__main__":
main()
将numpy导入为np
进口cv2
导入时间
def Func视频捕获(上限、浮动时间=10):
Float\u WantedTime=time.time()+Float\u time
Float\u CurentTime=time.time()
当Float\u CurentTime时,尝试以下方法:
import numpy as np
import cv2
import time
def Func_VideoCapture(Float_Time = 10):
Float_WantedTime = time.time() + Float_Time
Float_CurentTime = time.time()
cap = cv2.VideoCapture(0)
while Float_CurentTime<=Float_WantedTime:
#get current time
Float_CurentTime = time.time()
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
Float_Time = float(raw_input(">>> "))
Func_VideoCapture(Float_Time)
将numpy导入为np
进口cv2
导入时间
def Func_视频捕获(浮动时间=10):
Float\u WantedTime=time.time()+Float\u time
Float\u CurentTime=time.time()
cap=cv2.视频捕获(0)
而现在
import numpy as np
import cv2
import time
def Func_VideoCapture(Float_Time = 10):
Float_WantedTime = time.time() + Float_Time
Float_CurentTime = time.time()
cap = cv2.VideoCapture(0)
while Float_CurentTime<=Float_WantedTime:
#get current time
Float_CurentTime = time.time()
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('frame',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
if __name__ == "__main__":
Float_Time = float(raw_input(">>> "))
Func_VideoCapture(Float_Time)