Extract objects (fingerprint and signature) from an image using OpenCV and python [closed]

asked 2020-06-14 16:29:10 -0500

Abd313 gravatar image

updated 2020-06-15 00:53:09 -0500

At my website I receive an image contains the user fingerprint and signature, I wan't to extract these two pieces of information.

for example:

Original Image

I tried this:

 import os
import cv2
import numpy as np

#read image
rgb_img = cv2.imread('path')
rgb_img = cv2.resize(rgb_img, (900, 600))
gray_img = cv2.cvtColor(rgb_img, cv2.COLOR_BGR2GRAY)

#canny edge detection
canny = cv2.Canny(gray_img, 50, 120)

Canny

# Morphology Closing
kernel = np.ones((7, 23), np.uint8)
closing = cv2.morphologyEx(canny, cv2.MORPH_CLOSE, kernel)

After Morphology

# Find contours 
contours, hierarchy = cv2.findContours(closing.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)

# Sort Contors by area and then remove the largest frame contour
n = len(contours) - 1
contours = sorted(contours, key=cv2.contourArea, reverse=False)[:n]

#take a copy
copy = rgb_img.copy()

# Iterate through contours and draw the convex hull
for c in contours:
    if cv2.contourArea(c) < 750:
        continue
    hull = cv2.convexHull(c)
    cv2.drawContours(copy, [hull], 0, (0, 255, 0), 2)
    imshow('Convex Hull', copy)

Divided Image

Now my goals are:

1.Know which part is the signature and which is the fingerprint

2.Resolve the contours overlapping if exist

P.S: I'm not sure if the previous steps are final so please if you have better steps tell me.

These are some hard examples i may wanna deal with

image description image description

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-09-29 00:10:29.331002