Example #1
0
    def __init__(self):

        self._proj = project.load("Recording/")
        self._proj.setLogger(ProjectLogger())

        self._record_modules = (EntryRecorder, module.ModuleCameraExtendedcv,
                                module.ModuleAl5dPs4control)

        self._playback_modules = (
            EntryPlayback,
            # ModuleCameraCv,
            ModuleVideoSync)
Example #2
0
def get_sample_image():

    proj = project.load("Recording/")
    # Look at 101
    entry = proj.entry(266)
    video = entry.get("video_file", "video_numpy")

    image = video[80]
    image = processImage(image)
    #image = cv2.flip(image, 1)

    return image
Example #3
0
def count_num():

    proj = project.load("Recording/")

    count = 0

    num_entries = proj.entryCount()

    for i in range(num_entries):
        entry = proj.entry(i)
        duration = entry.get("control_duration")
        duration /= 1000.0
        c = duration * 30.0 / 8.0
        count += int(c)
        print count

    print count
Example #4
0
#!/usr/bin/env python

import arlo.api.project as project
import arlo.api.module as module
import arlo.input.ps4 as ps4
import arlo.utils.log as log
import arlo.utils.term as term


proj = project.load("Recording/")



toDelete = []

def clean(entry):

    shouldKeep = True
    shouldKeep &= entry.fileExists("control.json")
    shouldKeep &= entry.fileExists("control_frames.json")
    shouldKeep &= entry.fileExists("meta.json")
    shouldKeep &= entry.fileExists("video.avi")
    shouldKeep &= entry.fileExists("video_frames.json")
    
    if not shouldKeep:
    
        toDelete.append(entry.name())
    

proj.entries(clean)
Example #5
0
#!/usr/bin/env python

import arlo.api.project as project
import arlo.api.module as module
import arlo.input.ps4 as ps4
import arlo.utils.log as log
import arlo.utils.term as term

proj = project.load("Webcam/")

record_modules = [
    module.ModuleCameraExtendedcv
]

proj.record(record_modules)

Example #6
0
def recVideo():

    proj = project.load("Recording/")
    entry = proj.entry(304)

    data = entry.get("video_file", "video_numpy")
    print data.shape

    images = []
    for d in data:
        d = processImage(d)
        d = prepareData(d)
        images.append(d)

    images = np.array(images, dtype=np.float32)

    print images.shape
    print "Loading net..."
    net = vaegan.VAEGAN()
    network_saver = saver.NetworkSaver('vaegan/models/', net=net)
    network_saver.load()
    print "Net loaded"

    count = 0
    length = images.shape[0]
    i = 20

    total = []

    while True:
        if count >= length:
            break
        start = count
        end = min(count + i, length)
        print start, end

        imgBatch = images[start:end]
        rec = net.reconstruct(imgBatch)
        rec = rec.swapaxes(2, 3)
        rec = rec.swapaxes(1, 3)
        for r in rec:
            total.append(r)

        count += i

    total = np.array(total, np.float32)

    print total.shape
    print total
    total = np.array(total, np.uint8)

    # Output -------------------

    file = 'video_rec_new.avi'

    fourcc = cv2.VideoWriter_fourcc(*'XVID')
    fps = 30.0
    width = 128
    height = 128

    out = cv2.VideoWriter(file, fourcc, fps, (width, height))

    for f in total:
        out.write(f)

    out.release()
Example #7
0
def main():
    rec = project.load("Recording/")

    #TODO jonathan save values to a directory
    #root, new = node.load("Processed/")

    num_entries = rec.entryCount()

    index_frames = 0

    video_data = np.memmap('video_data.npy',
                           dtype='float32',
                           mode='w+',
                           shape=(max_frames, 3, 128, 128))
    control_data = np.memmap('control_data.npy',
                             dtype='float32',
                             mode='w+',
                             shape=(max_frames, 7))
    in_data = np.memmap('in_data.npy',
                        dtype='float32',
                        mode='w+',
                        shape=(max_frames, 1))

    for i in range(num_entries):
        entry = rec.entry(i)

        control_datetime = entry.get("control_datetime", "datetime")
        control_frames = entry.get("control_frame_times", "json_data")
        control = entry.get("control_file", "json_data")

        video_datetime = entry.get("video_datetime", "datetime")
        video_frames = entry.get("video_frame_times", "json_data")
        video = entry.get("video_file", "video_numpy")

        diff_ms = ext.delta_ms(control_datetime - video_datetime)
        video_start = 0
        control_start = diff_ms
        if diff_ms < 0:
            video_start = abs(diff_ms)
            control_start = 0

        timeRateS = 8.0 / 30.0  # seconds
        timeRate = timeRateS * 1000.0  # ms
        time = 0

        while True:

            if max_frames <= index_frames:
                break

            control_index = ext.timeIndex(time + control_start, control_frames)
            video_index = ext.timeIndex(time + video_start, video_frames)

            if control_index == None and video_index == None:
                break

            VIDEO = clampedIndex(video_index, video)
            CONTROL = clampedIndex(control_index, control)

            VIDEO = processImage(VIDEO)
            CONTROL = processControl(CONTROL)

            video_data[index_frames] = VIDEO
            control_data[index_frames] = CONTROL
            in_data[index_frames] = np.ones(1)

            time += timeRate
            index_frames += 1

        print "{} / {}".format(index_frames, max_frames)

        if max_frames <= index_frames:
            break

    np.save('img_data.npy', video_data)
    np.save('data_in.npy', in_data)
    np.save('data_out.npy', control_data)

    os.remove(video_data.filename)
    os.remove(in_data.filename)
    os.remove(control_data.filename)