def add_control_pane(self, fixed_width=220):
    # Control pane widget
    self.vpane = ZVerticalPane(self, fixed_width)
    
    self.block_size         = 11
    self.adaptive_method_id = 0;
    self.threshold_type_id  = 0;

    
    self.methods = {"ADAPTIVE_THRESH_MEAN_C": cv2.ADAPTIVE_THRESH_MEAN_C, 
                    "ADAPTIVE_THRESH_GAUSSIAN_C": cv2.ADAPTIVE_THRESH_GAUSSIAN_C}
    self.types   = {"THRESH_BINARY":  cv2.THRESH_BINARY  , 
                    "THRESH_BINARY_INV": cv2.THRESH_BINARY_INV }
    
    self.adaptive_method = ZLabeledComboBox(self.vpane, "AdaptiveMethod")
    self.adaptive_method.add_items(list(self.methods.keys() ))
    self.adaptive_method.add_activated_callback(self.adaptive_method_activated)
    
    self.threshold_type  = ZLabeledComboBox(self.vpane, "ThresholdType")
    self.threshold_type.add_items(list(self.types.keys()) )
    self.threshold_type.add_activated_callback(self.threshold_type_activated)
    
    self.labeled_slider = ZLabeledSlider(self.vpane, "BlockSize", take_odd =True,  
              minimum=3, maximum=43, value=self.block_size, fixed_width=200)
    self.labeled_slider.add_value_changed_callback(self.slider_value_changed)
    
    self.vpane.add(self.adaptive_method)
    self.vpane.add(self.threshold_type)    
    self.vpane.add(self.labeled_slider)

    self.set_right_dock(self.vpane)
    def add_control_pane(self, fixed_width=270):
        self.vpane = ZVerticalPane(self, fixed_width)

        self.rotator = ZLabeledSlider(self, "Rotator", False, self.MIN_ANGLE,
                                      self.MAX_ANGLE, self.CUR_ANGLE)

        self.axisPositioner = ZPositioner(self, "AXISPositioner",
                                          ["X", "Y", "Z"], self.AXIS_RANGE,
                                          self.AXIS_POS)

        self.eyePositioner = ZEyePositioner(self, "EyePositioner",
                                            ["X", "Y", "Z"], self.EYE_RANGE,
                                            self.EYE_POS)

        self.lightPositioner = ZLightPositioner(self, "LightPositioner",
                                                ["X", "Y", "Z"],
                                                self.LIGHT_RANGE,
                                                self.LIGHT_POS)

        self.vpane.add(self.rotator)
        self.vpane.add(self.axisPositioner)

        self.vpane.add(self.eyePositioner)
        self.vpane.add(self.lightPositioner)

        self.set_right_dock(self.vpane)
Ejemplo n.º 3
0
    def add_control_pane(self, fixed_width=220):
        # Control pane widget
        self.vpane = ZVerticalPane(self, fixed_width)

        self.filter_width_div_two = 30
        #self.adaptive_method_id = 0;
        #self.threshold_type_id  = 0;
        """
    self.methods = {"ADAPTIVE_THRESH_MEAN_C": cv2.ADAPTIVE_THRESH_MEAN_C, 
                    "ADAPTIVE_THRESH_GAUSSIAN_C": cv2.ADAPTIVE_THRESH_GAUSSIAN_C}
    self.types   = {"THRESH_BINARY":  cv2.THRESH_BINARY  , 
                    "THRESH_BINARY_INV": cv2.THRESH_BINARY_INV }
    
    self.adaptive_method = ZLabeledComboBox(self.vpane, "AdaptiveMethod")
    self.adaptive_method.add_items(list(self.methods.keys() ))
    self.adaptive_method.add_activated_callback(self.adaptive_method_activated)
    
    self.threshold_type  = ZLabeledComboBox(self.vpane, "ThresholdType")
    self.threshold_type.add_items(list(self.types.keys()) )
    self.threshold_type.add_activated_callback(self.threshold_type_activated)
    """
        self.labeled_slider = ZLabeledSlider(self.vpane,
                                             "Filter width // 2 ",
                                             take_odd=True,
                                             minimum=0,
                                             maximum=480 // 2,
                                             value=self.filter_width_div_two,
                                             fixed_width=200)
        self.labeled_slider.add_value_changed_callback(
            self.slider_value_changed)

        #self.vpane.add(self.adaptive_method)
        #self.vpane.add(self.threshold_type)
        self.vpane.add(self.labeled_slider)

        #self.set_right_dock(self.vpane)
        #self.grid = ZGridLayouter(self)

        self.main_layouter.add(self.vpane, 1, 2)
Ejemplo n.º 4
0
class MainView(ZApplicationView):
    class BinarizedImageView(ZOpenCVImageView):
        def __init__(self, parent):
            ZOpenCVImageView.__init__(self, parent)

    # Constructor
    def __init__(self, title, x, y, width, height):
        super(MainView, self).__init__(title, x, y, width, height)

        self.raw_video_queue = mp.Queue()
        self.to_binarize_video_queue = mp.Queue()
        self.binarized_video_queue = mp.Queue()

        # Binarize initial settings
        #self.block_size         = 11
        #self.adaptive_method_id = 0;
        #self.threshold_type_id  = 0;

        self.binarize_video_settings_queue = mp.Queue()
        #binarize_video_settings_queue.put_nowait((self.block_size, \
        #                                          self.adaptive_method_id, \
        #                                          self.threshold_type_id))

        self.time_snapshot_seconds = None  # initialized to None . Used for rate limiting processing pipelines
        self.processing_rate_limit_hz = 20  # 30 Hz seems to be about the maximum if this camera

        self.raw_image_view = ZOpenCVImageView(self)
        self.binarized_image_view = self.BinarizedImageView(self)

        self.add(self.raw_image_view)
        self.add(self.binarized_image_view)

        title = name
        self.setWindowTitle(title)

        self.show()

    def add_control_pane(self, fixed_width=220):
        # Control pane widget
        self.vpane = ZVerticalPane(self, fixed_width)

        #"""
        self.block_size = 11
        self.adaptive_method_id = 0
        self.threshold_type_id = 0
        #"""

        self.methods = {
            "ADAPTIVE_THRESH_MEAN_C": cv2.ADAPTIVE_THRESH_MEAN_C,
            "ADAPTIVE_THRESH_GAUSSIAN_C": cv2.ADAPTIVE_THRESH_GAUSSIAN_C
        }
        self.types = {
            "THRESH_BINARY": cv2.THRESH_BINARY,
            "THRESH_BINARY_INV": cv2.THRESH_BINARY_INV
        }

        self.adaptive_method = ZLabeledComboBox(self.vpane, "AdaptiveMethod")
        self.adaptive_method.add_items(list(self.methods.keys()))
        self.adaptive_method.add_activated_callback(
            self.adaptive_method_activated)

        self.threshold_type = ZLabeledComboBox(self.vpane, "ThresholdType")
        self.threshold_type.add_items(list(self.types.keys()))
        self.threshold_type.add_activated_callback(
            self.threshold_type_activated)

        self.labeled_slider = ZLabeledSlider(self.vpane,
                                             "BlockSize",
                                             take_odd=True,
                                             minimum=3,
                                             maximum=43,
                                             value=self.block_size,
                                             fixed_width=200)
        self.labeled_slider.add_value_changed_callback(
            self.slider_value_changed)

        self.vpane.add(self.adaptive_method)
        self.vpane.add(self.threshold_type)
        self.vpane.add(self.labeled_slider)

        self.set_right_dock(self.vpane)

    def slider_value_changed(self, value):
        self.block_size = int(value)
        if self.block_size % 2 == 0:
            # Block size should be odd.
            self.block_size = int((self.block_size * 2) / 2 + 1)
        #print("slider_value_changed:{}".format(block_size))

        #self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)

        settings = (self.adaptive_method_id, self.threshold_type_id,
                    self.block_size)
        self.binarize_video_settings_queue.put_nowait(settings)

    def adaptive_method_activated(self, text):
        #print("adaptive_method_activated:{}".format(text))
        self.adaptive_method_id = self.methods[text]

        #self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)

        settings = (self.adaptive_method_id, self.threshold_type_id,
                    self.block_size)
        self.binarize_video_settings_queue.put_nowait(settings)

    def threshold_type_activated(self, text):
        #print("threshold_type_activated:{}".format(text))
        self.threshold_type_id = self.types[text]

        #self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)

        settings = (self.adaptive_method_id, self.threshold_type_id,
                    self.block_size)
        self.binarize_video_settings_queue.put_nowait(settings)

    # Read a frame from a video buffer of the video capture, and set it the image view to draw it on the imag view
    def render(self):

        return_true = False
        #return_true = True
        #"""
        if not self.raw_video_queue.empty():
            raw_frame = self.raw_video_queue.get_nowait()

            if raw_frame.any() != None:
                self.raw_image_view.set_opencv_image(raw_frame)
                self.raw_image_view.update()

                # Send frame to processing queue
                # rate limited
                current_time_seconds = time()

                if self.time_snapshot_seconds == None:
                    self.time_snapshot_seconds = current_time_seconds

                if current_time_seconds > self.time_snapshot_seconds:  # Avoid dividing by zero

                    #print(1/(current_time_seconds-self.time_snapshot_seconds))

                    if ((1 /
                         (current_time_seconds - self.time_snapshot_seconds))
                            <= self.processing_rate_limit_hz):  # Rate limit

                        #print("Sending raw frame for further processing!")

                        self.to_binarize_video_queue.put_nowait(raw_frame)

                        self.time_snapshot_seconds = current_time_seconds

                return_true = True

        if not self.binarized_video_queue.empty():
            binarized_frame = self.binarized_video_queue.get_nowait()

            if binarized_frame.any() != None:
                self.binarized_image_view.set_opencv_image(binarized_frame)
                self.binarized_image_view.update()

                return_true = True
        #"""
        if return_true:
            return True
        else:
            return False

    def file_quit(self):
        self.terminated = True

    def closeEvent(self, ce):
        self.terminated = True
class MainView(ZOpenGLMainView):
    ##--------------------------------------------
    class OpenGLView(ZOpenGLView):
        def __init__(self, parent, angle, axis, eye, light):
            self.parent = parent
            super(ZOpenGLView, self).__init__(parent)
            self.angle = angle
            self.axis = axis
            self.veye = eye
            self.vlight = light

        def initializeGL(self):
            #glShadeModel(GL_FLAT)
            #glEnable(GL_DEPTH_TEST)
            #glMatrixMode(GL_PROJECTION)
            #glLoadIdentity()
            #glMatrixMode(GL_MODELVIEW)

            self.light = ZOpenGLLight(GL_LIGHT0)

            #self.material = ZOpenGLMaterial(GL_FRONT)
            self.sphere = None

            filename = "./images/ven0aaa2.jpg"

            self.createTexture(filename)
            self.parent.set_filenamed_title(filename)

        def paintGL(self):
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
            glClearColor(0.0, 0.0, 0.0, 0.0)
            glLoadIdentity()

            #gluLookAt(0.0, 2.0, -1.0, 0.0, 0.0, 0.0, 0.0, 30.0, 0.0);
            gluLookAt(self.veye[0], self.veye[1], self.veye[2], 0.0, 0.0, 0.0,
                      0.0, 1.0, 0.0)

            glEnable(GL_LIGHTING)
            self.light.position(self.vlight[0], self.vlight[1], self.vlight[2],
                                0.0)

            glTranslatef(0.0, 0.0, 0.0)
            glRotate(self.angle, self.axis[0], self.axis[1], self.axis[2])
            #self.material.diffuse(0.0, 0.0, 1.0, 1.0);

            #self.material.specular(1.0, 1.0, 1.0, 0.0);
            #self.material.shininess(100.0);

            if self.sphere != None:
                self.sphere.draw()

        def resizeGL(self, width, height):
            if width == 0 or height == 0:
                return
            glViewport(0, 0, width, height)
            glMatrixMode(GL_PROJECTION)
            glLoadIdentity()
            glFrustum(width / height, -width / height, -1.0, 1.0, 2.0, 30.0)
            glMatrixMode(GL_MODELVIEW)

        def createTexture(self, filename):
            self.sphere = ZOpenGLTexturedSphere(filename, None, 1.0, 40, 40)

        def setAngle(self, angle):
            self.angle = angle
            self.update()

        def setAxisPosition(self, axis):
            self.vaxis = axis
            self.update()

        def setEyePosition(self, eye):
            self.veye = eye
            self.update()

        def setLigtPosition(self, light):
            self.vlight = light
            self.update()

    ##--------------------------------------------
    # class variables
    MIN_ANGLE = -180
    MAX_ANGLE = 180
    CUR_ANGLE = 128
    AXIS_RANGE = [-100, 100]
    AXIS_POS = [-10, -50, 80.0]
    EYE_RANGE = [-200, 200]
    EYE_POS = [0.0, 1.0, 2]
    LIGHT_RANGE = [-200, 200]
    LIGHT_POS = [-14.0, -10, -70.0]

    # MainView Constructor
    def __init__(self, title, x, y, width, height):
        super(ZOpenGLMainView, self).__init__(title, x, y, width, height)

        # 1 Create first imageview.
        self.opengl_view = self.OpenGLView(self, self.CUR_ANGLE, self.AXIS_POS,
                                           self.EYE_POS, self.LIGHT_POS)

        # 2 Add the image view to a main_layout of this main view.
        self.add(self.opengl_view)

        # 3 Add callbacks to positioners.
        self.rotator.add_value_changed_callback(self.angle_changed)
        self.axisPositioner.add_value_changed_callback(self.axis_changed)
        self.eyePositioner.add_value_changed_callback(self.eye_changed)
        self.lightPositioner.add_value_changed_callback(self.light_changed)

        self.show()

    # Add control pane to MainView
    def add_control_pane(self, fixed_width=270):
        self.vpane = ZVerticalPane(self, fixed_width)

        self.rotator = ZLabeledSlider(self, "Rotator", False, self.MIN_ANGLE,
                                      self.MAX_ANGLE, self.CUR_ANGLE)

        self.axisPositioner = ZPositioner(self, "AXISPositioner",
                                          ["X", "Y", "Z"], self.AXIS_RANGE,
                                          self.AXIS_POS)

        self.eyePositioner = ZEyePositioner(self, "EyePositioner",
                                            ["X", "Y", "Z"], self.EYE_RANGE,
                                            self.EYE_POS)

        self.lightPositioner = ZLightPositioner(self, "LightPositioner",
                                                ["X", "Y", "Z"],
                                                self.LIGHT_RANGE,
                                                self.LIGHT_POS)

        self.vpane.add(self.rotator)
        self.vpane.add(self.axisPositioner)

        self.vpane.add(self.eyePositioner)
        self.vpane.add(self.lightPositioner)

        self.set_right_dock(self.vpane)

    def angle_changed(self, value):
        self.rotator.set_value_text(str(value))
        self.opengl_view.setAngle(value)

    def axis_changed(self, v):
        values = self.axisPositioner.get_values()
        self.opengl_view.setAxisPosition(values)

    def eye_changed(self, v):
        values = self.eyePositioner.get_values()
        self.opengl_view.setEyePosition(values)

    def light_changed(self, v):
        values = self.lightPositioner.get_values()
        self.opengl_view.setLigtPosition(values)

    # Show FileOpenDialog and select an image file.
    def file_open(self):
        options = QFileDialog.Options()
        filename, _ = QFileDialog.getOpenFileName(
            self,
            "FileOpenDialog",
            "",
            "All Files (*);;Image Files (*.png;*jpg;*.jpeg)",
            options=options)
        if filename:
            self.load_file(filename)

    def load_file(self, filename):
        self.opengl_view.createTexture(filename)
        self.set_filenamed_title(filename)
Ejemplo n.º 6
0
class MainView(ZApplicationView):
  
  class BinarizedImageView(ZOpenCVImageView):
    def __init__(self, parent):
      ZOpenCVImageView.__init__(self, parent)
      
    def load_source_image(self, source_image):
      image =  cv2.GaussianBlur(source_image, (3,3), 0, 0, borderType = cv2.BORDER_DEFAULT );
      #image =  cv2.GaussianBlur(source_image, (3,3), 0, 0)

      self.gray_image = cv2.cvtColor(source_image, cv2.COLOR_RGB2GRAY)
             
    def binarize(self, adaptive_method_id, threshold_type_id, block_size):
      MAX_PIXEL_VALUE = 255
      C               = 9.0
    
      binarized_image = cv2.adaptiveThreshold(self.gray_image,  MAX_PIXEL_VALUE, 
          adaptive_method_id, threshold_type_id, block_size,  C);
          
      #return binarized_image
      self.set_opencv_image(binarized_image)
      self.update()
  
  # Constructor
  def __init__(self, title, x, y, width, height):
    super(MainView, self).__init__(title, x, y, width, height)
    
    self.raw_video_queue = mp.Queue()
    
    self.raw_image_view  = ZOpenCVImageView(self)
    self.binarized_image_view = self.BinarizedImageView(self)

    self.add(self.raw_image_view)
    self.add(self.binarized_image_view)

    title = name
    self.setWindowTitle(title)
    
    self.show()
  
  def add_control_pane(self, fixed_width=220):
    # Control pane widget
    self.vpane = ZVerticalPane(self, fixed_width)
    
    self.block_size         = 11
    self.adaptive_method_id = 0;
    self.threshold_type_id  = 0;

    
    self.methods = {"ADAPTIVE_THRESH_MEAN_C": cv2.ADAPTIVE_THRESH_MEAN_C, 
                    "ADAPTIVE_THRESH_GAUSSIAN_C": cv2.ADAPTIVE_THRESH_GAUSSIAN_C}
    self.types   = {"THRESH_BINARY":  cv2.THRESH_BINARY  , 
                    "THRESH_BINARY_INV": cv2.THRESH_BINARY_INV }
    
    self.adaptive_method = ZLabeledComboBox(self.vpane, "AdaptiveMethod")
    self.adaptive_method.add_items(list(self.methods.keys() ))
    self.adaptive_method.add_activated_callback(self.adaptive_method_activated)
    
    self.threshold_type  = ZLabeledComboBox(self.vpane, "ThresholdType")
    self.threshold_type.add_items(list(self.types.keys()) )
    self.threshold_type.add_activated_callback(self.threshold_type_activated)
    
    self.labeled_slider = ZLabeledSlider(self.vpane, "BlockSize", take_odd =True,  
              minimum=3, maximum=43, value=self.block_size, fixed_width=200)
    self.labeled_slider.add_value_changed_callback(self.slider_value_changed)
    
    self.vpane.add(self.adaptive_method)
    self.vpane.add(self.threshold_type)    
    self.vpane.add(self.labeled_slider)

    self.set_right_dock(self.vpane)

  def slider_value_changed(self, value):
    self.block_size = int(value)
    if self.block_size % 2 == 0:
      # Block size should be odd.
      self.block_size = int((self.block_size * 2)/2 + 1)
    #print("slider_value_changed:{}".format(block_size))
    self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)
    
  def adaptive_method_activated(self, text):
    #print("adaptive_method_activated:{}".format(text))
    self.adaptive_method_id = self.methods[text]
    
    self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)
     
  def threshold_type_activated(self, text):
    #print("threshold_type_activated:{}".format(text))
    self.threshold_type_id = self.types[text]
    self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)
    
  # Read a frame from a video buffer of the video capture, and set it the image view to draw it on the imag view     
  def render(self):
    
    #return_true = False
    
    if not self.raw_video_queue.empty():
      raw_frame = self.raw_video_queue.get_nowait()
      
      if raw_frame.any() != None:
        self.raw_image_view.set_opencv_image(raw_frame)
        self.raw_image_view.update()
        
        
        self.binarized_image_view.load_source_image(raw_frame)
        self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)
        
        
        return True
      
    """
      
    if not self.binarized_video_queue.empty():
      binarized_frame = self.binarized_video_queue.get_notwait()
      if binarized_frame.any() != None:
        self.binarized_image_view.set_opencv_image(binarized_frame)
        self.binarized_image_view.update()
        return_true = True
    
    if return_true:
      return True
    else:
      return False
    """
    return False
    
  """
  def load_file(self, filename):
    self.image_view_3.load(filename)
    self.set_filenamed_title(filename)
 """
  
  def file_quit(self):
    self.terminated = True
    
  def closeEvent(self, ce):
    self.terminated = True
Ejemplo n.º 7
0
class MainView(ZApplicationView):
    # Constructor
    def __init__(self, title, x, y, width, height):
        super(MainView, self).__init__(title,
                                       x,
                                       y,
                                       width,
                                       height,
                                       layout=Z.Grid)

        self.raw_video_queue = Queue()
        self.to_dft_video_queue = Queue()
        self.dft_settings_queue = Queue()

        self.dft_settings_queue.put_nowait([30])  # temporary

        self.dft_magnitude_unfiltered_video_queue = Queue()
        self.dft_magnitude_filtered_video_queue = Queue()
        self.filtered_video_queue = Queue()

        self.time_snapshot_seconds = None  # initialized to None . Used for rate limiting processing pipelines
        self.processing_rate_limit_hz = 5

        self.raw_image_view = ZOpenCVImageView(self)
        self.dft_magnitude_unfiltered_image_view = ZOpenCVImageView(self)
        self.dft_magnitude_filtered_image_view = ZOpenCVImageView(self)
        self.filtered_image_view = ZOpenCVImageView(self)

        #self.grid = ZGridLayouter(self)

        self.main_layouter.add(self.raw_image_view, 0, 0)
        self.main_layouter.add(self.dft_magnitude_unfiltered_image_view, 0, 1)
        self.main_layouter.add(self.dft_magnitude_filtered_image_view, 1, 1)
        self.main_layouter.add(self.filtered_image_view, 1, 0)

        title = name
        self.setWindowTitle(title)

        self.show()

    #"""
    def add_control_pane(self, fixed_width=220):
        # Control pane widget
        self.vpane = ZVerticalPane(self, fixed_width)

        self.filter_width_div_two = 30
        #self.adaptive_method_id = 0;
        #self.threshold_type_id  = 0;
        """
    self.methods = {"ADAPTIVE_THRESH_MEAN_C": cv2.ADAPTIVE_THRESH_MEAN_C, 
                    "ADAPTIVE_THRESH_GAUSSIAN_C": cv2.ADAPTIVE_THRESH_GAUSSIAN_C}
    self.types   = {"THRESH_BINARY":  cv2.THRESH_BINARY  , 
                    "THRESH_BINARY_INV": cv2.THRESH_BINARY_INV }
    
    self.adaptive_method = ZLabeledComboBox(self.vpane, "AdaptiveMethod")
    self.adaptive_method.add_items(list(self.methods.keys() ))
    self.adaptive_method.add_activated_callback(self.adaptive_method_activated)
    
    self.threshold_type  = ZLabeledComboBox(self.vpane, "ThresholdType")
    self.threshold_type.add_items(list(self.types.keys()) )
    self.threshold_type.add_activated_callback(self.threshold_type_activated)
    """
        self.labeled_slider = ZLabeledSlider(self.vpane,
                                             "Filter width // 2 ",
                                             take_odd=True,
                                             minimum=0,
                                             maximum=480 // 2,
                                             value=self.filter_width_div_two,
                                             fixed_width=200)
        self.labeled_slider.add_value_changed_callback(
            self.slider_value_changed)

        #self.vpane.add(self.adaptive_method)
        #self.vpane.add(self.threshold_type)
        self.vpane.add(self.labeled_slider)

        #self.set_right_dock(self.vpane)
        #self.grid = ZGridLayouter(self)

        self.main_layouter.add(self.vpane, 1, 2)

    def slider_value_changed(self, value):
        self.block_size = int(value)
        #if self.block_size % 2 == 0:
        #  # Block size should be odd.
        #  self.block_size = int((self.block_size * 2)/2 + 1)
        #print("slider_value_changed:{}".format(block_size))

        #self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)
        """
    # Send frame to processing queue rate limited
    current_time_seconds = time()
    
    if self.time_snapshot_seconds == None:
      self.time_snapshot_seconds = current_time_seconds
    
    if ((1/(current_time_seconds-self.time_snapshot_seconds)) <= self.processing_rate_limit_hz): # Rate limit
        """

        settings = [self.block_size]

        self.dft_settings_queue.put_nowait(settings)

    #"""
    """
  def adaptive_method_activated(self, text):
    #print("adaptive_method_activated:{}".format(text))
    self.adaptive_method_id = self.methods[text]
    
    #self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)
    
    settings = (self.adaptive_method_id, self.threshold_type_id, self.block_size)
    self.binarize_video_settings_queue.put_nowait(settings)
     
  def threshold_type_activated(self, text):
    #print("threshold_type_activated:{}".format(text))
    self.threshold_type_id = self.types[text]
    
    #self.binarized_image_view.binarize(self.adaptive_method_id, self.threshold_type_id, self.block_size)
    
    settings = (self.adaptive_method_id, self.threshold_type_id, self.block_size)
    self.binarize_video_settings_queue.put_nowait(settings)
  """

    # Read a frame from a video buffer of the video capture, and set it the image view to draw it on the imag view
    def render(self):

        return_true = False

        if not self.raw_video_queue.empty():
            raw_frame = self.raw_video_queue.get_nowait()

            if raw_frame.any() != None:
                self.raw_image_view.set_opencv_image(raw_frame)
                self.raw_image_view.update()

                # Send frame to processing queue rate limited
                current_time_seconds = time()

                if self.time_snapshot_seconds == None:
                    self.time_snapshot_seconds = current_time_seconds

                if current_time_seconds > self.time_snapshot_seconds:  # Avoid dividing by zero

                    #print(1/(current_time_seconds-self.time_snapshot_seconds))

                    if ((1 /
                         (current_time_seconds - self.time_snapshot_seconds))
                            <= self.processing_rate_limit_hz):  # Rate limit

                        #print("Sending raw frame for further processing!")

                        self.to_dft_video_queue.put_nowait(raw_frame)

                        self.time_snapshot_seconds = current_time_seconds

                return_true = True

        if not self.dft_magnitude_unfiltered_video_queue.empty():
            dft_magnitude_unfiltered_frame = \
            self.dft_magnitude_unfiltered_video_queue.get_nowait()

            if dft_magnitude_unfiltered_frame.any() != None:
                self.dft_magnitude_unfiltered_image_view.set_opencv_image(
                    np.uint8(dft_magnitude_unfiltered_frame))
                self.dft_magnitude_unfiltered_image_view.update()

                return_true = True

        if not self.dft_magnitude_filtered_video_queue.empty():
            dft_magnitude_filtered_frame = \
            self.dft_magnitude_filtered_video_queue.get_nowait()

            if dft_magnitude_filtered_frame.any() != None:
                self.dft_magnitude_filtered_image_view.set_opencv_image(
                    np.uint8(dft_magnitude_filtered_frame))
                self.dft_magnitude_filtered_image_view.update()

                return_true = True

        if not self.filtered_video_queue.empty():
            filtered_video_frame = \
            self.filtered_video_queue.get_nowait()

            if filtered_video_frame.any() != None:
                self.filtered_image_view.set_opencv_image(
                    np.uint8(filtered_video_frame))
                self.filtered_image_view.update()

                return_true = True

        if return_true:
            return True
        else:
            return False

    def file_quit(self):
        self.terminated = True

    def closeEvent(self, ce):
        self.terminated = True