コード例 #1
0
ファイル: asciiart.py プロジェクト: derricw/asciisciit
 def show(self, resize_term=False, rescale=False):
     if resize_term:
         try:
             console.set_terminal_size(self.size)
         except:
             pass
     print(self.data)
コード例 #2
0
ファイル: asciiart.py プロジェクト: derricw/asciisciit
 def show(self, resize_term=False, rescale=False):
     if resize_term:
         try:
             console.set_terminal_size(self.size)
         except:
             pass
     print(self.data)
コード例 #3
0
ファイル: asciiart.py プロジェクト: derricw/asciisciit
def play_sequence(seq, fps=30, repeats=1):
    shape = seq[0].size
    console.set_terminal_size(shape)
    t = time.clock()
    for im in seq:
        console.clear_term()
        print(im)
        interval = time.clock()-t
        t = time.clock()
        remaining = 1.0/fps-interval
        if remaining > 0:
            time.sleep(remaining)
コード例 #4
0
ファイル: asciiart.py プロジェクト: derricw/asciisciit
def play_sequence(seq, fps=30, repeats=1):
    shape = seq[0].size
    console.set_terminal_size(shape)
    t = time.time()
    for im in seq:
        console.clear_term()
        print(im)
        interval = time.time()-t
        t = time.time()
        remaining = 1.0/fps-interval
        if remaining > 0:
            time.sleep(remaining)
コード例 #5
0
ファイル: asciiart.py プロジェクト: derricw/asciisciit
    def _play_movie(self, fps=None, repeats=1):
        fps = fps or self.default_fps
        if repeats < 0:
            repeats = 1  # lets just play movies once by default
        for i in range(repeats):
            video = cv2.VideoCapture(self.movie_path)
            frame = 0
            t = time.clock()
            while 1:
                result, image = video.read()
                if type(image) != np.ndarray:
                    print("End of movie.")
                    break
                if result:
                    ascii_img = AsciiImage(image,
                                           scalefactor=self.scalefactor,
                                           invert=self.invert,
                                           equalize=self.equalize,
                                           lut=self.lut,
                                           font_path=self.font_path)
                    #set terminal size on the first image?
                    if frame == 0:
                        try:
                            console.set_terminal_size(ascii_img.size)
                        except:
                            pass
                    console.clear_term()
                    print(ascii_img)
                    frame += 1
                else:
                    break
                draw_time = time.clock()-t
                t = time.clock()
                remaining = 1.0/fps-draw_time
                if remaining > 0:
                    time.sleep(remaining)
                    interval = draw_time+remaining
                else:
                    interval = draw_time
                self.frame_intervals.append(interval)
                self.draw_times.append(draw_time)

            print("Total frames displayed:", frame)
            print("Avg draw time:", np.mean(self.draw_times))
            print("Avg frame interval:", np.mean(self.frame_intervals))
            print("Max frame interval:", np.max(self.frame_intervals))
            print("Min frame interval:", np.min(self.frame_intervals))

            video.release()
コード例 #6
0
ファイル: asciiart.py プロジェクト: derricw/asciisciit
    def _play_movie(self, fps=None, repeats=1):
        fps = fps or self.default_fps
        if repeats < 0:
            repeats = 1  # lets just play movies once by default
        for i in range(repeats):
            video = cv2.VideoCapture(self.movie_path)
            frame = 0
            t = time.clock()
            while 1:
                result, image = video.read()
                if type(image) != np.ndarray:
                    print("End of movie.")
                    break
                if result:
                    ascii_img = AsciiImage(image,
                                           scalefactor=self.scalefactor,
                                           invert=self.invert,
                                           equalize=self.equalize,
                                           lut=self.lut,
                                           font_path=self.font_path)
                    #set terminal size on the first image?
                    if frame == 0:
                        try:
                            console.set_terminal_size(ascii_img.size)
                        except:
                            pass
                    console.clear_term()
                    print(ascii_img)
                    frame += 1
                else:
                    break
                draw_time = time.clock()-t
                t = time.clock()
                remaining = 1.0/fps-draw_time
                if remaining > 0:
                    time.sleep(remaining)
                    interval = draw_time+remaining
                else:
                    interval = draw_time
                self.frame_intervals.append(interval)
                self.draw_times.append(draw_time)

            print("Total frames displayed:", frame)
            print("Avg draw time:", np.mean(self.draw_times))
            print("Avg frame interval:", np.mean(self.frame_intervals))
            print("Max frame interval:", np.max(self.frame_intervals))
            print("Min frame interval:", np.min(self.frame_intervals))

            video.release()
コード例 #7
0
    def stream(self, fps=15.0):
        frame = 0
        t = time.clock()
        while 1:
            result, image = self.video.read()
            if type(image) != np.ndarray:
                if frame == 0:
                    raise IOError(
                        "No frames available. Bro, do you even camera?")
                ##TODO: find some way to break out besides ^C
                print("End of movie.")
                break
            if result:
                ascii_img = AsciiImage(image,
                                       scalefactor=self.scalefactor,
                                       invert=self.invert,
                                       equalize=self.equalize,
                                       lut=self.lut)
                #set terminal size on the first image?
                if frame == 0:
                    try:
                        console.set_terminal_size(ascii_img.size)
                    except:
                        pass
                console.clear_term()
                print(ascii_img)
                frame += 1
            else:
                break
            draw_time = time.clock() - t
            t = time.clock()
            remaining = 1.0 / fps - draw_time
            if remaining > 0:
                time.sleep(remaining)
                interval = draw_time + remaining
            else:
                interval = draw_time
            self.frame_intervals.append(interval)
            self.draw_times.append(draw_time)

        print("Total frames displayed:", frame)
        print("Avg draw time:", np.mean(self.draw_times))
        print("Avg frame interval:", np.mean(self.frame_intervals))
        print("Max frame interval:", np.max(self.frame_intervals))
        print("Min frame interval:", np.min(self.frame_intervals))

        self.release()
コード例 #8
0
ファイル: asciiart.py プロジェクト: derricw/asciisciit
    def stream(self, fps=15.0):
        frame = 0
        t = time.clock()
        while 1:
            result, image = self.video.read()
            if type(image) != np.ndarray:
                if frame == 0:
                    raise IOError("No frames available. Bro, do you even camera?")
                ##TODO: find some way to break out besides ^C
                print("End of movie.")
                break
            if result:
                ascii_img = AsciiImage(image,
                                       scalefactor=self.scalefactor,
                                       invert=self.invert,
                                       equalize=self.equalize,
                                       lut=self.lut)
                #set terminal size on the first image?
                if frame == 0:
                    try:
                        console.set_terminal_size(ascii_img.size)
                    except:
                        pass
                console.clear_term()
                print(ascii_img)
                frame += 1
            else:
                break
            draw_time = time.clock()-t
            t = time.clock()
            remaining = 1.0/fps-draw_time
            if remaining > 0:
                time.sleep(remaining)
                interval = draw_time+remaining
            else:
                interval = draw_time
            self.frame_intervals.append(interval)
            self.draw_times.append(draw_time)

        print("Total frames displayed:", frame)
        print("Avg draw time:", np.mean(self.draw_times))
        print("Avg frame interval:", np.mean(self.frame_intervals))
        print("Max frame interval:", np.max(self.frame_intervals))
        print("Min frame interval:", np.min(self.frame_intervals))

        self.release()