예제 #1
0
def create_annotation(form, object_name, labels, frame):
    annotation = Region()
    annotation.object_name = object_name
    if form.cleaned_data['high_level']:
        annotation.full_frame = True
        annotation.x = 0
        annotation.y = 0
        annotation.h = 0
        annotation.w = 0
    else:
        annotation.full_frame = False
        annotation.x = form.cleaned_data['x']
        annotation.y = form.cleaned_data['y']
        annotation.h = form.cleaned_data['h']
        annotation.w = form.cleaned_data['w']
    annotation.metadata_text = form.cleaned_data['metadata_text']
    annotation.metadata_json = form.cleaned_data['metadata_json']
    annotation.frame = frame
    annotation.video = frame.video
    annotation.region_type = Region.ANNOTATION
    annotation.save()
    for l in labels:
        if l.strip():
            dl = AppliedLabel()
            dl.video = annotation.video
            dl.frame = annotation.frame
            dl.region = annotation
            dl.label_name = l.strip()
            dl.source = dl.UI
            dl.save()
예제 #2
0
def create_annotation(form, object_name, labels, frame):
    annotation = Region()
    annotation.object_name = object_name
    if form.cleaned_data['high_level']:
        annotation.full_frame = True
        annotation.x = 0
        annotation.y = 0
        annotation.h = 0
        annotation.w = 0
    else:
        annotation.full_frame = False
        annotation.x = form.cleaned_data['x']
        annotation.y = form.cleaned_data['y']
        annotation.h = form.cleaned_data['h']
        annotation.w = form.cleaned_data['w']
    annotation.metadata_text = form.cleaned_data['metadata_text']
    annotation.metadata_json = form.cleaned_data['metadata_json']
    annotation.frame = frame
    annotation.video = frame.video
    annotation.region_type = Region.ANNOTATION
    annotation.save()
    for l in labels:
        if l.strip():
            dl = AppliedLabel()
            dl.video = annotation.video
            dl.frame = annotation.frame
            dl.region = annotation
            dl.label_name = l.strip()
            dl.source = dl.UI
            dl.save()
예제 #3
0
def import_legacy_annotation(a, video_obj, frame, vdn_dataset=None):
    da = Region()
    da.region_type = Region.ANNOTATION
    da.video = video_obj
    da.x = a['x']
    da.y = a['y']
    da.h = a['h']
    da.w = a['w']
    da.vdn_key = a['id']
    if vdn_dataset:
        da.vdn_dataset = vdn_dataset
    if a['label'].strip():
        da.object_name = a['label']
    da.frame = frame
    da.full_frame = a['full_frame']
    da.metadata_text = a['metadata_text']
    da.metadata_json = a['metadata_json']
    da.save()
    if a['label'].strip():
        dl = AppliedLabel()
        dl.region = da
        dl.label_name = a['label']
        dl.video = da.video
        dl.frame = da.frame
        dl.save()
    return da