ngx-face-api-js
Version:
Angular directives for face detection and face recognition in the browser. It is a wrapper for face-api.js, so it is not dependent on the browser implementation.
23 lines • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("@schematics/angular/utility/config");
const schematics_1 = require("@angular/cdk/schematics");
const terminal_1 = require("@angular-devkit/core/src/terminal");
const ng_ast_utils_1 = require("@schematics/angular/utility/ng-ast-utils");
function addNgxFaceApiJsModule(options) {
return (host) => {
const workspace = config_1.getWorkspace(host);
const project = schematics_1.getProjectFromWorkspace(workspace, options.project);
const appModulePath = ng_ast_utils_1.getAppModulePath(host, schematics_1.getProjectMainFile(project));
const ngxFaceApiJsModuleName = 'NgxFaceApiJsModule';
if (schematics_1.hasNgModuleImport(host, appModulePath, ngxFaceApiJsModuleName)) {
return console.warn(terminal_1.red(`Could not set up "${terminal_1.bold(ngxFaceApiJsModuleName)}" ` +
`because "${terminal_1.bold(ngxFaceApiJsModuleName)}" is already imported.`));
}
const modelsUrl = 'https://raw.githubusercontent.com/justadudewhohacks/face-api.js/master/weights';
schematics_1.addModuleImportToRootModule(host, `NgxFaceApiJsModule.forRoot({ modelsUrl: '${modelsUrl}' })`, 'ngx-face-api-js', project);
return host;
};
}
exports.addNgxFaceApiJsModule = addNgxFaceApiJsModule;
//# sourceMappingURL=addNgxFaceApiJsModule.js.map