本文整理汇总了Python中av_writer.AV_Writer.write_video_frame_compressed方法的典型用法代码示例。如果您正苦于以下问题:Python AV_Writer.write_video_frame_compressed方法的具体用法?Python AV_Writer.write_video_frame_compressed怎么用?Python AV_Writer.write_video_frame_compressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类av_writer.AV_Writer
的用法示例。
在下文中一共展示了AV_Writer.write_video_frame_compressed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Recorder
# 需要导入模块: from av_writer import AV_Writer [as 别名]
# 或者: from av_writer.AV_Writer import write_video_frame_compressed [as 别名]
#.........这里部分代码省略.........
self.notify_all( {'subject':'rec_started','rec_path':self.rec_path,'session_name':self.session_name,'network_propagate':network_propagate} )
def open_info_menu(self):
self.info_menu = ui.Growing_Menu('additional Recording Info',size=(300,300),pos=(300,300))
self.info_menu.configuration = self.info_menu_conf
def populate_info_menu():
self.info_menu.elements[:-2] = []
for name in self.user_info.iterkeys():
self.info_menu.insert(0,ui.Text_Input(name,self.user_info))
def set_user_info(new_string):
self.user_info = new_string
populate_info_menu()
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)
if self.g_pool.capture.jpeg_support:
self.writer.write_video_frame_compressed(frame)
else:
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))