Advertisement
nkb29597

Web app partial code

May 23rd, 2021
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. while True:
  2.     frames = []
  3.  
  4.     for i in range(0, duration): # duration is basically the number of frames I need per blob
  5.         (grabbed, frame) = video_stream.read()
  6.  
  7.         if not grabbed:
  8.             print("Finishing...")
  9.             sys.exit(0)
  10.  
  11.         frame = imutils.resize(frame, width=400)
  12.         frames.append(frame)
  13.  
  14.     frame_blob = cv2.dnn.blobFromImages(frames, 1.0,
  15.                                   (frame_size, frame_size),
  16.                                   (114.7748, 107.7354, 99.4750),
  17.                                   swapRB=True, crop=True)
  18.     frame_blob = np.transpose(frame_blob, (1, 0, 2, 3))
  19.     frame_blob = np.expand_dims(frame_blob, axis=0)
  20.  
  21.     neural_network.setInput(frame_blob)
  22.     outputs = neural_network.forward()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement