Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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 \

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():



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.

Files for indOCRArmy, version 0.1.13
Filename, size File type Python version Upload date Hashes
Filename, size indOCRArmy-0.1.13-py3-none-any.whl (12.5 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size indOCRArmy-0.1.13.tar.gz (12.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page