Commit 7a15387c authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Merge pull request #148 from Kelvinrr/master

Visualize single node using edge clean keys
parents 127d9ffa 7e8be393
Loading
Loading
Loading
Loading
+23 −1
Changes for autocnet/graph/edge.py: 23 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ from autocnet.matcher import subpixel as sp
from autocnet.matcher.feature import FlannMatcher
from autocnet.transformation.transformations import FundamentalMatrix, Homography
from autocnet.vis.graph_view import plot_edge
from autocnet.vis.graph_view import plot_node
from autocnet.cg import cg


@@ -379,7 +380,28 @@ class Edge(dict, MutableMapping):
        mask[mask] = self.suppression.mask
        self.masks = ('suppression', mask)

    def plot(self, ax=None, clean_keys=[], **kwargs):
    def plot_source(self, ax=None, clean_keys=[], **kwargs):  # pragma: no cover
        matches, mask = self.clean(clean_keys=clean_keys)
        indices = pd.Index(matches['source_idx'].values)
        return plot_node(self.source, index_mask=indices, **kwargs)

    def plot_destination(self, ax=None, clean_keys=[], **kwargs):  # pragma: no cover
        matches, mask = self.clean(clean_keys=clean_keys)
        indices = pd.Index(matches['destination_idx'].values)
        return plot_node(self.destination, index_mask=indices, **kwargs)

    def plot(self, ax=None, clean_keys=[], node=None, **kwargs):  # pragma: no cover
        dest_keys = [0, '0', 'destination', 'd', 'dest']
        source_keys = [1, '1', 'source', 's']

        # If node is not none, plot a single node
        if node in source_keys:
            return self.plot_source(self, clean_keys=clean_keys, **kwargs)

        elif node in dest_keys:
            return self.plot_destination(self, clean_keys=clean_keys, **kwargs)

        # Else, plot the whole edge
        return plot_edge(self, ax=ax, clean_keys=clean_keys, **kwargs)

    def clean(self, clean_keys, pid=None):
+8 −7
Changes for autocnet/vis/graph_view.py: 8 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ def plot_graph(graph, ax=None, cmap='Spectral', **kwargs):
    return ax


def plot_node(node, ax=None, clean_keys=[], **kwargs):
def plot_node(node, ax=None, clean_keys=[], index_mask=None, **kwargs):
    """
    Plot the array and keypoints for a given node.

@@ -88,10 +88,11 @@ def plot_node(node, ax=None, clean_keys=[], **kwargs):

    ax.imshow(array, cmap=cmap)

    keypoints = node.get_keypoints()
    if clean_keys:
        matches, mask = node.clean(clean_keys)
        keypoints = node.get_keypoints()[mask]
    keypoints = node.get_keypoints(index=index_mask)
    # Node has no clean method
    # if clean_keys:
    #     matches, mask = node.clean(clean_keys)
    #     keypoints = keypoints[mask]

    marker = '.'
    if 'marker' in kwargs.keys():
@@ -169,8 +170,6 @@ def plot_edge(edge, ax=None, clean_keys=[], image_space=100,
    else:
        cmap = 'Greys'

    ax.imshow(composite, cmap=cmap)

    matches, mask = edge.clean(clean_keys)

    source_keypoints = edge.source.get_keypoints(index=matches['source_idx'])
@@ -188,6 +187,8 @@ def plot_edge(edge, ax=None, clean_keys=[], image_space=100,
    newx = d_kps['x'] + x_offset
    ax.scatter(newx, d_kps['y'], **scatter_kwargs)

    ax.imshow(composite, cmap=cmap)

    # Draw the connecting lines
    color = 'y'
    if 'color' in line_kwargs.keys():
+490 −0

File added.

Preview size limit exceeded, changes collapsed.

+77 −17

File changed.

Preview size limit exceeded, changes collapsed.