Example #1
0
def main():
    video_play_thread = [1]
    is_looking_thread = IsLookingThread(video_play_thread)
    video_player = VideoPlayer("tanioka.mp4")
    is_looking_thread.start()
    while (True):
        video_player.play()
        video_player.check_state(video_play_thread[0])
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
Example #2
0
 def _initPlayer(self, videoUrls):
     self.videoPlayers = []
     for playerId, videoUrl in enumerate(videoUrls):
         videoPlayer = VideoPlayer(playerId, videoUrl)
         self.maxFps = max(self.maxFps, videoPlayer.fps)
         self.maxFrameCount = max(self.maxFrameCount,
                                  videoPlayer.frameCount)
         self.videoPlayers.append(videoPlayer)
     self.videoWidget = VideoWidget(self.videoPlayers)
     for videoPlayer in self.videoPlayers:
         videoPlayer.setMaxFps(self.maxFps)
Example #3
0
class Viewer(object):
    '''
    A high-level class for viewing any supported media type.
    Delegates viewing to the browser or video player depending on media
    type. The displaying is performed in a separate thread, so
    shutdown() must be called before killing the program to avoid
    errors upon program termination.
    '''

    DISPLAY_TIME_GRANULARITY = 1  # seconds
    BROWSER = Browser()
    PLAYER = VideoPlayer()

    VIEWERS = {
        Media.IMAGE: BROWSER,
        Media.WEB_PAGE: BROWSER,
        Media.VIDEO: PLAYER
    }

    def display_content(self, content, is_interrupted_func):
        self.logger = logging.getLogger(__name__)
        self.logger.debug('Viewer received content %s', content)
        viewer = self.VIEWERS[content.content_type]

        displayed_time = 0
        viewer.display_content(content)
        self.running = True

        while self.running and displayed_time < content.view_time:
            if is_interrupted_func(content):
                break
            time.sleep(self.DISPLAY_TIME_GRANULARITY)
            displayed_time += self.DISPLAY_TIME_GRANULARITY
            self.keep_alive(viewer, content)

        viewer.hide()
        self.logger.debug('Viewer finished displaying content %s', content)

    def keep_alive(self, viewer, content):
        if not viewer.is_alive():
            self.logger.debug('Resurrecting viewer for content %s', content)
            viewer.display_content(content)

    def shutdown(self):
        self.logger.debug('Viewer shutdown requested')
        self.running = False
        self.BROWSER.shutdown()
        self.PLAYER.shutdown()
        self.logger.debug('Viewer shutdown complete')
Example #4
0
    def __init__(self):
        super().__init__()

        assert len(self.UTILITY_SCORE) == len(self.VIDEO_BIT_RATE)
        # get video list
        vlc = video_list_collector()
        vlc.save_dir = self.VIDEO_TRACE
        vlc.load()
        self.video_list = vlc.get_trace_matrix(self.VIDEO_BIT_RATE)

        self.video_player = VideoPlayer(self.birate_list,self.video_list)
        self.buffer_thresh = self.video_player.buffer_thresh
        self.action_list = len(self.video_list)
        self.network_speed = np.zeros(self.HISTORY_SIZE)
        self.reset()
Example #5
0
 def play_video(self: 'Gui'):
     if not self.playing_video:
         self.playing_video = True
         self.video_player = VideoPlayer(self.playJpgFolder,
                                         self.playWavFile, 30)
         self.play_video_button.setText('Pause')
         self.video_player.play()
         self.play_video_button.setText('Play')
         self.playing_video = False
     else:
         self.keyboard_emulator.press('p')
         self.keyboard_emulator.release('p')
         self.video_paused = not self.video_paused
         if self.video_paused:
             self.play_video_button.setText('Play')
         else:
             self.play_video_button.setText('Pause')
Example #6
0
    def __init__(self, config_path):
        self._logger = getLogger("raspberry")
        self._logger.setLevel(INFO)
        formatter = Formatter(
            '%(asctime)s [%(name)s] %(levelname)s : %(message)s')
        stream_handler = StreamHandler()
        stream_handler.setLevel(INFO)
        stream_handler.setFormatter(formatter)
        self._logger.addHandler(stream_handler)
        signal.signal(signal.SIGINT, self.exit_gracefully)
        signal.signal(signal.SIGTERM, self.exit_gracefully)

        self._logger.info("Initializing...")
        self.preference_checker = Preferences(config_path)
        self.video_player = VideoPlayer()
        self.tv_controller = TVController()

        self._logger.info("Ready")
Example #7
0
    def _reload(self, load):
        if self.player != None:
            self.player.close()

        self.player = VideoPlayer()
        self.player.set_window_id(self.gui_controller.get_video_window_id())
        self.player.activate_video_callback(
            self.gui_controller.activate_video_area)
        self.player.open(self.exercise.get_video_path())
        self.player.set_callback(self._time_callback)
        self.paused = False
        self.gui_controller.activate_video_area(False)
        self.gui_controller.activate("loaded")
        self._update_word_list()
        self.timeUpdateThreadId = thread.start_new_thread(
            self.time_update_thread, ())

        if load and self.exercise.get_repeat_count_limit_by_sequence() == 0:
            #Auto start play only if repeat is not limited
            self.play()
        else:
            self.pause()
Example #8
0
    def _setup_player(self, mode, data_source=None):
        self.config[CONFIG_KEY_MODE] = mode
        # Set data source if specified
        if data_source is not None:
            self.config[CONFIG_KEY_DATA_SOURCE] = data_source

        # Quit current player
        if self.player is not None:
            self.player.release()
            self.player = None

        if self.player is None:
            # Create new player
            if mode in [MODE_VIDEO, MODE_STREAM]:
                from video_player import VideoPlayer
                self.player = VideoPlayer(self.config)
            elif mode == MODE_WEBPAGE:
                from web_player import WebPlayer
                self.player = WebPlayer(self.config)
        else:
            self.player.mode = mode
            self.player.data_source = self.config[CONFIG_KEY_DATA_SOURCE]
Example #9
0
from video_player import VideoPlayer

video_input = 'input/project_dataset/frames/concert'
audio_samples = 'input/project_dataset/audio/concert.wav'

player = VideoPlayer(video_input, audio_samples, 30)
player.play()
    
    #if video file input
    if len(sys.argv) > 1:
        cameras = [CameraFinder.create_file_camera(sys.argv[1])]

    # else scan for available cameras
    else:       
        cameras = CameraFinder.get_available_cameras()
        print('Found {} cameras.'.format(len(cameras)))

    if len(cameras) > 0:
        # index of the currently active camera
        cam_index = 0

        # initialize video player
        player = VideoPlayer(cameras[cam_index], WINDOW_NAME, fourcc)
        player.play()

        while player.playing:
            if player.camera_defect:
                print('ERROR: Camera not responding. Removing it from the list.')
                print('ERROR: CAMERA_BACKEND:',
                      cameras[cam_index % len(cameras)].backend)
                player.stop()
                # remove the malfunctioning camera
                cameras.remove(cameras[cam_index % len(cameras)])
                player.change_camera(cameras[cam_index % len(cameras)])
                player.play()

            # handle input
            key_pressed = cv2.waitKey(1)
Example #11
0
 def refresh_caches(self):
     global _player
     _player=VideoPlayer()
     if not _standalone:
         self._get_data_for_first_video()
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1030, 481)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.video_player_original = VideoPlayer(self.centralwidget)
        self.video_player_original.setEnabled(True)
        self.video_player_original.setGeometry(QtCore.QRect(10, 40, 500, 360))
        self.video_player_original.setObjectName("video_player_original")
        self.video_player_result = VideoPlayer(self.centralwidget)
        self.video_player_result.setGeometry(QtCore.QRect(520, 40, 500, 360))
        self.video_player_result.setObjectName("video_player_result")
        self.input_min_length = QtWidgets.QSpinBox(self.centralwidget)
        self.input_min_length.setGeometry(QtCore.QRect(210, 410, 171, 24))
        self.input_min_length.setMaximum(10000)
        self.input_min_length.setProperty("value", 100)
        self.input_min_length.setObjectName("input_min_length")
        self.input_thresh = QtWidgets.QSpinBox(self.centralwidget)
        self.input_thresh.setGeometry(QtCore.QRect(20, 410, 171, 24))
        self.input_thresh.setMinimum(-99)
        self.input_thresh.setProperty("value", -40)
        self.input_thresh.setObjectName("input_thresh")
        self.button_convert = QtWidgets.QPushButton(self.centralwidget)
        self.button_convert.setGeometry(QtCore.QRect(830, 400, 181, 32))
        self.button_convert.setObjectName("button_convert")
        self.line = QtWidgets.QFrame(self.centralwidget)
        self.line.setGeometry(QtCore.QRect(510, -10, 20, 391))
        self.line.setFrameShape(QtWidgets.QFrame.VLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(180, 10, 200, 20))
        font = QtGui.QFont()
        font.setPointSize(16)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(710, 10, 200, 20))
        font = QtGui.QFont()
        font.setPointSize(16)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.line_2 = QtWidgets.QFrame(self.centralwidget)
        self.line_2.setGeometry(QtCore.QRect(-3, 370, 1041, 20))
        self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(30, 390, 181, 16))
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setGeometry(QtCore.QRect(220, 390, 161, 20))
        self.label_4.setObjectName("label_4")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1030, 22))
        self.menubar.setObjectName("menubar")
        self.menu = QtWidgets.QMenu(self.menubar)
        self.menu.setObjectName("menu")
        self.menu_2 = QtWidgets.QMenu(self.menubar)
        self.menu_2.setObjectName("menu_2")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.action_2 = QtWidgets.QAction(MainWindow)
        self.action_2.setObjectName("action_2")
        self.action_3 = QtWidgets.QAction(MainWindow)
        self.action_3.setObjectName("action_3")
        self.action_4 = QtWidgets.QAction(MainWindow)
        self.action_4.setObjectName("action_4")
        self.actionGithub = QtWidgets.QAction(MainWindow)
        self.actionGithub.setObjectName("actionGithub")
        self.menu.addAction(self.action_2)
        self.menu.addAction(self.action_3)
        self.menu_2.addAction(self.action_4)
        self.menu_2.addAction(self.actionGithub)
        self.menubar.addAction(self.menu.menuAction())
        self.menubar.addAction(self.menu_2.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Example #13
0
    def create_frames(self):
        # Top frame
        self.top_frame = tk.LabelFrame(self.master, text='', bg="#E9E9E9")
        self.top_frame.pack(side='top', expand=True, fill='both')

        self.load_query_button = ttk.Button(self.top_frame,
                                            text='Load Query',
                                            command=self.load_query_video)
        self.load_query_button.grid(row=0, column=0, padx=0, pady=0)

        self.find_matches_button = ttk.Button(self.top_frame,
                                              text='Find matches',
                                              command=self.run_match)
        self.find_matches_button.grid(row=1, column=0, padx=0, pady=0)

        self.match_list = tk.Listbox(self.top_frame, height=4, bd=0)
        self.yscroll = tk.Scrollbar(self.top_frame, orient=tk.VERTICAL)
        self.match_list['yscrollcommand'] = self.yscroll.set
        self.match_list.grid(row=0, column=1, rowspan=2, stick='wens')
        self.yscroll.grid(row=0, column=1, rowspan=2, sticky='nse')
        self.match_list.bind('<Double-Button-1>', self.poll_match_list)
        self.curr_selection = -1

        self.top_frame.grid_columnconfigure(0, weight=1)
        self.top_frame.grid_columnconfigure(1, weight=2)

        # Middle frame
        self.middle_frame = tk.LabelFrame(self.master, text='')
        self.middle_frame.pack(side='top', expand=True, fill='both')

        self.status_label_text = tk.StringVar()
        self.status_label_text.set('LOGS')
        self.status_label = tk.Label(self.middle_frame,
                                     textvar=self.status_label_text,
                                     justify=tk.LEFT,
                                     anchor='w',
                                     wraplength=700,
                                     bg="black",
                                     fg="#C1E0FD")
        self.status_label.grid(row=0, column=0, stick='nswe', columnspan=2)

        self.middle_frame.grid_columnconfigure(0, weight=1)
        self.middle_frame.grid_columnconfigure(1, weight=1)

        self.query_player = VideoPlayer(self.middle_frame)
        self.query_player.grid(row=1, column=0, stick='nsw')
        self.db_player = VideoPlayer(self.middle_frame)
        self.db_player.grid(row=1, column=1, stick='nse')

        # Bottom frame
        self.bottom_frame = tk.LabelFrame(self.master, text='')
        self.bottom_frame.pack(side='top', expand=True, fill='both')

        self.match_info_label_text = tk.StringVar()
        # self.match_info_label_text.set('MATCH INFORMATION')
        self.match_info_label = tk.Label(self.bottom_frame,
                                         textvar=self.match_info_label_text,
                                         justify=tk.LEFT,
                                         anchor='e')
        self.match_info_label.grid(row=0, column=0, stick='nswe')

        image = cv2.imread(
            "/Users/nikhiljohny/Documents/_CSCI576Project/codebase/master/graph_place_holder.png"
        )
        width = 365
        height = 280
        dim = (width, height)
        image = cv2.resize(image, dim, interpolation=cv2.INTER_AREA)
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        image = Image.fromarray(image)
        image = ImageTk.PhotoImage(image)

        self.panelA = tk.Label(self.bottom_frame,
                               image=image,
                               width=365,
                               height=280)
        self.panelA.image = image
        self.panelA.grid(row=0, column=1, stick='nse', padx=0, pady=0)
        self.bottom_frame.grid_columnconfigure(0, weight=1)
        self.bottom_frame.grid_columnconfigure(1, weight=1)