Loading autocnet/camera/camera.py +31 −25 Original line number Diff line number Diff line import numpy as np import pandas as pd import cv2 def compute_epipoles(f): """ Loading Loading @@ -91,29 +93,26 @@ def triangulate(pt, pt1, p, p1): Returns ------- coords : ndarray (n, 4) array of triangulated coordinates in the form (x, y, z, a) (4, n) projection matrix """ npts = len(pt) a = np.zeros((4, 4)) coords = np.empty((npts, 4)) if isinstance(pt, pd.DataFrame): pt = pt.values if isinstance(pt1, pd.DataFrame): pt1 = pt.values for i in range(npts): # Compute AX = 0 a[0] = pt[i][0] * p[2] - p[0] a[1] = pt[i][1] * p[2] - p[1] a[2] = pt1[i][0] * p1[2] - p1[0] a[3] = pt1[i][1] * p1[2] - p1[1] # v.T is a least squares solution that minimizes the error residual u, s, vh = np.linalg.svd(a) v = vh.T coords[i] = v[:, 3] / (v[:, 3][-1]) return coords.T # Transpose for the openCV call if needed if pt.shape[0] != 3: pt = pt.T if pt1.shape[0] != 3: pt1 = pt1.T X = cv2.triangulatePoints(p, p1, pt[:2], pt1[:2]) # Homogenize X /= X[3] return X def projection_error(p1, p, pt, pt1): Loading Loading @@ -142,22 +141,29 @@ def projection_error(p1, p, pt, pt1): Returns ------- reproj_error : ndarray residuals : ndarray (n, 1) residuals for each correspondence cumulative_error : float sum of the residuals """ if p1.shape != (3,4): p1 = p1.reshape(3,4) # Triangulate the correspondences xw_est = triangulate(pt, pt1, p, p1) xhat = p.dot(xw_est).T xhat /= xhat[:, -1][:, np.newaxis] x2hat = p1.dot(xw_est).T x2hat /= x2hat[:, -1][:, np.newaxis] # Back project and homogenize xhat = np.dot(p, xw_est) xhat /= xhat[2] x2hat = np.dot(p1, xw_est) x2hat /= x2hat[2] # Compute residuals dist = (pt - xhat)**2 + (pt1 - x2hat)**2 reproj_error = np.sqrt(np.sum(dist, axis=1) / len(pt)) dist = (pt.T - xhat)**2 + (pt1.T - x2hat)**2 residuals = np.sum(dist, axis=0) reproj_error = np.sum(dist) return reproj_error return residuals, reproj_error autocnet/fileio/io_gdal.py +0 −5 Original line number Diff line number Diff line Loading @@ -214,11 +214,6 @@ class GeoDataset(object): xy_extent = self.xy_extent lowerlat, lowerlon = self.pixel_to_latlon(xy_extent[0][0], xy_extent[0][1]) upperlat, upperlon = self.pixel_to_latlon(xy_extent[1][0], xy_extent[1][1]) geom = {"type": "Polygon", "coordinates": [[[lowerlat, lowerlon], [lowerlat, upperlon], [upperlat, upperlon], [upperlat, lowerlon], [lowerlat, lowerlon]]]} self._latlon_extent = [(lowerlat, lowerlon), (upperlat, upperlon)] return self._latlon_extent Loading autocnet/graph/network.py +1 −1 Original line number Diff line number Diff line Loading @@ -276,7 +276,7 @@ class CandidateGraph(nx.Graph): hdf = None def match_features(self, **kwargs): def match_features(self, *args, **kwargs): """ For all connected edges in the graph, apply feature matching Loading autocnet/matcher/matcher.py +2 −2 Original line number Diff line number Diff line Loading @@ -55,8 +55,8 @@ def pattern_match(template, image, upsampling=16, func=cv2.TM_CCOEFF_NORMED, err if upsampling < 1: raise ValueError u_template = zoom(template, upsampling, order=1) u_image = zoom(image, upsampling, order=1) u_template = zoom(template, upsampling, order=3) u_image = zoom(image, upsampling, order=3) result = cv2.matchTemplate(u_image, u_template, method=func) min_corr, max_corr, min_loc, max_loc = cv2.minMaxLoc(result) Loading autocnet/utils/isis_serial_numbers.py +3 −3 Original line number Diff line number Diff line Loading @@ -86,15 +86,14 @@ def generate_serial_number(label): sub_group = find_nested_in_dict(label, search_position) serial_entry = sub_group[search_key] print(serial_entry) if serial_entry in search_translation.keys(): serial_entry = search_translation[serial_entry] elif '*' in search_translation.keys() and search_translation['*'] != '*': serial_entry = search_translation['*'] serial_number.append(serial_entry) except:pass print('HERE!') except: pass return '/'.join(serial_number) Loading @@ -103,6 +102,7 @@ class SerialNumberDecoder(pvl.decoder.PVLDecoder): A PVL Decoder class to handle cube label parsing for the purpose of creating a valid ISIS serial number. Inherits from the PVLDecoder in planetarypy's pvl module. """ def cast_unquoated_string(self, value): """ Overrides the parent class's method so that any un-quoted string type value found in the Loading Loading
autocnet/camera/camera.py +31 −25 Original line number Diff line number Diff line import numpy as np import pandas as pd import cv2 def compute_epipoles(f): """ Loading Loading @@ -91,29 +93,26 @@ def triangulate(pt, pt1, p, p1): Returns ------- coords : ndarray (n, 4) array of triangulated coordinates in the form (x, y, z, a) (4, n) projection matrix """ npts = len(pt) a = np.zeros((4, 4)) coords = np.empty((npts, 4)) if isinstance(pt, pd.DataFrame): pt = pt.values if isinstance(pt1, pd.DataFrame): pt1 = pt.values for i in range(npts): # Compute AX = 0 a[0] = pt[i][0] * p[2] - p[0] a[1] = pt[i][1] * p[2] - p[1] a[2] = pt1[i][0] * p1[2] - p1[0] a[3] = pt1[i][1] * p1[2] - p1[1] # v.T is a least squares solution that minimizes the error residual u, s, vh = np.linalg.svd(a) v = vh.T coords[i] = v[:, 3] / (v[:, 3][-1]) return coords.T # Transpose for the openCV call if needed if pt.shape[0] != 3: pt = pt.T if pt1.shape[0] != 3: pt1 = pt1.T X = cv2.triangulatePoints(p, p1, pt[:2], pt1[:2]) # Homogenize X /= X[3] return X def projection_error(p1, p, pt, pt1): Loading Loading @@ -142,22 +141,29 @@ def projection_error(p1, p, pt, pt1): Returns ------- reproj_error : ndarray residuals : ndarray (n, 1) residuals for each correspondence cumulative_error : float sum of the residuals """ if p1.shape != (3,4): p1 = p1.reshape(3,4) # Triangulate the correspondences xw_est = triangulate(pt, pt1, p, p1) xhat = p.dot(xw_est).T xhat /= xhat[:, -1][:, np.newaxis] x2hat = p1.dot(xw_est).T x2hat /= x2hat[:, -1][:, np.newaxis] # Back project and homogenize xhat = np.dot(p, xw_est) xhat /= xhat[2] x2hat = np.dot(p1, xw_est) x2hat /= x2hat[2] # Compute residuals dist = (pt - xhat)**2 + (pt1 - x2hat)**2 reproj_error = np.sqrt(np.sum(dist, axis=1) / len(pt)) dist = (pt.T - xhat)**2 + (pt1.T - x2hat)**2 residuals = np.sum(dist, axis=0) reproj_error = np.sum(dist) return reproj_error return residuals, reproj_error
autocnet/fileio/io_gdal.py +0 −5 Original line number Diff line number Diff line Loading @@ -214,11 +214,6 @@ class GeoDataset(object): xy_extent = self.xy_extent lowerlat, lowerlon = self.pixel_to_latlon(xy_extent[0][0], xy_extent[0][1]) upperlat, upperlon = self.pixel_to_latlon(xy_extent[1][0], xy_extent[1][1]) geom = {"type": "Polygon", "coordinates": [[[lowerlat, lowerlon], [lowerlat, upperlon], [upperlat, upperlon], [upperlat, lowerlon], [lowerlat, lowerlon]]]} self._latlon_extent = [(lowerlat, lowerlon), (upperlat, upperlon)] return self._latlon_extent Loading
autocnet/graph/network.py +1 −1 Original line number Diff line number Diff line Loading @@ -276,7 +276,7 @@ class CandidateGraph(nx.Graph): hdf = None def match_features(self, **kwargs): def match_features(self, *args, **kwargs): """ For all connected edges in the graph, apply feature matching Loading
autocnet/matcher/matcher.py +2 −2 Original line number Diff line number Diff line Loading @@ -55,8 +55,8 @@ def pattern_match(template, image, upsampling=16, func=cv2.TM_CCOEFF_NORMED, err if upsampling < 1: raise ValueError u_template = zoom(template, upsampling, order=1) u_image = zoom(image, upsampling, order=1) u_template = zoom(template, upsampling, order=3) u_image = zoom(image, upsampling, order=3) result = cv2.matchTemplate(u_image, u_template, method=func) min_corr, max_corr, min_loc, max_loc = cv2.minMaxLoc(result) Loading
autocnet/utils/isis_serial_numbers.py +3 −3 Original line number Diff line number Diff line Loading @@ -86,15 +86,14 @@ def generate_serial_number(label): sub_group = find_nested_in_dict(label, search_position) serial_entry = sub_group[search_key] print(serial_entry) if serial_entry in search_translation.keys(): serial_entry = search_translation[serial_entry] elif '*' in search_translation.keys() and search_translation['*'] != '*': serial_entry = search_translation['*'] serial_number.append(serial_entry) except:pass print('HERE!') except: pass return '/'.join(serial_number) Loading @@ -103,6 +102,7 @@ class SerialNumberDecoder(pvl.decoder.PVLDecoder): A PVL Decoder class to handle cube label parsing for the purpose of creating a valid ISIS serial number. Inherits from the PVLDecoder in planetarypy's pvl module. """ def cast_unquoated_string(self, value): """ Overrides the parent class's method so that any un-quoted string type value found in the Loading