Events handler¶
Handler is a constructor for the user input images processing rules. Handler has five processing steps:
Detect faces. User can set a list attributes for estimation and head angle thresholds.
Extract attributes. User can define which attributes should be extracted (basic attributes, face or body descriptors or both).
Match extracted descriptors by lists. User can define luna lists for matching and rules for matching.
Create objects using the extracted data and store them. User can define rules for creating samples, attributes, faces or even events. Also, see link policy inside the face storage policy - linking created faces to lists.
For detail see spec_create_new_handler.
Module contains schemas for handler
- class luna_handlers.classes.schemas.handler.CachedHandlerModel(**data)[source]
Cached handler model | contains minimal required fields
- classmethod postInit(values)[source]
Post init
- static postInitMatchPolicy(matchPolicies, accountId)[source]
Post init matching policy - apply handler account id for matching candidates :param matchPolicies: matching policies :param accountId: handler account id
- Return type:
None
- class luna_handlers.classes.schemas.handler.CreateHandlerModel(**data)[source]
Handler model for handler creation
- classmethod validateNPostInit(values)[source]
Validate handler, post init
- class luna_handlers.classes.schemas.handler.FaceInputEstimationsModel(**data)[source]
Model for incoming face estimations: urls, image or samples
- classmethod validateHandler(values)[source]
Validate handler model
- Return type:
dict
- class luna_handlers.classes.schemas.handler.HandlerInputEstimationsModel(*, image: ~typing.Optional[str] = None, mimetype: ~typing.Optional[str] = None, face_bounding_boxes: ~types.ConstrainedListValue[~classes.schemas.simple_schemas.BoundingBoxSchema] = None, body_bounding_boxes: ~types.ConstrainedListValue[~classes.schemas.simple_schemas.BoundingBoxSchema] = None, urls: ~classes.schemas.types.userConstrainedList.<locals>.UserConstrainedList[~luna_handlers.classes.schemas.handler.UrlForInputEvent] = None, samples: ~typing.Union[~classes.schemas.types.userConstrainedList.<locals>.UserConstrainedList[~luna_handlers.classes.schemas.handler.SampleForInputEvent], ~classes.schemas.types.userConstrainedList.<locals>.UserConstrainedList[~uuid.UUID]] = None, detect_time: ~classes.schemas.types.CustomDatetime = None, detect_ts: ~typing.Optional[~classes.schemas.types.DetectTs] = None, image_origin: ~classes.schemas.types.Str256 = None)[source]
Handler model for incoming estimations: urls, image(with face and/or body bounding boxes) or samples
- classmethod validateHandler(values)[source]
Validate handler model
- Return type:
dict
- class luna_handlers.classes.schemas.handler.SampleForInputEvent(**data)[source]
Sample schema
- class luna_handlers.classes.schemas.handler.UrlForInputEvent(**data)[source]
Url schema with detection time and image origin
- class luna_handlers.classes.schemas.handler.ValidatorHandlerModel(**data)[source]
Handler validator model
Module contains event structure.
- class luna_handlers.classes.event.BodyExtractedAttribute(descriptor=None, sampleIds=None)[source]
Body extracted attribute.
- asDict()[source]
Body attributes in api format.
- class luna_handlers.classes.event.Event(sdkEstimations=None, aggregatedEstimations=None, faceAttributes=None, bodyAttributes=None, sampleIds=None, meta=None)[source]
Structure for storage an event
- eventId
event id
- Type:
str
- eventUrl
(Optional[str]) event url
- sdkEstimations
face & body estimations
- Type:
list[ImageDetection]
- aggregateEstimations
event aggregate estimations
- Type:
AggregateEstimations
- faceAttributes
face extracted attribute
- Type:
FaceExtractedAttribute
- bodyAttributes
body extracted attribute
- Type:
BodyExtractedAttribute
- sampleIds
event attribute sample ids
- Type:
list[str]
- meta
user defined metadata
- Type:
EventMetadata
- tags
event tags (user defined & conditional ones)
- Type:
list[str]
- avatar
event avatar
- faceId
face id associated with the event
- Type:
Optional[str]
- faceUrl
face url
- Type:
Optional[str]
- linkedLists
list that contains the face
- Type:
Optional[List[str]]
- matches
list of match results
- Type:
List[EventMatchResult]
- asDict()[source]
Prepares dict representation.
- Return type:
dict
- class luna_handlers.classes.event.EventMetadata(accountId, handlerId, createEventTime, endEventTime, source=None, tags=None, userData=None, externalId=None, location=None, trackId=None)[source]
User defined event metadata.
- class luna_handlers.classes.event.ExtractedAttribute(descriptor=None, sampleIds=None)[source]
Attribute.
- attributeId
attribute id
- Type:
Optional[str]
- descriptor
descriptor
- Type:
RawDescriptorData
- sampleIds
sample ids
- Type:
list(str)
- class luna_handlers.classes.event.FaceExtractedAttribute(descriptor=None, basicAttributes=None, sampleIds=None)[source]
Face extracted attribute.
- asDict()[source]
Face attributes in api format.
- class luna_handlers.classes.event.GeoPosition(latitude=None, longitude=None)[source]
Event coordinates
- latitude
longitude coordinate
- Type:
Optional[float]
- longitude
longitude coordinate
- Type:
Optional[float]
- asDict()[source]
Convert coordinates to dict.
- Returns:
dict. Keys with non None value.
- Return type:
Dict
[str
,Optional
[float
]]
- copy()[source]
Deep copy coordinates.
- Returns:
event coordinates
- Return type:
GeoPosition
- isNotEmpty()[source]
Check geo position is not empty :returns: true if not empty else false
- Return type:
bool
- isValid()[source]
Check that both of coordinates are specified :returns: true if both of coordinates are set or no one otherwise false
- Return type:
bool
- class luna_handlers.classes.event.Location(street, houseNumber, district, area, city, geoPosition)[source]
Event location
- street
street
- Type:
Optional[str]
- houseNumber
house number
- Type:
Optional[str]
- district
district
- Type:
Optional[str]
- area
area
- Type:
Optional[str]
- city
city
- Type:
Optional[str]
- geoPosition
geo coordinates
- Type:
luna_handlers.classes.event.GeoPosition
- asDict()[source]
Convert location to dict.
- Returns:
dict. Keys with non None value.
- Return type:
Dict
[str
,str
]
- copy()[source]
Deep copy location.
- Returns:
event location
- Return type:
Location