当前位置: 首页>>代码示例>>Python>>正文


Python AV_Writer.release方法代码示例

本文整理汇总了Python中av_writer.AV_Writer.release方法的典型用法代码示例。如果您正苦于以下问题:Python AV_Writer.release方法的具体用法?Python AV_Writer.release怎么用?Python AV_Writer.release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在av_writer.AV_Writer的用法示例。


在下文中一共展示了AV_Writer.release方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Recorder

# 需要导入模块: from av_writer import AV_Writer [as 别名]
# 或者: from av_writer.AV_Writer import release [as 别名]

#.........这里部分代码省略.........

        populate_info_menu()
        self.info_menu.append(ui.Info_Text('Use the *user info* field to add/remove additional fields and their values. The format must be a valid Python dictionary. For example -- {"key":"value"}. You can add as many fields as you require. Your custom fields will be saved for your next session.'))
        self.info_menu.append(ui.Text_Input('user_info',self,setter=set_user_info,label="User info"))
        self.g_pool.gui.append(self.info_menu)

    def close_info_menu(self):
        if self.info_menu:
            self.info_menu_conf = self.info_menu.configuration
            self.g_pool.gui.remove(self.info_menu)
            self.info_menu = None

    def update(self,frame,events):
        if self.running:
            self.data['pupil_positions'] += events['pupil_positions']
            self.data['gaze_positions'] += events['gaze_positions']
            self.timestamps.append(frame.timestamp)
            self.writer.write_video_frame(frame)
            self.frame_count += 1

            # cv2.putText(frame.img, "Frame %s"%self.frame_count,(200,200), cv2.FONT_HERSHEY_SIMPLEX,1,(255,100,100))
            for p in events['pupil_positions']:
                pupil_pos = p['timestamp'],p['confidence'],p['id'],p['norm_pos'][0],p['norm_pos'][1],p['diameter']
                self.pupil_pos_list.append(pupil_pos)

            for g in events.get('gaze_positions',[]):
                gaze_pos = g['timestamp'],g['confidence'],g['norm_pos'][0],g['norm_pos'][1]
                self.gaze_pos_list.append(gaze_pos)

            self.button.status_text = self.get_rec_time_str()

    def stop(self,network_propagate=True):
        #explicit release of VideoWriter
        self.writer.release()
        self.writer = None

        if self.record_eye:
            for tx in self.g_pool.eye_tx:
                try:
                    tx.send((None,None))
                except:
                    logger.warning("Could not stop eye-recording. Please report this bug!")

        save_object(self.data,os.path.join(self.rec_path, "pupil_data"))

        gaze_list_path = os.path.join(self.rec_path, "gaze_positions.npy")
        np.save(gaze_list_path,np.asarray(self.gaze_pos_list))

        pupil_list_path = os.path.join(self.rec_path, "pupil_positions.npy")
        np.save(pupil_list_path,np.asarray(self.pupil_pos_list))

        timestamps_path = os.path.join(self.rec_path, "world_timestamps.npy")
        # ts = sanitize_timestamps(np.array(self.timestamps))
        ts = np.array(self.timestamps)
        np.save(timestamps_path,ts)

        try:
            copy2(os.path.join(self.g_pool.user_dir,"surface_definitions"),os.path.join(self.rec_path,"surface_definitions"))
        except:
            logger.info("No surface_definitions data found. You may want this if you do marker tracking.")

        try:
            copy2(os.path.join(self.g_pool.user_dir,"cal_pt_cloud.npy"),os.path.join(self.rec_path,"cal_pt_cloud.npy"))
        except:
            logger.warning("No calibration data found. Please calibrate first.")
开发者ID:lloves,项目名称:pupil,代码行数:69,代码来源:recorder.py

示例2: Recorder

# 需要导入模块: from av_writer import AV_Writer [as 别名]
# 或者: from av_writer.AV_Writer import release [as 别名]

#.........这里部分代码省略.........
            self.info_menu = None

    def update(self,frame,events):
        ''' listen to commands from eye window '''
        if self.g_pool.eye_pipes[0].poll():
            cmd = self.g_pool.eye_pipes[0].recv()
            # toggle recording if enter key clicked
            if cmd == GLFW_KEY_ENTER:
                self.toggle()
        if self.running:
            # for key,data in events.iteritems():
            #     if key not in ('dt'):
            #         try:
            #             self.data[key] += data
            #         except KeyError:
            #             self.data[key] = []
            #             self.data[key] += data

            ''' Record when it first started as this will be the start of calibration. When user click Enter again this
             should end calibration. Click once more to end recording'''
            if not self.calibration_start_at:
                self.calibration_start_at = frame.timestamp

            self.timestamps.append(frame.timestamp)
            self.writer.write_video_frame(frame)
            self.frame_count += 1

            # # cv2.putText(frame.img, "Frame %s"%self.frame_count,(200,200), cv2.FONT_HERSHEY_SIMPLEX,1,(255,100,100))

            self.button.status_text = self.get_rec_time_str()

    def stop(self, shutdown_os=False):
        #explicit release of VideoWriter
        self.writer.release()
        self.writer = None

        if self.record_eye:
            for alive, pipe in zip(self.g_pool.eyes_are_alive,self.g_pool.eye_pipes):
                if alive.value:
                    pipe.send(('Rec_Stop',None))

        # Mohammad: This will now save an empty dicts list
        save_object(self.data,os.path.join(self.rec_path, "pupil_data"))

        timestamps_path = os.path.join(self.rec_path, "world_timestamps.npy")
        # ts = sanitize_timestamps(np.array(self.timestamps))
        ts = np.array(self.timestamps)
        np.save(timestamps_path,ts)

        try:
            copy2(os.path.join(self.g_pool.user_dir,"surface_definitions"),os.path.join(self.rec_path,"surface_definitions"))
        except:
            logger.info("No surface_definitions data found. You may want this if you do marker tracking.")
        try:
            copy2(os.path.join(self.g_pool.user_dir,"user_calibration_data"),os.path.join(self.rec_path,"user_calibration_data"))
        except:
            logger.warning("No user calibration data found. Please calibrate first.")

        # camera_calibration = load_camera_calibration(self.g_pool)
        # if camera_calibration is not None:
        #     save_object(camera_calibration,os.path.join(self.rec_path, "camera_calibration"))
        # else:
        #     logger.info("No camera calibration found.")

        try:
            with open(self.meta_info_path, 'a') as f:
开发者ID:mothman1,项目名称:pupil,代码行数:70,代码来源:offline_recorder.py

示例3: Recorder

# 需要导入模块: from av_writer import AV_Writer [as 别名]
# 或者: from av_writer.AV_Writer import release [as 别名]

#.........这里部分代码省略.........
            ):
                self.g_pool.quickbar.append(self.low_disk_space_thumb)
            elif (
                disk_space >= self.warning_low_disk_space_th
                and self.low_disk_space_thumb in self.g_pool.quickbar
            ):
                self.g_pool.quickbar.remove(self.low_disk_space_thumb)

            if self.running and disk_space <= self.stop_rec_low_disk_space_th:
                self.stop()
                logger.error("Recording was stopped due to low disk space!")

        if self.running:
            for key, data in events.items():
                if key not in ("dt", "depth_frame") and not key.startswith("frame"):
                    try:
                        writer = self.pldata_writers[key]
                    except KeyError:
                        writer = PLData_Writer(self.rec_path, key)
                        self.pldata_writers[key] = writer
                    writer.extend(data)
            if "frame" in events:
                frame = events["frame"]
                self.writer.write_video_frame(frame)
                self.frame_count += 1

            # # cv2.putText(frame.img, "Frame %s"%self.frame_count,(200,200), cv2.FONT_HERSHEY_SIMPLEX,1,(255,100,100))

            self.button.status_text = self.get_rec_time_str()

    def stop(self):
        # explicit release of VideoWriter
        try:
            self.writer.release()
        except RuntimeError:
            logger.error("No world video recorded")
        else:
            logger.debug("Closed media container")
            self.g_pool.capture.intrinsics.save(self.rec_path, custom_name="world")
        finally:
            self.writer = None

        # save_object(self.data, os.path.join(self.rec_path, "pupil_data"))
        for writer in self.pldata_writers.values():
            writer.close()

        del self.pldata_writers

        try:
            copy2(
                os.path.join(self.g_pool.user_dir, "surface_definitions"),
                os.path.join(self.rec_path, "surface_definitions"),
            )
        except:
            logger.info(
                "No surface_definitions data found. You may want this if you do marker tracking."
            )

        try:
            with open(self.meta_info_path, "a", newline="") as csvfile:
                csv_utils.write_key_value_file(
                    csvfile,
                    {
                        "Duration Time": self.get_rec_time_str(),
                        "World Camera Frames": self.frame_count,
                        "World Camera Resolution": str(
开发者ID:pupil-labs,项目名称:pupil,代码行数:70,代码来源:recorder.py

示例4: Recorder

# 需要导入模块: from av_writer import AV_Writer [as 别名]
# 或者: from av_writer.AV_Writer import release [as 别名]

#.........这里部分代码省略.........
        self.info_menu.append(ui.Info_Text('Use the *user info* field to add/remove additional fields and their values. The format must be a valid Python dictionary. For example -- {"key":"value"}. You can add as many fields as you require. Your custom fields will be saved for your next session.'))
        self.info_menu.append(ui.Text_Input('user_info',self,setter=set_user_info,label="User info"))
        self.g_pool.gui.append(self.info_menu)

    def close_info_menu(self):
        if self.info_menu:
            self.info_menu_conf = self.info_menu.configuration
            self.g_pool.gui.remove(self.info_menu)
            self.info_menu = None

    def update(self,frame,events):
        if self.running:
            for key,data in events.iteritems():
                if key not in ('dt') and key != 'timestamp_unix':
                    try:
                        self.data[key] += data
                    except KeyError:
                        self.data[key] = []
                        self.data[key] += data

            self.timestamps.append(frame.timestamp)
            self.writer.write_video_frame(frame)
            self.frame_count += 1

            for glint in events['glint_positions']:
                self.glint_pos_list += glint
            self.timestampsUnix.append(events['timestamp_unix'])
            # # cv2.putText(frame.img, "Frame %s"%self.frame_count,(200,200), cv2.FONT_HERSHEY_SIMPLEX,1,(255,100,100))

            self.button.status_text = self.get_rec_time_str()

    def stop(self):
        #explicit release of VideoWriter
        self.writer.release()
        self.writer = None

        save_object(self.data,os.path.join(self.rec_path, "pupil_data"))



        self.glint_pos_list = np.array(self.glint_pos_list)
        glint_list_path = os.path.join(self.rec_path, "glint_positions.npy")
        np.save(glint_list_path,self.glint_pos_list)

        timestamps_path = os.path.join(self.rec_path, "world_timestamps.npy")
        # ts = sanitize_timestamps(np.array(self.timestamps))
        ts = np.array(self.timestamps)
        np.save(timestamps_path,ts)

        timestampsUnix_path = os.path.join(self.rec_path, "world_timestamps_unix.npy")
        tsUnix = np.array(self.timestampsUnix)
        np.save(timestampsUnix_path,tsUnix)


        try:
            copy2(os.path.join(self.g_pool.user_dir,"surface_definitions"),os.path.join(self.rec_path,"surface_definitions"))
        except:
            logger.info("No surface_definitions data found. You may want this if you do marker tracking.")
        try:
            copy2(os.path.join(self.g_pool.user_dir,"user_calibration_data"),os.path.join(self.rec_path,"user_calibration_data"))
        except:
            logger.warning("No user calibration data found. Please calibrate first.")

        try:
            copy2(os.path.join(self.g_pool.user_dir,"cal_pt_cloud_glint.npy"),os.path.join(self.rec_path,"cal_pt_cloud_glint.npy"))
        except:
开发者ID:prinkkala,项目名称:pupil,代码行数:70,代码来源:recorder.py


注:本文中的av_writer.AV_Writer.release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。