def concatenate_movies_in_folder(pathfilter, output_path, frame_size=(2048,2048,3)):
    for file in BatchProcess(pathfilter=pathfilter):
        print(pathfilter+file.split('/')[-1])
        writevid = WriteVideo(filename=output_path+file.split('/')[-1], frame_size=frame_size)
        for filename in BatchProcess(pathfilter=file[:-4]+"*.mp4", reverse_sort=True):
            readvid=ReadVideo(filename)
            for frame in range(readvid.num_frames):
                writevid.add_frame(readvid.read_next_frame())
            readvid.close()
        writevid.close()
def extract_section_movies_in_folder(pathfilter, output_path, start_frame=0, stop_frame=1, step=1, frame_size=(2048,2048,3)):
    for file in BatchProcess(pathfilter=pathfilter):
        print(pathfilter+file.split('/')[-1])
        writevid = WriteVideo(filename=output_path+file.split('/')[-1], frame_size=frame_size)
        for filename in BatchProcess(pathfilter=file[:-4]+"*.mp4", reverse_sort=True):
            readvid=ReadVideo(filename)
            for frame in range(start_frame,stop_frame,step):
                writevid.add_frame(readvid.read_next_frame())
            readvid.close()
        writevid.close()
Exemplo n.º 3
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)
Exemplo n.º 4
0
    # BW image with the crack extracted from background
    crack_frame = frame[:, :,
                        1]  #threshold(frame[:, :, 1], thresh=crack_threshval)
    crack_frame = rotate(crack_frame, angle)
    crack_frame = imfill(crack_frame)
    #crack_frame = extract_nth_biggest_object(crack_frame, n=0)
    return crack_frame, rot_frame, gray_frame


if __name__ == '__main__':

    #filename = '/media/ppzmis/data/Cracks/2020_03_17/25mMnacl5fps_2020-03-17-110622-0000.avi'
    filename = '/media/ppzmis/data/Cracks/2020_02_14/2020_02_14Newno_salt_20uL_A_5fps_2020-02-14-115652-0000.avi'
    vidObj = ReadVideo(filename=filename)
    angle = angle = 175  #-5+ 0.1503646
    fps = 5

    output = []
    for index in range(0, vidObj.num_frames - 1, 50):
        vidObj.set_frame(index)
        frame = vidObj.read_next_frame()
        crack_frame, rot_frame, gray_frame = processframe(frame, angle)
        compact_pos_pixels = find_compaction(rot_frame)

        time = (index + 1) / fps
        output.append([time, compact_pos_pixels])
    print('final')
    print(output)
    np.savetxt(filename[:-4] + 'pos_compactionb.txt', np.array(output))
Exemplo n.º 5
0
from Generic.filedialogs import BatchProcess
from Generic.video import ReadVideo
import numpy as np
from Generic.images import display
import cv2

if __name__ == '__main__':

    for file in BatchProcess(
            pathfilter=
            '/media/ppzmis/data/ActiveMatter/Microscopy/190820bacteriaand500nmparticles/videos/joined/StreamDIC???.mp4'
    ):
        readvid = ReadVideo(filename=file)
        frame_init = readvid.read_next_frame()  #.astype(np.int32)
        counter = 1
        sz = np.shape(frame_init)
        frame_assemble = np.reshape(frame_init, (sz[0], sz[1] * sz[2]))

        for i in range(readvid.num_frames - 1):
            frame = readvid.read_next_frame().astype(np.int32)
            new_frame = np.reshape(frame, (sz[0], sz[1] * sz[2]))
            frame_assemble = np.sum((frame_assemble, new_frame),
                                    axis=0,
                                    dtype=np.int32)
            counter = counter + 1
        frame = (frame_assemble / counter).astype(np.uint8)
        frame_assemble = np.reshape(frame, (sz[0], sz[1], sz[2]))
        cv2.imwrite(file[:-4] + '_bkgimg.png', frame_assemble)

        readvid.close()