text: # import the necessary packages
  from threading import Thread
  import cv2
  
  
  class WebcamVideoStream:
      def __init__(self, src=0, HD=False):
          # initialize the video camera stream and read the first frame
          # from the stream
          self.stream = cv2.VideoCapture(src)
          if HD:
              self.stream.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
              self.stream.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
          (self.grabbed, self.frame) = self.stream.read()
  
          # initialize the variable used to indicate if the thread should
          # be stopped
          self.stopped = False
  
      def start(self):
          # start the thread to read frames from the video stream
          Thread(target=self.update, args=()).start()
          return self
  
      def update(self):
          # keep looping infinitely until the thread is stopped
          while True:
              # if the thread indicator variable is set, stop the thread
              if self.stopped:
                  return
  
              # otherwise, read the next frame from the stream
              (self.grabbed, self.frame) = self.stream.read()
  
      def read(self):
          # return the frame most recently read
          return self.grabbed, self.frame
  
      def stop(self):
          # indicate that the thread should be stopped
          self.stopped = True
  
      def getWidth(self):
          # Get the width of the frames
          return int(self.stream.get(cv2.CAP_PROP_FRAME_WIDTH))
  
      def getHeight(self):
          # Get the height of the frames
          return int(self.stream.get(cv2.CAP_PROP_FRAME_HEIGHT))
  
      def getFPS(self):
          # Get the frame rate of the frames
          return int(self.stream.get(cv2.CAP_PROP_FPS))
  
      def isOpen(self):
          # Get the frame rate of the frames
          return self.stream.isOpened()
  
      def setFramePosition(self, framePos):
          self.stream.set(cv2.CAP_PROP_POS_FRAMES, framePos)
  
      def getFramePosition(self):
          return int(self.stream.get(cv2.CAP_PROP_POS_FRAMES))
  
      def getFrameCount(self):
          return int(self.stream.get(cv2.CAP_PROP_FRAME_COUNT))
  