1.0.0 • Published 6 months ago
iran-bank-cards-ocr v1.0.0
Iranian Bank Cards OCR
A TypeScript library to detect Iranian bank names, logos, and validate card numbers using OCR (Tesseract.js) and the Luhn algorithm.
Features
- Bank Detection: Detect Iranian bank names (in English and Persian) and logos based on card numbers.
- Card Validation: Validate card numbers using the Luhn algorithm.
- OCR Integration: Extract card numbers from images using Tesseract.js.
- Easy to Use: Simple and intuitive API for quick integration.
Installation
You can install the package via npm:
npm install iran-bank-cards-ocr
Or using yarn:
yarn add iran-bank-cards-ocr
Usage
Here's a quick example to get you started:
import readBankCard from 'iran-bank-card-reader';
async function main() {
const { cardNumber, bankInfo } = await readBankCard();
if (cardNumber && bankInfo) {
console.log(`Card Number: ${cardNumber}`);
console.log(`Bank Name (English): ${bankInfo.en}`);
console.log(`Bank Name (Persian): ${bankInfo.fa}`);
console.log(`Bank Logo URL: ${bankInfo.logo}`);
} else {
console.log('No valid card number found in the image.');
}
}
main();
API
readBankCard()
Captures an image from the camera, processes it to extract the card number, and detects the bank information.
Returns: A promise that resolves to an object with the following properties:
cardNumber
: The extracted card number (string | null).bankInfo
: An object containing the bank name (in English and Persian) and logo URL (object | null).
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeatureName
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/YourFeatureName
). - Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- Tesseract.js for OCR capabilities.
- Luhn Algorithm for card number validation.
Made with ❤️ by Peyman Pirzadeh
1.0.0
6 months ago