├── .editorconfig ├── .gitignore ├── LICENSE ├── README.md ├── angular.json ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package-lock.json ├── package.json ├── projects └── ng-open-cv │ ├── karma.conf.js │ ├── ng-package.json │ ├── package.json │ ├── src │ ├── lib │ │ ├── assets │ │ │ └── opencv │ │ │ │ ├── asm │ │ │ │ └── 3.4 │ │ │ │ │ └── opencv.js │ │ │ │ ├── data │ │ │ │ └── haarcascades │ │ │ │ │ ├── haarcascade_eye.xml │ │ │ │ │ ├── haarcascade_eye_tree_eyeglasses.xml │ │ │ │ │ ├── haarcascade_frontalcatface.xml │ │ │ │ │ ├── haarcascade_frontalcatface_extended.xml │ │ │ │ │ ├── haarcascade_frontalface_alt.xml │ │ │ │ │ ├── haarcascade_frontalface_alt2.xml │ │ │ │ │ ├── haarcascade_frontalface_alt_tree.xml │ │ │ │ │ ├── haarcascade_frontalface_default.xml │ │ │ │ │ ├── haarcascade_fullbody.xml │ │ │ │ │ ├── haarcascade_lefteye_2splits.xml │ │ │ │ │ ├── haarcascade_licence_plate_rus_16stages.xml │ │ │ │ │ ├── haarcascade_lowerbody.xml │ │ │ │ │ ├── haarcascade_profileface.xml │ │ │ │ │ ├── haarcascade_righteye_2splits.xml │ │ │ │ │ ├── haarcascade_russian_plate_number.xml │ │ │ │ │ ├── haarcascade_smile.xml │ │ │ │ │ └── haarcascade_upperbody.xml │ │ │ │ └── wasm │ │ │ │ └── 3.4 │ │ │ │ ├── opencv.js │ │ │ │ └── opencv_js.wasm │ │ ├── ng-open-cv.models.ts │ │ ├── ng-open-cv.module.ts │ │ ├── ng-open-cv.service.spec.ts │ │ └── ng-open-cv.service.ts │ ├── public_api.ts │ └── test.ts │ ├── tsconfig.lib.json │ ├── tsconfig.spec.json │ └── tslint.json ├── src ├── app │ ├── app-routing.module.spec.ts │ ├── app-routing.module.ts │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── example-list │ │ ├── example-list.component.css │ │ ├── example-list.component.html │ │ ├── example-list.component.spec.ts │ │ └── example-list.component.ts │ ├── face-detection │ │ ├── face-detection.component.css │ │ ├── face-detection.component.html │ │ ├── face-detection.component.spec.ts │ │ └── face-detection.component.ts │ └── hello │ │ ├── hello.component.css │ │ ├── hello.component.html │ │ ├── hello.component.spec.ts │ │ └── hello.component.ts ├── assets │ ├── .gitkeep │ ├── DaveChappelle.jpg │ └── opencv │ │ ├── data │ │ └── haarcascades │ │ │ ├── haarcascade_eye.xml │ │ │ ├── haarcascade_eye_tree_eyeglasses.xml │ │ │ ├── haarcascade_frontalcatface.xml │ │ │ ├── haarcascade_frontalcatface_extended.xml │ │ │ ├── haarcascade_frontalface_alt.xml │ │ │ ├── haarcascade_frontalface_alt2.xml │ │ │ ├── haarcascade_frontalface_alt_tree.xml │ │ │ ├── haarcascade_frontalface_default.xml │ │ │ ├── haarcascade_fullbody.xml │ │ │ ├── haarcascade_lefteye_2splits.xml │ │ │ ├── haarcascade_licence_plate_rus_16stages.xml │ │ │ ├── haarcascade_lowerbody.xml │ │ │ ├── haarcascade_profileface.xml │ │ │ ├── haarcascade_righteye_2splits.xml │ │ │ ├── haarcascade_russian_plate_number.xml │ │ │ ├── haarcascade_smile.xml │ │ │ └── haarcascade_upperbody.xml │ │ ├── opencv.js │ │ └── wasm │ │ └── opencv_js.wasm ├── browserslist ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json ├── tslint.json └── typings.d.ts ├── tsconfig.json ├── tslint.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | .history 20 | 21 | # IDE - VSCode 22 | .vscode/* 23 | !.vscode/settings.json 24 | !.vscode/tasks.json 25 | !.vscode/launch.json 26 | !.vscode/extensions.json 27 | 28 | # misc 29 | /.sass-cache 30 | /connect.lock 31 | /coverage 32 | /libpeerconnection.log 33 | npm-debug.log 34 | yarn-error.log 35 | testem.log 36 | /typings 37 | 38 | # System Files 39 | .DS_Store 40 | Thumbs.db 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Abou Kone 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NgOpenCV 2 | 3 | This is a library that integrates Angular v6+ with OpenCVJS, the Javascript port of the popular computer 4 | vision library. It will allow you to load the library (with its WASM components) and use it in your application. The loading is done asynchrosnously after your Angular app has booted. The attached service makes use of a notifier to indicate when the loading is done and the service and library is ready for use. 5 | 6 | [Please read this blog post for the whole background on how this library came together](https://medium.com/@abookone/integrating-opencv-js-with-an-angular-application-20ae11c7e217) 7 | 8 | 9 | 10 | ## Installation 11 | 12 | ### NPM 13 | 14 | ``` 15 | npm install ng-open-cv --save 16 | ``` 17 | 18 | 19 | ### Yarn 20 | 21 | ``` 22 | yarn add ng-open-cv 23 | ``` 24 | 25 | Once the library is installed you will need to copy the `opencv` content from the `node_modules/ng-open-cv/lib/assets` folder to your own `assets` folder. This folder 26 | contains the actual OpenCV library (v3.4) and its WASM and ASM.js files. 27 | 28 | ### Data files 29 | 30 | OpenCV.js uses classification files to perform certain detection operations. To use those files: 31 | 32 | * Get the folders you need from the [OpenCV data repository](https://github.com/opencv/opencv/tree/master/data) 33 | * Add the folders to your app's `assets\opencv\data` folder. Right now the `assets\data` folder that with this library only includes the *haarcascardes* files. 34 | * Use the `createFileFromUrl` in the NgOpenService class to load the file in memory. 35 | 36 | Example: 37 | 38 | ``` 39 | 40 | 41 | 42 | this.ngOpenCVService.createFileFromUrl( 43 | 'haarcascade_frontalface_default.xml', 44 | 'assets/opencv/data/haarcascades/haarcascade_frontalface_default.xml' 45 | ), 46 | 47 | 48 | ``` 49 | 50 | 51 | 52 | 3. Typings 53 | 54 | To your `src/typings.d.ts` file. add 55 | 56 | ``` 57 | declare var cv: any; 58 | ``` 59 | 60 | ## Demo 61 | 62 | [You can visit the demo site here](https://devakone.github.io/ng-open-cv/). 63 | 64 | ## Usage 65 | 66 | If you have installed NgOpenCV and copied the `opencv` folder to your `assets` directory, everything should work out of the box. 67 | 68 | 69 | #### 1. Import the `NgOpenCVModule` 70 | Create the configuration object needed to configure the loading of OpenCV.js for your application. By default the 3.4 asm.js version of the library will be loaded. The default options are 71 | 72 | ```ts 73 | DEFAULT_OPTIONS = { 74 | scriptUrl: 'assets/opencv/asm/3.4/opencv.js', 75 | usingWasm: false, 76 | locateFile: this.locateFile.bind(this), 77 | onRuntimeInitialized: () => {} 78 | }; 79 | ``` 80 | Adjust the `scriptUrl` to contain the path to your opencvjs file. If you wanted to load the WASM version, you would use a configuration like: 81 | 82 | ```ts 83 | const openCVConfig: OpenCVOptions = { 84 | scriptUrl: `assets/opencv/wasm/3.4/opencv.js`, 85 | wasmBinaryFile: 'wasm/3.4/opencv_js.wasm', 86 | usingWasm: true 87 | }; 88 | ``` 89 | 90 | ### Note: WASM is not supported on mobile Safari 91 | 92 | Import `NgOpenCVModule.forRoot(config)` in the NgModule of your application. 93 | The `forRoot` method is a convention for modules that provide a singleton service. Pass it the configuration object. 94 | 95 | ```ts 96 | import { BrowserModule } from '@angular/platform-browser'; 97 | import { NgModule } from '@angular/core'; 98 | 99 | import { AppComponent } from './app.component'; 100 | import { NgOpenCVModule } from 'ng-open-cv'; 101 | import { RouterModule } from '@angular/router'; 102 | import { AppRoutingModule } from './app-routing.module'; 103 | import { OpenCVOptions } from 'projects/ng-open-cv/src/public_api'; 104 | 105 | const openCVConfig: OpenCVOptions = { 106 | scriptUrl: `assets/opencv/opencv.js`, 107 | wasmBinaryFile: 'wasm/opencv_js.wasm', 108 | usingWasm: true 109 | }; 110 | 111 | @NgModule({ 112 | declarations: [ 113 | AppComponent, 114 | ], 115 | imports: [ 116 | BrowserModule, 117 | NgOpenCVModule.forRoot(openCVConfig), 118 | RouterModule, 119 | AppRoutingModule 120 | ], 121 | providers: [], 122 | bootstrap: [ 123 | AppComponent 124 | ] 125 | }) 126 | export class AppModule { } 127 | ``` 128 | 129 | If you have multiple NgModules and you use one as a shared NgModule (that you import in all of your other NgModules), 130 | don't forget that you can use it to export the `NgOpenCVModule` that you imported in order to avoid having to import it multiple times. 131 | 132 | ```ts 133 | ... 134 | const openCVConfig: OpenCVOptions = { 135 | scriptUrl: `assets/opencv/opencv.js`, 136 | wasmBinaryFile: 'wasm/opencv_js.wasm', 137 | usingWasm: true 138 | }; 139 | 140 | @NgModule({ 141 | imports: [ 142 | BrowserModule, 143 | NgOpenCVModule.forRoot(openCVConfig) 144 | ], 145 | exports: [BrowserModule, NgOpenCvModule], 146 | }) 147 | export class SharedModule { 148 | } 149 | ``` 150 | 151 | #### 3. Use the `NgOpenCVService` for your application 152 | - Import `NgOpenCVService` from `ng-open-cv` in your application code: 153 | 154 | ```ts 155 | import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; 156 | import { fromEvent, Observable } from 'rxjs'; 157 | import { switchMap } from 'rxjs/operators'; 158 | import { NgOpenCVService, OpenCVLoadResult } from 'ng-open-cv'; 159 | 160 | @Component({ 161 | selector: 'app-hello', 162 | templateUrl: './hello.component.html', 163 | styleUrls: ['./hello.component.css'] 164 | }) 165 | export class HelloComponent implements OnInit { 166 | 167 | // Keep tracks of the ready 168 | openCVLoadResult: Observable; 169 | 170 | // HTML Element references 171 | @ViewChild('fileInput') 172 | fileInput: ElementRef; 173 | @ViewChild('canvasOutput') 174 | canvasOutput: ElementRef; 175 | 176 | constructor(private ngOpenCVService: NgOpenCVService) { } 177 | 178 | ngOnInit() { 179 | this.openCVLoadResult = this.ngOpenCVService.isReady$; 180 | } 181 | 182 | loadImage(event) { 183 | if (event.target.files.length) { 184 | const reader = new FileReader(); 185 | const load$ = fromEvent(reader, 'load'); 186 | load$ 187 | .pipe( 188 | switchMap(() => { 189 | return this.ngOpenCVService.loadImageToHTMLCanvas(`${reader.result}`, this.canvasOutput.nativeElement); 190 | }) 191 | ) 192 | .subscribe( 193 | () => {}, 194 | err => { 195 | console.log('Error loading image', err); 196 | } 197 | ); 198 | reader.readAsDataURL(event.target.files[0]); 199 | } 200 | } 201 | 202 | } 203 | 204 | ``` 205 | 206 | The NgOpenCVService exposes a `isReady$` observable which you should always subscribe too before attempting to do anything OpenCV related. It emits an [OpenCVLoadResult](projects/ng-open-cv/src/lib/ng-open-cv.models.ts) object that is structured as: 207 | 208 | 209 | ```ts 210 | 211 | export interface OpenCVLoadResult { 212 | ready: boolean; 213 | error: boolean; 214 | loading: boolean; 215 | } 216 | 217 | ```` 218 | 219 | 220 | The following function gives you an example of how to use it your code: 221 | 222 | ```ts 223 | detectFace() { 224 | // before detecting the face we need to make sure that 225 | // 1. OpenCV is loaded 226 | // 2. The classifiers have been loaded 227 | this.ngOpenCVService.isReady$ 228 | .pipe( 229 | filter((result: OpenCVLoadResult) => result.ready), 230 | switchMap(() => { 231 | return this.classifiersLoaded$; 232 | }), 233 | tap(() => { 234 | this.clearOutputCanvas(); 235 | this.findFaceAndEyes(); 236 | }) 237 | ) 238 | .subscribe(() => { 239 | console.log('Face detected'); 240 | }); 241 | } 242 | ``` 243 | 244 | You can view more of this example code in the [Face Detection Component](src/app/face-detection/face-detection.component.ts) 245 | 246 | ## Build 247 | 248 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 249 | 250 | ## Running unit tests 251 | 252 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 253 | 254 | ## Running end-to-end tests 255 | 256 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 257 | 258 | # Credits 259 | [OpenCV.js](https://github.com/opencv/opencv) 260 | 261 | [How to build a library for Angular apps](https://medium.com/@tomsu/how-to-build-a-library-for-angular-apps-4f9b38b0ed11) 262 | 263 | # License 264 | [MIT](/LICENSE) 265 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "ng-open-cv-lib": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "targets": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/ng-open-cv-lib", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "src/tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "src/styles.css" 27 | ], 28 | "scripts": [] 29 | }, 30 | "configurations": { 31 | "production": { 32 | "fileReplacements": [ 33 | { 34 | "replace": "src/environments/environment.ts", 35 | "with": "src/environments/environment.prod.ts" 36 | } 37 | ], 38 | "optimization": true, 39 | "outputHashing": "all", 40 | "sourceMap": false, 41 | "extractCss": true, 42 | "namedChunks": false, 43 | "aot": true, 44 | "extractLicenses": true, 45 | "vendorChunk": false, 46 | "buildOptimizer": true 47 | } 48 | } 49 | }, 50 | "serve": { 51 | "builder": "@angular-devkit/build-angular:dev-server", 52 | "options": { 53 | "browserTarget": "ng-open-cv-lib:build", 54 | "port":4321 55 | }, 56 | "configurations": { 57 | "production": { 58 | "browserTarget": "ng-open-cv-lib:build:production" 59 | } 60 | } 61 | }, 62 | "extract-i18n": { 63 | "builder": "@angular-devkit/build-angular:extract-i18n", 64 | "options": { 65 | "browserTarget": "ng-open-cv-lib:build" 66 | } 67 | }, 68 | "test": { 69 | "builder": "@angular-devkit/build-angular:karma", 70 | "options": { 71 | "main": "src/test.ts", 72 | "polyfills": "src/polyfills.ts", 73 | "tsConfig": "src/tsconfig.spec.json", 74 | "karmaConfig": "src/karma.conf.js", 75 | "styles": [ 76 | "src/styles.css" 77 | ], 78 | "scripts": [], 79 | "assets": [ 80 | "src/favicon.ico", 81 | "src/assets" 82 | ] 83 | } 84 | }, 85 | "lint": { 86 | "builder": "@angular-devkit/build-angular:tslint", 87 | "options": { 88 | "tsConfig": [ 89 | "src/tsconfig.app.json", 90 | "src/tsconfig.spec.json" 91 | ], 92 | "exclude": [ 93 | "**/node_modules/**" 94 | ] 95 | } 96 | } 97 | } 98 | }, 99 | "ng-open-cv-lib-e2e": { 100 | "root": "e2e/", 101 | "projectType": "application", 102 | "targets": { 103 | "e2e": { 104 | "builder": "@angular-devkit/build-angular:protractor", 105 | "options": { 106 | "protractorConfig": "e2e/protractor.conf.js", 107 | "devServerTarget": "ng-open-cv-lib:serve" 108 | }, 109 | "configurations": { 110 | "production": { 111 | "devServerTarget": "ng-open-cv-lib:serve:production" 112 | } 113 | } 114 | }, 115 | "lint": { 116 | "builder": "@angular-devkit/build-angular:tslint", 117 | "options": { 118 | "tsConfig": "e2e/tsconfig.e2e.json", 119 | "exclude": [ 120 | "**/node_modules/**" 121 | ] 122 | } 123 | } 124 | } 125 | }, 126 | "ng-open-cv": { 127 | "root": "projects/ng-open-cv", 128 | "sourceRoot": "projects/ng-open-cv/src", 129 | "projectType": "library", 130 | "prefix": "opencv", 131 | "architect": { 132 | "build": { 133 | "builder": "@angular-devkit/build-ng-packagr:build", 134 | "options": { 135 | "tsConfig": "projects/ng-open-cv/tsconfig.lib.json", 136 | "project": "projects/ng-open-cv/ng-package.json" 137 | } 138 | }, 139 | "test": { 140 | "builder": "@angular-devkit/build-angular:karma", 141 | "options": { 142 | "main": "projects/ng-open-cv/src/test.ts", 143 | "tsConfig": "projects/ng-open-cv/tsconfig.spec.json", 144 | "karmaConfig": "projects/ng-open-cv/karma.conf.js" 145 | } 146 | }, 147 | "lint": { 148 | "builder": "@angular-devkit/build-angular:tslint", 149 | "options": { 150 | "tsConfig": [ 151 | "projects/ng-open-cv/tsconfig.lib.json", 152 | "projects/ng-open-cv/tsconfig.spec.json" 153 | ], 154 | "exclude": [ 155 | "**/node_modules/**" 156 | ] 157 | } 158 | } 159 | } 160 | } 161 | }, 162 | "defaultProject": "ng-open-cv-lib" 163 | } 164 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | 3 | describe('workspace-project App', () => { 4 | let page: AppPage; 5 | 6 | beforeEach(() => { 7 | page = new AppPage(); 8 | }); 9 | 10 | it('should display welcome message', () => { 11 | page.navigateTo(); 12 | expect(page.getParagraphText()).toEqual('Welcome to ng-open-cv-lib!'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getParagraphText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-open-cv-lib", 3 | "version": "0.3.1", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build --prod --base-href \"https://devakone.github.io/ng-open-cv/\"", 8 | "publish-site": "npm run build && npx ngh --dir=dist/ng-open-cv-lib", 9 | "test": "ng test", 10 | "lint": "ng lint", 11 | "e2e": "ng e2e", 12 | "build-lib": "ng build ng-open-cv", 13 | "build-lib-publish-site": "npm run package && npm run publish-site", 14 | "copy-lib-assets": "cp-cli projects/ng-open-cv/src/lib/assets dist/ng-open-cv/lib/assets", 15 | "copy-license": "cp LICENSE dist/ng-open-cv/", 16 | "copy-readme": "cp README.md dist/ng-open-cv/", 17 | "copy-files": "npm run copy-license && npm run copy-readme && npm run copy-lib-assets", 18 | "npm_pack": "cd dist/ng-open-cv && npm pack", 19 | "package": "npm run build-lib && npm run copy-files && npm run npm_pack" 20 | }, 21 | "private": true, 22 | "dependencies": { 23 | "@angular/animations": "^6.1.0", 24 | "@angular/common": "^6.1.0", 25 | "@angular/compiler": "^6.1.0", 26 | "@angular/core": "^6.1.0", 27 | "@angular/forms": "^6.1.0", 28 | "@angular/http": "^6.1.0", 29 | "@angular/platform-browser": "^6.1.0", 30 | "@angular/platform-browser-dynamic": "^6.1.0", 31 | "@angular/router": "^6.1.0", 32 | "core-js": "^2.5.4", 33 | "rxjs": "~6.2.0", 34 | "zone.js": "~0.8.26" 35 | }, 36 | "devDependencies": { 37 | "@angular-devkit/build-angular": "^0.13.8", 38 | "@angular-devkit/build-ng-packagr": "^0.13.8", 39 | "@angular/cli": "~6.2.1", 40 | "@angular/compiler-cli": "^6.1.0", 41 | "@angular/language-service": "^6.1.0", 42 | "@types/jasmine": "~2.8.8", 43 | "@types/jasminewd2": "~2.0.3", 44 | "@types/node": "~8.9.4", 45 | "angular-cli-ghpages": "^0.5.3", 46 | "codelyzer": "~4.3.0", 47 | "cp-cli": "^1.1.2", 48 | "jasmine-core": "~2.99.1", 49 | "jasmine-spec-reporter": "~4.2.1", 50 | "karma": "~3.0.0", 51 | "karma-chrome-launcher": "~2.2.0", 52 | "karma-coverage-istanbul-reporter": "~2.0.1", 53 | "karma-jasmine": "~1.1.2", 54 | "karma-jasmine-html-reporter": "^0.2.2", 55 | "ng-packagr": "^4.1.0", 56 | "protractor": "~5.4.0", 57 | "tar": ">=4.4.2", 58 | "ts-node": "~7.0.0", 59 | "tsickle": ">=0.29.0", 60 | "tslib": "^1.9.0", 61 | "tslint": "~5.11.0", 62 | "typescript": "~2.9.2", 63 | "webpack-dev-server": ">=3.1.11" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /projects/ng-open-cv/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /projects/ng-open-cv/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "../../node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "../../dist/ng-open-cv", 4 | "lib": { 5 | "entryFile": "src/public_api.ts" 6 | } 7 | } -------------------------------------------------------------------------------- /projects/ng-open-cv/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-open-cv", 3 | "author": "Abou Kone", 4 | "version": "0.3.1", 5 | "description": "Angular 6+ library integration for OpenCV.js", 6 | "keywords": [ 7 | "Angular", 8 | "OpenCV", 9 | "Library", 10 | "OpenCVJS", 11 | "Face Detection" 12 | ], 13 | "license": "SEE LICENSE IN LICENSE", 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/devakone/ng-open-cv-lib" 17 | }, 18 | "homepage": "https://medium.com/code-divoire/integrating-opencv-js-with-an-angular-application-20ae11c7e217", 19 | "peerDependencies": { 20 | "@angular/common": "^6.0.0-rc.0 || ^6.0.0", 21 | "@angular/core": "^6.1.8" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /projects/ng-open-cv/src/lib/assets/opencv/data/haarcascades/haarcascade_licence_plate_rus_16stages.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 64 16 7 | 8 | <_> 9 | 10 | 11 | <_> 12 | 13 | <_> 14 | 15 | 16 | 17 | <_> 18 | 32 2 8 6 -1. 19 | <_> 20 | 32 4 8 2 3. 21 | 0 22 | 1.6915600746870041e-002 23 | -9.5547717809677124e-001 24 | 8.9129137992858887e-001 25 | <_> 26 | 27 | <_> 28 | 29 | 30 | 31 | <_> 32 | 0 4 6 10 -1. 33 | <_> 34 | 3 4 3 10 2. 35 | 0 36 | 2.4228349328041077e-002 37 | -9.2089319229125977e-001 38 | 8.8723921775817871e-001 39 | <_> 40 | 41 | <_> 42 | 43 | 44 | 45 | <_> 46 | 55 0 8 6 -1. 47 | <_> 48 | 55 0 4 3 2. 49 | <_> 50 | 59 3 4 3 2. 51 | 0 52 | -1.0168660432100296e-002 53 | 8.8940089941024780e-001 54 | -7.7847331762313843e-001 55 | <_> 56 | 57 | <_> 58 | 59 | 60 | 61 | <_> 62 | 44 7 4 9 -1. 63 | <_> 64 | 44 10 4 3 3. 65 | 0 66 | 2.0863260142505169e-003 67 | -8.7998157739639282e-001 68 | 5.8651781082153320e-001 69 | -2.0683259963989258e+000 70 | -1 71 | -1 72 | <_> 73 | 74 | 75 | <_> 76 | 77 | <_> 78 | 79 | 80 | 81 | <_> 82 | 29 1 16 4 -1. 83 | <_> 84 | 29 3 16 2 2. 85 | 0 86 | 2.9062159359455109e-002 87 | -8.7765061855316162e-001 88 | 8.5373121500015259e-001 89 | <_> 90 | 91 | <_> 92 | 93 | 94 | 95 | <_> 96 | 0 5 9 8 -1. 97 | <_> 98 | 3 5 3 8 3. 99 | 0 100 | 2.3903399705886841e-002 101 | -9.2079448699951172e-001 102 | 7.5155001878738403e-001 103 | <_> 104 | 105 | <_> 106 | 107 | 108 | 109 | <_> 110 | 44 0 20 14 -1. 111 | <_> 112 | 44 0 10 7 2. 113 | <_> 114 | 54 7 10 7 2. 115 | 0 116 | -3.5404648631811142e-002 117 | 6.7834627628326416e-001 118 | -9.0937072038650513e-001 119 | <_> 120 | 121 | <_> 122 | 123 | 124 | 125 | <_> 126 | 41 7 6 9 -1. 127 | <_> 128 | 43 7 2 9 3. 129 | 0 130 | 6.2988721765577793e-003 131 | -8.1054258346557617e-001 132 | 5.8985030651092529e-001 133 | <_> 134 | 135 | <_> 136 | 137 | 138 | 139 | <_> 140 | 0 4 21 4 -1. 141 | <_> 142 | 7 4 7 4 3. 143 | 0 144 | 3.4959490876644850e-003 145 | -9.7632282972335815e-001 146 | 4.5473039150238037e-001 147 | -1.6632349491119385e+000 148 | 0 149 | -1 150 | <_> 151 | 152 | 153 | <_> 154 | 155 | <_> 156 | 157 | 158 | 159 | <_> 160 | 31 2 11 6 -1. 161 | <_> 162 | 31 4 11 2 3. 163 | 0 164 | 2.3864099755883217e-002 165 | -9.3137168884277344e-001 166 | 8.2478952407836914e-001 167 | <_> 168 | 169 | <_> 170 | 171 | 172 | 173 | <_> 174 | 56 3 6 11 -1. 175 | <_> 176 | 59 3 3 11 2. 177 | 0 178 | -2.5775209069252014e-002 179 | 8.5526448488235474e-001 180 | -8.7574672698974609e-001 181 | <_> 182 | 183 | <_> 184 | 185 | 186 | 187 | <_> 188 | 32 14 32 2 -1. 189 | <_> 190 | 32 15 32 1 2. 191 | 0 192 | -1.0646049864590168e-002 193 | 8.5167151689529419e-001 194 | -6.7789041996002197e-001 195 | <_> 196 | 197 | <_> 198 | 199 | 200 | 201 | <_> 202 | 0 2 8 14 -1. 203 | <_> 204 | 4 2 4 14 2. 205 | 0 206 | 2.7000989764928818e-002 207 | -8.0041092634201050e-001 208 | 6.4893317222595215e-001 209 | <_> 210 | 211 | <_> 212 | 213 | 214 | 215 | <_> 216 | 19 0 22 6 -1. 217 | <_> 218 | 19 0 11 3 2. 219 | <_> 220 | 30 3 11 3 2. 221 | 0 222 | 5.2989721298217773e-003 223 | -9.5342522859573364e-001 224 | 5.0140267610549927e-001 225 | -1.3346730470657349e+000 226 | 1 227 | -1 228 | <_> 229 | 230 | 231 | <_> 232 | 233 | <_> 234 | 235 | 236 | 237 | <_> 238 | 56 0 6 6 -1. 239 | <_> 240 | 56 0 3 3 2. 241 | <_> 242 | 59 3 3 3 2. 243 | 0 244 | -6.9233630783855915e-003 245 | 8.2654470205307007e-001 246 | -8.5396027565002441e-001 247 | <_> 248 | 249 | <_> 250 | 251 | 252 | 253 | <_> 254 | 32 0 14 12 -1. 255 | <_> 256 | 32 0 7 6 2. 257 | <_> 258 | 39 6 7 6 2. 259 | 0 260 | 1.2539249658584595e-001 261 | -1.2996139936149120e-002 262 | -3.2377028808593750e+003 263 | <_> 264 | 265 | <_> 266 | 267 | 268 | 269 | <_> 270 | 2 1 43 4 -1. 271 | <_> 272 | 2 3 43 2 2. 273 | 0 274 | 6.3474893569946289e-002 275 | -6.4648061990737915e-001 276 | 8.2302427291870117e-001 277 | <_> 278 | 279 | <_> 280 | 281 | 282 | 283 | <_> 284 | 34 10 30 5 -1. 285 | <_> 286 | 44 10 10 5 3. 287 | 0 288 | 4.2217150330543518e-002 289 | -7.5190877914428711e-001 290 | 6.3705182075500488e-001 291 | <_> 292 | 293 | <_> 294 | 295 | 296 | 297 | <_> 298 | 0 9 9 5 -1. 299 | <_> 300 | 3 9 3 5 3. 301 | 0 302 | 2.0000640302896500e-002 303 | -6.2077498435974121e-001 304 | 6.1317932605743408e-001 305 | -1.6521669626235962e+000 306 | 2 307 | -1 308 | <_> 309 | 310 | 311 | <_> 312 | 313 | <_> 314 | 315 | 316 | 317 | <_> 318 | 2 1 43 6 -1. 319 | <_> 320 | 2 3 43 2 3. 321 | 0 322 | 9.2297486960887909e-002 323 | -7.2764229774475098e-001 324 | 8.0554759502410889e-001 325 | <_> 326 | 327 | <_> 328 | 329 | 330 | 331 | <_> 332 | 53 4 9 8 -1. 333 | <_> 334 | 56 4 3 8 3. 335 | 0 336 | 2.7613969519734383e-002 337 | -7.0769268274307251e-001 338 | 7.3315787315368652e-001 339 | <_> 340 | 341 | <_> 342 | 343 | 344 | 345 | <_> 346 | 36 4 14 8 -1. 347 | <_> 348 | 36 4 7 4 2. 349 | <_> 350 | 43 8 7 4 2. 351 | 0 352 | 1.2465449981391430e-002 353 | -8.4359270334243774e-001 354 | 5.7046437263488770e-001 355 | <_> 356 | 357 | <_> 358 | 359 | 360 | 361 | <_> 362 | 14 14 49 2 -1. 363 | <_> 364 | 14 15 49 1 2. 365 | 0 366 | -2.3886829614639282e-002 367 | 8.2656508684158325e-001 368 | -5.2783298492431641e-001 369 | -1.4523630142211914e+000 370 | 3 371 | -1 372 | <_> 373 | 374 | 375 | <_> 376 | 377 | <_> 378 | 379 | 380 | 381 | <_> 382 | 0 5 4 9 -1. 383 | <_> 384 | 2 5 2 9 2. 385 | 0 386 | 1.8821349367499352e-002 387 | -8.1122857332229614e-001 388 | 6.9127470254898071e-001 389 | <_> 390 | 391 | <_> 392 | 393 | 394 | 395 | <_> 396 | 21 1 38 4 -1. 397 | <_> 398 | 21 3 38 2 2. 399 | 0 400 | 6.1703320592641830e-002 401 | -7.6482647657394409e-001 402 | 6.4212161302566528e-001 403 | <_> 404 | 405 | <_> 406 | 407 | 408 | 409 | <_> 410 | 44 12 18 3 -1. 411 | <_> 412 | 53 12 9 3 2. 413 | 0 414 | -1.6298670321702957e-002 415 | 5.0207728147506714e-001 416 | -8.4020161628723145e-001 417 | <_> 418 | 419 | <_> 420 | 421 | 422 | 423 | <_> 424 | 10 4 9 3 -1. 425 | <_> 426 | 13 4 3 3 3. 427 | 0 428 | -4.9458951689302921e-003 429 | 6.1991941928863525e-001 430 | -6.1633539199829102e-001 431 | <_> 432 | 433 | <_> 434 | 435 | 436 | 437 | <_> 438 | 40 4 10 4 -1. 439 | <_> 440 | 45 4 5 4 2. 441 | 0 442 | -5.1894597709178925e-003 443 | 4.4975179433822632e-001 444 | -8.0651968717575073e-001 445 | <_> 446 | 447 | <_> 448 | 449 | 450 | 451 | <_> 452 | 17 14 47 2 -1. 453 | <_> 454 | 17 15 47 1 2. 455 | 0 456 | -1.8824130296707153e-002 457 | 6.1992841958999634e-001 458 | -5.5643159151077271e-001 459 | <_> 460 | 461 | <_> 462 | 463 | 464 | 465 | <_> 466 | 8 5 4 7 -1. 467 | <_> 468 | 10 5 2 7 2. 469 | 0 470 | 5.6571601890027523e-003 471 | -4.8346561193466187e-001 472 | 6.8647360801696777e-001 473 | -2.2358059883117676e+000 474 | 4 475 | -1 476 | <_> 477 | 478 | 479 | <_> 480 | 481 | <_> 482 | 483 | 484 | 485 | <_> 486 | 56 0 6 6 -1. 487 | <_> 488 | 56 0 3 3 2. 489 | <_> 490 | 59 3 3 3 2. 491 | 0 492 | -9.1503243893384933e-003 493 | 6.8174481391906738e-001 494 | -7.7866071462631226e-001 495 | <_> 496 | 497 | <_> 498 | 499 | 500 | 501 | <_> 502 | 0 0 6 6 -1. 503 | <_> 504 | 0 0 3 3 2. 505 | <_> 506 | 3 3 3 3 2. 507 | 0 508 | 7.4933180585503578e-003 509 | -6.8696027994155884e-001 510 | 6.6913938522338867e-001 511 | <_> 512 | 513 | <_> 514 | 515 | 516 | 517 | <_> 518 | 13 4 48 2 -1. 519 | <_> 520 | 29 4 16 2 3. 521 | 0 522 | 4.5296419411897659e-002 523 | -7.3576509952545166e-001 524 | 5.9453499317169189e-001 525 | <_> 526 | 527 | <_> 528 | 529 | 530 | 531 | <_> 532 | 42 1 6 15 -1. 533 | <_> 534 | 42 6 6 5 3. 535 | 0 536 | 1.1669679544866085e-002 537 | -8.4733831882476807e-001 538 | 4.5461329817771912e-001 539 | <_> 540 | 541 | <_> 542 | 543 | 544 | 545 | <_> 546 | 30 8 3 5 -1. 547 | <_> 548 | 31 8 1 5 3. 549 | 0 550 | 2.5769430212676525e-003 551 | -5.8270388841629028e-001 552 | 7.7900522947311401e-001 553 | <_> 554 | 555 | <_> 556 | 557 | 558 | 559 | <_> 560 | 55 10 8 6 -1. 561 | <_> 562 | 55 13 8 3 2. 563 | 0 564 | -1.4139170525595546e-003 565 | 4.5126929879188538e-001 566 | -9.0696328878402710e-001 567 | -1.8782069683074951e+000 568 | 5 569 | -1 570 | <_> 571 | 572 | 573 | <_> 574 | 575 | <_> 576 | 577 | 578 | 579 | <_> 580 | 4 6 4 7 -1. 581 | <_> 582 | 6 6 2 7 2. 583 | 0 584 | -5.3149578161537647e-003 585 | 6.5218788385391235e-001 586 | -7.9464268684387207e-001 587 | <_> 588 | 589 | <_> 590 | 591 | 592 | 593 | <_> 594 | 56 3 6 8 -1. 595 | <_> 596 | 59 3 3 8 2. 597 | 0 598 | -2.2906960919499397e-002 599 | 6.6433382034301758e-001 600 | -7.3633247613906860e-001 601 | <_> 602 | 603 | <_> 604 | 605 | 606 | 607 | <_> 608 | 37 2 4 6 -1. 609 | <_> 610 | 37 4 4 2 3. 611 | 0 612 | 9.4887977465987206e-003 613 | -8.2612031698226929e-001 614 | 4.9333500862121582e-001 615 | <_> 616 | 617 | <_> 618 | 619 | 620 | 621 | <_> 622 | 0 10 30 6 -1. 623 | <_> 624 | 0 12 30 2 3. 625 | 0 626 | 4.5138411223888397e-002 627 | -5.4704028367996216e-001 628 | 7.6927912235260010e-001 629 | <_> 630 | 631 | <_> 632 | 633 | 634 | 635 | <_> 636 | 0 4 21 12 -1. 637 | <_> 638 | 7 4 7 12 3. 639 | 0 640 | 2.5049019604921341e-002 641 | -8.6739641427993774e-001 642 | 5.2807968854904175e-001 643 | -1.0597369670867920e+000 644 | 6 645 | -1 646 | <_> 647 | 648 | 649 | <_> 650 | 651 | <_> 652 | 653 | 654 | 655 | <_> 656 | 44 0 1 14 -1. 657 | <_> 658 | 44 7 1 7 2. 659 | 0 660 | 6.6414438188076019e-003 661 | -7.7290147542953491e-001 662 | 6.9723731279373169e-001 663 | <_> 664 | 665 | <_> 666 | 667 | 668 | 669 | <_> 670 | 54 3 4 3 -1. 671 | <_> 672 | 56 3 2 3 2. 673 | 0 674 | 2.4703629314899445e-003 675 | -7.4289917945861816e-001 676 | 6.6825848817825317e-001 677 | <_> 678 | 679 | <_> 680 | 681 | 682 | 683 | <_> 684 | 32 0 30 6 -1. 685 | <_> 686 | 32 0 15 3 2. 687 | <_> 688 | 47 3 15 3 2. 689 | 0 690 | -2.2910499945282936e-002 691 | 4.3986389040946960e-001 692 | -9.0588808059692383e-001 693 | <_> 694 | 695 | <_> 696 | 697 | 698 | 699 | <_> 700 | 0 8 9 7 -1. 701 | <_> 702 | 3 8 3 7 3. 703 | 0 704 | 3.4193221479654312e-002 705 | -6.9507479667663574e-001 706 | 6.2501090764999390e-001 707 | <_> 708 | 709 | <_> 710 | 711 | 712 | 713 | <_> 714 | 30 10 3 3 -1. 715 | <_> 716 | 31 10 1 3 3. 717 | 0 718 | 1.5060020377859473e-003 719 | -6.8670761585235596e-001 720 | 8.2241541147232056e-001 721 | <_> 722 | 723 | <_> 724 | 725 | 726 | 727 | <_> 728 | 21 3 24 4 -1. 729 | <_> 730 | 29 3 8 4 3. 731 | 0 732 | 1.9838380467263050e-005 733 | -9.2727631330490112e-001 734 | 6.4723730087280273e-001 735 | <_> 736 | 737 | <_> 738 | 739 | 740 | 741 | <_> 742 | 42 3 12 6 -1. 743 | <_> 744 | 46 3 4 6 3. 745 | 0 746 | -2.2170299416757189e-005 747 | 5.6555831432342529e-001 748 | -9.6788132190704346e-001 749 | -1.4993519783020020e+000 750 | 7 751 | -1 752 | <_> 753 | 754 | 755 | <_> 756 | 757 | <_> 758 | 759 | 760 | 761 | <_> 762 | 56 9 6 6 -1. 763 | <_> 764 | 59 9 3 6 2. 765 | 0 766 | -1.1395259760320187e-002 767 | 7.1383631229400635e-001 768 | -8.7429678440093994e-001 769 | <_> 770 | 771 | <_> 772 | 773 | 774 | 775 | <_> 776 | 6 4 1 6 -1. 777 | <_> 778 | 6 7 1 3 2. 779 | 0 780 | -2.1864590235054493e-003 781 | 8.5311782360076904e-001 782 | -6.4777731895446777e-001 783 | <_> 784 | 785 | <_> 786 | 787 | 788 | 789 | <_> 790 | 0 0 12 4 -1. 791 | <_> 792 | 0 0 6 2 2. 793 | <_> 794 | 6 2 6 2 2. 795 | 0 796 | 2.3193720262497663e-003 797 | -7.6411879062652588e-001 798 | 7.1867972612380981e-001 799 | <_> 800 | 801 | <_> 802 | 803 | 804 | 805 | <_> 806 | 43 12 18 2 -1. 807 | <_> 808 | 52 12 9 2 2. 809 | 0 810 | -7.9916073009371758e-003 811 | 6.6442942619323730e-001 812 | -7.9540950059890747e-001 813 | <_> 814 | 815 | <_> 816 | 817 | 818 | 819 | <_> 820 | 9 5 2 8 -1. 821 | <_> 822 | 10 5 1 8 2. 823 | 0 824 | 1.4212740352377295e-003 825 | -6.3904231786727905e-001 826 | 7.5050598382949829e-001 827 | -8.4829801321029663e-001 828 | 8 829 | -1 830 | <_> 831 | 832 | 833 | <_> 834 | 835 | <_> 836 | 837 | 838 | 839 | <_> 840 | 1 9 6 3 -1. 841 | <_> 842 | 3 9 2 3 3. 843 | 0 844 | 6.4091659151017666e-003 845 | -8.8425230979919434e-001 846 | 9.9953681230545044e-001 847 | <_> 848 | 849 | <_> 850 | 851 | 852 | 853 | <_> 854 | 56 8 2 8 -1. 855 | <_> 856 | 56 12 2 4 2. 857 | 0 858 | -6.3316390151157975e-004 859 | 8.3822172880172729e-001 860 | -9.8322170972824097e-001 861 | <_> 862 | 863 | <_> 864 | 865 | 866 | 867 | <_> 868 | 24 2 6 13 -1. 869 | <_> 870 | 26 2 2 13 3. 871 | 0 872 | -6.4947169448714703e-005 873 | 1. 874 | -9.1822808980941772e-001 875 | <_> 876 | 877 | <_> 878 | 879 | 880 | 881 | <_> 882 | 33 7 24 4 -1. 883 | <_> 884 | 41 7 8 4 3. 885 | 0 886 | 5.3404141217470169e-003 887 | -9.4317251443862915e-001 888 | 9.0425151586532593e-001 889 | -6.0007210820913315e-002 890 | 9 891 | -1 892 | <_> 893 | 894 | 895 | <_> 896 | 897 | <_> 898 | 899 | 900 | 901 | <_> 902 | 1 1 57 4 -1. 903 | <_> 904 | 1 3 57 2 2. 905 | 0 906 | 1.0755469650030136e-001 907 | -7.1647202968597412e-001 908 | 8.7827038764953613e-001 909 | <_> 910 | 911 | <_> 912 | 913 | 914 | 915 | <_> 916 | 0 2 6 14 -1. 917 | <_> 918 | 3 2 3 14 2. 919 | 0 920 | 3.1668949872255325e-002 921 | -8.7051069736480713e-001 922 | 5.8807212114334106e-001 923 | <_> 924 | 925 | <_> 926 | 927 | 928 | 929 | <_> 930 | 52 3 6 10 -1. 931 | <_> 932 | 54 3 2 10 3. 933 | 0 934 | -1.0572380386292934e-002 935 | 6.2438100576400757e-001 936 | -7.4027371406555176e-001 937 | <_> 938 | 939 | <_> 940 | 941 | 942 | 943 | <_> 944 | 1 14 61 2 -1. 945 | <_> 946 | 1 15 61 1 2. 947 | 0 948 | -2.7396259829401970e-002 949 | 8.9776748418807983e-001 950 | -5.2986758947372437e-001 951 | <_> 952 | 953 | <_> 954 | 955 | 956 | 957 | <_> 958 | 28 0 11 12 -1. 959 | <_> 960 | 28 4 11 4 3. 961 | 0 962 | 2.5918649509549141e-002 963 | -8.6482518911361694e-001 964 | 5.3121817111968994e-001 965 | -9.6125108003616333e-001 966 | 10 967 | -1 968 | <_> 969 | 970 | 971 | <_> 972 | 973 | <_> 974 | 975 | 976 | 977 | <_> 978 | 22 1 41 4 -1. 979 | <_> 980 | 22 3 41 2 2. 981 | 0 982 | 7.1039132773876190e-002 983 | -7.5719678401947021e-001 984 | 7.5645631551742554e-001 985 | <_> 986 | 987 | <_> 988 | 989 | 990 | 991 | <_> 992 | 41 6 6 8 -1. 993 | <_> 994 | 43 6 2 8 3. 995 | 0 996 | 7.6241148635745049e-003 997 | -7.9783838987350464e-001 998 | 7.1733069419860840e-001 999 | <_> 1000 | 1001 | <_> 1002 | 1003 | 1004 | 1005 | <_> 1006 | 50 9 14 5 -1. 1007 | <_> 1008 | 57 9 7 5 2. 1009 | 0 1010 | -2.7092639356851578e-002 1011 | 6.0071170330047607e-001 1012 | -8.4794402122497559e-001 1013 | <_> 1014 | 1015 | <_> 1016 | 1017 | 1018 | 1019 | <_> 1020 | 4 1 12 5 -1. 1021 | <_> 1022 | 10 1 6 5 2. 1023 | 0 1024 | -8.1267888890579343e-004 1025 | 5.9364068508148193e-001 1026 | -8.9295238256454468e-001 1027 | <_> 1028 | 1029 | <_> 1030 | 1031 | 1032 | 1033 | <_> 1034 | 37 9 3 3 -1. 1035 | <_> 1036 | 38 9 1 3 3. 1037 | 0 1038 | 8.3705072756856680e-004 1039 | -6.4887362718582153e-001 1040 | 7.8537952899932861e-001 1041 | -1.0618970394134521e+000 1042 | 11 1043 | -1 1044 | <_> 1045 | 1046 | 1047 | <_> 1048 | 1049 | <_> 1050 | 1051 | 1052 | 1053 | <_> 1054 | 54 0 10 6 -1. 1055 | <_> 1056 | 54 0 5 3 2. 1057 | <_> 1058 | 59 3 5 3 2. 1059 | 0 1060 | -9.7556859254837036e-003 1061 | 7.6982218027114868e-001 1062 | -8.5293501615524292e-001 1063 | <_> 1064 | 1065 | <_> 1066 | 1067 | 1068 | 1069 | <_> 1070 | 47 0 6 11 -1. 1071 | <_> 1072 | 49 0 2 11 3. 1073 | 0 1074 | -8.6617246270179749e-003 1075 | 8.4029090404510498e-001 1076 | -7.1949690580368042e-001 1077 | <_> 1078 | 1079 | <_> 1080 | 1081 | 1082 | 1083 | <_> 1084 | 19 2 20 2 -1. 1085 | <_> 1086 | 19 3 20 1 2. 1087 | 0 1088 | 1.6897840425372124e-002 1089 | -5.3601992130279541e-001 1090 | 9.5484441518783569e-001 1091 | <_> 1092 | 1093 | <_> 1094 | 1095 | 1096 | 1097 | <_> 1098 | 14 4 6 11 -1. 1099 | <_> 1100 | 17 4 3 11 2. 1101 | 0 1102 | 4.7526158596156165e-005 1103 | -7.6412862539291382e-001 1104 | 7.5398761034011841e-001 1105 | <_> 1106 | 1107 | <_> 1108 | 1109 | 1110 | 1111 | <_> 1112 | 31 9 33 2 -1. 1113 | <_> 1114 | 42 9 11 2 3. 1115 | 0 1116 | 6.5607670694589615e-003 1117 | -9.9346441030502319e-001 1118 | 6.4864277839660645e-001 1119 | -7.3307347297668457e-001 1120 | 12 1121 | -1 1122 | <_> 1123 | 1124 | 1125 | <_> 1126 | 1127 | <_> 1128 | 1129 | 1130 | 1131 | <_> 1132 | 6 1 53 6 -1. 1133 | <_> 1134 | 6 3 53 2 3. 1135 | 0 1136 | 1.0103269666433334e-001 1137 | -7.3275578022003174e-001 1138 | 8.4619927406311035e-001 1139 | <_> 1140 | 1141 | <_> 1142 | 1143 | 1144 | 1145 | <_> 1146 | 49 9 4 6 -1. 1147 | <_> 1148 | 49 9 2 3 2. 1149 | <_> 1150 | 51 12 2 3 2. 1151 | 0 1152 | -2.8920811018906534e-004 1153 | 7.1564781665802002e-001 1154 | -8.8221758604049683e-001 1155 | <_> 1156 | 1157 | <_> 1158 | 1159 | 1160 | 1161 | <_> 1162 | 0 9 30 7 -1. 1163 | <_> 1164 | 10 9 10 7 3. 1165 | 0 1166 | 1.0838840156793594e-002 1167 | -8.7420248985290527e-001 1168 | 6.0648679733276367e-001 1169 | <_> 1170 | 1171 | <_> 1172 | 1173 | 1174 | 1175 | <_> 1176 | 40 4 6 2 -1. 1177 | <_> 1178 | 42 4 2 2 3. 1179 | 0 1180 | 5.0803890917450190e-004 1181 | -9.0554022789001465e-001 1182 | 6.4213967323303223e-001 1183 | <_> 1184 | 1185 | <_> 1186 | 1187 | 1188 | 1189 | <_> 1190 | 1 9 6 1 -1. 1191 | <_> 1192 | 3 9 2 1 3. 1193 | 0 1194 | 2.3357039317488670e-003 1195 | -9.2574918270111084e-001 1196 | 8.6384928226470947e-001 1197 | <_> 1198 | 1199 | <_> 1200 | 1201 | 1202 | 1203 | <_> 1204 | 47 3 4 10 -1. 1205 | <_> 1206 | 47 8 4 5 2. 1207 | 0 1208 | 8.0239427916239947e-005 1209 | -9.9618428945541382e-001 1210 | 9.5355111360549927e-001 1211 | <_> 1212 | 1213 | <_> 1214 | 1215 | 1216 | 1217 | <_> 1218 | 31 5 30 11 -1. 1219 | <_> 1220 | 41 5 10 11 3. 1221 | 0 1222 | 3.2030208967626095e-003 1223 | -1. 1224 | 1.0001050233840942e+000 1225 | <_> 1226 | 1227 | <_> 1228 | 1229 | 1230 | 1231 | <_> 1232 | 0 0 2 1 -1. 1233 | <_> 1234 | 1 0 1 1 2. 1235 | 0 1236 | 0. 1237 | 0. 1238 | -1. 1239 | <_> 1240 | 1241 | <_> 1242 | 1243 | 1244 | 1245 | <_> 1246 | 21 3 42 5 -1. 1247 | <_> 1248 | 35 3 14 5 3. 1249 | 0 1250 | 2.6143440045416355e-003 1251 | -1. 1252 | 1.0002139806747437e+000 1253 | <_> 1254 | 1255 | <_> 1256 | 1257 | 1258 | 1259 | <_> 1260 | 0 0 2 1 -1. 1261 | <_> 1262 | 1 0 1 1 2. 1263 | 0 1264 | 0. 1265 | 0. 1266 | -1. 1267 | <_> 1268 | 1269 | <_> 1270 | 1271 | 1272 | 1273 | <_> 1274 | 8 5 30 9 -1. 1275 | <_> 1276 | 8 8 30 3 3. 1277 | 0 1278 | -7.0475979009643197e-004 1279 | 1. 1280 | -9.9976968765258789e-001 1281 | <_> 1282 | 1283 | <_> 1284 | 1285 | 1286 | 1287 | <_> 1288 | 3 12 33 3 -1. 1289 | <_> 1290 | 14 12 11 3 3. 1291 | 0 1292 | 2.1271279547363520e-003 1293 | -9.9694627523422241e-001 1294 | 1.0002720355987549e+000 1295 | <_> 1296 | 1297 | <_> 1298 | 1299 | 1300 | 1301 | <_> 1302 | 0 0 3 2 -1. 1303 | <_> 1304 | 1 0 1 2 3. 1305 | 0 1306 | -2.4224430671893060e-004 1307 | 1. 1308 | -1. 1309 | <_> 1310 | 1311 | <_> 1312 | 1313 | 1314 | 1315 | <_> 1316 | 46 4 3 8 -1. 1317 | <_> 1318 | 47 4 1 8 3. 1319 | 0 1320 | 7.4700301047414541e-004 1321 | -9.9108231067657471e-001 1322 | 9.9941182136535645e-001 1323 | -1.0991690158843994e+000 1324 | 13 1325 | -1 1326 | <_> 1327 | 1328 | 1329 | <_> 1330 | 1331 | <_> 1332 | 1333 | 1334 | 1335 | <_> 1336 | 1 2 6 5 -1. 1337 | <_> 1338 | 3 2 2 5 3. 1339 | 0 1340 | 1.7227890202775598e-003 1341 | -9.3608891963958740e-001 1342 | 8.7251222133636475e-001 1343 | <_> 1344 | 1345 | <_> 1346 | 1347 | 1348 | 1349 | <_> 1350 | 0 3 18 5 -1. 1351 | <_> 1352 | 6 3 6 5 3. 1353 | 0 1354 | 2.7599320746958256e-003 1355 | -9.9757021665573120e-001 1356 | 1.0000289678573608e+000 1357 | <_> 1358 | 1359 | <_> 1360 | 1361 | 1362 | 1363 | <_> 1364 | 3 1 6 14 -1. 1365 | <_> 1366 | 6 1 3 14 2. 1367 | 0 1368 | -8.9444358309265226e-005 1369 | 1. 1370 | -9.9264812469482422e-001 1371 | <_> 1372 | 1373 | <_> 1374 | 1375 | 1376 | 1377 | <_> 1378 | 3 6 2 10 -1. 1379 | <_> 1380 | 3 11 2 5 2. 1381 | 0 1382 | -2.7962020249105990e-004 1383 | 8.2833290100097656e-001 1384 | -9.8444151878356934e-001 1385 | <_> 1386 | 1387 | <_> 1388 | 1389 | 1390 | 1391 | <_> 1392 | 42 0 4 6 -1. 1393 | <_> 1394 | 42 0 2 3 2. 1395 | <_> 1396 | 44 3 2 3 2. 1397 | 0 1398 | -2.7560539820115082e-005 1399 | 1. 1400 | -9.9543339014053345e-001 1401 | -9.1314977407455444e-001 1402 | 14 1403 | -1 1404 | 1405 | -------------------------------------------------------------------------------- /projects/ng-open-cv/src/lib/assets/opencv/wasm/3.4/opencv_js.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/projects/ng-open-cv/src/lib/assets/opencv/wasm/3.4/opencv_js.wasm -------------------------------------------------------------------------------- /projects/ng-open-cv/src/lib/ng-open-cv.models.ts: -------------------------------------------------------------------------------- 1 | export interface OpenCVLocateFileFn { 2 | (path: string, scriptDirectory: string); 3 | } 4 | 5 | export interface OpenCvRuntimeInitializedFn { 6 | (); 7 | } 8 | 9 | export interface OpenCVOptions { 10 | scriptUrl: string; 11 | wasmBinaryFile?: string; 12 | usingWasm?: boolean; 13 | locateFile?: OpenCVLocateFileFn; 14 | onRuntimeInitialized?: OpenCvRuntimeInitializedFn; 15 | } 16 | 17 | export interface OpenCVLoadResult { 18 | ready: boolean; 19 | error: boolean; 20 | loading: boolean; 21 | } 22 | -------------------------------------------------------------------------------- /projects/ng-open-cv/src/lib/ng-open-cv.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule, ModuleWithProviders } from '@angular/core'; 2 | import { NgOpenCVService, OPEN_CV_CONFIGURATION } from './ng-open-cv.service'; 3 | import { OpenCVOptions } from './ng-open-cv.models'; 4 | 5 | @NgModule({ 6 | imports: [], 7 | declarations: [], 8 | exports: [], 9 | providers: [NgOpenCVService] 10 | }) 11 | export class NgOpenCVModule { 12 | /** 13 | * 14 | * Setup the module in your application's root bootstrap. 15 | * 16 | * 17 | * @memberOf NgOpenCvModule 18 | */ 19 | static forRoot(config: OpenCVOptions): ModuleWithProviders { 20 | return { 21 | ngModule: NgOpenCVModule, 22 | providers: [{ provide: OPEN_CV_CONFIGURATION, useValue: config }] 23 | }; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /projects/ng-open-cv/src/lib/ng-open-cv.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { NgOpenCVService } from './ng-open-cv.service'; 4 | 5 | describe('NgOpenCVService', () => { 6 | beforeEach(() => TestBed.configureTestingModule({})); 7 | 8 | it('should be created', () => { 9 | const service: NgOpenCVService = TestBed.get(NgOpenCVService); 10 | expect(service).toBeTruthy(); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /projects/ng-open-cv/src/lib/ng-open-cv.service.ts: -------------------------------------------------------------------------------- 1 | import { Inject, Injectable, InjectionToken } from '@angular/core'; 2 | import { BehaviorSubject, Observable } from 'rxjs'; 3 | 4 | import { OpenCVLoadResult, OpenCVOptions } from './ng-open-cv.models'; 5 | 6 | /* 7 | Angular modifification of the OpenCV utils script found at https://docs.opencv.org/master/utils.js 8 | */ 9 | declare var cv: any; 10 | 11 | export const OPEN_CV_CONFIGURATION = new InjectionToken('Angular OpenCV Configuration Object'); 12 | 13 | @Injectable({ 14 | providedIn: 'root' 15 | }) 16 | export class NgOpenCVService { 17 | errorOutput: HTMLElement; 18 | src = null; 19 | dstC1 = null; 20 | dstC3 = null; 21 | dstC4 = null; 22 | 23 | stream: any; 24 | video: any; 25 | private isReady = new BehaviorSubject({ 26 | ready: false, 27 | error: false, 28 | loading: true 29 | }); 30 | isReady$: Observable = this.isReady.asObservable(); 31 | onCameraStartedCallback: (a, b) => void; 32 | OPENCV_URL = 'opencv.js'; 33 | DEFAULT_OPTIONS = { 34 | scriptUrl: 'assets/opencv/asm/3.4/opencv.js', 35 | wasmBinaryFile: 'wasm/3.4/opencv_js.wasm', 36 | usingWasm: false, 37 | locateFile: this.locateFile.bind(this), 38 | onRuntimeInitialized: () => {} 39 | }; 40 | 41 | constructor(@Inject(OPEN_CV_CONFIGURATION) options: OpenCVOptions) { 42 | this.setScriptUrl(options.scriptUrl); 43 | const opts = { ...this.DEFAULT_OPTIONS, options }; 44 | this.loadOpenCv(opts); 45 | } 46 | 47 | private locateFile(path, scriptDirectory): string { 48 | if (path === 'opencv_js.wasm') { 49 | return scriptDirectory + '/wasm/' + path; 50 | } else { 51 | return scriptDirectory + path; 52 | } 53 | } 54 | 55 | setScriptUrl(url: string) { 56 | this.OPENCV_URL = url; 57 | } 58 | 59 | loadOpenCv(options: OpenCVOptions) { 60 | this.isReady.next({ 61 | ready: false, 62 | error: false, 63 | loading: true 64 | }); 65 | window['Module'] = { ...options }; 66 | const script = document.createElement('script'); 67 | script.setAttribute('async', ''); 68 | script.setAttribute('type', 'text/javascript'); 69 | script.addEventListener('load', () => { 70 | const onRuntimeInitializedCallback = () => { 71 | if (options.onRuntimeInitialized) { 72 | options.onRuntimeInitialized(); 73 | } 74 | this.isReady.next({ 75 | ready: true, 76 | error: false, 77 | loading: false 78 | }); 79 | }; 80 | cv.onRuntimeInitialized = onRuntimeInitializedCallback; 81 | }); 82 | script.addEventListener('error', () => { 83 | const err = this.printError('Failed to load ' + this.OPENCV_URL); 84 | this.isReady.next({ 85 | ready: false, 86 | error: true, 87 | loading: false 88 | }); 89 | this.isReady.error(err); 90 | }); 91 | script.src = this.OPENCV_URL; 92 | const node = document.getElementsByTagName('script')[0]; 93 | if (node) { 94 | node.parentNode.insertBefore(script, node); 95 | } else { 96 | document.head.appendChild(script); 97 | } 98 | } 99 | 100 | createFileFromUrl(path, url) { 101 | const request = new XMLHttpRequest(); 102 | request.open('GET', url, true); 103 | request.responseType = 'arraybuffer'; 104 | return new Observable(observer => { 105 | const { next, error: catchError, complete } = observer; 106 | request.onload = ev => { 107 | if (request.readyState === 4) { 108 | if (request.status === 200) { 109 | const data = new Uint8Array(request.response); 110 | cv.FS_createDataFile('/', path, data, true, false, false); 111 | observer.next(); 112 | observer.complete(); 113 | } else { 114 | this.printError('Failed to load ' + url + ' status: ' + request.status); 115 | observer.error(); 116 | } 117 | } 118 | }; 119 | request.send(); 120 | }); 121 | } 122 | 123 | loadImageToCanvas(imageUrl, canvasId: string): Observable { 124 | return Observable.create(observer => { 125 | const canvas: HTMLCanvasElement = document.getElementById(canvasId); 126 | const ctx = canvas.getContext('2d'); 127 | const img = new Image(); 128 | img.crossOrigin = 'anonymous'; 129 | img.onload = () => { 130 | canvas.width = img.width; 131 | canvas.height = img.height; 132 | ctx.drawImage(img, 0, 0, img.width, img.height); 133 | observer.next(); 134 | observer.complete(); 135 | }; 136 | img.src = imageUrl; 137 | }); 138 | } 139 | 140 | loadImageToHTMLCanvas(imageUrl: string, canvas: HTMLCanvasElement): Observable { 141 | return Observable.create(observer => { 142 | const ctx = canvas.getContext('2d'); 143 | const img = new Image(); 144 | img.crossOrigin = 'anonymous'; 145 | img.onload = () => { 146 | canvas.width = img.width; 147 | canvas.height = img.height; 148 | ctx.drawImage(img, 0, 0, img.width, img.height); 149 | observer.next(); 150 | observer.complete(); 151 | }; 152 | img.src = imageUrl; 153 | }); 154 | } 155 | 156 | clearError() { 157 | this.errorOutput.innerHTML = ''; 158 | } 159 | 160 | printError(err) { 161 | if (typeof err === 'undefined') { 162 | err = ''; 163 | } else if (typeof err === 'number') { 164 | if (!isNaN(err)) { 165 | if (typeof cv !== 'undefined') { 166 | err = 'Exception: ' + cv.exceptionFromPtr(err).msg; 167 | } 168 | } 169 | } else if (typeof err === 'string') { 170 | const ptr = Number(err.split(' ')[0]); 171 | if (!isNaN(ptr)) { 172 | if (typeof cv !== 'undefined') { 173 | err = 'Exception: ' + cv.exceptionFromPtr(ptr).msg; 174 | } 175 | } 176 | } else if (err instanceof Error) { 177 | err = err.stack.replace(/\n/g, '
'); 178 | } 179 | throw new Error(err); 180 | } 181 | 182 | loadCode(scriptId, textAreaId) { 183 | const scriptNode = document.getElementById(scriptId); 184 | const textArea = document.getElementById(textAreaId); 185 | if (scriptNode.type !== 'text/code-snippet') { 186 | throw Error('Unknown code snippet type'); 187 | } 188 | textArea.value = scriptNode.text.replace(/^\n/, ''); 189 | } 190 | 191 | addFileInputHandler(fileInputId, canvasId) { 192 | const inputElement = document.getElementById(fileInputId); 193 | inputElement.addEventListener( 194 | 'change', 195 | e => { 196 | const files = e.target['files']; 197 | if (files.length > 0) { 198 | const imgUrl = URL.createObjectURL(files[0]); 199 | this.loadImageToCanvas(imgUrl, canvasId); 200 | } 201 | }, 202 | false 203 | ); 204 | } 205 | 206 | onVideoCanPlay() { 207 | if (this.onCameraStartedCallback) { 208 | this.onCameraStartedCallback(this.stream, this.video); 209 | } 210 | } 211 | 212 | startCamera(resolution, callback, videoId) { 213 | const constraints = { 214 | qvga: { width: { exact: 320 }, height: { exact: 240 } }, 215 | vga: { width: { exact: 640 }, height: { exact: 480 } } 216 | }; 217 | let video = document.getElementById(videoId); 218 | if (!video) { 219 | video = document.createElement('video'); 220 | } 221 | 222 | let videoConstraint = constraints[resolution]; 223 | if (!videoConstraint) { 224 | videoConstraint = true; 225 | } 226 | 227 | navigator.mediaDevices 228 | .getUserMedia({ video: videoConstraint, audio: false }) 229 | .then(stream => { 230 | video.srcObject = stream; 231 | video.play(); 232 | this.video = video; 233 | this.stream = stream; 234 | this.onCameraStartedCallback = callback; 235 | video.addEventListener('canplay', this.onVideoCanPlay.bind(this), false); 236 | }) 237 | .catch(err => { 238 | this.printError('Camera Error: ' + err.name + ' ' + err.message); 239 | }); 240 | } 241 | 242 | stopCamera() { 243 | if (this.video) { 244 | this.video.pause(); 245 | this.video.srcObject = null; 246 | this.video.removeEventListener('canplay', this.onVideoCanPlay.bind(this)); 247 | } 248 | if (this.stream) { 249 | this.stream.getVideoTracks()[0].stop(); 250 | } 251 | } 252 | 253 | getContours(src, width, height) { 254 | cv.cvtColor(src, this.dstC1, cv.COLOR_RGBA2GRAY); 255 | cv.threshold(this.dstC1, this.dstC4, 120, 200, cv.THRESH_BINARY); 256 | const contours = new cv.MatVector(); 257 | const hierarchy = new cv.Mat(); 258 | cv.findContours(this.dstC4, contours, hierarchy, cv.RETR_CCOMP, cv.CHAIN_APPROX_SIMPLE, { 259 | x: 0, 260 | y: 0 261 | }); 262 | this.dstC3.delete(); 263 | this.dstC3 = cv.Mat.ones(height, width, cv.CV_8UC3); 264 | for (let i = 0; i < contours.size(); ++i) { 265 | const color = new cv.Scalar(0, 255, 0); 266 | cv.drawContours(this.dstC3, contours, i, color, 1, cv.LINE_8, hierarchy); 267 | } 268 | contours.delete(); 269 | hierarchy.delete(); 270 | return this.dstC3; 271 | } 272 | } 273 | -------------------------------------------------------------------------------- /projects/ng-open-cv/src/public_api.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Public API Surface of ng-open-cv 3 | */ 4 | 5 | export * from './lib/ng-open-cv.models'; 6 | export * from './lib/ng-open-cv.service'; 7 | export * from './lib/ng-open-cv.module'; 8 | 9 | -------------------------------------------------------------------------------- /projects/ng-open-cv/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'core-js/es7/reflect'; 4 | import 'zone.js/dist/zone'; 5 | import 'zone.js/dist/zone-testing'; 6 | import { getTestBed } from '@angular/core/testing'; 7 | import { 8 | BrowserDynamicTestingModule, 9 | platformBrowserDynamicTesting 10 | } from '@angular/platform-browser-dynamic/testing'; 11 | 12 | declare const require: any; 13 | 14 | // First, initialize the Angular testing environment. 15 | getTestBed().initTestEnvironment( 16 | BrowserDynamicTestingModule, 17 | platformBrowserDynamicTesting() 18 | ); 19 | // Then we find all the tests. 20 | const context = require.context('./', true, /\.spec\.ts$/); 21 | // And load the modules. 22 | context.keys().map(context); 23 | -------------------------------------------------------------------------------- /projects/ng-open-cv/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../out-tsc/lib", 5 | "target": "es2015", 6 | "module": "es2015", 7 | "moduleResolution": "node", 8 | "declaration": true, 9 | "sourceMap": true, 10 | "inlineSources": true, 11 | "emitDecoratorMetadata": true, 12 | "experimentalDecorators": true, 13 | "importHelpers": true, 14 | "types": [], 15 | "lib": [ 16 | "dom", 17 | "es2015" 18 | ] 19 | }, 20 | "angularCompilerOptions": { 21 | "annotateForClosureCompiler": true, 22 | "skipTemplateCodegen": true, 23 | "strictMetadataEmit": true, 24 | "fullTemplateTypeCheck": true, 25 | "strictInjectionParameters": true, 26 | "enableResourceInlining": true 27 | }, 28 | "exclude": [ 29 | "src/test.ts", 30 | "**/*.spec.ts" 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /projects/ng-open-cv/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts" 12 | ], 13 | "include": [ 14 | "**/*.spec.ts", 15 | "**/*.d.ts" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /projects/ng-open-cv/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "opencv", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "opencv", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/app/app-routing.module.spec.ts: -------------------------------------------------------------------------------- 1 | import { AppRoutingModule } from './app-routing.module'; 2 | 3 | describe('AppRoutingModule', () => { 4 | let appRoutingModule: AppRoutingModule; 5 | 6 | beforeEach(() => { 7 | appRoutingModule = new AppRoutingModule(); 8 | }); 9 | 10 | it('should create an instance', () => { 11 | expect(appRoutingModule).toBeTruthy(); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { FaceDetectionComponent } from './face-detection/face-detection.component'; 4 | import { ExampleListComponent } from './example-list/example-list.component'; 5 | import { HelloComponent } from './hello/hello.component'; 6 | 7 | const routes: Routes = [ 8 | { path: 'hello', component: HelloComponent }, 9 | { path: 'face-detection', component: FaceDetectionComponent }, 10 | { path: 'example-list', component: ExampleListComponent }, 11 | { path: '', redirectTo: '/example-list', pathMatch: 'full' }, 12 | ]; 13 | 14 | @NgModule({ 15 | imports: [ 16 | RouterModule.forRoot(routes) 17 | ], 18 | declarations: [] 19 | }) 20 | export class AppRoutingModule { } 21 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { AppComponent } from './app.component'; 3 | describe('AppComponent', () => { 4 | beforeEach(async(() => { 5 | TestBed.configureTestingModule({ 6 | declarations: [ 7 | AppComponent 8 | ], 9 | }).compileComponents(); 10 | })); 11 | it('should create the app', async(() => { 12 | const fixture = TestBed.createComponent(AppComponent); 13 | const app = fixture.debugElement.componentInstance; 14 | expect(app).toBeTruthy(); 15 | })); 16 | it(`should have as title 'ng-open-cv-lib'`, async(() => { 17 | const fixture = TestBed.createComponent(AppComponent); 18 | const app = fixture.debugElement.componentInstance; 19 | expect(app.title).toEqual('ng-open-cv-lib'); 20 | })); 21 | it('should render title in a h1 tag', async(() => { 22 | const fixture = TestBed.createComponent(AppComponent); 23 | fixture.detectChanges(); 24 | const compiled = fixture.debugElement.nativeElement; 25 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to ng-open-cv-lib!'); 26 | })); 27 | }); 28 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | 4 | @Component({ 5 | selector: 'app-root', 6 | templateUrl: './app.component.html', 7 | styleUrls: ['./app.component.css'] 8 | }) 9 | export class AppComponent { 10 | title = 'NgOpenCV: Angular OpenCV Integration Service'; 11 | 12 | constructor(){ 13 | 14 | } 15 | 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppComponent } from './app.component'; 5 | import { NgOpenCVModule } from 'ng-open-cv'; 6 | import { FaceDetectionComponent } from './face-detection/face-detection.component'; 7 | import { RouterModule } from '@angular/router'; 8 | import { AppRoutingModule } from './app-routing.module'; 9 | import { OpenCVOptions } from 'projects/ng-open-cv/src/public_api'; 10 | import { ExampleListComponent } from './example-list/example-list.component'; 11 | import { HelloComponent } from './hello/hello.component'; 12 | 13 | const openCVConfig: OpenCVOptions = { 14 | scriptUrl: `assets/opencv/opencv.js`, 15 | wasmBinaryFile: 'wasm/opencv_js.wasm', 16 | usingWasm: true 17 | }; 18 | 19 | @NgModule({ 20 | declarations: [ 21 | AppComponent, 22 | FaceDetectionComponent, 23 | ExampleListComponent, 24 | HelloComponent 25 | ], 26 | imports: [ 27 | BrowserModule, 28 | NgOpenCVModule.forRoot(openCVConfig), 29 | RouterModule, 30 | AppRoutingModule 31 | ], 32 | providers: [], 33 | bootstrap: [ 34 | AppComponent 35 | ] 36 | }) 37 | export class AppModule { } 38 | -------------------------------------------------------------------------------- /src/app/example-list/example-list.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/src/app/example-list/example-list.component.css -------------------------------------------------------------------------------- /src/app/example-list/example-list.component.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

4 | NgOpenCV: OpenCV.js integration with Angular 5 |

6 | Angular Logo 7 |
8 |

Here are some examples to get you you started:

9 | 10 | 18 | -------------------------------------------------------------------------------- /src/app/example-list/example-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | import { By } from '@angular/platform-browser'; 4 | import { DebugElement } from '@angular/core'; 5 | 6 | import { ExampleListComponent } from './example-list.component'; 7 | 8 | describe('ExampleListComponent', () => { 9 | let component: ExampleListComponent; 10 | let fixture: ComponentFixture; 11 | 12 | beforeEach(async(() => { 13 | TestBed.configureTestingModule({ 14 | declarations: [ ExampleListComponent ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(ExampleListComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /src/app/example-list/example-list.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-example-list', 5 | templateUrl: './example-list.component.html', 6 | styleUrls: ['./example-list.component.css'] 7 | }) 8 | export class ExampleListComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/face-detection/face-detection.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/src/app/face-detection/face-detection.component.css -------------------------------------------------------------------------------- /src/app/face-detection/face-detection.component.html: -------------------------------------------------------------------------------- 1 |

Face Detection Example

2 |

3 | <canvas> elements named canvasInput and canvasOutput have been prepared.
4 | Click Detect Face button to see the result. You can choose another image.
5 |

6 | 7 |
8 | 9 | 10 | 13 | 16 | 17 | 18 | 22 | 25 | 26 |
11 | 12 | 14 | 15 |
19 |
canvasInput
21 |
23 |
canvasOutput
24 |
27 |
28 |
29 |
30 |
31 |
32 | More Examples 33 |
34 | -------------------------------------------------------------------------------- /src/app/face-detection/face-detection.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | import { By } from '@angular/platform-browser'; 4 | import { DebugElement } from '@angular/core'; 5 | 6 | import { FaceDetectionComponent } from './face-detection.component'; 7 | 8 | describe('FaceDetectionComponent', () => { 9 | let component: FaceDetectionComponent; 10 | let fixture: ComponentFixture; 11 | 12 | beforeEach(async(() => { 13 | TestBed.configureTestingModule({ 14 | declarations: [ FaceDetectionComponent ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(FaceDetectionComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /src/app/face-detection/face-detection.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ViewChild, AfterViewInit, ElementRef } from '@angular/core'; 2 | import { NgOpenCVService, OpenCVLoadResult } from 'ng-open-cv'; 3 | import { tap, switchMap, filter } from 'rxjs/operators'; 4 | import { forkJoin, Observable, empty, fromEvent, BehaviorSubject } from 'rxjs'; 5 | 6 | @Component({ 7 | selector: 'app-face-detection', 8 | templateUrl: './face-detection.component.html', 9 | styleUrls: ['./face-detection.component.css'] 10 | }) 11 | export class FaceDetectionComponent implements AfterViewInit, OnInit { 12 | imageUrl = 'assets/DaveChappelle.jpg'; 13 | // Notifies of the ready state of the classifiers load operation 14 | private classifiersLoaded = new BehaviorSubject(false); 15 | classifiersLoaded$ = this.classifiersLoaded.asObservable(); 16 | 17 | // HTML Element references 18 | @ViewChild('fileInput') 19 | fileInput: ElementRef; 20 | @ViewChild('canvasInput') 21 | canvasInput: ElementRef; 22 | @ViewChild('canvasOutput') 23 | canvasOutput: ElementRef; 24 | 25 | // Inject the NgOpenCVService 26 | constructor(private ngOpenCVService: NgOpenCVService) {} 27 | 28 | ngOnInit() { 29 | // Always subscribe to the NgOpenCVService isReady$ observer before using a CV related function to ensure that the OpenCV has been 30 | // successfully loaded 31 | this.ngOpenCVService.isReady$ 32 | .pipe( 33 | // The OpenCV library has been successfully loaded if result.ready === true 34 | filter((result: OpenCVLoadResult) => result.ready), 35 | switchMap(() => { 36 | // Load the face and eye classifiers files 37 | return this.loadClassifiers(); 38 | }) 39 | ) 40 | .subscribe(() => { 41 | // The classifiers have been succesfully loaded 42 | this.classifiersLoaded.next(true); 43 | }); 44 | } 45 | 46 | ngAfterViewInit(): void { 47 | // Here we just load our example image to the canvas 48 | this.ngOpenCVService.isReady$ 49 | .pipe( 50 | filter((result: OpenCVLoadResult) => result.ready), 51 | tap((result: OpenCVLoadResult) => { 52 | this.ngOpenCVService.loadImageToHTMLCanvas(this.imageUrl, this.canvasInput.nativeElement).subscribe(); 53 | }) 54 | ) 55 | .subscribe(() => {}); 56 | } 57 | 58 | readDataUrl(event) { 59 | if (event.target.files.length) { 60 | const reader = new FileReader(); 61 | const load$ = fromEvent(reader, 'load'); 62 | load$ 63 | .pipe( 64 | switchMap(() => { 65 | return this.ngOpenCVService.loadImageToHTMLCanvas(`${reader.result}`, this.canvasInput.nativeElement); 66 | }) 67 | ) 68 | .subscribe( 69 | () => {}, 70 | err => { 71 | console.log('Error loading image', err); 72 | } 73 | ); 74 | reader.readAsDataURL(event.target.files[0]); 75 | } 76 | } 77 | // Before attempting face detection, we need to load the appropriate classifiers in memory first 78 | // by using the createFileFromUrl(path, url) function, which takes two parameters 79 | // @path: The path you will later use in the detectMultiScale function call 80 | // @url: The url where to retrieve the file from. 81 | loadClassifiers(): Observable { 82 | return forkJoin( 83 | this.ngOpenCVService.createFileFromUrl( 84 | 'haarcascade_frontalface_default.xml', 85 | `assets/opencv/data/haarcascades/haarcascade_frontalface_default.xml` 86 | ), 87 | this.ngOpenCVService.createFileFromUrl( 88 | 'haarcascade_eye.xml', 89 | `assets/opencv/data/haarcascades/haarcascade_eye.xml` 90 | ) 91 | ); 92 | } 93 | 94 | detectFace() { 95 | // before detecting the face we need to make sure that 96 | // 1. OpenCV is loaded 97 | // 2. The classifiers have been loaded 98 | this.ngOpenCVService.isReady$ 99 | .pipe( 100 | filter((result: OpenCVLoadResult) => result.ready), 101 | switchMap(() => { 102 | return this.classifiersLoaded$; 103 | }), 104 | tap(() => { 105 | this.clearOutputCanvas(); 106 | this.findFaceAndEyes(); 107 | }) 108 | ) 109 | .subscribe(() => { 110 | console.log('Face detected'); 111 | }); 112 | } 113 | 114 | clearOutputCanvas() { 115 | const context = this.canvasOutput.nativeElement.getContext('2d'); 116 | context.clearRect(0, 0, this.canvasOutput.nativeElement.width, this.canvasOutput.nativeElement.height); 117 | } 118 | 119 | findFaceAndEyes() { 120 | // Example code from OpenCV.js to perform face and eyes detection 121 | // Slight adapted for Angular 122 | const src = cv.imread(this.canvasInput.nativeElement.id); 123 | const gray = new cv.Mat(); 124 | cv.cvtColor(src, gray, cv.COLOR_RGBA2GRAY, 0); 125 | const faces = new cv.RectVector(); 126 | const eyes = new cv.RectVector(); 127 | const faceCascade = new cv.CascadeClassifier(); 128 | const eyeCascade = new cv.CascadeClassifier(); 129 | // load pre-trained classifiers, they should be in memory now 130 | faceCascade.load('haarcascade_frontalface_default.xml'); 131 | eyeCascade.load('haarcascade_eye.xml'); 132 | // detect faces 133 | const msize = new cv.Size(0, 0); 134 | faceCascade.detectMultiScale(gray, faces, 1.1, 3, 0, msize, msize); 135 | for (let i = 0; i < faces.size(); ++i) { 136 | const roiGray = gray.roi(faces.get(i)); 137 | const roiSrc = src.roi(faces.get(i)); 138 | const point1 = new cv.Point(faces.get(i).x, faces.get(i).y); 139 | const point2 = new cv.Point(faces.get(i).x + faces.get(i).width, faces.get(i).y + faces.get(i).height); 140 | cv.rectangle(src, point1, point2, [255, 0, 0, 255]); 141 | // detect eyes in face ROI 142 | eyeCascade.detectMultiScale(roiGray, eyes); 143 | for (let j = 0; j < eyes.size(); ++j) { 144 | const point3 = new cv.Point(eyes.get(j).x, eyes.get(j).y); 145 | const point4 = new cv.Point(eyes.get(j).x + eyes.get(j).width, eyes.get(j).y + eyes.get(j).height); 146 | cv.rectangle(roiSrc, point3, point4, [0, 0, 255, 255]); 147 | } 148 | roiGray.delete(); 149 | roiSrc.delete(); 150 | } 151 | cv.imshow(this.canvasOutput.nativeElement.id, src); 152 | src.delete(); 153 | gray.delete(); 154 | faceCascade.delete(); 155 | eyeCascade.delete(); 156 | faces.delete(); 157 | eyes.delete(); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /src/app/hello/hello.component.css: -------------------------------------------------------------------------------- 1 | .ready{ 2 | color: green; 3 | font-weight: bold; 4 | } 5 | -------------------------------------------------------------------------------- /src/app/hello/hello.component.html: -------------------------------------------------------------------------------- 1 |

Hello World Example

2 |

3 | Use the Choose File button to load an image through OpenCV.js in the canvasOutput section 4 |

5 |
6 |
Waiting for OpenCV.js to load!
7 |
OpenCV.js is ready!
8 |
OpenCV.js load error!
9 |
10 | 11 |
12 | 13 | 14 | 15 | 18 | 19 | 20 | 23 | 24 |
16 | 17 |
21 |
canvasOutput
22 |
25 |
27 |
28 | 29 |
30 | More Examples 31 |
32 | -------------------------------------------------------------------------------- /src/app/hello/hello.component.spec.ts: -------------------------------------------------------------------------------- 1 | /* tslint:disable:no-unused-variable */ 2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 3 | import { By } from '@angular/platform-browser'; 4 | import { DebugElement } from '@angular/core'; 5 | 6 | import { HelloComponent } from './hello.component'; 7 | 8 | describe('HelloComponent', () => { 9 | let component: HelloComponent; 10 | let fixture: ComponentFixture; 11 | 12 | beforeEach(async(() => { 13 | TestBed.configureTestingModule({ 14 | declarations: [ HelloComponent ] 15 | }) 16 | .compileComponents(); 17 | })); 18 | 19 | beforeEach(() => { 20 | fixture = TestBed.createComponent(HelloComponent); 21 | component = fixture.componentInstance; 22 | fixture.detectChanges(); 23 | }); 24 | 25 | it('should create', () => { 26 | expect(component).toBeTruthy(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /src/app/hello/hello.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; 2 | import { fromEvent, Observable } from 'rxjs'; 3 | import { switchMap } from 'rxjs/operators'; 4 | import { NgOpenCVService, OpenCVLoadResult } from 'ng-open-cv'; 5 | 6 | @Component({ 7 | selector: 'app-hello', 8 | templateUrl: './hello.component.html', 9 | styleUrls: ['./hello.component.css'] 10 | }) 11 | export class HelloComponent implements OnInit { 12 | 13 | // Keep tracks of the ready 14 | openCVLoadResult: Observable; 15 | 16 | // HTML Element references 17 | @ViewChild('fileInput') 18 | fileInput: ElementRef; 19 | @ViewChild('canvasOutput') 20 | canvasOutput: ElementRef; 21 | 22 | constructor(private ngOpenCVService: NgOpenCVService) { } 23 | 24 | ngOnInit() { 25 | this.openCVLoadResult = this.ngOpenCVService.isReady$; 26 | } 27 | 28 | loadImage(event) { 29 | if (event.target.files.length) { 30 | const reader = new FileReader(); 31 | const load$ = fromEvent(reader, 'load'); 32 | load$ 33 | .pipe( 34 | switchMap(() => { 35 | return this.ngOpenCVService.loadImageToHTMLCanvas(`${reader.result}`, this.canvasOutput.nativeElement); 36 | }) 37 | ) 38 | .subscribe( 39 | () => {}, 40 | err => { 41 | console.log('Error loading image', err); 42 | } 43 | ); 44 | reader.readAsDataURL(event.target.files[0]); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/assets/DaveChappelle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/src/assets/DaveChappelle.jpg -------------------------------------------------------------------------------- /src/assets/opencv/data/haarcascades/haarcascade_licence_plate_rus_16stages.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 64 16 7 | 8 | <_> 9 | 10 | 11 | <_> 12 | 13 | <_> 14 | 15 | 16 | 17 | <_> 18 | 32 2 8 6 -1. 19 | <_> 20 | 32 4 8 2 3. 21 | 0 22 | 1.6915600746870041e-002 23 | -9.5547717809677124e-001 24 | 8.9129137992858887e-001 25 | <_> 26 | 27 | <_> 28 | 29 | 30 | 31 | <_> 32 | 0 4 6 10 -1. 33 | <_> 34 | 3 4 3 10 2. 35 | 0 36 | 2.4228349328041077e-002 37 | -9.2089319229125977e-001 38 | 8.8723921775817871e-001 39 | <_> 40 | 41 | <_> 42 | 43 | 44 | 45 | <_> 46 | 55 0 8 6 -1. 47 | <_> 48 | 55 0 4 3 2. 49 | <_> 50 | 59 3 4 3 2. 51 | 0 52 | -1.0168660432100296e-002 53 | 8.8940089941024780e-001 54 | -7.7847331762313843e-001 55 | <_> 56 | 57 | <_> 58 | 59 | 60 | 61 | <_> 62 | 44 7 4 9 -1. 63 | <_> 64 | 44 10 4 3 3. 65 | 0 66 | 2.0863260142505169e-003 67 | -8.7998157739639282e-001 68 | 5.8651781082153320e-001 69 | -2.0683259963989258e+000 70 | -1 71 | -1 72 | <_> 73 | 74 | 75 | <_> 76 | 77 | <_> 78 | 79 | 80 | 81 | <_> 82 | 29 1 16 4 -1. 83 | <_> 84 | 29 3 16 2 2. 85 | 0 86 | 2.9062159359455109e-002 87 | -8.7765061855316162e-001 88 | 8.5373121500015259e-001 89 | <_> 90 | 91 | <_> 92 | 93 | 94 | 95 | <_> 96 | 0 5 9 8 -1. 97 | <_> 98 | 3 5 3 8 3. 99 | 0 100 | 2.3903399705886841e-002 101 | -9.2079448699951172e-001 102 | 7.5155001878738403e-001 103 | <_> 104 | 105 | <_> 106 | 107 | 108 | 109 | <_> 110 | 44 0 20 14 -1. 111 | <_> 112 | 44 0 10 7 2. 113 | <_> 114 | 54 7 10 7 2. 115 | 0 116 | -3.5404648631811142e-002 117 | 6.7834627628326416e-001 118 | -9.0937072038650513e-001 119 | <_> 120 | 121 | <_> 122 | 123 | 124 | 125 | <_> 126 | 41 7 6 9 -1. 127 | <_> 128 | 43 7 2 9 3. 129 | 0 130 | 6.2988721765577793e-003 131 | -8.1054258346557617e-001 132 | 5.8985030651092529e-001 133 | <_> 134 | 135 | <_> 136 | 137 | 138 | 139 | <_> 140 | 0 4 21 4 -1. 141 | <_> 142 | 7 4 7 4 3. 143 | 0 144 | 3.4959490876644850e-003 145 | -9.7632282972335815e-001 146 | 4.5473039150238037e-001 147 | -1.6632349491119385e+000 148 | 0 149 | -1 150 | <_> 151 | 152 | 153 | <_> 154 | 155 | <_> 156 | 157 | 158 | 159 | <_> 160 | 31 2 11 6 -1. 161 | <_> 162 | 31 4 11 2 3. 163 | 0 164 | 2.3864099755883217e-002 165 | -9.3137168884277344e-001 166 | 8.2478952407836914e-001 167 | <_> 168 | 169 | <_> 170 | 171 | 172 | 173 | <_> 174 | 56 3 6 11 -1. 175 | <_> 176 | 59 3 3 11 2. 177 | 0 178 | -2.5775209069252014e-002 179 | 8.5526448488235474e-001 180 | -8.7574672698974609e-001 181 | <_> 182 | 183 | <_> 184 | 185 | 186 | 187 | <_> 188 | 32 14 32 2 -1. 189 | <_> 190 | 32 15 32 1 2. 191 | 0 192 | -1.0646049864590168e-002 193 | 8.5167151689529419e-001 194 | -6.7789041996002197e-001 195 | <_> 196 | 197 | <_> 198 | 199 | 200 | 201 | <_> 202 | 0 2 8 14 -1. 203 | <_> 204 | 4 2 4 14 2. 205 | 0 206 | 2.7000989764928818e-002 207 | -8.0041092634201050e-001 208 | 6.4893317222595215e-001 209 | <_> 210 | 211 | <_> 212 | 213 | 214 | 215 | <_> 216 | 19 0 22 6 -1. 217 | <_> 218 | 19 0 11 3 2. 219 | <_> 220 | 30 3 11 3 2. 221 | 0 222 | 5.2989721298217773e-003 223 | -9.5342522859573364e-001 224 | 5.0140267610549927e-001 225 | -1.3346730470657349e+000 226 | 1 227 | -1 228 | <_> 229 | 230 | 231 | <_> 232 | 233 | <_> 234 | 235 | 236 | 237 | <_> 238 | 56 0 6 6 -1. 239 | <_> 240 | 56 0 3 3 2. 241 | <_> 242 | 59 3 3 3 2. 243 | 0 244 | -6.9233630783855915e-003 245 | 8.2654470205307007e-001 246 | -8.5396027565002441e-001 247 | <_> 248 | 249 | <_> 250 | 251 | 252 | 253 | <_> 254 | 32 0 14 12 -1. 255 | <_> 256 | 32 0 7 6 2. 257 | <_> 258 | 39 6 7 6 2. 259 | 0 260 | 1.2539249658584595e-001 261 | -1.2996139936149120e-002 262 | -3.2377028808593750e+003 263 | <_> 264 | 265 | <_> 266 | 267 | 268 | 269 | <_> 270 | 2 1 43 4 -1. 271 | <_> 272 | 2 3 43 2 2. 273 | 0 274 | 6.3474893569946289e-002 275 | -6.4648061990737915e-001 276 | 8.2302427291870117e-001 277 | <_> 278 | 279 | <_> 280 | 281 | 282 | 283 | <_> 284 | 34 10 30 5 -1. 285 | <_> 286 | 44 10 10 5 3. 287 | 0 288 | 4.2217150330543518e-002 289 | -7.5190877914428711e-001 290 | 6.3705182075500488e-001 291 | <_> 292 | 293 | <_> 294 | 295 | 296 | 297 | <_> 298 | 0 9 9 5 -1. 299 | <_> 300 | 3 9 3 5 3. 301 | 0 302 | 2.0000640302896500e-002 303 | -6.2077498435974121e-001 304 | 6.1317932605743408e-001 305 | -1.6521669626235962e+000 306 | 2 307 | -1 308 | <_> 309 | 310 | 311 | <_> 312 | 313 | <_> 314 | 315 | 316 | 317 | <_> 318 | 2 1 43 6 -1. 319 | <_> 320 | 2 3 43 2 3. 321 | 0 322 | 9.2297486960887909e-002 323 | -7.2764229774475098e-001 324 | 8.0554759502410889e-001 325 | <_> 326 | 327 | <_> 328 | 329 | 330 | 331 | <_> 332 | 53 4 9 8 -1. 333 | <_> 334 | 56 4 3 8 3. 335 | 0 336 | 2.7613969519734383e-002 337 | -7.0769268274307251e-001 338 | 7.3315787315368652e-001 339 | <_> 340 | 341 | <_> 342 | 343 | 344 | 345 | <_> 346 | 36 4 14 8 -1. 347 | <_> 348 | 36 4 7 4 2. 349 | <_> 350 | 43 8 7 4 2. 351 | 0 352 | 1.2465449981391430e-002 353 | -8.4359270334243774e-001 354 | 5.7046437263488770e-001 355 | <_> 356 | 357 | <_> 358 | 359 | 360 | 361 | <_> 362 | 14 14 49 2 -1. 363 | <_> 364 | 14 15 49 1 2. 365 | 0 366 | -2.3886829614639282e-002 367 | 8.2656508684158325e-001 368 | -5.2783298492431641e-001 369 | -1.4523630142211914e+000 370 | 3 371 | -1 372 | <_> 373 | 374 | 375 | <_> 376 | 377 | <_> 378 | 379 | 380 | 381 | <_> 382 | 0 5 4 9 -1. 383 | <_> 384 | 2 5 2 9 2. 385 | 0 386 | 1.8821349367499352e-002 387 | -8.1122857332229614e-001 388 | 6.9127470254898071e-001 389 | <_> 390 | 391 | <_> 392 | 393 | 394 | 395 | <_> 396 | 21 1 38 4 -1. 397 | <_> 398 | 21 3 38 2 2. 399 | 0 400 | 6.1703320592641830e-002 401 | -7.6482647657394409e-001 402 | 6.4212161302566528e-001 403 | <_> 404 | 405 | <_> 406 | 407 | 408 | 409 | <_> 410 | 44 12 18 3 -1. 411 | <_> 412 | 53 12 9 3 2. 413 | 0 414 | -1.6298670321702957e-002 415 | 5.0207728147506714e-001 416 | -8.4020161628723145e-001 417 | <_> 418 | 419 | <_> 420 | 421 | 422 | 423 | <_> 424 | 10 4 9 3 -1. 425 | <_> 426 | 13 4 3 3 3. 427 | 0 428 | -4.9458951689302921e-003 429 | 6.1991941928863525e-001 430 | -6.1633539199829102e-001 431 | <_> 432 | 433 | <_> 434 | 435 | 436 | 437 | <_> 438 | 40 4 10 4 -1. 439 | <_> 440 | 45 4 5 4 2. 441 | 0 442 | -5.1894597709178925e-003 443 | 4.4975179433822632e-001 444 | -8.0651968717575073e-001 445 | <_> 446 | 447 | <_> 448 | 449 | 450 | 451 | <_> 452 | 17 14 47 2 -1. 453 | <_> 454 | 17 15 47 1 2. 455 | 0 456 | -1.8824130296707153e-002 457 | 6.1992841958999634e-001 458 | -5.5643159151077271e-001 459 | <_> 460 | 461 | <_> 462 | 463 | 464 | 465 | <_> 466 | 8 5 4 7 -1. 467 | <_> 468 | 10 5 2 7 2. 469 | 0 470 | 5.6571601890027523e-003 471 | -4.8346561193466187e-001 472 | 6.8647360801696777e-001 473 | -2.2358059883117676e+000 474 | 4 475 | -1 476 | <_> 477 | 478 | 479 | <_> 480 | 481 | <_> 482 | 483 | 484 | 485 | <_> 486 | 56 0 6 6 -1. 487 | <_> 488 | 56 0 3 3 2. 489 | <_> 490 | 59 3 3 3 2. 491 | 0 492 | -9.1503243893384933e-003 493 | 6.8174481391906738e-001 494 | -7.7866071462631226e-001 495 | <_> 496 | 497 | <_> 498 | 499 | 500 | 501 | <_> 502 | 0 0 6 6 -1. 503 | <_> 504 | 0 0 3 3 2. 505 | <_> 506 | 3 3 3 3 2. 507 | 0 508 | 7.4933180585503578e-003 509 | -6.8696027994155884e-001 510 | 6.6913938522338867e-001 511 | <_> 512 | 513 | <_> 514 | 515 | 516 | 517 | <_> 518 | 13 4 48 2 -1. 519 | <_> 520 | 29 4 16 2 3. 521 | 0 522 | 4.5296419411897659e-002 523 | -7.3576509952545166e-001 524 | 5.9453499317169189e-001 525 | <_> 526 | 527 | <_> 528 | 529 | 530 | 531 | <_> 532 | 42 1 6 15 -1. 533 | <_> 534 | 42 6 6 5 3. 535 | 0 536 | 1.1669679544866085e-002 537 | -8.4733831882476807e-001 538 | 4.5461329817771912e-001 539 | <_> 540 | 541 | <_> 542 | 543 | 544 | 545 | <_> 546 | 30 8 3 5 -1. 547 | <_> 548 | 31 8 1 5 3. 549 | 0 550 | 2.5769430212676525e-003 551 | -5.8270388841629028e-001 552 | 7.7900522947311401e-001 553 | <_> 554 | 555 | <_> 556 | 557 | 558 | 559 | <_> 560 | 55 10 8 6 -1. 561 | <_> 562 | 55 13 8 3 2. 563 | 0 564 | -1.4139170525595546e-003 565 | 4.5126929879188538e-001 566 | -9.0696328878402710e-001 567 | -1.8782069683074951e+000 568 | 5 569 | -1 570 | <_> 571 | 572 | 573 | <_> 574 | 575 | <_> 576 | 577 | 578 | 579 | <_> 580 | 4 6 4 7 -1. 581 | <_> 582 | 6 6 2 7 2. 583 | 0 584 | -5.3149578161537647e-003 585 | 6.5218788385391235e-001 586 | -7.9464268684387207e-001 587 | <_> 588 | 589 | <_> 590 | 591 | 592 | 593 | <_> 594 | 56 3 6 8 -1. 595 | <_> 596 | 59 3 3 8 2. 597 | 0 598 | -2.2906960919499397e-002 599 | 6.6433382034301758e-001 600 | -7.3633247613906860e-001 601 | <_> 602 | 603 | <_> 604 | 605 | 606 | 607 | <_> 608 | 37 2 4 6 -1. 609 | <_> 610 | 37 4 4 2 3. 611 | 0 612 | 9.4887977465987206e-003 613 | -8.2612031698226929e-001 614 | 4.9333500862121582e-001 615 | <_> 616 | 617 | <_> 618 | 619 | 620 | 621 | <_> 622 | 0 10 30 6 -1. 623 | <_> 624 | 0 12 30 2 3. 625 | 0 626 | 4.5138411223888397e-002 627 | -5.4704028367996216e-001 628 | 7.6927912235260010e-001 629 | <_> 630 | 631 | <_> 632 | 633 | 634 | 635 | <_> 636 | 0 4 21 12 -1. 637 | <_> 638 | 7 4 7 12 3. 639 | 0 640 | 2.5049019604921341e-002 641 | -8.6739641427993774e-001 642 | 5.2807968854904175e-001 643 | -1.0597369670867920e+000 644 | 6 645 | -1 646 | <_> 647 | 648 | 649 | <_> 650 | 651 | <_> 652 | 653 | 654 | 655 | <_> 656 | 44 0 1 14 -1. 657 | <_> 658 | 44 7 1 7 2. 659 | 0 660 | 6.6414438188076019e-003 661 | -7.7290147542953491e-001 662 | 6.9723731279373169e-001 663 | <_> 664 | 665 | <_> 666 | 667 | 668 | 669 | <_> 670 | 54 3 4 3 -1. 671 | <_> 672 | 56 3 2 3 2. 673 | 0 674 | 2.4703629314899445e-003 675 | -7.4289917945861816e-001 676 | 6.6825848817825317e-001 677 | <_> 678 | 679 | <_> 680 | 681 | 682 | 683 | <_> 684 | 32 0 30 6 -1. 685 | <_> 686 | 32 0 15 3 2. 687 | <_> 688 | 47 3 15 3 2. 689 | 0 690 | -2.2910499945282936e-002 691 | 4.3986389040946960e-001 692 | -9.0588808059692383e-001 693 | <_> 694 | 695 | <_> 696 | 697 | 698 | 699 | <_> 700 | 0 8 9 7 -1. 701 | <_> 702 | 3 8 3 7 3. 703 | 0 704 | 3.4193221479654312e-002 705 | -6.9507479667663574e-001 706 | 6.2501090764999390e-001 707 | <_> 708 | 709 | <_> 710 | 711 | 712 | 713 | <_> 714 | 30 10 3 3 -1. 715 | <_> 716 | 31 10 1 3 3. 717 | 0 718 | 1.5060020377859473e-003 719 | -6.8670761585235596e-001 720 | 8.2241541147232056e-001 721 | <_> 722 | 723 | <_> 724 | 725 | 726 | 727 | <_> 728 | 21 3 24 4 -1. 729 | <_> 730 | 29 3 8 4 3. 731 | 0 732 | 1.9838380467263050e-005 733 | -9.2727631330490112e-001 734 | 6.4723730087280273e-001 735 | <_> 736 | 737 | <_> 738 | 739 | 740 | 741 | <_> 742 | 42 3 12 6 -1. 743 | <_> 744 | 46 3 4 6 3. 745 | 0 746 | -2.2170299416757189e-005 747 | 5.6555831432342529e-001 748 | -9.6788132190704346e-001 749 | -1.4993519783020020e+000 750 | 7 751 | -1 752 | <_> 753 | 754 | 755 | <_> 756 | 757 | <_> 758 | 759 | 760 | 761 | <_> 762 | 56 9 6 6 -1. 763 | <_> 764 | 59 9 3 6 2. 765 | 0 766 | -1.1395259760320187e-002 767 | 7.1383631229400635e-001 768 | -8.7429678440093994e-001 769 | <_> 770 | 771 | <_> 772 | 773 | 774 | 775 | <_> 776 | 6 4 1 6 -1. 777 | <_> 778 | 6 7 1 3 2. 779 | 0 780 | -2.1864590235054493e-003 781 | 8.5311782360076904e-001 782 | -6.4777731895446777e-001 783 | <_> 784 | 785 | <_> 786 | 787 | 788 | 789 | <_> 790 | 0 0 12 4 -1. 791 | <_> 792 | 0 0 6 2 2. 793 | <_> 794 | 6 2 6 2 2. 795 | 0 796 | 2.3193720262497663e-003 797 | -7.6411879062652588e-001 798 | 7.1867972612380981e-001 799 | <_> 800 | 801 | <_> 802 | 803 | 804 | 805 | <_> 806 | 43 12 18 2 -1. 807 | <_> 808 | 52 12 9 2 2. 809 | 0 810 | -7.9916073009371758e-003 811 | 6.6442942619323730e-001 812 | -7.9540950059890747e-001 813 | <_> 814 | 815 | <_> 816 | 817 | 818 | 819 | <_> 820 | 9 5 2 8 -1. 821 | <_> 822 | 10 5 1 8 2. 823 | 0 824 | 1.4212740352377295e-003 825 | -6.3904231786727905e-001 826 | 7.5050598382949829e-001 827 | -8.4829801321029663e-001 828 | 8 829 | -1 830 | <_> 831 | 832 | 833 | <_> 834 | 835 | <_> 836 | 837 | 838 | 839 | <_> 840 | 1 9 6 3 -1. 841 | <_> 842 | 3 9 2 3 3. 843 | 0 844 | 6.4091659151017666e-003 845 | -8.8425230979919434e-001 846 | 9.9953681230545044e-001 847 | <_> 848 | 849 | <_> 850 | 851 | 852 | 853 | <_> 854 | 56 8 2 8 -1. 855 | <_> 856 | 56 12 2 4 2. 857 | 0 858 | -6.3316390151157975e-004 859 | 8.3822172880172729e-001 860 | -9.8322170972824097e-001 861 | <_> 862 | 863 | <_> 864 | 865 | 866 | 867 | <_> 868 | 24 2 6 13 -1. 869 | <_> 870 | 26 2 2 13 3. 871 | 0 872 | -6.4947169448714703e-005 873 | 1. 874 | -9.1822808980941772e-001 875 | <_> 876 | 877 | <_> 878 | 879 | 880 | 881 | <_> 882 | 33 7 24 4 -1. 883 | <_> 884 | 41 7 8 4 3. 885 | 0 886 | 5.3404141217470169e-003 887 | -9.4317251443862915e-001 888 | 9.0425151586532593e-001 889 | -6.0007210820913315e-002 890 | 9 891 | -1 892 | <_> 893 | 894 | 895 | <_> 896 | 897 | <_> 898 | 899 | 900 | 901 | <_> 902 | 1 1 57 4 -1. 903 | <_> 904 | 1 3 57 2 2. 905 | 0 906 | 1.0755469650030136e-001 907 | -7.1647202968597412e-001 908 | 8.7827038764953613e-001 909 | <_> 910 | 911 | <_> 912 | 913 | 914 | 915 | <_> 916 | 0 2 6 14 -1. 917 | <_> 918 | 3 2 3 14 2. 919 | 0 920 | 3.1668949872255325e-002 921 | -8.7051069736480713e-001 922 | 5.8807212114334106e-001 923 | <_> 924 | 925 | <_> 926 | 927 | 928 | 929 | <_> 930 | 52 3 6 10 -1. 931 | <_> 932 | 54 3 2 10 3. 933 | 0 934 | -1.0572380386292934e-002 935 | 6.2438100576400757e-001 936 | -7.4027371406555176e-001 937 | <_> 938 | 939 | <_> 940 | 941 | 942 | 943 | <_> 944 | 1 14 61 2 -1. 945 | <_> 946 | 1 15 61 1 2. 947 | 0 948 | -2.7396259829401970e-002 949 | 8.9776748418807983e-001 950 | -5.2986758947372437e-001 951 | <_> 952 | 953 | <_> 954 | 955 | 956 | 957 | <_> 958 | 28 0 11 12 -1. 959 | <_> 960 | 28 4 11 4 3. 961 | 0 962 | 2.5918649509549141e-002 963 | -8.6482518911361694e-001 964 | 5.3121817111968994e-001 965 | -9.6125108003616333e-001 966 | 10 967 | -1 968 | <_> 969 | 970 | 971 | <_> 972 | 973 | <_> 974 | 975 | 976 | 977 | <_> 978 | 22 1 41 4 -1. 979 | <_> 980 | 22 3 41 2 2. 981 | 0 982 | 7.1039132773876190e-002 983 | -7.5719678401947021e-001 984 | 7.5645631551742554e-001 985 | <_> 986 | 987 | <_> 988 | 989 | 990 | 991 | <_> 992 | 41 6 6 8 -1. 993 | <_> 994 | 43 6 2 8 3. 995 | 0 996 | 7.6241148635745049e-003 997 | -7.9783838987350464e-001 998 | 7.1733069419860840e-001 999 | <_> 1000 | 1001 | <_> 1002 | 1003 | 1004 | 1005 | <_> 1006 | 50 9 14 5 -1. 1007 | <_> 1008 | 57 9 7 5 2. 1009 | 0 1010 | -2.7092639356851578e-002 1011 | 6.0071170330047607e-001 1012 | -8.4794402122497559e-001 1013 | <_> 1014 | 1015 | <_> 1016 | 1017 | 1018 | 1019 | <_> 1020 | 4 1 12 5 -1. 1021 | <_> 1022 | 10 1 6 5 2. 1023 | 0 1024 | -8.1267888890579343e-004 1025 | 5.9364068508148193e-001 1026 | -8.9295238256454468e-001 1027 | <_> 1028 | 1029 | <_> 1030 | 1031 | 1032 | 1033 | <_> 1034 | 37 9 3 3 -1. 1035 | <_> 1036 | 38 9 1 3 3. 1037 | 0 1038 | 8.3705072756856680e-004 1039 | -6.4887362718582153e-001 1040 | 7.8537952899932861e-001 1041 | -1.0618970394134521e+000 1042 | 11 1043 | -1 1044 | <_> 1045 | 1046 | 1047 | <_> 1048 | 1049 | <_> 1050 | 1051 | 1052 | 1053 | <_> 1054 | 54 0 10 6 -1. 1055 | <_> 1056 | 54 0 5 3 2. 1057 | <_> 1058 | 59 3 5 3 2. 1059 | 0 1060 | -9.7556859254837036e-003 1061 | 7.6982218027114868e-001 1062 | -8.5293501615524292e-001 1063 | <_> 1064 | 1065 | <_> 1066 | 1067 | 1068 | 1069 | <_> 1070 | 47 0 6 11 -1. 1071 | <_> 1072 | 49 0 2 11 3. 1073 | 0 1074 | -8.6617246270179749e-003 1075 | 8.4029090404510498e-001 1076 | -7.1949690580368042e-001 1077 | <_> 1078 | 1079 | <_> 1080 | 1081 | 1082 | 1083 | <_> 1084 | 19 2 20 2 -1. 1085 | <_> 1086 | 19 3 20 1 2. 1087 | 0 1088 | 1.6897840425372124e-002 1089 | -5.3601992130279541e-001 1090 | 9.5484441518783569e-001 1091 | <_> 1092 | 1093 | <_> 1094 | 1095 | 1096 | 1097 | <_> 1098 | 14 4 6 11 -1. 1099 | <_> 1100 | 17 4 3 11 2. 1101 | 0 1102 | 4.7526158596156165e-005 1103 | -7.6412862539291382e-001 1104 | 7.5398761034011841e-001 1105 | <_> 1106 | 1107 | <_> 1108 | 1109 | 1110 | 1111 | <_> 1112 | 31 9 33 2 -1. 1113 | <_> 1114 | 42 9 11 2 3. 1115 | 0 1116 | 6.5607670694589615e-003 1117 | -9.9346441030502319e-001 1118 | 6.4864277839660645e-001 1119 | -7.3307347297668457e-001 1120 | 12 1121 | -1 1122 | <_> 1123 | 1124 | 1125 | <_> 1126 | 1127 | <_> 1128 | 1129 | 1130 | 1131 | <_> 1132 | 6 1 53 6 -1. 1133 | <_> 1134 | 6 3 53 2 3. 1135 | 0 1136 | 1.0103269666433334e-001 1137 | -7.3275578022003174e-001 1138 | 8.4619927406311035e-001 1139 | <_> 1140 | 1141 | <_> 1142 | 1143 | 1144 | 1145 | <_> 1146 | 49 9 4 6 -1. 1147 | <_> 1148 | 49 9 2 3 2. 1149 | <_> 1150 | 51 12 2 3 2. 1151 | 0 1152 | -2.8920811018906534e-004 1153 | 7.1564781665802002e-001 1154 | -8.8221758604049683e-001 1155 | <_> 1156 | 1157 | <_> 1158 | 1159 | 1160 | 1161 | <_> 1162 | 0 9 30 7 -1. 1163 | <_> 1164 | 10 9 10 7 3. 1165 | 0 1166 | 1.0838840156793594e-002 1167 | -8.7420248985290527e-001 1168 | 6.0648679733276367e-001 1169 | <_> 1170 | 1171 | <_> 1172 | 1173 | 1174 | 1175 | <_> 1176 | 40 4 6 2 -1. 1177 | <_> 1178 | 42 4 2 2 3. 1179 | 0 1180 | 5.0803890917450190e-004 1181 | -9.0554022789001465e-001 1182 | 6.4213967323303223e-001 1183 | <_> 1184 | 1185 | <_> 1186 | 1187 | 1188 | 1189 | <_> 1190 | 1 9 6 1 -1. 1191 | <_> 1192 | 3 9 2 1 3. 1193 | 0 1194 | 2.3357039317488670e-003 1195 | -9.2574918270111084e-001 1196 | 8.6384928226470947e-001 1197 | <_> 1198 | 1199 | <_> 1200 | 1201 | 1202 | 1203 | <_> 1204 | 47 3 4 10 -1. 1205 | <_> 1206 | 47 8 4 5 2. 1207 | 0 1208 | 8.0239427916239947e-005 1209 | -9.9618428945541382e-001 1210 | 9.5355111360549927e-001 1211 | <_> 1212 | 1213 | <_> 1214 | 1215 | 1216 | 1217 | <_> 1218 | 31 5 30 11 -1. 1219 | <_> 1220 | 41 5 10 11 3. 1221 | 0 1222 | 3.2030208967626095e-003 1223 | -1. 1224 | 1.0001050233840942e+000 1225 | <_> 1226 | 1227 | <_> 1228 | 1229 | 1230 | 1231 | <_> 1232 | 0 0 2 1 -1. 1233 | <_> 1234 | 1 0 1 1 2. 1235 | 0 1236 | 0. 1237 | 0. 1238 | -1. 1239 | <_> 1240 | 1241 | <_> 1242 | 1243 | 1244 | 1245 | <_> 1246 | 21 3 42 5 -1. 1247 | <_> 1248 | 35 3 14 5 3. 1249 | 0 1250 | 2.6143440045416355e-003 1251 | -1. 1252 | 1.0002139806747437e+000 1253 | <_> 1254 | 1255 | <_> 1256 | 1257 | 1258 | 1259 | <_> 1260 | 0 0 2 1 -1. 1261 | <_> 1262 | 1 0 1 1 2. 1263 | 0 1264 | 0. 1265 | 0. 1266 | -1. 1267 | <_> 1268 | 1269 | <_> 1270 | 1271 | 1272 | 1273 | <_> 1274 | 8 5 30 9 -1. 1275 | <_> 1276 | 8 8 30 3 3. 1277 | 0 1278 | -7.0475979009643197e-004 1279 | 1. 1280 | -9.9976968765258789e-001 1281 | <_> 1282 | 1283 | <_> 1284 | 1285 | 1286 | 1287 | <_> 1288 | 3 12 33 3 -1. 1289 | <_> 1290 | 14 12 11 3 3. 1291 | 0 1292 | 2.1271279547363520e-003 1293 | -9.9694627523422241e-001 1294 | 1.0002720355987549e+000 1295 | <_> 1296 | 1297 | <_> 1298 | 1299 | 1300 | 1301 | <_> 1302 | 0 0 3 2 -1. 1303 | <_> 1304 | 1 0 1 2 3. 1305 | 0 1306 | -2.4224430671893060e-004 1307 | 1. 1308 | -1. 1309 | <_> 1310 | 1311 | <_> 1312 | 1313 | 1314 | 1315 | <_> 1316 | 46 4 3 8 -1. 1317 | <_> 1318 | 47 4 1 8 3. 1319 | 0 1320 | 7.4700301047414541e-004 1321 | -9.9108231067657471e-001 1322 | 9.9941182136535645e-001 1323 | -1.0991690158843994e+000 1324 | 13 1325 | -1 1326 | <_> 1327 | 1328 | 1329 | <_> 1330 | 1331 | <_> 1332 | 1333 | 1334 | 1335 | <_> 1336 | 1 2 6 5 -1. 1337 | <_> 1338 | 3 2 2 5 3. 1339 | 0 1340 | 1.7227890202775598e-003 1341 | -9.3608891963958740e-001 1342 | 8.7251222133636475e-001 1343 | <_> 1344 | 1345 | <_> 1346 | 1347 | 1348 | 1349 | <_> 1350 | 0 3 18 5 -1. 1351 | <_> 1352 | 6 3 6 5 3. 1353 | 0 1354 | 2.7599320746958256e-003 1355 | -9.9757021665573120e-001 1356 | 1.0000289678573608e+000 1357 | <_> 1358 | 1359 | <_> 1360 | 1361 | 1362 | 1363 | <_> 1364 | 3 1 6 14 -1. 1365 | <_> 1366 | 6 1 3 14 2. 1367 | 0 1368 | -8.9444358309265226e-005 1369 | 1. 1370 | -9.9264812469482422e-001 1371 | <_> 1372 | 1373 | <_> 1374 | 1375 | 1376 | 1377 | <_> 1378 | 3 6 2 10 -1. 1379 | <_> 1380 | 3 11 2 5 2. 1381 | 0 1382 | -2.7962020249105990e-004 1383 | 8.2833290100097656e-001 1384 | -9.8444151878356934e-001 1385 | <_> 1386 | 1387 | <_> 1388 | 1389 | 1390 | 1391 | <_> 1392 | 42 0 4 6 -1. 1393 | <_> 1394 | 42 0 2 3 2. 1395 | <_> 1396 | 44 3 2 3 2. 1397 | 0 1398 | -2.7560539820115082e-005 1399 | 1. 1400 | -9.9543339014053345e-001 1401 | -9.1314977407455444e-001 1402 | 14 1403 | -1 1404 | 1405 | -------------------------------------------------------------------------------- /src/assets/opencv/wasm/opencv_js.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/src/assets/opencv/wasm/opencv_js.wasm -------------------------------------------------------------------------------- /src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devakone/ng-open-cv/9c8407713b16dcdc72762db9c4eb184568338570/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NgOpenCvLib 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | 14 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html 15 | */ 16 | 17 | declare var cv: any; 18 | 19 | /*************************************************************************************************** 20 | * BROWSER POLYFILLS 21 | */ 22 | 23 | /** IE9, IE10 and IE11 requires all of the following polyfills. **/ 24 | // import 'core-js/es6/symbol'; 25 | // import 'core-js/es6/object'; 26 | // import 'core-js/es6/function'; 27 | // import 'core-js/es6/parse-int'; 28 | // import 'core-js/es6/parse-float'; 29 | // import 'core-js/es6/number'; 30 | // import 'core-js/es6/math'; 31 | // import 'core-js/es6/string'; 32 | // import 'core-js/es6/date'; 33 | // import 'core-js/es6/array'; 34 | // import 'core-js/es6/regexp'; 35 | // import 'core-js/es6/map'; 36 | // import 'core-js/es6/weak-map'; 37 | // import 'core-js/es6/set'; 38 | 39 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 40 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 41 | 42 | /** IE10 and IE11 requires the following for the Reflect API. */ 43 | // import 'core-js/es6/reflect'; 44 | 45 | 46 | /** Evergreen browsers require these. **/ 47 | // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. 48 | import 'core-js/es7/reflect'; 49 | 50 | 51 | /** 52 | * Web Animations `@angular/platform-browser/animations` 53 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 54 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 55 | **/ 56 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 57 | 58 | /** 59 | * By default, zone.js will patch all possible macroTask and DomEvents 60 | * user can disable parts of macroTask/DomEvents patch by setting following flags 61 | */ 62 | 63 | // (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 64 | // (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 65 | // (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 66 | 67 | /* 68 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 69 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 70 | */ 71 | // (window as any).__Zone_enable_cross_context_check = true; 72 | 73 | /*************************************************************************************************** 74 | * Zone JS is required by default for Angular itself. 75 | */ 76 | import 'zone.js/dist/zone'; // Included with Angular CLI. 77 | 78 | 79 | 80 | /*************************************************************************************************** 81 | * APPLICATION IMPORTS 82 | */ 83 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | div, 3 | p { 4 | font: 400 14px/22px Roboto, sans-serif; 5 | } 6 | canvas, 7 | img, 8 | video { 9 | border: 1px solid black; 10 | } 11 | canvas{ 12 | max-width: 320px; 13 | } 14 | td { 15 | padding: 10px 0px 0px 10px; 16 | text-align: center; 17 | } 18 | button { 19 | display: inline-block; 20 | color: #fff; 21 | background-color: #337ab7; 22 | border-color: #2e6da4; 23 | padding: 6px 12px; 24 | margin-bottom: 0; 25 | font-size: 14px; 26 | font-weight: bold; 27 | text-align: center; 28 | white-space: nowrap; 29 | vertical-align: middle; 30 | -ms-touch-action: manipulation; 31 | touch-action: manipulation; 32 | cursor: pointer; 33 | -webkit-user-select: none; 34 | -moz-user-select: none; 35 | -ms-user-select: none; 36 | user-select: none; 37 | background-image: none; 38 | border: 1px solid transparent; 39 | border-radius: 4px; 40 | } 41 | button[disabled] { 42 | cursor: not-allowed; 43 | filter: alpha(opacity=65); 44 | -webkit-box-shadow: none; 45 | box-shadow: none; 46 | opacity: 0.65; 47 | } 48 | .control { 49 | margin-bottom: 3px; 50 | } 51 | .err { 52 | color: red; 53 | font-weight: bold; 54 | } 55 | .caption { 56 | margin: 0; 57 | font-weight: bold; 58 | } 59 | .code { 60 | padding: 4px 6px; 61 | margin: 4px 8px 4px 2px; 62 | background-color: #fbfcfd; 63 | border: 1px solid #c4cfe5; 64 | font-family: monospace, fixed; 65 | font-size: 13px; 66 | min-height: 13px; 67 | line-height: 1; 68 | text-wrap: unrestricted; 69 | padding-bottom: 0px; 70 | margin: 0px; 71 | } 72 | .hidden { 73 | display: none; 74 | } 75 | .small { 76 | max-width: 300px; 77 | } 78 | .more-examples{ 79 | margin-top: 20px; 80 | } 81 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/typings.d.ts: -------------------------------------------------------------------------------- 1 | declare var cv: any; 2 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "es2015", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "target": "es5", 13 | "typeRoots": [ 14 | "node_modules/@types" 15 | ], 16 | "lib": [ 17 | "es2017", 18 | "dom" 19 | ], 20 | "paths": { 21 | "ng-open-cv": [ 22 | "dist/ng-open-cv", 23 | "dist/ng-open-cv", 24 | "dist/ng-open-cv" 25 | ], 26 | "ng-open-cv/*": [ 27 | "dist/ng-open-cv/*", 28 | "dist/ng-open-cv/*", 29 | "dist/ng-open-cv/*" 30 | ] 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "node_modules/codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-redundant-jsdoc": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "unified-signatures": true, 111 | "variable-name": false, 112 | "whitespace": [ 113 | true, 114 | "check-branch", 115 | "check-decl", 116 | "check-operator", 117 | "check-separator", 118 | "check-type" 119 | ], 120 | "no-output-on-prefix": true, 121 | "use-input-property-decorator": true, 122 | "use-output-property-decorator": true, 123 | "use-host-property-decorator": true, 124 | "no-input-rename": true, 125 | "no-output-rename": true, 126 | "use-life-cycle-interface": true, 127 | "use-pipe-transform-interface": true, 128 | "component-class-suffix": true, 129 | "directive-class-suffix": true 130 | } 131 | } 132 | --------------------------------------------------------------------------------