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: str = None, mimetype: 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, 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.Event(faceAttributes=None, bodyAttributes=None, aggregateEstimations=None, detections=None)[source]
 Structure for storage a event
- source
 source of event
- Type
 str
- tags
 tags which is associated with the event
- Type
 List[str]
- externalId
 external id created face
- Type
 Optional[str]
- userData
 user data created face
- Type
 str
- matches
 list of match results
- Type
 List[EventMatchResult]
- faceAttributes
 extracted face attributes
- Type
 _APIAttributeForExtract
- bodyAttributes
 extracted body attributes
- Type
 _APIAttributeForExtract
- eventId
 event id
- Type
 str
- faceId
 face id associated with the event
- Type
 str
- faceUrl
 face url
- Type
 str
- linkedLists
 list that contains the face
- Type
 Optional[List[str]]
- location
 event location
- Type
 Location
- detections
 face & body detections
- Type
 List[dict]
- aggregateEstimations
 detection aggregated estimations
- Type
 AggregateEstimations
- eventUrl
 (str) event url
- trackId
 (str) event track id
- 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
- luna_handlers.classes.event.eventAsDict(event)[source]
 Return event in the response format.
- Parameters
 event – event
- Returns
 event as dict
- Return type
 dict
