Example #1
0
def order(filename):
    core_name = os.path.splitext(filename)[0]
    vid_name = filename
    data_name = core_name + '.hdf5'
    out_name = core_name + '_check_order.png'
    data = dataframes.DataStore(data_name)
    crop = data.metadata['crop']
    vid = video.ReadVideo(vid_name)
    frame = 100
    im = images.crop_img(vid.find_frame(frame), crop)
    circles = data.df.loc[frame, ['x', 'y', 'r', 'order_r', 'order_i']]
    circles['order_mag'] = np.abs(circles.order_r + 1j * circles.order_i)
    circles = circles[['x', 'y', 'r', 'order_mag']].values
    out = images.draw_circles(im, circles)
    out = images.add_colorbar(out)
    images.display(out)
    images.save(out, out_name)
Example #2
0
from Generic.video import ReadVideo
from Generic.images import display

if __name__ == '__main__':
    readvid = ReadVideo()

    for i in range(readvid.num_frames):
        frame = readvid.read_next_frame()
        display(frame)
Example #3
0
    """
    if preprocess:
        grayscale_img = images.bgr_2_grayscale(img)
        binary_img = adaptive_threshold(grayscale_img,
                                        block_size=block_size,
                                        constant=constant,
                                        mode=mode)
        # noise removal
        kernel = np.ones((3, 3), np.uint8)
        opening = cv2.morphologyEx(binary_img,
                                   cv2.MORPH_OPEN,
                                   kernel,
                                   iterations=2)
        # sure background area
        sure_bg = cv2.dilate(opening, kernel, iterations=3)
    else:
        binary_img = img
    dist_transform = cv2.distanceTransform(binary_img, cv2.DIST_L2, 5)
    return dist_transform


if __name__ == '__main__':
    from Generic import images
    from Generic import video

    read_vid = video.ReadVideo(
        '/media/ppzmis/data/ActiveMatter/bacteria_plastic/bacteria.avi')
    im = read_vid.read_next_frame()

    images.display(im, title='a')
Example #4
0
            self._setup_process(width, height)
        self.process.stdin.write(frame)
        self.frame_no += 1

    def _setup_process(self, width, height):
        self.process = (ffmpeg.input(
            'pipe:',
            format='rawvideo',
            pix_fmt='rgb24',
            s='{}x{}'.format(width, height),
            r=50).output(self.filename,
                         pix_fmt='yuv420p',
                         vcodec='libx264',
                         preset=self.preset,
                         video_bitrate=self.video_bitrate,
                         r=self.framerate).overwrite_output().run_async(
                             pipe_stdin=True, quiet=False))

    def close(self):
        self.process.stdin.close()
        self.process.wait()


if __name__ == "__main__":
    from Generic import images
    input_video = '/media/ppzmis/data/ActiveMatter/bacteria_plastic/bacteria.mp4'
    vid = ReadVideoFFMPEG(input_video)
    for f in range(10):
        frame = vid.read_frame()
        images.display(frame)
from Generic import images

im = images.load("/media/data/Data/Logs/2020_1_15_15_29/0_mean.png", 0)

# %%
images.display(im)

# %%
# images.ThresholdGui(im)
# %%
threshold = images.threshold(im, 200)
images.display(threshold)

# %%
dilate = images.dilate(threshold, (5, 5))
# dilate = threshold
images.display(dilate)

# %%
opening = images.opening(dilate, (13, 13))
opening = images.opening(dilate, (21, 21))
images.display(opening)

# %%
center = images.center_of_mass(threshold)
im0 = images.draw_circle(im, center[0], center[1], 5)
im0 = images.draw_circle(im0,
                         im0.shape[1] // 2,
                         im0.shape[0] // 2,
                         5,
                         color=images.BLUE)