Skip to main content

A package for reading id and name on KTP and SIM

Project description

Indo OCR Army

This is a package for OCR Identity card in Indonesia (KTP and SIM). This packages build on top of detectron2 so you should install detectron2 first and some requirements need to install separately before you run this packages, Note that we test it on a device with GPU/CUDA if there is an error please report an issue to our email. After install this package, please follow the tutorial bellow:

# if use conda
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch

# if use python
pip install torch==1.5.1
pip install torchvision
python -m pip install detectron2 -f \ https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.5/index.html

for comprehensive use, you can do this:

import os
import cv2
import matplotlib.pyplot as plt

from IndoOCRArmy import defaultConfig, DrawOCR, numericalDetectron2, boundingBoxesDetectron2, alphabeticalDetectron2, easypredict

# load classes
cfg = defaultConfig()

for key in cfg.keys():
    if 'list_cuda' in cfg[key]:
        cfg[key]['list_cuda'] = [0]

drawer_ocr = DrawOCR(cfg['drawOCR'])
bBoxDet = boundingBoxesDetectron2(cfg['boundingBoxesDetectron2'])
numDet = numericalDetectron2(cfg['numericalDetectron2'])
alphaDet = alphabeticalDetectron2(cfg['alphabeticalDetectron2'])

# load image
image_ktp = cv2.imread("assets/ktp_example.jpg")
image_sim = cv2.imread("assets/sim_example.jpg")

# detect boundingboxes
crops, boxes, labels = bBoxDet.predict(image_ktp, input_type='ktp')

# detect number and alphabet
dict_ID = numDet.predict_ensemble(crops[0])
dict_Name = alphaDet.predict_ensemble(crops[1])

# choose `weighted_hardvote_word` for the best result according to our benchmark
ID =  dict_ID.get("weighted_hardvote_word")
Name =  dict_Name.get("weighted_hardvote_word")

# parse NIK to get information about : location, gender, and birthdate
parse_NIK = numDet.parse_nik(ID)

# create listdata and listlabel for visualization later
listdata = [ID, Name]
listlabel = [x for x in list(labels.values()) if x is not None]
for label, data in parse_NIK.items():
    listdata.append(data)
    listlabel.append(label)

print(ID)
print(Name)

drawer_ocr.show_list_images(list_img=crops.values())

For visuzlize comprehensive result, use this:

drawer_ocr.show_desc(image_ktp, boxes, labels, listdata, listlabel)

For quick result, use this:

image_ktp = cv2.imread("assets/ktp_example.jpg")
easypredict(image_ktp, bBoxDet, numDet, alphaDet, input_type='ktp')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

indOCRArmy-0.1.13.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

indOCRArmy-0.1.13-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file indOCRArmy-0.1.13.tar.gz.

File metadata

  • Download URL: indOCRArmy-0.1.13.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for indOCRArmy-0.1.13.tar.gz
Algorithm Hash digest
SHA256 71b683c8d0a16b214aeb6a265b707d75df5bfec7890c0d1e9363a1c828fceb8e
MD5 9528b4dd9002f192d37269af54430b92
BLAKE2b-256 09776919e44d0fb5fb609fc7603ca1bde8327bf7c0d15671f1bee48223a191ec

See more details on using hashes here.

File details

Details for the file indOCRArmy-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: indOCRArmy-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.3

File hashes

Hashes for indOCRArmy-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 4f65384a56c26179878b5bc65ba7a9c4df729b7e3c51832e3fff4b08ee5ee7da
MD5 df2217855013aac2ce76f63213f12022
BLAKE2b-256 1578ba29adab7e7ce58dc24746ba615adc5ee64e30eb4f87a41a769776956091

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page