def detectCards(image):
    toWarp = image.copy()
    cropped_dict = dict()
    # cropped_list = {}
    adjusted = pp.histogram_adjust(image.copy())
    segmented = pp.segmentation(adjusted)
    contours, hierarchy = cv2.findContours(np.uint8(segmented), cv2.RETR_CCOMP,
                                           cv2.CHAIN_APPROX_SIMPLE)
    contours_sorted = sorted(contours, key=cv2.contourArea, reverse=True)
    hull_list = []
    for cnt in contours_sorted[:10]:
        hull = cv2.convexHull(cnt)
        x, y, w, h = cv2.boundingRect(hull)
        if pp.isCardRect(x, y, w, h, hull_list):
            hull_list.append(hull)
            img_box = cv2.rectangle(image, (x, y), (x + w, y + h),
                                    color=(0, 255, 0),
                                    thickness=4)
            eps = computeEps(w, h)
            rect_point = np.array([
                [x - eps, y - eps],
                [x + w + eps, y - eps],
                [x + w + eps, y + h + eps],
                [x - eps, y + h + eps],
            ])
            warped = four_point_transform(toWarp, rect_point)
            # cropped_list.append(warped)
            cropped_dict[x - eps] = warped
    return cropped_dict, image
from matplotlib.patches import Rectangle
from scipy.signal import convolve2d
import time
import sys
sys.path.append("..")
from basic import imshow
import basic
from preprocess import enhance
import preprocess as pre
from minutiaeExtract import minutiaeExtract
from basic import block_view

FVC0 = '/home/zhangzimou/Desktop/code_lnk/database/FVC2000/'
FVC2 = '/home/zhangzimou/Desktop/code_lnk/database/FVC2002/'
FVC4 = '/home/zhangzimou/Desktop/code_lnk/database/FVC2004/'
path = FVC4 + 'DB2_B/'

blockSize = 8

img = cv2.imread(path + '106_1.tif', 0)

img_seg, imgfore = pre.segmentation(img)

plt.figure()
imshow(img)
plt.figure()
plt.subplot(1, 2, 1)
imshow(img_seg)
plt.subplot(1, 2, 2)
plt.imshow(imgfore, cmap='gray')
from minutiaeExtract import minutiaeExtract
from basic import block_view
from _match import minutiaeMatch
import match

FVC0='/home/zhangzimou/Desktop/code_lnk/database/FVC2000/'
FVC2='/home/zhangzimou/Desktop/code_lnk/database/FVC2002/'
FVC4='/home/zhangzimou/Desktop/code_lnk/database/FVC2004/'
path=FVC2+'DB1_B/'

blockSize=8

img1=cv2.imread(path+'101_1.tif',0)
img2=cv2.imread(path+'101_1.tif',0)

img_seg1,imgfore1=pre.segmentation(img1)
img_seg2,imgfore2=pre.segmentation(img2)

imgE1,imgfore1=enhance(img1)
imgE2,imgfore2=enhance(img2)
imgB1=basic.binarize(imgE1)
imgB2=basic.binarize(imgE2)
imgT1=pre.thinning(imgB1)
imgT2=pre.thinning(imgB2)


plt.figure()
plt.subplot(1,2,1)
imshow(img_seg1)
plt.subplot(1,2,2)
imshow(img_seg2)
Beispiel #4
0
import time
from basic import imshow
import basic
from preprocess import enhance
import preprocess as pre
from minutiaeExtract import minutiaeExtract

FVC0 = '/home/zhangzimou/Desktop/code_lnk/database/FVC2000/'
FVC2 = '/home/zhangzimou/Desktop/code_lnk/database/FVC2002/'
FVC4 = '/home/zhangzimou/Desktop/code_lnk/database/FVC2004/'
path = FVC4 + 'DB1_B/'

start = time.clock()

img = cv2.imread(path + '110_2.tif', 0)
image, imgfore = pre.segmentation(img)

blockSize = 8
boxSize = 4
theta = pre.calcDirectionBox(image, blockSize, boxSize)

P = [
    theta[2:, 1:-1], theta[2:, 2:], theta[1:-1, 2:], theta[:-2, 2:],
    theta[:-2, 1:-1], theta[:-2, :-2], theta[1:-1, :-2], theta[2:, :-2]
]

N, M = image.shape
N1, M1 = theta.shape
delta = np.zeros((N1 - 2, M1 - 2))
for i in range(8):
    if i == 7:
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle
from scipy.signal import convolve2d
import time
import sys
sys.path.append("..")
from basic import imshow
import basic
from preprocess import enhance
import preprocess as pre
from minutiaeExtract import minutiaeExtract

start = time.clock()
img_origin = cv2.imread('../pic4.tif', 0)
img_origin, imgfore = pre.segmentation(img_origin)
blockSize = 16
theta = pre.calcDirection(img_origin, blockSize)
wl = pre.calcWl(img_origin, blockSize)
#img=ridgeComp2(img,theta,blockSize)
img_enhance = pre.GaborFilter(img_origin, blockSize, wl, np.pi / 2 - theta)
img_enhance[np.where(imgfore == 255)] = 255

img_thin = pre.thinning(basic.binarize(img_enhance))
ending, bifur, theta1, theta2 = minutiaeExtract(img_thin, imgfore)
ending, bifur = ending.T, bifur.T

end = time.clock()
print end - start
plt.figure()
imshow(img_origin)