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.BaseHandlerimplements the FindFace Web Interface (without Video Processing)
facenapi.server.base_video_handler.BaseVideoHandlerimplements Video Processing.Note
BaseVideoHandlerparses thefkvideo_detectorrequests and passes the parsed data to theprocess_framemethod.
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_detectorsends API requests directly tofindface-facenapi. To use a plugin as a proxy script between the components, assign the plugin path to therequest-urlparameter offkvideo_detector. The plugin path is specified insideapp.add_handlers()in the plugin. It is/static-demo/frameforhtml-demo-report.py, and/demo/frameforwebsocket-demo-plugin.
- The
html-demo-report.pyplugin identifies faces detected in video by thefkvideo_detectorcomponent and saves the identification results to a static HTML file. - The
websocket-demo-pluginplugin identifies faces detected in video by thefkvideo_detectorcomponent and sends the identification results to a websocket.