def test_get_distance_to_nearest_keypoint(self): ''' Shall create vector of distances ''' keyPoints1, descr1 = find_key_points(self.img1, nFeatures=self.nFeatures) keyPoints2, descr2 = find_key_points(self.img2, nFeatures=self.nFeatures) x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1, keyPoints2, descr2) dist = get_distance_to_nearest_keypoint(x1, y1, self.img1.shape) plt.imsave('sea_ice_drift_tests_%s.png' % inspect.currentframe().f_code.co_name, dist) self.assertEqual(dist.shape, self.img1.shape)
def test_get_displacement_pix(self): ''' Shall find matching coordinates and plot quiver in pixel/line''' keyPoints1, descr1 = find_key_points(self.img1, nFeatures=self.nFeatures) keyPoints2, descr2 = find_key_points(self.img2, nFeatures=self.nFeatures) x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1, keyPoints2, descr2) u, v = get_displacement_pix(self.n1, x1, y1, self.n2, x2, y2) plt.quiver(x1, y1, u, v) plt.savefig('sea_ice_drift_tests_%s.png' % inspect.currentframe().f_code.co_name) plt.close('all') self.assertEqual(len(u), len(x1))
def test_get_displacement_km(self): ''' Shall find matching coordinates and plot quiver in lon/lat''' keyPoints1, descr1 = find_key_points(self.img1, nFeatures=self.nFeatures) keyPoints2, descr2 = find_key_points(self.img2, nFeatures=self.nFeatures) x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1, keyPoints2, descr2) h = get_displacement_km(self.n1, x1, y1, self.n2, x2, y2) plt.scatter(x1, y1, 30, h) plt.colorbar() plt.savefig('sea_ice_drift_tests_%s.png' % inspect.currentframe().f_code.co_name) plt.close('all') self.assertTrue(len(h) == len(x1))
def test_interpolation_near(self): keyPoints1, descr1 = find_key_points(self.img1, nFeatures=self.nFeatures) keyPoints2, descr2 = find_key_points(self.img2, nFeatures=self.nFeatures) x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1, keyPoints2, descr2) x2p1, y2p1 = interpolation_near(x1, y1, x2, y2, x1, y1) plt.subplot(1,2,1) plt.plot(x2, x2p1, '.') plt.subplot(1,2,2) plt.plot(y2, y2p1, '.') plt.savefig('sea_ice_drift_tests_%s.png' % inspect.currentframe().f_code.co_name) plt.close('all') self.assertEqual(len(x2p1), len(x1))
def test_get_drift_vectors(self): keyPoints1, descr1 = find_key_points(self.img1, nFeatures=self.nFeatures) keyPoints2, descr2 = find_key_points(self.img2, nFeatures=self.nFeatures) x1, y1, x2, y2 = get_match_coords(keyPoints1, descr1, keyPoints2, descr2) u, v, lon1, lat1, lon2, lat2 = get_drift_vectors(self.n1, x1, y1, self.n2, x2, y2) plt.plot(lon1, lat1, '.') plt.plot(lon2, lat2, '.') plt.quiver(lon1, lat1, u, v, angles='xy', scale_units='xy', scale=0.25) plt.savefig('sea_ice_drift_tests_%s.png' % inspect.currentframe().f_code.co_name) plt.close('all') self.assertEqual(len(u), len(x1)) self.assertEqual(len(v), len(x1))
def setUp(self): super(SeaIceDriftFTLibTests, self).setUp() self.keyPoints1, self.descr1 = find_key_points( self.img1, nFeatures=self.nFeatures) self.keyPoints2, self.descr2 = find_key_points( self.img2, nFeatures=self.nFeatures)