G2A Many GEOs
SHARE
TWEET

Untitled

silver2row May 23rd, 2020 1,584 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import ffmpeg
  2. import sys
  3. import cv2
  4. import numpy as np
  5. from matplotlib import pyplot as plt, patches
  6. import os
  7.  
  8. try:
  9.     def main():
  10.         path = 'figures'
  11.  
  12.         for i in range(5):
  13.             _fig, ax = plt.subplots()
  14.             x = range(3 * i)
  15.             y = [n * n for n in x]
  16.             ax.add_patch(patches.Rectangle(xy=(i, 1), width=1, height=10))
  17.             plt.step(x, y, linewidth=3, where="mid")
  18.             out = 'fig_{}.png'.format(i)
  19.             dest = os.path.join(path, out)
  20.             plt.savefig(dest)
  21.             plt.clf()
  22.         print("Just about done!")
  23.     main()
  24.  
  25.     cap = cv2.VideoCapture(0)
  26.  
  27.     if(cap.isOpened() == False):
  28.         print("Cannot get the video feed!")
  29.  
  30.     frame_width  = int(cap.get(5))
  31.     frame_height = int(cap.get(5))
  32.  
  33.     out = cv2.VideoWriter("outs.mpg", cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), 10, (frame_width, frame_height))
  34.  
  35.     while(True):
  36.         ret, frame = cap.read()
  37.         if ret == True:
  38.             out.write(frame)
  39.  
  40.         else:
  41.             break
  42.  
  43. #cap.release()
  44. #out.release()
  45.  
  46. #cv2.destroyAllWindows()
  47.  
  48.     def read_frame_as_jpeg(out, err):
  49.         out, err = (
  50.             ffmpeg
  51.             .input("outs.mpg3")
  52.             .filter('select', 'gte(n,{})'.format(40))
  53.             .output('pipe:', vframes=1, format='image2', vcodec='mjpeg')
  54.             .run(capture_stdout=True)
  55.         )
  56.         return out
  57.  
  58.     cap.release()
  59.     out.release()
  60.    
  61.     cv2.destroyAllWindows()
  62.  
  63. except KeyboardInterrupt:
  64.     print("Peace!")
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top