close
import cv2 # 使用視訊鏡頭擷取影像 cv2.namedWindow("preview") vc = cv2.VideoCapture(0) if vc.isOpened(): # try to get the first frame rval, frame = vc.read() else: rval = False count = 0 while rval: cv2.imshow("preview", frame) # 產生視窗 rval, frame = vc.read() cv2.imwrite("frame%d.jpg" % count, frame) # 將影格轉為 frame key = cv2.waitKey(100) # 調整影格數 if key == 27: # 按esc停止 break count += 1 cv2.destroyWindow("preview")
import cv2
# 使用視訊鏡頭擷取影像
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
if vc.isOpened(): # try to get the first frame
rval, frame = vc.read()
else:
rval = False
count = 0
while rval:
cv2.imshow("preview", frame) # 產生視窗
rval, frame = vc.read()
cv2.imwrite("frame%d.jpg" % count, frame) # 將影格轉為 frame
key = cv2.waitKey(100) # 調整影格數
if key == 27: # 按esc停止
break
count += 1
cv2.destroyWindow("preview")
全站熱搜