def minutiae_whole_image(model_path,
                         sample_path,
                         imgs,
                         output_name='reconstruction/gen:0'):
    imgs = glob.glob('/Data/Rolled/NISTSD14/Image2/*.bmp')
    imgs.sort()

    with tf.Graph().as_default():
        with TowerContext('', is_training=False):
            with tf.Session() as sess:
                is_training = get_current_tower_context().is_training
                load_model(model_path)
                images_placeholder = tf.get_default_graph().get_tensor_by_name(
                    'QueueInput/input_deque:0')
                # is_training
                minutiae_cylinder_placeholder = tf.get_default_graph(
                ).get_tensor_by_name(output_name)
                for n, file in enumerate(imgs):
                    img0 = cv2.imread(file, cv2.IMREAD_GRAYSCALE)
                    img = img0 / 128.0 - 1
                    img = np.expand_dims(img, axis=2)
                    img = np.expand_dims(img, axis=0)
                    feed_dict = {images_placeholder: img}
                    minutiae_cylinder = sess.run(minutiae_cylinder_placeholder,
                                                 feed_dict=feed_dict)

                    minutiae_cylinder = np.squeeze(minutiae_cylinder, axis=0)
                    minutiae = prepare_data.get_minutiae_from_cylinder(
                        minutiae_cylinder, thr=0.25)
                    minutiae = prepare_data.refine_minutiae(minutiae,
                                                            dist_thr=10,
                                                            ori_dist=np.pi / 4)
                    prepare_data.show_minutiae(img0, minutiae)
                    print n
示例#2
0
def minutiae_whole_image(model_path,sample_path, imgs, output_name='reconstruction/gen:0'):
    #imgs = glob.glob('/media/kaicao/Data/Data/Rolled/NISTSD4/Image_Aligned'+'/*.jpeg')
    #imgs = glob.glob('/home/kaicao/Dropbox/Research/Data/Latent/NISTSD27/image/'+'*.bmp')
    imgs = glob.glob('/future/Data/Rolled/NISTSD14/Image2/*.bmp')
    #imgs = glob.glob('/research/prip-kaicao/Data/Latent/DB/NIST27/image/' + '*.bmp')
    #imgs = glob.glob('/research/prip-kaicao/Data/Rolled/NIST4/Image/'+'*.bmp')
    imgs.sort()
    weight = get_weights(opt.SHAPE, opt.SHAPE, 12)
    import os
    #if not os.path.isdir(sample_path):
    #    os.makedirs(sample_path)
    with tf.Graph().as_default():

        with TowerContext('', is_training=False):
            with tf.Session() as sess:
                is_training= get_current_tower_context().is_training
                load_model(model_path)
                images_placeholder = tf.get_default_graph().get_tensor_by_name('QueueInput/input_deque:0')
                #is_training
                minutiae_cylinder_placeholder = tf.get_default_graph().get_tensor_by_name(output_name)
                for n, file in enumerate(imgs):
                    img0 = cv2.imread(file,cv2.IMREAD_GRAYSCALE)
                    img = img0/128.0-1
                    img = np.expand_dims(img,axis=2)
                    img = np.expand_dims(img,axis=0)
                    feed_dict = {images_placeholder: img}
                    minutiae_cylinder= sess.run(minutiae_cylinder_placeholder, feed_dict=feed_dict)

                    minutiae_cylinder = np.squeeze(minutiae_cylinder,axis=0)
                    minutiae = prepare_data.get_minutiae_from_cylinder(minutiae_cylinder,thr=0.25)

                    #cv2.imwrite('test_0.jpeg', (minutiae_cylinder[:, :, 0:3]) * 255)
                    #cv2.imwrite('test_1.jpeg', (minutiae_cylinder[:, :, 3:6]) * 255)
                    #cv2.imwrite('test_2.jpeg', (minutiae_cylinder[:, :, 6:9]) * 255)
                    #cv2.imwrite('test_3.jpeg', (minutiae_cylinder[:, :, 9:12]) * 255)
                    #prepare_data.show_features(img, minutiae, fname=os.path.basename(file)[:-4] +'.jpeg')

                    minutiae = prepare_data.refine_minutiae(minutiae, dist_thr=10, ori_dist=np.pi / 4)
                    prepare_data.show_minutiae(img0, minutiae)
                    print n