Exemple #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--content",
                        help="1: Point To Target" + " 2: Change Detection" +
                        " 3: Odd One Out" + " 4: Visual Search" +
                        " 5: Multiple Object Tracking" +
                        " 6: Random Dot Motion Descrimination",
                        type=int,
                        default=1)
    args = parser.parse_args()

    content_type = args.content

    if content_type == CONTENT_POINT_TO_TARGET:
        content = PointToTargetContent()
    elif content_type == CONTENT_CHANGE_DETECTION:
        content = ChangeDetectionContent()
    elif content_type == CONTENT_ODD_ONE_OUT:
        content = OddOneOutContent()
    elif content_type == CONTENT_VISUAL_SEARCH:
        content = VisualSearchContent()
    elif content_type == CONTENT_MULTIPLE_OBJECT_TRACKING:
        content = MultipleObjectTrackingContent()
    else:
        content = RandomDotMotionDiscriminationContent()

    FPS = 60
    display_size = (128 * 4 + 16, 500)
    inspector = Inspector(content, display_size)

    clock = pygame.time.Clock()
    running = True

    frame_count = 0

    if RECORDING:
        writer = MovieWriter("out.mov", inspector.display_size, FPS)

    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        inspector.update()
        clock.tick(FPS)

        if RECORDING:
            d = inspector.get_frame()
            writer.add_frame(d)

            frame_count += 1

            if frame_count > 1000:
                running = False

    if RECORDING:
        writer.close()
Exemple #2
0
def get_content(content_type):
    if content_type == Contents.POINT_TO_TARGET:
        content = PointToTargetContent()
    elif content_type == Contents.CHANGE_DETECTION:
        content = ChangeDetectionContent()
    elif content_type == Contents.ODD_ONE_OUT:
        content = OddOneOutContent()
    elif content_type == Contents.VISUAL_SEARCH:
        content = VisualSearchContent()
    elif content_type == Contents.MULTIPLE_OBJECT_TRACKING:
        content = MultipleObjectTrackingContent()
    else:
        content = RandomDotMotionDiscriminationContent()
    return content
Exemple #3
0
def check_offscreen():
    content = PointToTargetContent()
    env = Environment(content)

    frame_size = 10

    for i in range(frame_size):
        dh = np.random.uniform(low=-0.02, high=0.02)
        dv = np.random.uniform(low=-0.02, high=0.02)
        action = np.array([dh, dv])
        obs, reward, done, info = env.step(action)

        image = obs['screen']

        save_img(image)

        if done:
            print("Episode terminated")
            obs = env.reset()
Exemple #4
0
import cv2

from oculoenv import PointToTargetContent, ChangeDetectionContent, OddOneOutContent, VisualSearchContent, MultipleObjectTrackingContent, RandomDotMotionDiscriminationContent
from inspector import Inspector

import flask
from flask import Flask, make_response, send_from_directory
from jinja2 import FileSystemLoader
from werkzeug.local import Local, LocalManager

app = Flask(__name__, static_url_path='')
app.secret_key = 'oculomotor'
app.jinja_loader = FileSystemLoader(os.getcwd() + '/templates')

contents = [
    PointToTargetContent(),
    ChangeDetectionContent(),
    OddOneOutContent(),
    VisualSearchContent(),
    MultipleObjectTrackingContent(),
    RandomDotMotionDiscriminationContent(),
]

display_size = (128 * 4 + 16, 500)


class Runner(object):
    def __init__(self):
        self.content_id = 0
        self.inspector = Inspector(contents[self.content_id], display_size)
        self.lock = Lock()
Exemple #5
0
                        "3: Odd One Out\n4: Visual Search\n" +
                        "5: Multiple Object Tracking\n" +
                        "6: Random Dot Motion Descrimination",
                        type=int,
                        default=1)
    parser.add_argument(
        "--step_debug",
        help="Flag to debug execute step by step with one key press",
        type=bool,
        default=False)

    args = parser.parse_args()

    if args.content == Contents.POINT_TO_TARGET:
        content = PointToTargetContent(target_size="small",
                                       use_lure=True,
                                       lure_size="large")
    elif args.content == Contents.CHANGE_DETECTION:
        content = ChangeDetectionContent(target_number=2,
                                         max_learning_count=20,
                                         max_interval_count=10)
    elif args.content == Contents.ODD_ONE_OUT:
        content = OddOneOutContent()
    elif args.content == Contents.VISUAL_SEARCH:
        content = VisualSearchContent()
    elif args.content == Contents.MULTIPLE_OBJECT_TRACKING:
        content = MultipleObjectTrackingContent()
    elif args.content == Contents.RANDOM_DOT_MOTION_DISCRIMINATION:
        content = RandomDotMotionDiscriminationContent()
    else:
        print("Unknown argument")
Exemple #6
0
from gym.envs.registration import register
from oculoenv import PointToTargetContent, ChangeDetectionContent, OddOneOutContent, VisualSearchContent, MultipleObjectTrackingContent, RandomDotMotionDiscriminationContent

# see https://github.com/wbap/oculoenv/blob/master/examples/example_display.py

# PointToTarget
register(
    id='PointToTarget-v0',
    entry_point='gym_oculoenv.oculo:GymOculoEnv',
    kwargs={'content': PointToTargetContent()}
)

register(
    id='PointToTargetRetina-v0',
    entry_point='gym_oculoenv.oculo:GymOculoEnv',
    kwargs={'content': PointToTargetContent(), 'retina': True}
)

register(
    id='PointToTargetSkip-v0',
    entry_point='gym_oculoenv.oculo:GymOculoEnv',
    kwargs={'content': PointToTargetContent(), 'skip_red_cursor': True}
)

register(
    id='PointToTargetRetinaSkip-v0',
    entry_point='gym_oculoenv.oculo:GymOculoEnv',
    kwargs={'content': PointToTargetContent(), 'skip_red_cursor': True, 'retina': True}
)

register(
Exemple #7
0
def make_contents():
    return [PointToTargetContent(), ChangeDetectionContent(), OddOneOutContent(), VisualSearchContent(), MultipleObjectTrackingContent(), RandomDotMotionDiscriminationContent()]