Example #1
0
def import_region(a,video_obj,frame,detection_to_pk,vdn_dataset=None):
    da = Region()
    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']
    da.metadata_text = a['metadata_text']
    da.metadata_json = a['metadata_json']
    da.region_type = a['region_type']
    da.confidence = a['confidence']
    da.object_name = a['object_name']
    da.full_frame = a['full_frame']
    if vdn_dataset:
        da.vdn_dataset = vdn_dataset
    if 'label' in a and a['label'].strip():
        da.label = a['label']
        if vdn_dataset:
            label_object, created = VLabel.objects.get_or_create(label_name=a['label'], source=VLabel.VDN, video=video_obj, vdn_dataset=vdn_dataset)
        else:
            label_object, created = VLabel.objects.get_or_create(label_name=a['label'], source=VLabel.UI, video=video_obj)
        da.label_parent = label_object
    da.frame = frame
    da.save()
    if da.region_type == Region.DETECTION:
        detection_to_pk[a['id']]=da.pk
    return da
Example #2
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.label = a['label']
        if vdn_dataset:
            label_object, created = VLabel.objects.get_or_create(label_name=a['label'], source=VLabel.VDN, video=video_obj, vdn_dataset=vdn_dataset)
        else:
            label_object, created = VLabel.objects.get_or_create(label_name=a['label'], source=VLabel.UI, video=video_obj)
        da.label_parent = label_object
    da.frame = frame
    da.full_frame = a['full_frame']
    da.metadata_text = a['metadata_text']
    da.metadata_json = a['metadata_json']
    da.save()
    return da