# Path: utils/s2p_mosaic.py
# def vrt_body_source(fname,band,src_x,src_y,src_w,src_h,dst_x,dst_y,dst_w,dst_h):
# def vrt_header(w,h,dataType='Float32'):
# def vrt_footer():
# def global_extent(tiles):
# def write_row_vrts(tiles,sub_img,vrt_basename,min_x,max_x):
# def write_main_vrt(vrt_row,vrt_name,min_x,max_x,min_y,max_y):
# def main(tiles_file,outfile,sub_img):


import numpy as np
import argparse
import os
import sys
import json
import shutil
import multiprocessing
import collections
import subprocess
import glob
import s2p
        import rasterio
from utils import s2p_mosaic
                                  "apt-get install gdal-bin libgdal-dev\n"))
    except ImportError:
        raise AssertionError('rasterio does not seem to be installed.')


def unit_image_keypoints():

    kpts = s2p.sift.image_keypoints('tests/data/input_triplet/img_02.tif', 100, 100, 200, 200)

    test_kpts = np.loadtxt(kpts)
    ref_kpts  = np.loadtxt('tests/data/expected_output/units/unit_image_keypoints.txt')

    test_set = set(map(tuple,test_kpts[:,0:2]))
    ref_set = set(map(tuple,ref_kpts[:,0:2]))

    print(str(test_kpts.shape[0]-len(test_set))+" spatially redundant kpts found in test")
    print(str(ref_kpts.shape[0]-len(ref_set))+" spatially redundant kpts found in ref")

    common_set = test_set.intersection(ref_set)

    print(str(len(test_set)-len(common_set))+" kpts found in test but not in ref")
    print(str(len(ref_set)-len(common_set))+" kpts found in ref but not in test")

    dist_tol = 0.01

    nb_test_not_in_ref = 0
    for i in range(test_kpts.shape[0]):
        found = False
        for j in range(ref_kpts.shape[0]):
            dist = np.linalg.norm(test_kpts[i,0:2]-ref_kpts[j,0:2])

# Path: utils/s2p_mosaic.py
# def vrt_body_source(fname,band,src_x,src_y,src_w,src_h,dst_x,dst_y,dst_w,dst_h):
# def vrt_header(w,h,dataType='Float32'):
# def vrt_footer():
# def global_extent(tiles):
# def write_row_vrts(tiles,sub_img,vrt_basename,min_x,max_x):
# def write_main_vrt(vrt_row,vrt_name,min_x,max_x,min_y,max_y):
# def main(tiles_file,outfile,sub_img):


# Path: tests/test_s2p.py
import numpy as np
import argparse
import os
import sys
import json
import shutil
import multiprocessing
import collections
import subprocess
import glob
import s2p
        import rasterio
from utils import s2p_mosaic

                                  "apt-get install gdal-bin libgdal-dev\n"))
    except ImportError:
        raise AssertionError('rasterio does not seem to be installed.')


def unit_image_keypoints():

    kpts = s2p.sift.image_keypoints('tests/data/input_triplet/img_02.tif', 100, 100, 200, 200)

    test_kpts = np.loadtxt(kpts)
    ref_kpts  = np.loadtxt('tests/data/expected_output/units/unit_image_keypoints.txt')

    test_set = set(map(tuple,test_kpts[:,0:2]))
    ref_set = set(map(tuple,ref_kpts[:,0:2]))

    print(str(test_kpts.shape[0]-len(test_set))+" spatially redundant kpts found in test")
    print(str(ref_kpts.shape[0]-len(ref_set))+" spatially redundant kpts found in ref")

    common_set = test_set.intersection(ref_set)

    print(str(len(test_set)-len(common_set))+" kpts found in test but not in ref")
    print(str(len(ref_set)-len(common_set))+" kpts found in ref but not in test")

    dist_tol = 0.01

    nb_test_not_in_ref = 0
    for i in range(test_kpts.shape[0]):
        found = False
        for j in range(ref_kpts.shape[0]):
            dist = np.linalg.norm(test_kpts[i,0:2]-ref_kpts[j,0:2])

            if dist<dist_tol: