class_docstr: This is an auxiliary class that enables Video Stabilization for vidgear with minimalistic latency, and at the expense
  of little to no additional computational requirements.
  
  The basic idea behind it is to tracks and save the salient feature array for the given number of frames and then uses
  these anchor point to cancel out all perturbations relative to it for the incoming frames in the queue. This class relies
  heavily on **Threaded Queue mode** for error-free & ultra-fast frame handling.
docstr: This constructor method initializes the object state and attributes of the Stabilizer class.
  
  Parameters:
      smoothing_radius (int): alter averaging window size.
      border_type (str): changes the extended border type.
      border_size (int): enables and set the value for extended border size to reduce the black borders.
      crop_n_zoom (bool): enables cropping and zooming of frames(to original size) to reduce the black borders.
      logging (bool): enables/disables logging.
code: def __init__(
      self,
      smoothing_radius=25,
      border_type="black",
      border_size=0,
      crop_n_zoom=False,
      logging=False,
  ):
      """
      This constructor method initializes the object state and attributes of the Stabilizer class.
  
      Parameters:
          smoothing_radius (int): alter averaging window size.
          border_type (str): changes the extended border type.
          border_size (int): enables and set the value for extended border size to reduce the black borders.
          crop_n_zoom (bool): enables cropping and zooming of frames(to original size) to reduce the black borders.
          logging (bool): enables/disables logging.
      """
      # print current version
      logcurr_vidgear_ver(logging=logging)
  
      # initialize deques for handling input frames and its indexes
      self.__frame_queue = deque(maxlen=smoothing_radius)
      self.__frame_queue_indexes = deque(maxlen=smoothing_radius)
  
      # enable logging if specified
      self.__logging = False
      if logging:
          self.__logging = logging
  
      # define and create Adaptive histogram equalization (AHE) object for optimizations
      self.__clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
  
      # initialize global vars
      self.__smoothing_radius = smoothing_radius  # averaging window, handles the quality of stabilization at expense of latency and sudden panning
      self.__smoothed_path = (
          None  # handles the smoothed path with box filter
      )
      self.__path = None  # handles path i.e cumulative sum of previous_2_current transformations along a axis
      self.__transforms = (
          []
      )  # handles previous_2_current transformations [dx,dy,da]
      self.__frame_transforms_smoothed = None  # handles smoothed array of previous_2_current transformations w.r.t to frames
      self.__previous_gray = None  # handles previous gray frame
      self.__previous_keypoints = None  # handles previous detect_GFTTed keypoints w.r.t previous gray frame
      self.__frame_height, self.frame_width = (
          0,
          0,
      )  # handles width and height of input frames
      self.__crop_n_zoom = 0  # handles cropping and zooms frames to reduce the black borders from stabilization being too noticeable.
  
      # if check if crop_n_zoom defined
      if crop_n_zoom and border_size:
          self.__crop_n_zoom = (
              border_size  # crops and zoom frame to original size
          )
          self.__border_size = 0  # zero out border size
          self.__frame_size = None  # handles frame size for zooming
          if logging:
              logger.debug(
                  "Setting Cropping margin {} pixels".format(
                      border_size
                  )
              )
      else:
          # Add output borders to frame
          self.__border_size = border_size
          if self.__logging and border_size:
              logger.debug(
                  "Setting Border size {} pixels".format(border_size)
              )
  
      # define valid border modes
      border_modes = {
          "black": cv2.BORDER_CONSTANT,
          "reflect": cv2.BORDER_REFLECT,
          "reflect_101": cv2.BORDER_REFLECT_101,
          "replicate": cv2.BORDER_REPLICATE,
          "wrap": cv2.BORDER_WRAP,
      }
      # choose valid border_mode from border_type
      if border_type in [
          "black",
          "reflect",
          "reflect_101",
          "replicate",
          "wrap",
      ]:
          if not crop_n_zoom:
              # initialize global border mode variable
              self.__border_mode = border_modes[border_type]
              if self.__logging and border_type != "black":
                  logger.debug(
                      "Setting Border type: {}".format(border_type)
                  )
          else:
              # log and reset to default
              if self.__logging and border_type != "black":
                  logger.debug(
                      "Setting border type is disabled if cropping is enabled!"
                  )
              self.__border_mode = border_modes["black"]
      else:
          # otherwise log if not
          if logging:
              logger.debug("Invalid input border type!")
          self.__border_mode = border_modes[
              "black"
          ]  # reset to default mode
  
      # define OpenCV version
      self.__cv2_version = check_CV_version()
  
      # retrieve best interpolation
      self.__interpolation = retrieve_best_interpolation(
          ["INTER_LINEAR_EXACT", "INTER_LINEAR", "INTER_AREA"]
      )
  
      # define normalized box filter
      self.__box_filter = np.ones(smoothing_radius) / smoothing_radius
  
file_path: vidgear/vidgear/gears/stabilizer.py
imports: import cv2
  import numpy
  import logging
  from collections import deque
  from .helper import logger_handler, check_CV_version, retrieve_best_interpolation, logcurr_vidgear_ver
label_desc: Use image node_id 1 to create a new Stabilizer object  with example: obj = Stabilizer(smoothing_radius, border_type, border_size, crop_n_zoom, logging)