Loading .travis.yml +7 −5 Original line number Diff line number Diff line Loading @@ -34,10 +34,12 @@ install: # Install the non-conda packages if required, requirements.txt duplicates are ignored - conda install -c https://conda.anaconda.org/jlaura opencv3=3.0.0 - conda config --add channels conda-forge - conda install runipy - conda install -c https://conda.anaconda.org/conda-forge gdal h5py - pip install -r requirements.txt - pip install coverage - pip install coveralls - python runipynbs.py script: - nosetests --with-coverage --cover-package=autocnet Loading @@ -48,16 +50,16 @@ after_success: notifications: webhooks: urls: - https://webhooks.gitter.im/e/6cbe4b65fff6764ed80f # - https://webhooks.gitter.im/e/6cbe4b65fff6764ed80f on_success: always on_failure: always on_start: never email: recipients: - kberry@usgs.gov - dmlytle@usgs.gov - jwbacker@usgs.gov - krodriguez@usgs.gov # - kberry@usgs.gov # - dmlytle@usgs.gov # - jwbacker@usgs.gov # - krodriguez@usgs.gov on_success: always on_failure: always autocnet/cg/cg.py +56 −0 Original line number Diff line number Diff line import json import ogr import pandas as pd from scipy.spatial import ConvexHull Loading Loading @@ -45,3 +47,57 @@ def overlapping_polygon_area(polys): intersection = intersection.Intersection(geom) area = intersection.GetArea() return area def convex_hull(points): """ Parameters ---------- points : ndarray (n, 2) array of point coordinates Returns ------- hull : 2-D convex hull Provides a convex hull that is used to determine coverage """ if isinstance(points, pd.DataFrame) : points = pd.DataFrame.as_matrix(points) hull = ConvexHull(points) return hull def two_poly_overlap(poly1, poly2): """ Parameters ---------- poly1 : ogr polygon Any polygon that shares some kind of overlap with poly2 poly2 : ogr polygon Any polygon that shares some kind of overlap with poly1 Returns ------- overlap_info : list Percentage of overlap between the two images and the area that is being overlapped """ a_o = poly2.Intersection(poly1).GetArea() area1 = poly1.GetArea() area2 = poly2.GetArea() overlap_area = a_o overlap_percn = (a_o / (area1 + area2 - a_o)) * 100 overlap_info = [overlap_percn, overlap_area] return overlap_info autocnet/cg/tests/test_cg.py +13 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ sys.path.insert(0, os.path.abspath('..')) import numpy as np from .. import cg from osgeo import ogr class TestArea(unittest.TestCase): Loading @@ -19,3 +20,15 @@ class TestArea(unittest.TestCase): ratio = cg.convex_hull_ratio(self.pts, total_area) self.assertAlmostEqual(0.7566490, ratio, 5) def test_overlap(self): wkt1 = "POLYGON ((0 40, 40 40, 40 0, 0 0, 0 40))" wkt2 = "POLYGON ((20 60, 60 60, 60 20, 20 20, 20 60))" poly1 = ogr.CreateGeometryFromWkt(wkt1) poly2 = ogr.CreateGeometryFromWkt(wkt2) info = cg.two_poly_overlap(poly1, poly2) self.assertEqual(info[1], 400) self.assertAlmostEqual(info[0], 14.285714285) No newline at end of file autocnet/fileio/notebooks/Protocol Buffers.ipynbdeleted 100644 → 0 +0 −44 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python import autocnet.fileio.ControlNetFileV0002_pb2 as spec ``` %% Cell type:code id: tags: ``` python print dir(spec) ``` %% Output ['ControlNetFileHeaderV0002', 'ControlPointFileEntryV0002', 'DESCRIPTOR', '_CONTROLNETFILEHEADERV0002', '_CONTROLPOINTFILEENTRYV0002', '_CONTROLPOINTFILEENTRYV0002_APRIORISOURCE', '_CONTROLPOINTFILEENTRYV0002_MEASURE', '_CONTROLPOINTFILEENTRYV0002_MEASURE_MEASURELOGDATA', '_CONTROLPOINTFILEENTRYV0002_MEASURE_MEASURETYPE', '_CONTROLPOINTFILEENTRYV0002_POINTLOGDATA', '_CONTROLPOINTFILEENTRYV0002_POINTTYPE', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'descriptor', 'descriptor_pb2', 'message', 'reflection'] %% Cell type:code id: tags: ``` python header = spec.ControlNetFileHeaderV0002() header.created = "12/4/15" header.description = "Just a date" header.lastModified = "12/4/15" header.networkId = "This is the ID" #header.pointMessageSizes = 1.0 header.targetName = "Moon" header.userName = "my name" header_buffer = header.SerializeToString() ``` %% Cell type:code id: tags: ``` python header_buffer ``` %% Output '\n\x0eThis is the ID\x12\x04Moon\x1a\x0712/4/15"\x0712/4/15*\x0bJust a date2\x07my name' %% Cell type:code id: tags: ``` python ``` autocnet/graph/edge.py +23 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ from autocnet.matcher import suppression_funcs as spf from autocnet.matcher import subpixel as sp from autocnet.transformation.transformations import FundamentalMatrix, Homography from autocnet.vis.graph_view import plot_edge from autocnet.cg import cg class Edge(dict, MutableMapping): Loading @@ -31,6 +32,11 @@ class Edge(dict, MutableMapping): With key equal to an autoincrementing integer and value equal to a dict of parameters used to generate this realization. weight : dict Dictionary with two keys overlap_area, and overlap_percn overlap_area returns the area overlaped by both images overlap_percn retuns the total percentage of overlap """ def __init__(self, source=None, destination=None): Loading @@ -41,6 +47,8 @@ class Edge(dict, MutableMapping): self.fundamental_matrix = None self._subpixel_offsets = None self.weight = {} self._observers = set() # Subscribe the heatlh observer Loading Loading @@ -410,3 +418,18 @@ class Edge(dict, MutableMapping): mask = pd.Series(True, self.matches.index) return matches, mask def overlap(self): """ Acts on an edge and returns the overlap area and percentage of overlap between the two images on the edge. Data is returned to the weight dictionary """ poly1 = self.source.geodata.footprint poly2 = self.destination.geodata.footprint overlapinfo = cg.two_poly_overlap(poly1, poly2) self.weight['overlap_area'] = overlapinfo[1] self.weight['overlap_percn'] = overlapinfo[0] Loading
.travis.yml +7 −5 Original line number Diff line number Diff line Loading @@ -34,10 +34,12 @@ install: # Install the non-conda packages if required, requirements.txt duplicates are ignored - conda install -c https://conda.anaconda.org/jlaura opencv3=3.0.0 - conda config --add channels conda-forge - conda install runipy - conda install -c https://conda.anaconda.org/conda-forge gdal h5py - pip install -r requirements.txt - pip install coverage - pip install coveralls - python runipynbs.py script: - nosetests --with-coverage --cover-package=autocnet Loading @@ -48,16 +50,16 @@ after_success: notifications: webhooks: urls: - https://webhooks.gitter.im/e/6cbe4b65fff6764ed80f # - https://webhooks.gitter.im/e/6cbe4b65fff6764ed80f on_success: always on_failure: always on_start: never email: recipients: - kberry@usgs.gov - dmlytle@usgs.gov - jwbacker@usgs.gov - krodriguez@usgs.gov # - kberry@usgs.gov # - dmlytle@usgs.gov # - jwbacker@usgs.gov # - krodriguez@usgs.gov on_success: always on_failure: always
autocnet/cg/cg.py +56 −0 Original line number Diff line number Diff line import json import ogr import pandas as pd from scipy.spatial import ConvexHull Loading Loading @@ -45,3 +47,57 @@ def overlapping_polygon_area(polys): intersection = intersection.Intersection(geom) area = intersection.GetArea() return area def convex_hull(points): """ Parameters ---------- points : ndarray (n, 2) array of point coordinates Returns ------- hull : 2-D convex hull Provides a convex hull that is used to determine coverage """ if isinstance(points, pd.DataFrame) : points = pd.DataFrame.as_matrix(points) hull = ConvexHull(points) return hull def two_poly_overlap(poly1, poly2): """ Parameters ---------- poly1 : ogr polygon Any polygon that shares some kind of overlap with poly2 poly2 : ogr polygon Any polygon that shares some kind of overlap with poly1 Returns ------- overlap_info : list Percentage of overlap between the two images and the area that is being overlapped """ a_o = poly2.Intersection(poly1).GetArea() area1 = poly1.GetArea() area2 = poly2.GetArea() overlap_area = a_o overlap_percn = (a_o / (area1 + area2 - a_o)) * 100 overlap_info = [overlap_percn, overlap_area] return overlap_info
autocnet/cg/tests/test_cg.py +13 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ sys.path.insert(0, os.path.abspath('..')) import numpy as np from .. import cg from osgeo import ogr class TestArea(unittest.TestCase): Loading @@ -19,3 +20,15 @@ class TestArea(unittest.TestCase): ratio = cg.convex_hull_ratio(self.pts, total_area) self.assertAlmostEqual(0.7566490, ratio, 5) def test_overlap(self): wkt1 = "POLYGON ((0 40, 40 40, 40 0, 0 0, 0 40))" wkt2 = "POLYGON ((20 60, 60 60, 60 20, 20 20, 20 60))" poly1 = ogr.CreateGeometryFromWkt(wkt1) poly2 = ogr.CreateGeometryFromWkt(wkt2) info = cg.two_poly_overlap(poly1, poly2) self.assertEqual(info[1], 400) self.assertAlmostEqual(info[0], 14.285714285) No newline at end of file
autocnet/fileio/notebooks/Protocol Buffers.ipynbdeleted 100644 → 0 +0 −44 Original line number Diff line number Diff line %% Cell type:code id: tags: ``` python import autocnet.fileio.ControlNetFileV0002_pb2 as spec ``` %% Cell type:code id: tags: ``` python print dir(spec) ``` %% Output ['ControlNetFileHeaderV0002', 'ControlPointFileEntryV0002', 'DESCRIPTOR', '_CONTROLNETFILEHEADERV0002', '_CONTROLPOINTFILEENTRYV0002', '_CONTROLPOINTFILEENTRYV0002_APRIORISOURCE', '_CONTROLPOINTFILEENTRYV0002_MEASURE', '_CONTROLPOINTFILEENTRYV0002_MEASURE_MEASURELOGDATA', '_CONTROLPOINTFILEENTRYV0002_MEASURE_MEASURETYPE', '_CONTROLPOINTFILEENTRYV0002_POINTLOGDATA', '_CONTROLPOINTFILEENTRYV0002_POINTTYPE', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'descriptor', 'descriptor_pb2', 'message', 'reflection'] %% Cell type:code id: tags: ``` python header = spec.ControlNetFileHeaderV0002() header.created = "12/4/15" header.description = "Just a date" header.lastModified = "12/4/15" header.networkId = "This is the ID" #header.pointMessageSizes = 1.0 header.targetName = "Moon" header.userName = "my name" header_buffer = header.SerializeToString() ``` %% Cell type:code id: tags: ``` python header_buffer ``` %% Output '\n\x0eThis is the ID\x12\x04Moon\x1a\x0712/4/15"\x0712/4/15*\x0bJust a date2\x07my name' %% Cell type:code id: tags: ``` python ```
autocnet/graph/edge.py +23 −0 Original line number Diff line number Diff line Loading @@ -13,6 +13,7 @@ from autocnet.matcher import suppression_funcs as spf from autocnet.matcher import subpixel as sp from autocnet.transformation.transformations import FundamentalMatrix, Homography from autocnet.vis.graph_view import plot_edge from autocnet.cg import cg class Edge(dict, MutableMapping): Loading @@ -31,6 +32,11 @@ class Edge(dict, MutableMapping): With key equal to an autoincrementing integer and value equal to a dict of parameters used to generate this realization. weight : dict Dictionary with two keys overlap_area, and overlap_percn overlap_area returns the area overlaped by both images overlap_percn retuns the total percentage of overlap """ def __init__(self, source=None, destination=None): Loading @@ -41,6 +47,8 @@ class Edge(dict, MutableMapping): self.fundamental_matrix = None self._subpixel_offsets = None self.weight = {} self._observers = set() # Subscribe the heatlh observer Loading Loading @@ -410,3 +418,18 @@ class Edge(dict, MutableMapping): mask = pd.Series(True, self.matches.index) return matches, mask def overlap(self): """ Acts on an edge and returns the overlap area and percentage of overlap between the two images on the edge. Data is returned to the weight dictionary """ poly1 = self.source.geodata.footprint poly2 = self.destination.geodata.footprint overlapinfo = cg.two_poly_overlap(poly1, poly2) self.weight['overlap_area'] = overlapinfo[1] self.weight['overlap_percn'] = overlapinfo[0]