class_docstr: PiGear is similar to CamGear API but exclusively made to support various Raspberry Pi Camera Modules (such as OmniVision OV5647 Camera Module and Sony IMX219 Camera Module).
  PiGear provides a flexible multi-threaded framework around complete picamera python library, and provide us the ability to exploit almost all of its parameters like brightness,
  saturation, sensor_mode, iso, exposure, etc. effortlessly. Furthermore, PiGear also supports multiple camera modules, such as in the case of Raspberry-Pi Compute Module IO boards.
  
  Best of all, PiGear contains Threaded Internal Timer - that silently keeps active track of any frozen-threads/hardware-failures and exit safely, if any does occur. That means that
  if you're running PiGear API in your script and someone accidentally pulls the Camera-Module cable out, instead of going into possible kernel panic, API will exit safely to save resources.
  
  !!! warning "Make sure to enable [Raspberry Pi hardware-specific settings](https://picamera.readthedocs.io/en/release-1.13/quickstart.html) prior using this API, otherwise nothing will work."
class_docstr_tok: ["PiGear","is","similar","to","CamGear","API","but","exclusively","made","to","support","various","Raspberry","Pi","Camera","Modules","(","such","as","OmniVision","OV5647","Camera","Module","and","Sony","IMX219","Camera","Module",")",".","PiGear","provides","a","flexible","multi-threaded","framework","around","complete","picamera","python","library",",","and","provide","us","the","ability","to","exploit","almost","all","of","its","parameters","like","brightness",",","saturation",",","sensor_mode",",","iso",",","exposure",",","etc",".","effortlessly",".","Furthermore",",","PiGear","also","supports","multiple","camera","modules",",","such","as","in","the","case","of","Raspberry-Pi","Compute","Module","IO","boards",".","Best","of","all",",","PiGear","contains","Threaded","Internal","Timer","-","that","silently","keeps","active","track","of","any","frozen-threads\/hardware-failures","and","exit","safely",",","if","any","does","occur",".","That","means","that","if","you","'re","running","PiGear","API","in","your","script","and","someone","accidentally","pulls","the","Camera-Module","cable","out",",","instead","of","going","into","possible","kernel","panic",",","API","will","exit","safely","to","save","resources",".","!","!","!","warning","``","Make","sure","to","enable","[","Raspberry","Pi","hardware-specific","settings","]","(","https",":","\/\/picamera.readthedocs.io\/en\/release-1.13\/quickstart.html",")","prior","using","this","API",",","otherwise","nothing","will","work",".","''"]
docstr: A **Threaded Frames Extractor**, that keep iterating frames from PiCamera API to a internal monitored deque,
  until the thread is terminated, or frames runs out.
docstr_tok: ["A","*","*","Threaded","Frames","Extractor","*","*",",","that","keep","iterating","frames","from","PiCamera","API","to","a","internal","monitored","deque",",","until","the","thread","is","terminated",",","or","frames","runs","out","."]
code: def __update(self):
      """
      A **Threaded Frames Extractor**, that keep iterating frames from PiCamera API to a internal monitored deque,
      until the thread is terminated, or frames runs out.
      """
      # keep looping infinitely until the thread is terminated
      while not (self.__terminate):
          try:
              # Try to iterate next frame from generator
              stream = next(self.stream)
          except Exception:
              # catch and save any exceptions
              self.__exceptions = sys.exc_info()
              break  # exit
  
          # __update timer
          self.__t_elasped = time.time()
  
          # grab the frame from the stream and clear the stream in
          # preparation for the next frame
          frame = stream.array
          self.__rawCapture.seek(0)
          self.__rawCapture.truncate()
  
          # apply colorspace if specified
          if not (self.color_space is None):
              # apply colorspace to frames
              color_frame = None
              try:
                  if isinstance(self.color_space, int):
                      color_frame = cv2.cvtColor(
                          frame, self.color_space
                      )
                  else:
                      self.__logging and logger.warning(
                          "Global color_space parameter value `{}` is not a valid!".format(
                              self.color_space
                          )
                      )
                      self.color_space = None
              except Exception as e:
                  # Catch if any error occurred
                  self.color_space = None
                  if self.__logging:
                      logger.exception(str(e))
                      logger.warning(
                          "Input colorspace is not a valid colorspace!"
                      )
  
              if not (color_frame is None):
                  self.frame = color_frame
              else:
                  self.frame = frame
          else:
              self.frame = frame
  
      # terminate processes
      if not (self.__terminate):
          self.__terminate = True
  
      # release picamera resources
      self.__rawCapture.close()
      self.__camera.close()
  
file_path: vidgear/vidgear/gears/pigear.py
imports: import cv2
  import sys
  import time
  import logging
  from threading import Thread
  from .helper import capPropId, logger_handler, import_dependency_safe, logcurr_vidgear_ver
label_desc: Use image node_id 4 for calling the PiGear obj's underlying member method code with example usage: obj.__update() without return types