1234567891011121314151617181920212223242526272829303132333435 |
- import numpy as np
- import cv2
- import time
- #cap = cv2.VideoCapture('rtsp://192.168.50.181/av0_0')
- cap = cv2.VideoCapture('http://192.168.50.177:81/stream')
- #cap = cv2.VideoCapture(0)
- fourcc = cv2.VideoWriter_fourcc(*'XVID')
- # 建立 VideoWriter 物件,輸出影片至 output.avi
- # FPS 值為 20.0,解析度為 640x360
- #out = cv2.VideoWriter('output_test.avi', fourcc, 25.0, (1920, 1080))
- out = cv2.VideoWriter('outputtest.avi', fourcc, 25.0, (320, 240))
- while(True):
- ret, frame = cap.read()
- if ret == True:
- out.write(frame)
- frame = cv2.resize(frame, (800, 600))
- cv2.imshow('frame',frame)
- if cv2.waitKey(1) & 0xFF == ord('p'):
- now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
- cv2.imwrite('C:\\Users\\User\\Desktop\\company_files\\opencv\\' + now + ".jpg", frame)
- elif cv2.waitKey(1) & 0xFF == ord('q'):
- break
- # When everything done, release the capture
- cap.release()
- cv2.destroyAllWindows()
|