Luna services clients description
Here presented possibilities of luna-services clients.
Events client
The luna-events client which allows to create events, get events and get events statistics
Module contains luna-events client adapted for usage in lambda
- class luna_lambda_tools.public.clients.events.Events(eventsClient, accountId)[source]
Luna-events client
- deleteEvents(target=None, handlerId=None, createTimeGte=None, createTimeLt=None, insertTimeGte=None, insertTimeLt=None, raiseError=True, **kwargs)[source]
Delete events by filters.
- Parameters:
target (
UnionType
[list
[str
],None
]) – event deletion info targetshandlerId (
UnionType
[str
,None
]) – event handler idcreateTimeGte (
UnionType
[str
,None
]) – lower including create time boundarycreateTimeLt (
UnionType
[str
,None
]) – upper excluding create time boundaryinsertTimeGte (
UnionType
[str
,None
]) – lower including insert time boundaryinsertTimeLt (
UnionType
[str
,None
]) – upper excluding insert time boundaryraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getEvent(eventId, target=None, raiseError=True, **kwargs)[source]
Get event by id.
- Parameters:
eventId (
str
) – event idtarget (
UnionType
[list
[Literal
[‘account_id’, ‘create_time’, ‘end_time’, ‘event_id’, ‘handler_id’, ‘external_id’, ‘source’, ‘stream_id’, ‘top_match’, ‘match_result’, ‘face_detections’, ‘face_id’, ‘attach_result’, ‘gender’, ‘age’, ‘emotion’, ‘ethnic_group’, ‘liveness’, ‘deepfake’, ‘body_detections’, ‘body_basic_attributes’, ‘upper_body’, ‘lower_body’, ‘accessories’, ‘tags’, ‘user_data’, ‘location’, ‘mask’, ‘track_id’, ‘meta’]],None
]) – list of events’ fields to receive instead of full eventsraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getEventDescriptor(eventId=None, descriptorVersion=None, descriptorType=None, raiseError=True, **kwargs)[source]
Get event descriptor by filters.
- Parameters:
eventId (
UnionType
[str
,None
]) – event iddescriptorVersion (
UnionType
[int
,None
]) – descriptor versiondescriptorType (
UnionType
[str
,None
]) – Kind of the descriptor (body or face)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event descriptor will be returned.
- Return type:
class
- getEvents(target=None, createTimeGte=None, createTimeLt=None, endTimeGte=None, endTimeLt=None, eventIds=None, eventIdGte=None, eventIdLt=None, handlerIds=None, externalIds=None, topMatchingCandidatesLabel=None, topSimilarObjectIds=None, topSimilarExternalIds=None, topSimilarObjectSimilarityGte=None, topSimilarObjectSimilarityLt=None, ageLt=None, ageGte=None, gender=None, emotions=None, masks=None, ethnicGroups=None, liveness=None, apparentAgeGte=None, apparentAgeLt=None, apparentGender=None, headwearStates=None, headwearApparentColors=None, sleeveLengths=None, upperClothingColors=None, lowerGarmentTypes=None, lowerGarmentColors=None, shoesApparentColors=None, backpackStates=None, faceIds=None, userData=None, page=1, pageSize=10, order='desc', sources=None, tags=None, cities=None, areas=None, districts=None, streets=None, houseNumbers=None, originLongitude=None, originLatitude=None, longitudeDelta=None, latitudeDelta=None, trackIds=None, meta=None, raiseError=True, **kwargs)[source]
Get events by filters.
- Parameters:
target (
UnionType
[list
[Literal
[‘account_id’, ‘create_time’, ‘end_time’, ‘event_id’, ‘handler_id’, ‘external_id’, ‘source’, ‘stream_id’, ‘top_match’, ‘match_result’, ‘face_detections’, ‘face_id’, ‘attach_result’, ‘gender’, ‘age’, ‘emotion’, ‘ethnic_group’, ‘liveness’, ‘deepfake’, ‘body_detections’, ‘body_basic_attributes’, ‘upper_body’, ‘lower_body’, ‘accessories’, ‘tags’, ‘user_data’, ‘location’, ‘mask’, ‘track_id’, ‘meta’]],None
]) – list of events’ fields to receive instead of full eventscreateTimeGte (
UnionType
[str
,None
]) – lower including create time boundarycreateTimeLt (
UnionType
[str
,None
]) – upper excluding create time boundaryendTimeGte (
UnionType
[str
,None
]) – lower including end time boundaryendTimeLt (
UnionType
[str
,None
]) – upper excluding end time boundaryfaceIds (
UnionType
[list
[str
],None
]) – ids of faces linked with an eventeventIds (
UnionType
[list
[str
],None
]) – event idseventIdGte (
UnionType
[str
,None
]) – event id lower including boundeventIdLt (
UnionType
[str
,None
]) – event id upper excluding boundhandlerIds (
UnionType
[list
[str
],None
]) – handler idsexternalIds (
UnionType
[list
[str
],None
]) – external idsuserData (
UnionType
[str
,None
]) – event user datasources (
UnionType
[list
[Union
[str
,Literal
[‘null’]]],None
]) – list of sourcetags (
UnionType
[list
[str
],None
]) – users tagstopMatchingCandidatesLabel (
UnionType
[str
,None
]) – top matching candidates labeltopSimilarObjectIds (
UnionType
[list
[str
],None
]) – top similar object idstopSimilarExternalIds (
UnionType
[list
[str
],None
]) – top similar external idstopSimilarObjectSimilarityGte (
UnionType
[float
,None
]) – lower including top similarity boundarytopSimilarObjectSimilarityLt (
UnionType
[float
,None
]) – upper excluding top similarity boundaryageLt (
UnionType
[int
,None
]) – upper excluding age boundaryageGte (
UnionType
[int
,None
]) – lower including age boundarygender (
Union
[int
,Literal
[‘null’],None
]) – gender of event (0 or 1)emotions (
UnionType
[list
[Union
[int
,Literal
[‘null’]]],None
]) – dominant emotions in event (one of (1, 2, 3, 4, 5, 6, 7) - matches “anger”, “disgust”, “fear”, “happiness”, “neutral”, “sadness”, “surprise”)masks (
UnionType
[list
[Union
[int
,Literal
[‘null’]]],None
]) – dominant masks in event (one of (1, 2, 3) - matches “missing”, “medical_mask”, “occluded”)ethnicGroups (
UnionType
[list
[Union
[int
,Literal
[‘null’]]],None
]) – dominant ethnicity of the face ((1, 2, 3, 4) - means (indian, asian, african_american, caucasian)liveness (
UnionType
[list
[Union
[int
,Literal
[‘null’]]],None
]) – dominant liveness of the face ((0, 1, 2) - means (“spoof”, “real”, “unknown”))apparentAgeLt (
UnionType
[int
,None
]) – apparent age upper excluding boundaryapparentAgeGte (
UnionType
[int
,None
]) – apparent age upper including boundaryapparentGender (
Union
[list
[Literal
[0, 1, 2]],Literal
[‘null’]]) – apparent gender estimation values (0 - female, 1 - male, 2 - undefined)headwearStates (
UnionType
[list
[Union
[Literal
[0, 1, 2],Literal
[‘null’]]],None
]) – headwear states (0 - absent, 1 - present, 2 - undefined)headwearApparentColors (
UnionType
[list
[Union
[Literal
[‘undefined’, ‘black’, ‘white’, ‘other’],Literal
[‘null’]]],None
]) – headwear apparent colorssleeveLengths (
UnionType
[list
[Literal
[‘short’, ‘long’, ‘undefined’, ‘null’]],None
]) – sleeve lengthsupperClothingColors (
UnionType
[list
[Union
[Literal
[‘black’, ‘blue’, ‘green’, ‘gray’, ‘orange’, ‘purple’, ‘red’, ‘white’, ‘yellow’, ‘pink’, ‘brown’, ‘beige’, ‘khaki’, ‘multicolored’, ‘undefined’],Literal
[‘null’]]],None
]) – upper clothing colorslowerGarmentTypes (
UnionType
[list
[Literal
[‘undefined’, ‘trousers’, ‘shorts’, ‘skirt’, ‘null’]],None
]) – lower garment typeslowerGarmentColors (
UnionType
[list
[Union
[Literal
[‘black’, ‘blue’, ‘green’, ‘gray’, ‘orange’, ‘purple’, ‘red’, ‘white’, ‘yellow’, ‘pink’, ‘brown’, ‘beige’, ‘khaki’, ‘multicolored’, ‘undefined’],Literal
[‘null’]]],None
]) – lower garment colorsshoesApparentColors (
UnionType
[list
[Union
[Literal
[‘undefined’, ‘black’, ‘white’, ‘other’],Literal
[‘null’]]],None
]) – shoes apparent colorsbackpackStates (
UnionType
[list
[Union
[Literal
[0, 1, 2],Literal
[‘null’]]],None
]) – backpack states (0 - absent, 1 - present, 2 - undefined)areas (
UnionType
[list
[Union
[str
,Literal
[‘null’]]],None
]) – list of areasstreets (
UnionType
[list
[Union
[str
,Literal
[‘null’]]],None
]) – list of streetsdistricts (
UnionType
[list
[Union
[str
,Literal
[‘null’]]],None
]) – list of districtscities (
UnionType
[list
[Union
[str
,Literal
[‘null’]]],None
]) – list of citieshouseNumbers (
UnionType
[list
[Union
[str
,Literal
[‘null’]]],None
]) – list of house numbersoriginLongitude (
Union
[float
,Literal
[‘null’],None
]) – origin longitude in degreesoriginLatitude (
Union
[float
,Literal
[‘null’],None
]) – origin latitude in degreeslongitudeDelta (
UnionType
[float
,None
]) – longitude delta in degreeslatitudeDelta (
UnionType
[float
,None
]) – latitude delta in degreestrackIds (
UnionType
[list
[Union
[str
,Literal
[‘null’]]],None
]) – list of track idsmeta (
UnionType
[dict
,None
]) – user-defined event meta’s filters in format {meta.<path.to.field>__<operator>:<type>: <value>}page (
UnionType
[int
,None
]) – number of result pagepageSize (
UnionType
[int
,None
]) – count of results in pageorder (
UnionType
[str
,None
]) – result sort order (ask or desc)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- getEventsStats(query=<luna3.common.http_objs.StatQuery object>, raiseError=True, **kwargs)[source]
Get events statistics by aggregation (<aggregator> and <groupBy> on <target>) and filters.
- Parameters:
query (
StatQuery
) – query object or query dict, contained in StatQuery objectraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with event statistics will be returned.
- Return type:
class
- headEvent(eventId, raiseError=True, **kwargs)[source]
Check event existence by id.
- Parameters:
eventId (
str
) – event idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with events will be returned.
- Return type:
class
- saveEvents(events, waitEventsSaving=None, raiseError=True, **kwargs)[source]
Save events to luna-events.
- Parameters:
events (
list
[Event
]) – list of eventswaitEventsSaving (
UnionType
[bool
,None
]) – whether to wait events saving (response will be received only after events will be saved)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
Faces client
The luna-faces client which allows to create/get/delete faces/attributes/lists
Module contains luna-faces client adapted for usage in lambda
- class luna_lambda_tools.public.clients.faces.Faces(facesClient, accountId)[source]
Luna-faces client
- createAttribute(basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, xpk=None, ttl=None, raiseError=True, **kwargs)[source]
Create new attributes. Notice that XPK argument overwrites basic attributes and descriptors above.
- Parameters:
descriptors (
UnionType
[list
[UnionType
[bytes
,RawDescriptor
]],None
]) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
UnionType
[dict
,None
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.xpk (
bytes
) – SDKObject bytes to load attributes fromttl (
UnionType
[int
,None
]) – temporary attribute ttlraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with attribute id.
- Return type:
class
- createFace(attributeId=None, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, eventId=None, userData='', externalId=None, avatar=None, listIds=None, raiseError=True, **kwargs)[source]
Create new face in luna-faces
- Parameters:
attributeId (
UnionType
[str
,None
]) – attribute iddescriptors (
UnionType
[list
[UnionType
[bytes
,RawDescriptor
]],None
]) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
UnionType
[dict
,None
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.eventId (
UnionType
[str
,None
]) – reference to event which created faceuserData (
UnionType
[str
,None
]) – face user dataexternalId (
UnionType
[str
,None
]) – external id of the face, if it has its own mapping in the systemavatar (
UnionType
[str
,None
]) – face avatar urllistIds (
UnionType
[list
[str
],None
]) – created face will be attach to these listsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created face id will be returned.
- Return type:
class
- createList(userData='', listId=None, raiseError=True, **kwargs)[source]
Create list.
- Parameters:
userData (
str
) – user datalistId (
UnionType
[str
,None
]) – custom list id to create the listraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with created list id will be returned.
- Return type:
class
- deleteAttribute(attributeId, raiseError=True, **kwargs)[source]
Delete attribute with specifeid id
- Parameters:
attributeId (
str
) – attribute idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return response empty body.
- Return type:
class
- deleteFace(faceId, raiseError=True, **kwargs)[source]
Delete face. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- deleteFaceAttributes(faceId, raiseError=True, **kwargs)[source]
Delete face attributes.
- Parameters:
faceId (
str
) – face idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse
- Return type:
class
- deleteFaces(faceIds, ignore=None, raiseError=True, **kwargs)[source]
Delete faces. Optional you can set, that faces must belong to account.
- Parameters:
faceIds (
list
[str
]) – face id listignore (
UnionType
[int
,None
]) – ignore non-existing facesraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- deleteList(listId, withFaces=0, raiseError=True, **kwargs)[source]
Remove list. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list idwithFaces (
int
) – remove lists and all faces witch is contained in the listsraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- deleteLists(listIds, withFaces=None, raiseError=True, **kwargs)[source]
Delete lists. Optional you can set, that lists must belong to account.
- Parameters:
listIds (
list
[str
]) – ids of listswithFaces (
int
) – remove lists and all the faces contained in the listsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- getAttribute(attributeId, descriptorVersion=None, targets=None, raiseError=True, **kwargs)[source]
Retrieve a attribute by id.
- Parameters:
attributeId (
str
) – attribute idtargets (
UnionType
[list
[str
],None
]) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_timedescriptorVersion (
int
) – descriptor version to receiveraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with attribute.
- Return type:
class
- getAttributeIds(listId=None, timeLt=None, timeGte=None, page=1, pageSize=1000, raiseError=True, **kwargs)[source]
Get ids of attributes from list by period.
- Parameters:
listId (
UnionType
[str
,None
]) – list idtimeLt (
UnionType
[str
,None
]) – upper bound of face update timetimeGte (
UnionType
[str
,None
]) – lower bound of face update timepage (
UnionType
[int
,None
]) – page, default 1pageSize (
UnionType
[int
,None
]) – page size, default 1000, max 100000raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes ids will be returned.
- Return type:
class
- getAttributeSamples(attributeId, raiseError=True, **kwargs)[source]
Retrieve a attribute by id.
- Parameters:
attributeId (
str
) – attribute idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with samples.
- Return type:
class
- getAttributes(attributeIds, descriptorVersion=None, targets=None, raiseError=True, **kwargs)[source]
Get list of attributes
- Parameters:
attributeIds (
list
[str
]) – list of attributes of interesttargets (
UnionType
[list
[str
],None
]) – Available targets: descriptor, basic_attributes, basic_attributes_samples, face_descriptors_samples, account_id, create_timedescriptorVersion (
int
) – descriptor version to receiveraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- getAttributesFromList(listId, linkKeyLt=None, linkKeyGte=None, limit=1000, parity=None, raiseError=True, **kwargs)[source]
Get all attributes from list by period.
- Parameters:
listId (
str
) – list idlinkKeyLt (
UnionType
[str
,None
]) – upper including link key boundarylinkKeyGte (
UnionType
[str
,None
]) – lower including link key boundarylimit (
UnionType
[int
,None
]) – limitparity (
UnionType
[int
,None
]) – if 1 - get with even and odd max link keys else max link keyraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes will be returned.
- Return type:
class
- getFace(faceId, targets=None, raiseError=True, **kwargs)[source]
Get face by id. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face idtargets (
UnionType
[list
[str
],None
]) – targets to get faceraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with face will be returned.
- Return type:
class
- getFaceAttributeSamples(faceId, raiseError=True, **kwargs)[source]
Get face attribute samples.
- Parameters:
faceId (
str
) – face idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attribute samples will be returned.
- Return type:
class
- getFaceAttributes(faceId, targets=None, descriptorVersion=None, raiseError=True, **kwargs)[source]
Get face attributes.
- Parameters:
faceId (
str
) – face idtargets (
UnionType
[list
[str
],None
]) – targets to get face attributes. Available targets: create_time, face_descriptor, basic_attributes, face_descriptor_samples, basic_attributes_samples.descriptorVersion (
UnionType
[int
,None
]) – descriptor versionraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes will be returned.
- Return type:
class
- getFaces(userData=None, eventId=None, listId=None, faceIds=None, timeLt=None, timeGte=None, page=1, pageSize=10, attributeIds=None, externalIds=None, faceIdGte=None, faceIdLt=None, targets=None, raiseError=True, **kwargs)[source]
Get faces by filters. Optional you can set, that faces must belong to account.
- Parameters:
userData (
UnionType
[str
,None
]) – user data, part of user data, case insensitiveeventId (
UnionType
[str
,None
]) – event idlistId (
UnionType
[str
,None
]) – list idfaceIds (
UnionType
[list
[str
],None
]) – face idstimeLt (
UnionType
[str
,None
]) – upper bound of face create timetimeGte (
UnionType
[str
,None
]) – lower bound of face create timepage (
UnionType
[int
,None
]) – page count, default 1pageSize (
UnionType
[int
,None
]) – page size, default 10, unlimited if -1attributeIds (
UnionType
[list
[str
],None
]) – attributes idsexternalIds (
UnionType
[list
[str
],None
]) – list of external identifiers of persons, if they have their own mapping in the systemfaceIdGte (
UnionType
[str
,None
]) – lower face id including boundaryfaceIdLt (
UnionType
[str
,None
]) – upper face id excluding boundarytargets (
UnionType
[list
[str
],None
]) – targets to get facesraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with faces will be returned.
- Return type:
class
- getFacesAttributes(faceIds, raiseError=True, **kwargs)[source]
Return attributeId of faces from faceIds list
- Parameters:
faceIds (
list
) – list of faceId for return their attributesraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with attributes ids will be returned.
- Return type:
class
- getFacesCount(userData=None, eventId=None, listId=None, faceIds=None, timeLt=None, timeGte=None, attributeIds=None, externalIds=None, faceIdGte=None, faceIdLt=None, raiseError=True, **kwargs)[source]
Count faces by filters. Optional you can set, that faces must belong to account.
- Parameters:
userData (
UnionType
[str
,None
]) – user data, part of user data, case insensitiveeventId (
UnionType
[str
,None
]) – event idlistId (
UnionType
[str
,None
]) – list idfaceIds (
UnionType
[list
[str
],None
]) – face idstimeLt (
UnionType
[str
,None
]) – upper bound of face create timetimeGte (
UnionType
[str
,None
]) – lower bound of face create timeattributeIds (
UnionType
[list
[str
],None
]) – attributes idsexternalIds (
UnionType
[list
[str
],None
]) – list of external identifiers of persons, if they have their own mapping in the systemfaceIdGte (
UnionType
[str
,None
]) – lower face id including boundaryfaceIdLt (
UnionType
[str
,None
]) – upper face id excluding boundaryraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with number of faces will be returned.
- Return type:
class
- getList(listId, page=1, pageSize=10, raiseError=True, **kwargs)[source]
Get list. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list idpage (
UnionType
[int
,None
]) – page count, default 1pageSize (
UnionType
[int
,None
]) – page size, default 10raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with list will be returned.
- Return type:
class
- getLists(userData=None, userDataEq=None, createTimeLt=None, createTimeGte=None, lastUpdateTimeLt=None, lastUpdateTimeGte=None, listIds=None, listIdLt=None, listIdGte=None, page=1, pageSize=10, raiseError=True, **kwargs)[source]
Get lists. Optional you can set, that lists must belong to account.
- Parameters:
userData (
UnionType
[str
,None
]) – user data, part of user data, case sensitiveuserDataEq (
UnionType
[str
,None
]) – user data, case sensitivecreateTimeLt (
UnionType
[str
,None
]) – upper bound of list create timecreateTimeGte (
UnionType
[str
,None
]) – lower bound of list create time including boundarylastUpdateTimeLt (
UnionType
[str
,None
]) – upper bound of list last update timelastUpdateTimeGte (
UnionType
[str
,None
]) – lower bound of list last update time including boundarylistIdLt (
UnionType
[str
,None
]) – upper bound of list idlistIdGte (
UnionType
[str
,None
]) – lower bound of list id including boundarylistIds (
UnionType
[list
[str
],None
]) – list idspage (
UnionType
[int
,None
]) – page, default 1pageSize (
UnionType
[int
,None
]) – page size, default 10raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with lists will be returned.
- Return type:
class
- getListsCount(userData=None, userDataEq=None, createTimeLt=None, createTimeGte=None, lastUpdateTimeLt=None, lastUpdateTimeGte=None, listIds=None, listIdLt=None, listIdGte=None, raiseError=True, **kwargs)[source]
Get number of lists. Optional you can set, that lists must belong to account.
- Parameters:
userData (
UnionType
[str
,None
]) – user data, part of user data, case sensitiveuserDataEq (
UnionType
[str
,None
]) – user datacreateTimeLt (
UnionType
[str
,None
]) – upper bound of list create timecreateTimeGte (
UnionType
[str
,None
]) – lower bound of list create time including boundarylastUpdateTimeLt (
UnionType
[str
,None
]) – upper bound of list last update timelastUpdateTimeGte (
UnionType
[str
,None
]) – lower bound of list last update time including boundarylistIds (
UnionType
[list
[str
],None
]) – list idslistIdLt (
UnionType
[str
,None
]) – upper bound of list idlistIdGte (
UnionType
[str
,None
]) – lower bound of list id including boundaryraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with number of lists will be returned.
- Return type:
class
- headAttribute(attributeId, raiseError=True, **kwargs)[source]
Check attributes with attribute id exists.
- Parameters:
attributeId (
str
) – attribute idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- headFace(faceId, raiseError=True, **kwargs)[source]
Check face existence by id. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- headList(listId, raiseError=True, **kwargs)[source]
Check list existence. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list idraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- linkFacesToList(listId, faceIds, raiseError=True, **kwargs)[source]
Attach faces to list.
- Parameters:
listId (
str
) – list idfaceIds (
list
[str
]) – face idsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- patchFace(faceId, eventId=None, userData=None, externalId=None, avatar=None, raiseError=True, **kwargs)[source]
Update face. You can update event id, user data, attribute id. Optional you can set, that face must belong to account.
- Parameters:
faceId (
str
) – face ideventId (
UnionType
[str
,None
]) – new event idexternalId (
UnionType
[str
,None
]) – external id of the face, if it has its own mapping in the systemuserData (
UnionType
[str
,None
]) – new user dataavatar (
UnionType
[str
,None
]) – face avatar urlraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- patchList(listId, userData, raiseError=True, **kwargs)[source]
Update user data of list. Optional you can set, that list must belong to account.
- Parameters:
listId (
str
) – list iduserData (
str
) – new user dataraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- putAttribute(attributeId, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, xpk=None, ttl=None, force=None, raiseError=True, **kwargs)[source]
Put attribute by id. Notice that XPK argument overwrites basic attributes and descriptors above.
- Parameters:
attributeId (
str
) – attribute iddescriptors (
UnionType
[list
[UnionType
[bytes
,RawDescriptor
]],None
]) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
UnionType
[dict
,None
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.xpk (
bytes
) – SDKObject bytes to load attributes fromttl (
UnionType
[int
,None
]) – temporary attribute ttlforce (
UnionType
[int
,None
]) – replace or not existence attributeraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- putFace(faceId, externalId=None, attributeId=None, basicAttributes=None, descriptors=None, descriptorSamples=None, basicAttributesSamples=None, eventId=None, userData='', avatar=None, listIds=None, raiseError=True, **kwargs)[source]
Put face in luna-faces
- Parameters:
faceId (
str
) – external face idexternalId (
UnionType
[str
,None
]) – external id of the face, if it has its own mapping in the systemattributeId (
UnionType
[str
,None
]) – attribute iddescriptors (
UnionType
[list
[UnionType
[bytes
,RawDescriptor
]],None
]) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
UnionType
[dict
,None
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.eventId (
UnionType
[str
,None
]) – reference to event which created faceuserData (
UnionType
[str
,None
]) – face user dataavatar (
UnionType
[str
,None
]) – face avatar urllistIds (
UnionType
[list
[str
],None
]) – created face will be attach to these listsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with face id will be returned.
- Return type:
class
- putFaceAttributes(faceId, attributeId=None, basicAttributes=None, descriptors=None, basicAttributesSamples=None, descriptorSamples=None, raiseError=True, **kwargs)[source]
Put face attributes.
- Parameters:
faceId (
str
) – face idattributeId (
UnionType
[str
,None
]) – attribute iddescriptors (
UnionType
[list
[UnionType
[bytes
,RawDescriptor
]],None
]) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
UnionType
[dict
,None
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse
- Return type:
class
- unlinkFacesFromList(listId, faceIds, raiseError=True, **kwargs)[source]
Detach faces to list.
- Parameters:
listId (
str
) – list idfaceIds (
list
[str
]) – face idsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- updateFaceAttributes(faceId, attributeId=None, basicAttributes=None, descriptors=None, basicAttributesSamples=None, descriptorSamples=None, raiseError=True, **kwargs)[source]
Update face attributes.
- Parameters:
faceId (
str
) – face idattributeId (
UnionType
[str
,None
]) – attribute iddescriptors (
UnionType
[list
[UnionType
[bytes
,RawDescriptor
]],None
]) – list of descriptors different versionsdescriptorSamples (
list
[str
]) – list of warp image id from which the attribute was extracted.basicAttributes (
UnionType
[dict
,None
]) – dict with basic attributes (age, gender, ethnicity)basicAttributesSamples (
list
[str
]) – list of warp image id from which the basic attribute was extracted.raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse
- Return type:
class
Luna Image Store client
The luna-image-store client which allows to create/get/delete images and objects
Module contains luna-image-store client adapted for usage in lambda
- class luna_lambda_tools.public.clients.lis.LIS(lisClient, accountId, bucket)[source]
Luna-image-store client
- deleteImage(imageId, raiseError=True, **kwargs)[source]
Delete image from bucket.
- Parameters:
imageId (
str
) – image id to deleteraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- deleteImages(imageIds, raiseError=True, **kwargs)[source]
Delete images from bucket.
- Parameters:
imageIds (
list
[str
]) – images ids to deleteraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- deleteObject(objectId, raiseError=True, **kwargs)[source]
Delete object from bucket.
- Parameters:
objectId (
str
) – object idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- deleteObjects(objectIds, raiseError=True, **kwargs)[source]
Delete objects from bucket.
- Parameters:
objectIds (
list
[str
]) – objects ids to deleteraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- getImage(imageId, withMeta=None, raiseError=True, **kwargs)[source]
Get image from bucket.
- Parameters:
imageId (
str
) – external image idwithMeta (
bool
) – whether to retrieve user-defined image metadataraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- getObject(objectId, raiseError=True, **kwargs)[source]
Get object from bucket.
- Parameters:
objectId (
str
) – object idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- headImage(imageId, withMeta=None, raiseError=True, **kwargs)[source]
Check image existence in bucket.
- Parameters:
imageId (
str
) – external image idwithMeta (
bool
) – whether to retrieve user-defined image metadataraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- headObject(objectId, raiseError=True, **kwargs)[source]
Check object existence in bucket.
- Parameters:
objectId (
str
) – object idraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- postImage(imageInBytes, contentType='image/jpeg', raiseError=True, **kwargs)[source]
Post an image to bucket.
- Parameters:
imageInBytes (
UnionType
[bytes
,bytearray
]) – byte’s array (image)contentType (
str
) – content-type of image or image/jpeg for defaultraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- postObject(objectBody, contentType='application/json', raiseError=True, **kwargs)[source]
Post object to bucket.
- Parameters:
objectBody (
str
) – object, available: text, jsoncontentType (
str
) – content-type of object or application/json for defaultraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- putImage(imageInBytes, imageId, contentType='image/jpeg', raiseError=True, **kwargs)[source]
Put an image to bucket.
- Parameters:
imageInBytes (
UnionType
[bytes
,bytearray
]) – byte’s array (image)imageId (
str
) – image idcontentType (
str
) – content-type of image or image/jpeg for defaultraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
- putObject(objectBody, objectId, contentType='application/json', raiseError=True, **kwargs)[source]
Put object to bucket.
- Parameters:
objectBody (
str
) – object, available: text, jsonobjectId (
str
) – object idcontentType (
UnionType
[str
,None
]) – content-type of object or application/json for defaultraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json with version.
- Return type:
class
Luna Python Matcher client
The luna-python-matcher client which allows to match/crossmatch faces/bodies
Module contains luna-python-matcher client adapted for usage in lambda
- class luna_lambda_tools.public.clients.lpm.LPM(lpmClient, accountId)[source]
Luna-python-matcher client
- crossmatchBodies(candidateFilters, referenceFilters, limit=None, threshold=None, sorting=None, raiseError=True, **kwargs)[source]
Cross Matcher API allows to submit tasks to a service that searches for events by given filters and matches them with each other. Resource implements body descriptors matching.
- Parameters:
candidateFilters (
EventFilters
) – candidate events filtersreferenceFilters (
EventFilters
) – reference events filterslimit (
UnionType
[int
,None
]) – matching limitthreshold (
UnionType
[int
,None
]) – matching thresholdsorting (
UnionType
[int
,None
]) – whether to sort match resultsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- crossmatchFaces(candidateFilters, referenceFilters, limit=None, threshold=None, sorting=None, raiseError=True, **kwargs)[source]
Cross Matcher API allows to submit tasks to a service that searches for faces/events by given filters and matches them with each other. Resource implements face descriptors matching.
- Parameters:
candidateFilters (
UnionType
[FaceFilters
,EventFilters
,AttributeFilters
]) – candidate filtersreferenceFilters (
UnionType
[FaceFilters
,EventFilters
,AttributeFilters
]) – reference filterslimit (
UnionType
[int
,None
]) – matching limitthreshold (
UnionType
[int
,None
]) – matching thresholdsorting (
UnionType
[int
,None
]) – whether to sort match resultsraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- matchBodies(candidates, references, raiseError=True, **kwargs)[source]
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
- Parameters:
candidates (
list
[Candidates
]) – Candidates object with info about candidates (possible type variants: events)references (
list
[UnionType
[Reference
,BinaryReference
]]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, raw descriptors)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- matchFaces(candidates, references, raiseError=True, **kwargs)[source]
Matcher API allows to submit tasks to a service that searches for faces similar to a given reference(s) by matching them. An attribute descriptor should be extracted for reference(s) and candidate(s). A source for references are events, attributes and faces. A source for candidates are faces and lists.
- Parameters:
candidates (
list
[Candidates
]) – Candidates object with info about candidatesreferences (
list
[UnionType
[Reference
,BinaryReference
]]) – list of Reference objects. Each object has entity id and it type (possible type variants: events, attributes, faces, raw descriptors)raiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching (failed and succeeded matches)
- Return type:
class
- matchRaw(candidates, references, raiseError=True, **kwargs)[source]
Matcher raw API allows to match each candidate with each reference descriptors.
- Parameters:
candidates (
list
[BinaryReference
]) – list of BinaryReference objects for candidatesreferences (
list
[BinaryReference
]) – list of BinaryReference objects for referencesraiseError – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching for each reference
- Return type:
class
Luna Remote SDK client
The luna-remote-sdk client which allows to detect faces/bodies on images, extract descriptors and estimate several parameters
Module contains luna-remote-sdk client adapted for usage in lambda
- class luna_lambda_tools.public.clients.lrs.LRS(lrsClient, accountId)[source]
Luna-remote-sdk client
- sdk(inputData, multifacePolicy=1, detectFace=None, detectBody=None, estimateHeadPose=None, estimateLandmarks68=None, estimateLandmarks5=None, estimateQuality=None, estimateGaze=None, estimateEyesAttributes=None, estimateEmotions=None, estimateMouthAttributes=None, estimateMask=None, estimateGlasses=None, estimateLiveness=None, estimateFaceWarp=None, estimateBodyWarp=None, aggregateAttributes=None, estimateBasicAttributes=None, estimateBodyDescriptor=None, estimateFaceDescriptor=None, estimateUpperBody=None, estimateLowerBody=None, estimateBodyBasicAttributes=None, estimateAccessories=None, pitchThreshold=None, rollThreshold=None, yawThreshold=None, scoreThreshold=None, maskStates=None, livenessStates=None, imageType=None, useExifInfo=None, extractExif=None, raiseError=True, **kwargs)[source]
Detect faces on input images.
- Parameters:
inputData (
UnionType
[BinaryImage
,list
[BinaryImage
],list
[UrlForDetection
],list
[str
]]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idsmultifacePolicy (
int
) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the imagedetectFace (
UnionType
[int
,None
]) – detect facesdetectBody (
UnionType
[int
,None
]) – detect human bodiesestimateHeadPose (
UnionType
[int
,None
]) – Available values : 0, 1estimateLandmarks5 (
UnionType
[int
,None
]) – Available values : 0, 1estimateLandmarks68 (
UnionType
[int
,None
]) – Available values : 0, 1estimateQuality (
UnionType
[int
,None
]) – Available values : 0, 1estimateGaze (
UnionType
[int
,None
]) – Available values : 0, 1estimateEyesAttributes (
UnionType
[int
,None
]) – Available values : 0, 1estimateMouthAttributes (
UnionType
[int
,None
]) – Available values : 0, 1estimateEmotions (
UnionType
[int
,None
]) – Available values : 0, 1estimateMask (
UnionType
[int
,None
]) – Available values: 0, 1estimateGlasses (
UnionType
[int
,None
]) – Available values: 0, 1estimateLiveness (
UnionType
[int
,None
]) – Available values: 0, 1estimateFaceDescriptor (
UnionType
[int
,None
]) – Available values : 0, 1estimateBodyDescriptor (
UnionType
[int
,None
]) – Available values : 0, 1estimateBasicAttributes (
UnionType
[int
,None
]) – Available values : 0, 1estimateBodyWarp (
UnionType
[int
,None
]) – Available values : 0, 1estimateFaceWarp (
UnionType
[int
,None
]) – Available values : 0, 1estimateUpperBody (
UnionType
[int
,None
]) – Available values : 0, 1estimateLowerBody (
UnionType
[int
,None
]) – Available values : 0, 1estimateBodyBasicAttributes (
UnionType
[int
,None
]) – Available values : 0, 1estimateAccessories (
UnionType
[int
,None
]) – Available values : 0, 1pitchThreshold (
UnionType
[int
,None
]) – maximum deviation pitch angle from 0rollThreshold (
UnionType
[int
,None
]) – maximum deviation roll angle from 0yawThreshold (
UnionType
[int
,None
]) – maximum deviation yaw angle from 0scoreThreshold (
float
) – descriptor garbage scoremaskStates (
UnionType
[list
[int
],None
]) – Array of integer (filter by mask state) (Items Enum:1 2 3)livenessStates (
UnionType
[list
[int
],None
]) – Array of integer (filter by liveness state) (Items Enum:0 1 2)aggregateAttributes (
UnionType
[int
,None
]) – Available values : 0, 1imageType (
UnionType
[int
,None
]) – image type (0 - raw image, 1 - face warped image, 2 - body warped image)useExifInfo (
UnionType
[int
,None
]) – whether to use exif info for auto orientationextractExif (
UnionType
[int
,None
]) – extract EXIF meta information from imagesraiseError (
bool
) – whether to raise LunaApiException in case of failure
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with samples, exif, filename for succeeded images and errors for failed images will be returned.
- Return type:
class
Luna Sender client
The luna-sender client which allows to send custom events to luna-sender
Module contains luna-sender client adapted for usage in lambda
- class luna_lambda_tools.public.clients.sender.Sender(senderClient, accountId)[source]
Luna-sender client
- publish(events, *, handlerId, eventCreateTime, eventEndTime, raiseError=True, **kwargs)[source]
Publish user generated events. :type events:
list
[dict
] :param events: user generated events to be published :type handlerId:str
:param handlerId: event handler id :type eventCreateTime:str
:param eventCreateTime: event creation time :type eventEndTime:str
:param eventEndTime: event end time :param raiseError: whether to raise LunaApiException in case of failure
Luna Handlers client
The luna-handlers client which allows to send custom events to luna-handlers
Module contains luna-handlers client adapted for usage in lambda
- class luna_lambda_tools.public.clients.handlers.Handlers(handlersClient, accountId)[source]
Luna-handlers client
- checkHandlerById(handlerId, **kwargs)[source]
Check whether handler exists by its id
- Parameters:
handlerId (
str
) – handler id (uuid4)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- checkVerifier(verifierId, **kwargs)[source]
Check verifier existence
- Parameters:
verifierId (
str
) – verifier id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- createHandler(policies=None, handlerType=None, lambdaId=None, description=None, **kwargs)[source]
Create new handler. Handler determinate a list of rules for proccessing input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.
- Parameters:
policies (
UnionType
[Policies
,None
]) – object with policies informationhandlerType (
UnionType
[int
,None
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)lambdaId (
UnionType
[str
,None
]) – lambda iddescription (
UnionType
[str
,None
]) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url
- Return type:
class
- createVerifier(policies=None, description=None, **kwargs)[source]
Create new verifier. Verifier determinate a list of rules for processing & verification of input images. You can set parameters for detecting faces, extracting attributes. You can set rules for matching attributes and creating faces from them.
- Parameters:
policies (
UnionType
[VerifierPolicies
,None
]) – object with policies informationdescription (
UnionType
[str
,None
]) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new verifier id and url
- Return type:
class
- deleteHandlerById(handlerId, **kwargs)[source]
Remove handler by id
- Parameters:
handlerId (
str
) – handler id (uuid4)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- deleteVerifier(verifierId, **kwargs)[source]
Remove verifier
- Args:
verifierId: verifier id
- Returns:
class:~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
Union
[Awaitable
[LunaResponse
],LunaResponse
]
- detectFaces(inputData, multifacePolicy=1, estimateHeadPose=0, detectLandmarks68=0, extractExif=0, estimateQuality=0, estimateGaze=0, estimateEyesAttributes=0, estimateEmotions=0, estimateMask=0, estimateMouthAttributes=0, pitchThreshold=None, rollThreshold=None, yawThreshold=None, warpedImage=0, useExifInfo=None, estimateFaceQuality=0, **kwargs)[source]
Detect faces on input images.
- Parameters:
inputData (
UnionType
[BinaryImage
,list
[BinaryImage
],list
[UrlForDetection
],list
[str
]]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idsmultifacePolicy (
int
) – multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the imageestimateHeadPose (
int
) – Available values : 0, 1detectLandmarks68 (
int
) – Available values : 0, 1extractExif (
int
) – Available values : 0, 1estimateQuality (
int
) – Available values : 0, 1estimateGaze (
int
) – Available values : 0, 1estimateEyesAttributes (
int
) – Available values : 0, 1estimateMouthAttributes (
int
) – Available values : 0, 1estimateEmotions (
int
) – Available values : 0, 1estimateMask (
int
) – Available values : 0, 1pitchThreshold (
UnionType
[int
,None
]) – maximum deviation pitch angle from 0rollThreshold (
UnionType
[int
,None
]) – maximum deviation roll angle from 0yawThreshold (
UnionType
[int
,None
]) – maximum deviation yaw angle from 0warpedImage (
int
) – Whether input image is a warped or arbitrary image.useExifInfo (
UnionType
[int
,None
]) – whether to use exif info for auto orientationestimateFaceQuality (
int
) – whether to estimate face quality
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse json with samples, exif, filename for succeeded images and errors for failed images will be returned.
- Return type:
class
- emitEvents(handlerId, inputData, policies=None, externalId=None, userData=None, aggregateAttributes=None, source=None, streamId=None, city=None, street=None, district=None, area=None, houseNumber=None, tags=None, latitude=None, longitude=None, imageType=None, lunaEventTime=None, lunaEventEndTime=None, trackId=None, useExifInfo=None, meta=None, **kwargs)[source]
Emit input events.
- Parameters:
handlerId (
str
) – handler idinputData (
UnionType
[BinaryImage
,list
[BinaryImage
],list
[UrlForDetection
],list
[str
],list
[SampleForDetection
]]) – one of: - Single image or images list for extraction (supported formats “jpeg, png, tif, ppm, bmp”). - list of urls with images - list of images’ idspolicies (
UnionType
[Policies
,dict
,None
]) – object with policies information for dynamic handlerexternalId (
UnionType
[str
,None
]) – external iduserData (
UnionType
[str
,None
]) – user dataaggregateAttributes (
UnionType
[int
,None
]) – aggregate all attributes (descriptot, age, gender) or not (0 or 1)source (
UnionType
[str
,None
]) – sourcestreamId (
UnionType
[str
,None
]) – stream idcity (
UnionType
[str
,None
]) – event citystreet (
UnionType
[str
,None
]) – event streetarea (
UnionType
[str
,None
]) – event areadistrict (
UnionType
[str
,None
]) – event districthouseNumber (
UnionType
[str
,None
]) – event house numbertags (
UnionType
[str
,None
]) – tagslatitude (
UnionType
[float
,None
]) – event latitude in degreeslongitude (
UnionType
[float
,None
]) – event longitude in degreesimageType (
int
) – image type (0 - raw image, 1 - face warped image, 2 - body warped image)lunaEventTime (
UnionType
[str
,None
]) – user defined event create timelunaEventEndTime (
UnionType
[str
,None
]) – user defined event end timetrackId (
UnionType
[str
,None
]) – (str) event track iduseExifInfo (
UnionType
[int
,None
]) – whether to use exif info for auto orientationmeta (
UnionType
[dict
,None
]) – user-defined event metadata
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url
- Return type:
class
- emitStreamEvents(handlerId, inputData, **kwargs)[source]
Emit stream events.
- Parameters:
handlerId (
str
) – handler idinputData (
StreamEventsSource
) – structure with stream event(s) source
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return json new handler id and url
- Return type:
class
- extractAttrFromSample(sampleIds, scoreThreshold=0, extractDescriptor=1, extractBasicAttributes=0, aggregateAttributes=0, ttl=None, **kwargs)[source]
Extract attributes from samples.
- Parameters:
sampleIds (
list
[str
]) – list of samplesscoreThreshold (
float
) – number [ 0 .. 1 ]; example: 0.99; descriptor quality score threshold. All the attributes with quality score below the threshold will be ignored (and not stored in the DB). The function will proceed as usual with all the remaining descriptors (if left).extractDescriptor (
int
) – Available values : 0, 1; whether to extract face descriptor(s)extractBasicAttributes (
int
) – Available values : 0, 1; whether to extract basic attributes (gender, age, ethnicity)aggregateAttributes (
int
) – Available values : 0, 1; whether to aggregate face descriptor(s); If true, all extracted attributes will be aggregated and stored in as a single attribute. Otherwise, all attributes will be stored for every sample.ttl (
UnionType
[int
,None
]) – temporary attribute ttl
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with attributes info
- Return type:
class
- getHandlerById(handlerId, **kwargs)[source]
Get handler by its id
- Parameters:
handlerId (
str
) – handler id (uuid4)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with handler info
- Return type:
class
- getHandlers(description=None, handlerType=None, page=1, pageSize=10, **kwargs)[source]
Get handlers by filters
- Parameters:
description (
UnionType
[str
,None
]) – Find all handlers with description which “like” of this parameterhandlerType (
UnionType
[int
,None
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)page (
int
) – The number of pagepageSize (
int
) – The numbers of items on page
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with handlers info
- Return type:
class
- getHandlersCount(description=None, handlerType=None, **kwargs)[source]
Get handlers count by filters
- Parameters:
description (
UnionType
[str
,None
]) – Find all handlers with description which “like” of this parameterhandlerType (
UnionType
[int
,None
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: handlers count
- Return type:
class
- getVerifier(verifierId, **kwargs)[source]
Get verifier
- Parameters:
verifierId (
str
) – verifier id- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifier info
- Return type:
class
- getVerifiers(description=None, page=1, pageSize=10, **kwargs)[source]
Get verifiers by filters
- Parameters:
description (
UnionType
[str
,None
]) – verifier description (“like” parameter)page (
int
) – The number of pagepageSize (
int
) – The numbers of items on page
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifiers info
- Return type:
class
- getVerifiersCount(description=None, **kwargs)[source]
Count verifiers that satisfy the filters
- Parameters:
description (
UnionType
[str
,None
]) – verifier description (“like” parameter)- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: verifier count
- Return type:
class
- putVerifier(verifierId, policies=None, description=None, **kwargs)[source]
Replace verifier
- Parameters:
verifierId (
str
) – verifier idpolicies (
UnionType
[VerifierPolicies
,None
]) – object with policies informationdescription (
UnionType
[str
,None
]) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: no text returns
- Return type:
class
- saveEvent(handlerId, event, waitSaving=None, **kwargs)[source]
Save raw event.
- Parameters:
handlerId (
str
) – handler idevent (
UnionType
[RawEvent
,dict
[str
,Any
]]) – raw eventwaitSaving (
UnionType
[int
,None
]) – whether to wait for event saving
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- updateHandler(handlerId, policies=None, handlerType=None, lambdaId=None, description=None, **kwargs)[source]
Update a handler. You can not update a part of handler.
- Parameters:
handlerId (
str
) – handler idpolicies (
UnionType
[Policies
,None
]) – object with policies informationhandlerType (
UnionType
[int
,None
]) – handler type (0 - static, 1 - dynamic, 2 - lambda)lambdaId (
UnionType
[str
,None
]) – lambda iddescription (
UnionType
[str
,None
]) – user description
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse will return nothing in text field
- Return type:
class
- upgradeObjectFromSample(data, **kwargs)[source]
Upgrade basic attributes and/or descriptor in a object using samples.
- Parameters:
data (
UnionType
[FaceAttributeUpgrade
,EventAttributeUpgrade
]) – face or attribute upgrade object- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with attributes info
- Return type:
class
- validateHandler(policies, **kwargs)[source]
Validate handler policies.
- Parameters:
policies (
UnionType
[Policies
,dict
]) – object with policies information- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse.
- Return type:
class
- verifyData(verifierId, inputData, eventIds=None, externalIds=None, faceIds=None, attributeIds=None, imageType=None, useExifInfo=None, **kwargs)[source]
Perform data verification against specified objects. Only one objects set is allowed.
- Parameters:
verifierId (
str
) – verifier idinputData (
UnionType
[BinaryImage
,BinaryDescriptorData
,list
[UnionType
[BinaryImage
,BinaryDescriptorData
]]]) – one of: - Single image - Single descriptor - List of images and descriptorsfaceIds (
UnionType
[list
[str
],None
]) – faces ids to verify againsteventIds (
UnionType
[list
[str
],None
]) – event ids to verify againstexternalIds (
UnionType
[list
[str
],None
]) – external ids to verify againstattributeIds (
UnionType
[list
[str
],None
]) – temporary attribute ids to verify againstimageType (
UnionType
[int
,None
]) – image type (0 - raw image, 1 - face warped image)useExifInfo (
UnionType
[int
,None
]) – whether to use exif info for auto orientation
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: json with verifications info
- Return type:
class
- verifyRaw(candidates, references, verifierId, **kwargs)[source]
Verify raw API allows to match each candidate with each reference descriptors.
- Parameters:
verifierId (
str
) – verifier idcandidates (
list
[BinaryReference
]) – list of BinaryReference objects for candidatesreferences (
list
[BinaryReference
]) – list of BinaryReference objects for references verifierId: verifier id
- Returns:
~.LunaResponse or asyncio coroutine with LunaResponse. In body of :class: ~.LunaResponse: results of matching
- Return type:
class