code: def read_frames(args):
      # Create a VideoCapture object and read from input file
      # If the input is the camera, pass 0 instead of the video file name
  
      # If Reading a camera, we convert to int
      try:
          device = int(args.input)
      except:
          device = args.input
  
      cap = cv2.VideoCapture(device)
  
      # Check if video opened successfully
      if cap.isOpened() == False:
          print("Error opening video stream or file")
  
      frame_cnt = 0
  
      # Read until video is completed
      while cap.isOpened():
          # Capture frame-by-frame
          ret, frame = cap.read()
          if ret == True:
              # Encode the frame into byte data
              data = cv2.imencode(".jpg", frame)[1].tobytes()
              queue.append(data)
              frame_cnt += 1
  
              # For videos, add a sleep so that we read at 30 FPS
              if not isinstance(device, int):
                  time.sleep(1.0 / 30)
  
          # Break the loop
          else:
              break
  
      print("Done reading {} frames".format(frame_cnt))
  
      # When everything done, release the video capture object
      cap.release()
  
      # Closes all the frames
      cv2.destroyAllWindows()
  
file_path: serve/examples/image_classifier/near_real_time_video/request.py
imports: import argparse
  import base64
  import json
  import time
  from collections import deque
  from concurrent.futures import as_completed
  from threading import Thread
  import cv2
  import requests
  from requests_futures.sessions import FuturesSession
label_desc: Use image node_id 1 for calling a global function with example usage: read_frames(args) without return types