def visualize_helper(box_list): vgrid_spec = VGridSpec( video_meta=video_metadata_intel, vis_format=VideoBlockFormat(imaps=[(str(i), box) for i, box in enumerate(box_list)]), video_endpoint=VIDEO_COLLECTION_BASEURL_INTEL) return VGridWidget(vgrid_spec=vgrid_spec.to_json_compressed())
def find_clips_for_keyword(keyword, use_only_video=False): ism = {} for vm in tqdm(video_metadata): if not vm["annotation_filename"] or (not vm["only_video"] and use_only_video): continue try: h5 = eeghdf.Eeghdf(vm["annotation_filename"]) except: print(vm["annotation_filename"]) os.remove(vm["annotation_filename"]) continue starts = [start / 10**7 for start in h5._annotation_start100ns] texts = h5._annotation_text if not keyword or any(keyword.lower() in text.lower() for text in texts): interval_set = IntervalSet([ Interval( Bounds3D(start, start + 5), # we set the duration { 'spatial_type': SpatialType_Caption(">>" + text + "\n"), 'metadata': {} }) for start, text in zip(starts, texts) ]) ism[vm["id"]] = interval_set print( f"Found {len(ism)} videos with keyword {keyword} in the annotations.") vgrid_spec = VGridSpec(video_meta=video_metadata_wrapper, vis_format=VideoBlockFormat(imaps=[('bboxes', ism)]), video_endpoint='http://localhost:8080') return VGridWidget(vgrid_spec=vgrid_spec.to_json_compressed())
) ) pose_metadata[video_meta.id] = IntervalSet(pose_intervals) # In[29]: pose_annotation_files # In[31]: vgrid_spec = VGridSpec( video_meta = metadata_videos, vis_format = VideoBlockFormat(imaps = [ ('pose', IntervalSetMapping(pose_metadata)) ]), video_endpoint = 'http://localhost:8080' ) VGridWidget(vgrid_spec = vgrid_spec.to_json_compressed()) # In[ ]:
ism = IntervalSetMapping({ 0: IntervalSet([ Interval( Bounds3D(0, 10), { 'spatial_type': SpatialType_Temporal(), 'metadata': { 'generic_metadata': Metadata_Generic( 'this will be drawn below the timeline when expanded' ), 'other_generic_metadata': Metadata_Generic({ 'key': 'this object will also be stringified' }) } } ) ]) }) vgrid_spec = VGridSpec( video_meta = video_metadata, vis_format = VideoBlockFormat(imaps = [ ('bboxes', ism) ]) ) # Pass this to your Javascript application somehow json_for_js = vgrid_spec.to_json_compressed()