Document Scanner :bookmark_tabs:
U-Net Like Pretrained Model For Scene Document Detection (pytorch, Semantic Segmentation)
Quick Links
Dependencies
- Install Dependencies
$ pip install -r requirements.txt
- Download model weights Here, place it in
Structure/
Usage:
scanner = Scanner("Structure/Scanner-Detector.pth", config_)
Load model.
org = cv2.imread(fname)
org_gray = cv2.cvtColor(org, cv2.COLOR_RGB2GRAY)
org_resize = cv2.resize(org_gray, (256, 256), interpolation = cv2.INTER_AREA)
Read image in gray scale and resize it to 256*256.
mask = scanner.ScanView(org_resize)
Detect document area.
paper, approx = ExtractPaper(org_gray, mask)
org = DrawBox(org, approx)
Extract document and draw bounding box on original image.
paper = EnhacePaper(paper)
Enhance extracted document.