def visualize(self, frame):
     visualizer = VideoVisualizer()
     steps = []
     steps.append(self.__getFrameMatrix__(self.input, frame))
     output = self.__getFrameMatrix__(self.output, frame)
     steps.append(output)
     visualizeFrame = Frame(np.hstack(steps))
     visualizer.showFrameQuick(type(self).__name__, visualizeFrame)
     for i in range(1000):
         cv2i.waitKey(1)
Exemplo n.º 2
0
    def showFrameQuick(self, window, frame):
        """

        Display a frame withot waiting function. This is used to see results of
        the algorithms on the fly or to visualize videos frame by frame. If not
        cv2.waitKey is called then the window is not displayed.
        
        :param Frame frame: frame to be displayed.

        * Example 1::
        
            from egovision import Video
            from egovision.values.paths import VIDEO_EXAMPLE_PATH
            from egovision.output import VideoVisualizer
            video = Video(VIDEO_EXAMPLE_PATH.format("BENCHTEST.MP4"))
            VideoVisualizer.showFrameQuick("BENCHTEST", video.next())
        """
        cv2i.imshow(window, frame.matrix)
        for i in range(1):
            cv2i.waitKey(1)
Exemplo n.º 3
0
    def showFrame(self, window, frame):
        """
        Display a fream.
        
        :param Frame frame: frame to be displayed.

        * Example 1::
        
            from egovision import Video
            from egovision.values.paths import VIDEO_EXAMPLE_PATH
            from egovision.output import VideoVisualizer
            video = Video(VIDEO_EXAMPLE_PATH.format("BENCHTEST.MP4"))
            VideoVisualizer.showFrame("BENCHTEST", video.next())
        """
        cv2i.imshow(window, frame.matrix)
        k = cv2i.waitKey(0)
        if k != -1:
            cv2i.destroyWindow(window)
            [cv2i.waitKey(1)
             for x in range(10)]  # The worst solution of the world
Exemplo n.º 4
0
 def visualize(self, frame):
     visualizer = VideoVisualizer()
     steps = []
     inputProbability = self.__getFrameMatrix__(self.input, frame)
     steps.append(inputProbability)
     steps.append(
         self.smoother.__getFrameMatrix__(self.smoother.output, frame))
     steps.append(
         self.thresholder.__getFrameMatrix__(self.thresholder.output,
                                             frame))
     steps.append(
         self.borderFilter.__getFrameMatrix__(self.borderFilter.output,
                                              frame))
     steps.append(
         self.areaFilter.__getFrameMatrix__(self.areaFilter.output, frame))
     steps.append(
         self.numberFilter.__getFrameMatrix__(self.numberFilter.output,
                                              frame))
     visualizeFrame = Frame(np.hstack(steps))
     visualizer.showFrameQuick(type(self).__name__, visualizeFrame)
     for i in range(100):
         cv2i.waitKey(1)
Exemplo n.º 5
0
    def showVideo(self, window, video):
        """
        Display a video.
        
        :param Video video: Show video.

        * Example 1::
        
            from egovision import Video
            from egovision.values.paths import VIDEO_EXAMPLE_PATH
            from egovision.output import VideoVisualizer
            video = Video(VIDEO_EXAMPLE_PATH.format("BENCHTEST.MP4"))
            VideoVisualizer.showVideo("BENCHTEST", video)
        """
        for frame in video:
            self.showFrameQuick(window, frame)
            if cv2i.waitKey(1) > 0:
                break
            else:
                pass