ngx-image-id-detector
Version:
A package that detects if an image is a Vietnamese citizen ID using Tesseract.js
68 lines (44 loc) โข 1.58 kB
Markdown
# ๐ท ngx-image-id-detector
**ngx-image-id-detector** is an Angular library for detecting whether an image is a Vietnamese Citizen ID card (CCCD) using OCR (`Tesseract.js`). It can distinguish between the front side, back side, or unrecognized images.
## โจ Features
* โ
Detects the **front** side of CCCD
* โ
Detects the **back** side of CCCD
* โ Distinguishes invalid images (blurred, glare, cropped, not CCCD)
* ๐ Supports Vietnamese language with Tesseract.js (`lang: vie`)
* ๐ Returns results as Observable, suitable for Angular
## ๐ฆ Installation
```bash
npm install ngx-image-id-detector tesseract.js
```
## ๐ Version Compatibility
| ngx-image-id-detector | Angular version | Tesseract.js version |
| --------------------- | --------------- | -------------------- |
| 1.x | 16+ | 4.x |
| 0.x | 13โ15 | 2.x |
## ๐งช Example
Demo source is available in the `example/` folder:
```ts
import { DetectIdService } from 'ngx-image-id-detector';
constructor(private detectIdService: DetectIdService) {}
onImageSelected(file: File) {
this.detectIdService.detect(file).subscribe(result => {
console.log(result);
});
}
```
## โ
Result Structure
```ts
interface DetectIdResult {
side: 'front' | 'back' | 'unknown';
text: string;
}
```
## ๐ GitHub Repository
๐ [https://github.com/nguyentrunghieutcu/ngx-image-id-detector](https://github.com/nguyentrunghieutcu/ngx-image-id-detector)
## ๐ License
[MIT](LICENSE)