Python package for detecting information from a ktp / indonesian id card
Project description
PISAHKAN KTP: Indonesian ID Card (KTP) Information Segmentation
About
pisahkan_ktp is a Python function that extracts province, NIK, and personal information from an image of an Indonesian National Identity Card (KTP). It utilizes image processing techniques to locate and isolate relevant sections of the KTP image, then extracts text data accurately. The extracted information is returned in a structured format, facilitating further processing or integration into other applications.
Requirements
- Python 3.7 or Higher
- numpy
- opencv-python
- opencv-contrib-python
- pythonRLSA
Key Features
- Extracts province, NIK, and personal information from Indonesian National Identity Card (KTP) images.
- Utilizes image processing techniques to locate and isolate relevant sections accurately.
- Returns extracted information in a structured format for easy integration and further processing.
Usage
Manual Installation via Github
- Clone Repository
git clone https://github.com/hanifabd/pisahkan-ktp - Installation
cd pisahkan-ktp && pip install dist/pisahkan_ktp-0.2.11-py3-none-any.whl
Installation Using Pip
- Installation
pip install pisahkan-ktp
Inference
-
Usage
-
Text Area
-
Standard Segmenter
# Input ==> Image Path from pisahkan_ktp.ktp_segmenter import segmenter image_path = "./tests/sample.jpg" result = segmenter(image_path) print(result) # Input ==> Numpy Array Image ==> cv2.imread(image_path) from pisahkan_ktp.ktp_segmenter import segmenter_ndarray image_path = "./tests/sample.jpg" image = cv2.imread(image_path) result = segmenter_ndarray(image) print(result)
-
Adaptive Segmenter (Adjust contrast level in preprocessing)
# Input ==> Image Path from pisahkan_ktp.ktp_segmenter import adaptive_segmenter image_path = "./tests/sample.jpg" result = adaptive_segmenter(image_path, contrast_factor=1.7, delta_contrast=0.7, gamma_factor=1.0) print(result) # Input ==> Numpy Array Image ==> cv2.imread(image_path) from pisahkan_ktp.ktp_segmenter import adaptive_segmenter_ndarray image_path = "./tests/sample.jpg" image = cv2.imread(image_path) result = adaptive_segmenter_ndarray(image, contrast_factor=1.7, delta_contrast=0.7, gamma_factor=1.0) print(result)
-
-
Pass-Photo & Signature
# Input ==> Image Path from pisahkan_ktp.ktp_segmenter import getPassPhoto, getSignature image_path = "./tests/sample.jpg" result = getPassPhoto(image_path) # Output Image Numpy Array # Input ==> Numpy Array Image ==> cv2.imread(image_path) from pisahkan_ktp.ktp_segmenter import getPassPhotoNdarray, getSignatureNdarray image_path = "./tests/sample.jpg" image = cv2.imread(image_path) result = getPassPhotoNdarray(image) # Output Image Numpy Array
NOTE!!! Input image must be a clear Indonesian ID Card (KTP) no/less background noise for optimal performance
-
-
Result Text Area
{ "image": [originalImage], "provinsiArea": [segmented_provinsi_img_matrix_list], "nikArea": [segmented_nik_img_matrix_list], "detailArea": [segmented_detail_img_matrix_list], }
-
Preview
-
Original Image
-
Provinsi Area Cropped
-
NIK Area Cropped
-
Detail Area Cropped
-
How to Show in Matplotlib
Input ==> Image Path
from pisahkan_ktp.ktp_segmenter import segmenter
import matplotlib.pyplot as plt
import cv2
def show_result(result_dict):
num_boxes = len(result_dict)
fig, axes = plt.subplots(num_boxes, 1)
if num_boxes == 1:
axes = [axes]
for i, bbox in enumerate(result_dict):
ax = axes[i]
if bbox.size:
ax.imshow(cv2.cvtColor(bbox, cv2.COLOR_BGR2RGB))
ax.axis('off')
plt.tight_layout()
plt.show()
image_path = "./tests/sample.jpg"
result = segmenter(image_path)
# Close pop up window first to see other result -> VSCODE
show_result(result["provinsiArea"])
show_result(result["nikArea"])
show_result(result["detailArea"])
Input ==> Numpy Array Image ==> cv2.imread(image_path)
from pisahkan_ktp.ktp_segmenter import segmenter_ndarray
import matplotlib.pyplot as plt
import cv2
def show_result(result_dict):
num_boxes = len(result_dict)
fig, axes = plt.subplots(num_boxes, 1)
if num_boxes == 1:
axes = [axes]
for i, bbox in enumerate(result_dict):
ax = axes[i]
if bbox.size:
ax.imshow(cv2.cvtColor(bbox, cv2.COLOR_BGR2RGB))
ax.axis('off')
plt.tight_layout()
plt.show()
image_path = "./tests/sample.jpg"
image = cv2.imread(image_path)
result = segmenter_ndarray(image)
# Close pop up window first to see other result
show_result(result["provinsiArea"])
show_result(result["nikArea"])
show_result(result["detailArea"])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pisahkan_ktp-0.2.12.tar.gz.
File metadata
- Download URL: pisahkan_ktp-0.2.12.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
970ac640cbbc30c32b4caa1014391aa97a3ad7ee76a6a1e6a458e14f7a8fe8d9
|
|
| MD5 |
157f3d615c5c0508a56634a8b3cafa69
|
|
| BLAKE2b-256 |
3b4c2ba01daa1c0247901a3e6064f1527369bfdfca9aa9908b157cda1b39dddd
|
File details
Details for the file pisahkan_ktp-0.2.12-py3-none-any.whl.
File metadata
- Download URL: pisahkan_ktp-0.2.12-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52470108e4f45d17ab4c971aedd67a707d67de629af62bc6d1492fb0d7dc3484
|
|
| MD5 |
c9e4ae201a31ddd3969640a31d21be68
|
|
| BLAKE2b-256 |
4675971bcea40ef72e64478712b10fe8062a3b646b6d3f80b4d5a45e090f9dcf
|