コード例 #1
0
 def set_file(self, file_name):
     self.file_name = file_name
     # a file can be a directory
     if os.path.isdir(file_name):
         self.imagefolder = ImageFolder()
         self.imagefolder.read_folder(file_name)
         return True
     # check if it's an image
     image = cv2.imread(file_name)
     if image is not None:
         self.imagefolder = ImageFolder()
         self.imagefolder.read_image(file_name)
         return True
     # if the file is not a video, videocapture not return None
     # check if it's supported video
     video = cv2.VideoCapture(file_name)
     if video:
         self.movie = Movie(file_name)
         return True
     return False
コード例 #2
0
ファイル: media_video.py プロジェクト: Octets/SeaGoatVision
 def set_file(self, file_name):
     self.file_name = file_name
     # a file can be a directory
     if os.path.isdir(file_name):
         self.imagefolder = ImageFolder()
         self.imagefolder.read_folder(file_name)
         return True
     # check if it's an image
     image = cv2.imread(file_name)
     if image is not None:
         self.imagefolder = ImageFolder()
         self.imagefolder.read_image(file_name)
         return True
     # if the file is not a video, videocapture not return None
     # check if it's supported video
     video = cv2.VideoCapture(file_name)
     if video:
         self.movie = Movie(file_name)
         return True
     return False
コード例 #3
0
class MediaVideo(Media):
    def __init__(self, name):
        super(MediaVideo, self).__init__()
        self.movie = None
        self.imagefolder = None

        self.media_name = name
        self.file_name = None
        self.is_playing = False

    def is_media_streaming(self):
        return False

    def is_media_video(self):
        return True

    def reset(self):
        if self.movie:
            self.movie.reset()

    def get_type_media(self):
        return keys.get_media_type_video_name()

    def open(self):
        Media.open(self)
        self.play()

    def get_total_frames(self):
        if self.movie:
            return self.movie.get_total_frames()
        elif self.imagefolder:
            return self.imagefolder.get_total_frames()
        return -1

    def do_cmd(self, action, value):
        if not self.thread and not self.is_client_manager:
            return False
        if action == keys.get_key_media_play():
            if self.thread.pause:
                self.thread.pause = False
                return True
            return False
        elif action == keys.get_key_media_pause():
            if not self.thread.pause:
                self.thread.pause = True
                return True
            return False
        elif action == keys.get_key_media_loop():
            self.set_loop_enable(not self.active_loop)
        elif action == keys.get_key_media_frame():
            self.change_frame(value)
        else:
            return False
        return True

    def change_frame(self, value):
        if self.movie:
            self.movie.set_position(value)
            self.notify_observer(self.movie.next())
        elif self.imagefolder:
            self.imagefolder.set_pos(value)
            self.notify_observer(self.imagefolder.next())

    def set_file(self, file_name):
        self.file_name = file_name
        # a file can be a directory
        if os.path.isdir(file_name):
            self.imagefolder = ImageFolder()
            self.imagefolder.read_folder(file_name)
            return True
        # check if it's an image
        image = cv2.imread(file_name)
        if image is not None:
            self.imagefolder = ImageFolder()
            self.imagefolder.read_image(file_name)
            return True
        # if the file is not a video, videocapture not return None
        # check if it's supported video
        video = cv2.VideoCapture(file_name)
        if video:
            self.movie = Movie(file_name)
            return True
        return False

    def play(self):
        self.is_playing = True

    def pause(self):
        self.is_playing = False

    def next(self):
        if self.movie:
            return self.movie.next()
        if self.imagefolder:
            return self.imagefolder.next()
        return
コード例 #4
0
ファイル: media_video.py プロジェクト: Octets/SeaGoatVision
class MediaVideo(Media):

    def __init__(self, name):
        super(MediaVideo, self).__init__()
        self.movie = None
        self.imagefolder = None

        self.media_name = name
        self.file_name = None
        self.is_playing = False

    def is_media_streaming(self):
        return False

    def is_media_video(self):
        return True

    def reset(self):
        if self.movie:
            self.movie.reset()

    def get_type_media(self):
        return keys.get_media_type_video_name()

    def open(self):
        Media.open(self)
        self.play()

    def get_total_frames(self):
        if self.movie:
            return self.movie.get_total_frames()
        elif self.imagefolder:
            return self.imagefolder.get_total_frames()
        return -1

    def do_cmd(self, action, value):
        if not self.thread and not self.is_client_manager:
            return False
        if action == keys.get_key_media_play():
            if self.thread.pause:
                self.thread.pause = False
                return True
            return False
        elif action == keys.get_key_media_pause():
            if not self.thread.pause:
                self.thread.pause = True
                return True
            return False
        elif action == keys.get_key_media_loop():
            self.set_loop_enable(not self.active_loop)
        elif action == keys.get_key_media_frame():
            self.change_frame(value)
        else:
            return False
        return True

    def change_frame(self, value):
        if self.movie:
            self.movie.set_position(value)
            self.notify_observer(self.movie.next())
        elif self.imagefolder:
            self.imagefolder.set_pos(value)
            self.notify_observer(self.imagefolder.next())

    def set_file(self, file_name):
        self.file_name = file_name
        # a file can be a directory
        if os.path.isdir(file_name):
            self.imagefolder = ImageFolder()
            self.imagefolder.read_folder(file_name)
            return True
        # check if it's an image
        image = cv2.imread(file_name)
        if image is not None:
            self.imagefolder = ImageFolder()
            self.imagefolder.read_image(file_name)
            return True
        # if the file is not a video, videocapture not return None
        # check if it's supported video
        video = cv2.VideoCapture(file_name)
        if video:
            self.movie = Movie(file_name)
            return True
        return False

    def play(self):
        self.is_playing = True

    def pause(self):
        self.is_playing = False

    def next(self):
        if self.movie:
            return self.movie.next()
        if self.imagefolder:
            return self.imagefolder.next()
        return