Build Plugin around HTTP HandlerΒΆ
Plugins are great as proxy scripts that manage communication between fkvideo_detector
and findface-facenapi
and redirect findface-facenapi
responses to an application that can process and render them. Another practical use case is sending the facial recognition results to a websocket or saving them to a file.
When writing a plugin for these use cases, you can inherit from the following ready-to-use HTTP handlers:
facenapi.core.http.base_handler.BaseHandler
implements the FindFace Web Interface (without Video Processing)
facenapi.server.base_video_handler.BaseVideoHandler
implements Video Processing.Note
BaseVideoHandler
parses thefkvideo_detector
requests and passes the parsed data to theprocess_frame
method.
Note
To refer to the findface-facenapi
context in a class that inherits from a HTTP API handler, use self.ctx
, e.g. self.ctx.faces.Model.from_extraction_face(eface)
.
The following examples will help you use these handlers in your plugin:
Important
By default,
fkvideo_detector
sends API requests directly tofindface-facenapi
. To use a plugin as a proxy script between the components, assign the plugin path to therequest-url
parameter offkvideo_detector
. The plugin path is specified insideapp.add_handlers()
in the plugin. It is/static-demo/frame
forhtml-demo-report.py
, and/demo/frame
forwebsocket-demo-plugin
.
- The
html-demo-report.py
plugin identifies faces detected in video by thefkvideo_detector
component and saves the identification results to a static HTML file. - The
websocket-demo-plugin
plugin identifies faces detected in video by thefkvideo_detector
component and sends the identification results to a websocket.