Ejemplo n.º 1
0
def get_picture_objects_for_group(group_id):
    """
    Gets all the pictures belonging to a group, groups them in an array under the snaps they belong to
    """
    url_base = get_url_base()
    picture_links = []
    args_dict = {}
    snaps_dict = {}
    snaps = []
    args_dict["type"] = "picture"
    args_dict["group_id"] = group_id
    pictures_dict = get_documents_from_criteria(args_dict)
    for picture_id in pictures_dict:
        picture_link = url_base + url_for("picture.get_picture", picture_id=picture_id)
        snap_id = pictures_dict[picture_id]["snap_id"]
        if snap_id in snaps_dict:
            snaps_dict[snap_id]["picture_objects"].append(pictures_dict[picture_id])
        else:
            snaps_dict[snap_id] = {
                "created": pictures_dict[picture_id]["created"],
                "id": snap_id,
                "picture_objects": [pictures_dict[picture_id]],
            }
    snaps_array = snaps_dict.values()
    snaps_array.sort(key=lambda x: x["created"])
    return snaps_array
Ejemplo n.º 2
0
def index():
    '''
    Lists top level endpoints for the merging app
    '''
    url_base = get_url_base()
    top_level_links = {
        'merge_images': url_base + url_for('merging.call_merge_images'),
    }
    return Response(json.dumps(top_level_links), status=200, mimetype='application/json')
Ejemplo n.º 3
0
def index():
    '''
    Lists top level endpoints for analysis
    '''
    url_base = get_url_base()
    top_level_links = { 
        'scale_image': url_base + url_for('analysis.call_scale_image'),
        'edge_detect': url_base + url_for('analysis.call_edge_detect'),
    }
    return Response(json.dumps(top_level_links), status=200, mimetype='application/json')
Ejemplo n.º 4
0
def index():
    '''
    Lists top level endpoints for camera
    '''
    url_base = get_url_base()
    top_level_links = {
        'picam_still': url_base + url_for('camera.picam_still'),
        'thermal_still': url_base + url_for('camera.thermal_still'),
        'both_still': url_base + url_for('camera.both_still'),
    }
    return Response(json.dumps(top_level_links), status=200, mimetype='application/json')
Ejemplo n.º 5
0
def index():
    '''
    Returns top level links to the 'get settings' and 'list groups' views 
    '''
    url_base = get_url_base()
    top_level_links = {
        'settings': url_base + url_for('admin.get_settings'),
        'snaps': url_base + url_for('admin.list_snaps'),
        'groups': url_base + url_for('admin.list_groups'),
    }
    return Response(json.dumps(top_level_links), status=200, mimetype='application/json')
Ejemplo n.º 6
0
def index():
    '''
    Lists top level endpoints for calibration
    '''
    url_base = get_url_base()
    top_level_links = { 
        'distortion_sets': url_base + url_for('calibration.list_distortion_sets'),
        'distortion_pairs': url_base + url_for('calibration.list_distortion_pairs'),
        'calibration_sessions': url_base + url_for('calibration.list_calibration_sessions'),
    }
    return Response(json.dumps(top_level_links), status=200, mimetype='application/json')
Ejemplo n.º 7
0
def index():
    url_base = get_url_base()
    top_level_links = {
        'admin': url_base + url_for('admin.index'),
        'camera': url_base + url_for('camera.index'),
        'pictures': url_base + url_for('picture.list_pictures'),
        'merging': url_base + url_for('merging.index'),
        'analysis': url_base + url_for('analysis.index'),
        'calibration': url_base + url_for('calibration.index'),
        'docs': url_base + '/docs/_build/html',
    }
    return Response(json.dumps(top_level_links), status=200, mimetype='application/json')
Ejemplo n.º 8
0
def index():
    '''
    Lists top level endpoints for analysis
    '''
    url_base = get_url_base()
    top_level_links = {
        'scale_image': url_base + url_for('analysis.call_scale_image'),
        'edge_detect': url_base + url_for('analysis.call_edge_detect'),
    }
    return Response(json.dumps(top_level_links),
                    status=200,
                    mimetype='application/json')
Ejemplo n.º 9
0
def index():
    '''
    Returns top level links to the 'get settings' and 'list groups' views 
    '''
    url_base = get_url_base()
    top_level_links = {
        'settings': url_base + url_for('admin.get_settings'),
        'snaps': url_base + url_for('admin.list_snaps'),
        'groups': url_base + url_for('admin.list_groups'),
    }
    return Response(json.dumps(top_level_links),
                    status=200,
                    mimetype='application/json')
Ejemplo n.º 10
0
def index():
    '''
    Lists top level endpoints for camera
    '''
    url_base = get_url_base()
    top_level_links = {
        'picam_still': url_base + url_for('camera.picam_still'),
        'thermal_still': url_base + url_for('camera.thermal_still'),
        'both_still': url_base + url_for('camera.both_still'),
    }
    return Response(json.dumps(top_level_links),
                    status=200,
                    mimetype='application/json')
Ejemplo n.º 11
0
def index():
    url_base = get_url_base()
    top_level_links = {
        'admin': url_base + url_for('admin.index'),
        'camera': url_base + url_for('camera.index'),
        'pictures': url_base + url_for('picture.list_pictures'),
        'merging': url_base + url_for('merging.index'),
        'analysis': url_base + url_for('analysis.index'),
        'calibration': url_base + url_for('calibration.index'),
        'docs': url_base + '/docs/_build/html',
    }
    return Response(json.dumps(top_level_links),
                    status=200,
                    mimetype='application/json')
Ejemplo n.º 12
0
def get_picture_links_for_group(group_id):
    '''
    Gets all the pictures belonging to a given group id
    '''
    # TODO sort these ascending on time
    url_base = get_url_base()
    picture_links = []
    args_dict = {}
    args_dict['type'] = 'picture'
    args_dict['group_id'] = group_id
    pictures_dict = get_documents_from_criteria(args_dict)
    for picture_id in pictures_dict:
        picture_link = url_base + url_for('picture.get_picture', picture_id=picture_id)
        picture_links.append(picture_link)
    return picture_links
Ejemplo n.º 13
0
def get_picture_links_for_group(group_id):
    """
    Gets all the pictures belonging to a given group id
    """
    # TODO sort these ascending on time
    url_base = get_url_base()
    picture_links = []
    args_dict = {}
    args_dict["type"] = "picture"
    args_dict["group_id"] = group_id
    pictures_dict = get_documents_from_criteria(args_dict)
    for picture_id in pictures_dict:
        picture_link = url_base + url_for("picture.get_picture", picture_id=picture_id)
        picture_links.append(picture_link)
    return picture_links
Ejemplo n.º 14
0
def index():
    '''
    Lists top level endpoints for calibration
    '''
    url_base = get_url_base()
    top_level_links = {
        'distortion_sets':
        url_base + url_for('calibration.list_distortion_sets'),
        'distortion_pairs':
        url_base + url_for('calibration.list_distortion_pairs'),
        'calibration_sessions':
        url_base + url_for('calibration.list_calibration_sessions'),
    }
    return Response(json.dumps(top_level_links),
                    status=200,
                    mimetype='application/json')
Ejemplo n.º 15
0
def get_picture_objects_for_group(group_id):
    '''
    Gets all the pictures belonging to a group, groups them in an array under the snaps they belong to
    '''
    url_base = get_url_base()
    picture_links = []
    args_dict = {}
    snaps_dict = {}
    snaps = []
    args_dict['type'] = 'picture'
    args_dict['group_id'] = group_id
    pictures_dict = get_documents_from_criteria(args_dict)
    for picture_id in pictures_dict:
        picture_link = url_base + url_for('picture.get_picture', picture_id=picture_id)
        snap_id =  pictures_dict[picture_id]['snap_id']
        if snap_id in snaps_dict:
            snaps_dict[snap_id]['picture_objects'].append(pictures_dict[picture_id])
        else:
            snaps_dict[snap_id] = {'created': pictures_dict[picture_id]['created'],
                                   'id': snap_id,
                                   'picture_objects': [pictures_dict[picture_id]]}
    snaps_array = snaps_dict.values()
    snaps_array.sort(key=lambda x: x['created'])
    return snaps_array