def spatiotemporal_cubes(file_tuples, shape, n_patches=numpy.inf, rng=None):
 frame_lookup = FrameLookup([(a, b[0]) for (a, b) in file_tuples])
 file_lookup = OrderedDict(file_tuples)
 (patch_length, patch_height, patch_width) = shape
 done = 0
 rng = make_np_rng(rng, which_method='random_integers')
 while (done < n_patches):
  frame = rng.random_integers(0, (len(frame_lookup) - 1))
  (filename, file_length, frame_no) = frame_lookup[frame]
  if ((file_length - frame_no) < patch_length):
   continue
  (_, video_height, video_width) = file_lookup[filename][:3]
  last_row = (video_height - patch_height)
  last_col = (video_width - patch_width)
  row = rng.random_integers(0, last_row)
  col = rng.random_integers(0, last_col)
  patch_slice = (slice(frame_no, (frame_no + patch_length)), slice(row, (row + patch_height)), slice(col, (col + patch_width)))
  done += 1
  (yield (filename, patch_slice))

def spatiotemporal_cubes ( file_tuples , shape , n_patches = numpy . inf , rng = None ) : frame_lookup = FrameLookup ( [ ( a , b [ 0 ] ) for ( a , b ) in file_tuples ] ) file_lookup = OrderedDict ( file_tuples ) ( patch_length , patch_height , patch_width ) = shape done = 0 rng = make_np_rng ( rng , which_method = 'random_integers' ) while ( done < n_patches ) : frame = rng . random_integers ( 0 , ( len ( frame_lookup ) - 1 ) ) ( filename , file_length , frame_no ) = frame_lookup [ frame ] if ( ( file_length - frame_no ) < patch_length ) : continue ( _ , video_height , video_width ) = file_lookup [ filename ] [ : 3 ] last_row = ( video_height - patch_height ) last_col = ( video_width - patch_width ) row = rng . random_integers ( 0 , last_row ) col = rng . random_integers ( 0 , last_col ) patch_slice = ( slice ( frame_no , ( frame_no + patch_length ) ) , slice ( row , ( row + patch_height ) ) , slice ( col , ( col + patch_width ) ) ) done += 1 ( yield ( filename , patch_slice ) )
generator function that yields a stream of representing a spatiotemporal patch of that file .