All Projects → devakone → Ng Open Cv

devakone / Ng Open Cv

Licence: mit
Angular 6+ & OpenCV.js integration service library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Ng Open Cv

Face Tracking With Anime Characters
Hello! I have made a Python project where YURI from the game doki doki literature club accesses the webcam and stares directly into the players soul. Hope you enjoy!
Stars: ✭ 320 (+788.89%)
Mutual labels:  opencv, face-detection
Fast face detector
A face detector based on the work "Aggregate channel features for multi-view face detection" presented by Bin Yang, Junjie Yan, Zhen Lei and Stan Z. Li.
Stars: ✭ 35 (-2.78%)
Mutual labels:  opencv, face-detection
Facemoji
😆 A voice chatbot that can imitate your expression. OpenCV+Dlib+Live2D+Moments Recorder+Turing Robot+Iflytek IAT+Iflytek TTS
Stars: ✭ 320 (+788.89%)
Mutual labels:  opencv, face-detection
Marvel
Marvel - Face Recognition With Android & OpenCV
Stars: ✭ 199 (+452.78%)
Mutual labels:  opencv, face-detection
Human Detection And Tracking
Human-detection-and-Tracking
Stars: ✭ 753 (+1991.67%)
Mutual labels:  opencv, face-detection
Add Christmas Hat
Add Christmas hat on one's head based on OpneCV and Dlib
Stars: ✭ 251 (+597.22%)
Mutual labels:  opencv, face-detection
Yoloface
Deep learning-based Face detection using the YOLOv3 algorithm (https://github.com/sthanhng/yoloface)
Stars: ✭ 339 (+841.67%)
Mutual labels:  opencv, face-detection
Opencv Facial Landmark Detection
使用OpenCV实现人脸关键点检测
Stars: ✭ 153 (+325%)
Mutual labels:  opencv, face-detection
Php Opencv
PHP extensions for OpenCV
Stars: ✭ 524 (+1355.56%)
Mutual labels:  opencv, face-detection
Opencv4nodejs
Nodejs bindings to OpenCV 3 and OpenCV 4
Stars: ✭ 4,444 (+12244.44%)
Mutual labels:  opencv, face-detection
Opencv Course
Learn OpenCV in 4 Hours - Code used in my Python and OpenCV course on freeCodeCamp.
Stars: ✭ 185 (+413.89%)
Mutual labels:  opencv, face-detection
Mocr
Meaningful Optical Character Recognition from identity cards with Deep Learning.
Stars: ✭ 19 (-47.22%)
Mutual labels:  opencv, face-detection
Attendance Using Face
Face-recognition using Siamese network
Stars: ✭ 174 (+383.33%)
Mutual labels:  opencv, face-detection
Pigo
Fast face detection, pupil/eyes localization and facial landmark points detection library in pure Go.
Stars: ✭ 3,542 (+9738.89%)
Mutual labels:  opencv, face-detection
Proctoring Ai
Creating a software for automatic monitoring in online proctoring
Stars: ✭ 155 (+330.56%)
Mutual labels:  opencv, face-detection
Autocrop
😌 Automatically detects and crops faces from batches of pictures.
Stars: ✭ 320 (+788.89%)
Mutual labels:  opencv, face-detection
Animoji Animate
Facial-Landmarks Detection based animating application similar to Apple-Animoji™
Stars: ✭ 142 (+294.44%)
Mutual labels:  opencv, face-detection
Hololenswithopencvforunityexample
HoloLens With OpenCVforUnity Example
Stars: ✭ 142 (+294.44%)
Mutual labels:  opencv, face-detection
Libfaceid
libfaceid is a research framework for prototyping of face recognition solutions. It seamlessly integrates multiple detection, recognition and liveness models w/ speech synthesis and speech recognition.
Stars: ✭ 354 (+883.33%)
Mutual labels:  opencv, face-detection
Facepixeler
A simple C# program that can automatically detect and blur faces in images. Uses OpenCV and EmguCV.
Stars: ✭ 5 (-86.11%)
Mutual labels:  opencv, face-detection

NgOpenCV

This is a library that integrates Angular v6+ with OpenCVJS, the Javascript port of the popular computer 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.

Please read this blog post for the whole background on how this library came together

Installation

NPM

npm install ng-open-cv --save

Yarn

yarn add ng-open-cv

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 contains the actual OpenCV library (v3.4) and its WASM and ASM.js files.

Data files

OpenCV.js uses classification files to perform certain detection operations. To use those files:

  • Get the folders you need from the OpenCV data repository
  • 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.
  • Use the createFileFromUrl in the NgOpenService class to load the file in memory.

Example:




this.ngOpenCVService.createFileFromUrl(
        'haarcascade_frontalface_default.xml',
        'assets/opencv/data/haarcascades/haarcascade_frontalface_default.xml'
      ),


  1. Typings

To your src/typings.d.ts file. add

declare var cv: any;

Demo

You can visit the demo site here.

Usage

If you have installed NgOpenCV and copied the opencv folder to your assets directory, everything should work out of the box.

1. Import the NgOpenCVModule

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

DEFAULT_OPTIONS = {
    scriptUrl: 'assets/opencv/asm/3.4/opencv.js',
    usingWasm: false,
    locateFile: this.locateFile.bind(this),
    onRuntimeInitialized: () => {}
  };

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:

const openCVConfig: OpenCVOptions = {
  scriptUrl: `assets/opencv/wasm/3.4/opencv.js`,
  wasmBinaryFile: 'wasm/3.4/opencv_js.wasm',
  usingWasm: true
};

Note: WASM is not supported on mobile Safari

Import NgOpenCVModule.forRoot(config) in the NgModule of your application. The forRoot method is a convention for modules that provide a singleton service. Pass it the configuration object.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { NgOpenCVModule } from 'ng-open-cv';
import { RouterModule } from '@angular/router';
import { AppRoutingModule } from './app-routing.module';
import { OpenCVOptions } from 'projects/ng-open-cv/src/public_api';

const openCVConfig: OpenCVOptions = {
  scriptUrl: `assets/opencv/opencv.js`,
  wasmBinaryFile: 'wasm/opencv_js.wasm',
  usingWasm: true
};

@NgModule({
   declarations: [
      AppComponent,
   ],
   imports: [
      BrowserModule,
      NgOpenCVModule.forRoot(openCVConfig),
      RouterModule,
      AppRoutingModule
   ],
   providers: [],
   bootstrap: [
      AppComponent
   ]
})
export class AppModule { }

If you have multiple NgModules and you use one as a shared NgModule (that you import in all of your other NgModules), 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.

...
const openCVConfig: OpenCVOptions = {
  scriptUrl: `assets/opencv/opencv.js`,
  wasmBinaryFile: 'wasm/opencv_js.wasm',
  usingWasm: true
};

@NgModule({
    imports: [
        BrowserModule,
        NgOpenCVModule.forRoot(openCVConfig)
    ],
    exports: [BrowserModule, NgOpenCvModule],
})
export class SharedModule {
}

3. Use the NgOpenCVService for your application

  • Import NgOpenCVService from ng-open-cv in your application code:
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
import { fromEvent, Observable } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { NgOpenCVService, OpenCVLoadResult } from 'ng-open-cv';

@Component({
  selector: 'app-hello',
  templateUrl: './hello.component.html',
  styleUrls: ['./hello.component.css']
})
export class HelloComponent implements OnInit {

  // Keep tracks of the ready
  openCVLoadResult: Observable<OpenCVLoadResult>;

  // HTML Element references
  @ViewChild('fileInput')
  fileInput: ElementRef;
  @ViewChild('canvasOutput')
  canvasOutput: ElementRef;

  constructor(private ngOpenCVService: NgOpenCVService) { }

  ngOnInit() {
    this.openCVLoadResult = this.ngOpenCVService.isReady$;
  }

  loadImage(event) {
    if (event.target.files.length) {
      const reader = new FileReader();
      const load$ = fromEvent(reader, 'load');
      load$
        .pipe(
          switchMap(() => {
            return this.ngOpenCVService.loadImageToHTMLCanvas(`${reader.result}`, this.canvasOutput.nativeElement);
          })
        )
        .subscribe(
          () => {},
          err => {
            console.log('Error loading image', err);
          }
        );
      reader.readAsDataURL(event.target.files[0]);
    }
  }

}

The NgOpenCVService exposes a isReady$ observable which you should always subscribe too before attempting to do anything OpenCV related. It emits an OpenCVLoadResult object that is structured as:

export interface OpenCVLoadResult {
 ready: boolean;
 error: boolean;
 loading: boolean;
}

The following function gives you an example of how to use it your code:

detectFace() {
   // before detecting the face we need to make sure that
   // 1. OpenCV is loaded
   // 2. The classifiers have been loaded
   this.ngOpenCVService.isReady$
     .pipe(
       filter((result: OpenCVLoadResult) => result.ready),
       switchMap(() => {
         return this.classifiersLoaded$;
       }),
       tap(() => {
         this.clearOutputCanvas();
         this.findFaceAndEyes();
       })
     )
     .subscribe(() => {
       console.log('Face detected');
     });
 }

You can view more of this example code in the Face Detection Component

Build

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.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Credits

OpenCV.js

How to build a library for Angular apps

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].