opencv_get_photo.py 820 B

1234567891011121314151617181920212223242526
  1. import numpy as np
  2. import cv2
  3. import time
  4. cap = cv2.VideoCapture('http://192.168.50.177:81/stream')
  5. while(True):
  6. # Capture frame-by-frame
  7. ret, frame = cap.read()
  8. # Our operations on the frame come here
  9. gray = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
  10. frame = cv2.resize(frame, (1936,1096))
  11. #frame = cv2.resize(frame, (320, 240))
  12. # Display the resulting frame
  13. cv2.imshow('frame',frame)
  14. if cv2.waitKey(1) & 0xFF == ord('p'):
  15. now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
  16. cv2.imwrite('D:\\fatwolf\\company_files\\opencv\\' + now + ".png", frame)
  17. print('save: '+now+'.png')
  18. elif cv2.waitKey(1) & 0xFF == ord('q'):
  19. break
  20. # When everything done, release the capture
  21. cap.release()
  22. cv2.destroyAllWindows()