Esempio n. 1
0
    client = Camomile(server)
    client.login(userAdmin, pwdAdmin)

    # create queue
    id_queueIn = client.createQueue(inQueueEvidence, returns_id=True)
    id_queueOut = client.createQueue(outQueueEvidence, returns_id=True)

    id_corpus = client.getCorpora(corpusName, returns_id=True)
    if id_corpus == []:
        print args['<corpusName>'], 'is not found in the database'
        sys.exit(0)
    id_corpus = id_corpus[0]

    id_layerEvidence = client.getLayers(corpus=id_corpus, name=submissionName+".evidence", returns_id=True)
    if id_layerEvidence == []:
        print shotLayerName, 'is not found in the database'
        sys.exit(0)
    id_layerEvidence = id_layerEvidence[0]

    # add annotation in inQueue
    le = []
    for media in client.getMedia(corpus=id_corpus):
        for a in client.getAnnotations(layer=id_layerEvidence, medium=media['_id']):
            shot = client.getAnnotation(a['fragment'])
            e = {"fragment":{"id_medium": media['_id'], "start":shot['fragment']['segment']['start'] , "end":shot['fragment']['segment']['end'] },
                 "data":{"person_name": a['data']['person_name'], "source": a['data']['source']},
                 "id_evidence": id_layerEvidence
                }
            le.append(e)
    client.updateQueue(id_queueIn, elements=le)
Esempio n. 2
0
                                        submissionName+".label",
                                        description={"id_label": "", "submission": "primary", "status": "workInProgress"},
                                        fragment_type='mediaeval.persondiscovery._id_shot',
                                        data_type='mediaeval.persondiscovery.evidence',
                                        returns_id=True)

    id_layer_evidence = client.createLayer(id_corpus, 
                                           submissionName+".evidence",
                                           description={"id_evidence": "", "submission": "primary", "status": "workInProgress"},
                                           fragment_type='mediaeval.persondiscovery._id_shot',
                                           data_type='mediaeval.persondiscovery.evidence',
                                           returns_id=True)

    # find id of the shot annotations
    id_shots = {}
    for shot in client.getAnnotations(layer=id_layer):
        id_shots.setdefault(shot['id_medium'], {})
        id_shots[shot['id_medium']][shot['fragment']['shot_number']] = shot['_id']

    # find id of the media
    id_media = {}
    for media in client.getMedia(corpus=id_corpus):
        id_media[media['name']] = media['_id']
    
    # parse label
    labels = {}
    for line in open(labelFile).read().splitlines():
        videoID, shotNumber, personName, confidence = line.split(' ')
        label = {"id_layer": id_layer_label,
                 "id_medium": id_media[videoID],
                 "fragment": id_shots[id_media[videoID]][shotNumber],
# test corpus
test = client.getCorpora(name = 'mediaeval.test', returns_id=True)[0]

# teams
teams = {team._id: team.name
         for team in client.getGroups()
         if team.name.startswith('team_') or team.name == 'organizer'}

media = {medium._id: medium.name for medium in client.getMedia(test)}

shotLayer = client.getLayers(test, name='mediaeval.submission_shot')[0]._id

print "get the shot number"
shots = {}
for a in client.getAnnotations(shotLayer):
    shots.setdefault(a.id_medium, {})
    shots[a.id_medium][a._id] = a.fragment.shot_number

# evaluate every original submissions
for labelLayer in client.getLayers(
        test, data_type='mediaeval.persondiscovery.label'):

    # we are only looking for original submissions (not copies)
    if 'copy' in labelLayer.description:
        continue

    if labelLayer.description.get('status', 'incomplete') != 'complete':
        continue

    print teams[labelLayer.description.id_team], labelLayer.name
Esempio n. 4
0
    server = Config.get('mainSection', 'url')+":"+Config.get('mainSection', 'port')
    userAdmin = Config.get('userSection', 'userAdmin')
    pwdAdmin = Config.get('userSection', 'pwdAdmin')

    client = Camomile(server)
    client.login(userAdmin, pwdAdmin)

    
    count = 0
    deleted = 0

    for l in client.getLayers():
        # if "annotateur" in l.name:
        print l.name
        annotations = client.getAnnotations(l._id)
        print('annotations : %d' % len(annotations))

        # tmp = [[(u'start', a['fragment']['start']), (u'end', a['fragment']['end']), (u'data', a['data'])] for a in annotations]
        # tmp = []
        # for a in annotations:
        #     tmp.append({'start': a['fragment']['start'], 'end': a['fragment']['end'], u'data': a['data']})

        tmp = [{'start': a['fragment']['start'], 'end': a['fragment']['end'], u'data': a['data'], 'id_medium': a['id_medium']} for a in annotations]

        cleaned = [dict(t) for t in set([tuple(d.items()) for d in tmp])]

        seen = set()
        doublons = []
        indices = []
        for i in range(0, len(tmp)):