def check(filename): core_name = os.path.splitext(filename)[0] vid_name = core_name + '.MP4' data_name = core_name + '.hdf5' out_name = core_name + '_check.png' data = dataframes.DataStore(data_name) crop = data.metadata['crop'] vid = video.ReadVideo(vid_name) print(vid_name) frames = np.arange(4)*vid.num_frames//4 ims = [images.crop(vid.read_frame(f), crop) for f in frames] circles = [data.get_info(f, ['x', 'y', 'r']) for f in frames] new_ims = [images.draw_circles(im, c) for im, c in zip(ims, circles)] out = images.vstack(images.hstack(new_ims[0], new_ims[1]), images.hstack(new_ims[2], new_ims[3])) images.save(out, out_name)
def find_center(self, im): im0 = im.copy() im = images.threshold(im, 80) im = images.opening(im, (6, 6)) center = images.center_of_mass(im) im0 = images.gray_to_bgr(im0) im0 = images.draw_circle(im0, center[0], center[1], 5) im = images.gray_to_bgr(im) im = images.draw_circle(im, center[0], center[1], 5) images.save(images.hstack(im, im0), self.log_direc + '{}.png'.format(self.i)) self.i += 1 return center
def find_center(self, im): im0 = im.copy() im = images.gaussian_blur(im, (5, 5)) circles = trackpy.locate(im, 5) center = circles[['x', 'y']].values.mean(axis=0) im0 = images.gray_to_bgr(im0) im0 = images.draw_circle(im0, center[0], center[1], 5) im1 = images.gray_to_bgr(im) im1 = images.draw_circle(im1, center[0], center[1], 5) im2 = images.gray_to_bgr(im) im2 = images.draw_circles(im2, circles[['x', 'y', 'size']].values) images.save(images.hstack(im1, im0, im2), self.log_direc + '{}.png'.format(self.i)) self.i += 1 return center
from labvision import video, images vid = video.ReadVideo( "/home/ppxjd3/Code/labvision/labvision/data/numbered_video.mp4") frame_numbers = [0, 1, 2, 3, 10, 11, 20, 21, 20, 19, 18] for f in frame_numbers: frame1 = vid.read_frame(f) frame2 = vid.read_frame(f) frame = images.hstack(frame1, frame2) images.display(frame, title=f'{f}')
def _display_img(self, *ims): if len(ims) == 1: self.im = ims[0] else: self.im = hstack(*ims)