Unverified Commit b4ca7a57 authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Various bug fixes (#422)

* Fixed variable name

* Added a try catch for when orb can't find a point

* Fixed NetworkNode creation

* Typo fix

* Added km to meters conversion

* Added a check that the point stays in the overlap

* Removed in geom check

* Fixed acn_overlaps kwarg call

* Added geom in overlap check
parent 4c916693
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ class Node(dict, MutableMapping):
        self['node_id'] = node_id
        self['hash'] = image_name
        self.masks = pd.DataFrame()
        self.ignore = False

    @property
    def camera(self):
@@ -100,6 +99,16 @@ class Node(dict, MutableMapping):
    def keypoints(self, kps):
        self._keypoints = kps

    @property
    def ignore(self):
        if not hasattr(self, '_ignore'):
            self._ignore = False
        return self._ignore

    @ignore.setter
    def ignore(self, ignore):
        self._ignore = ignore

    def __repr__(self):
        return """
        NodeID: {}
+29 −13
Original line number Diff line number Diff line
@@ -195,7 +195,11 @@ def place_points_in_overlap(nodes, geom, cam_type="csm",

        # Extract ORB features in a sub-image around the desired point
        image, _, _ = clip_roi(node.geodata, sample, line, size_x=size, size_y=size)
        try:
            interesting = extract_most_interesting(image)
        except:
            warnings.warn('Could not find an interesting feature around point')
            continue

        # kps are in the image space with upper left origin, so convert to
        # center origin and then convert back into full image space
@@ -204,30 +208,42 @@ def place_points_in_overlap(nodes, geom, cam_type="csm",

        # Get the updated lat/lon from the feature in the node
        if cam_type == "isis":
            p = isis.point_info(node["image_path"], newsample, newline, pointtype="image")
            p = isis.point_info(node["image_path"], newsample, newline, point_type="image")
            x, y, z = p["GroundPoint"]["BodyFixedCoordinate"].value
            if p["GroundPoint"]["BodyFixedCoordinate"].units.lower() == "km":
                x = x * 1000
                y = y * 1000
                z = z * 1000
        elif cam_type == "csm":
            image_coord = csmapi.ImageCoord(newline, newsample)
            pcoord = node.camera.imageToGround(image_coord)
            # Get the BCEF coordinate from the lon, lat
            lon, lat, _ = reproject([pcoord.x, pcoord.y, pcoord.z], semi_major, semi_minor,
                            'geocent', 'latlon')
            updated_lon, updated_lat, _ = reproject([pcoord.x, pcoord.y, pcoord.z],
                                                    semi_major, semi_minor, 'geocent', 'latlon')

            # Get the new DEM height
            if dem is None:
                height = 0
                updated_height = 0
            else:
                px, py = dem.latlon_to_pixel(lat, lon)
                height = dem.read_array(1, [px, py, 1, 1])[0][0]
                px, py = dem.latlon_to_pixel(updated_lat, updated_lon)
                updated_height = dem.read_array(1, [px, py, 1, 1])[0][0]


            # Get the BCEF coordinate from the lon, lat
            x, y, z = reproject([lon, lat, height], semi_major, semi_minor,
                                'latlon', 'geocent')
            x, y, z = reproject([updated_lon, updated_lat, updated_height],
                                semi_major, semi_minor, 'latlon', 'geocent')

        geom = shapely.geometry.Point(x, y, z)
        point = Points(apriori=geom,
                       adjusted=geom,
        # If the updated point is outside of the overlap, then revert back to the
        # original point and hope the matcher can handle it when sub-pixel registering
        updated_lon, updated_lat, updated_height = reproject([x, y, z], semi_major, semi_minor,
                                                             'geocent', 'latlon')
        if not geom.contains(shapely.geometry.Point(updated_lon, updated_lat)):
            x, y, z = reproject([lon, lat, height],
                                semi_major, semi_minor, 'latlon', 'geocent')

        point_geom = shapely.geometry.Point(x, y, z)
        point = Points(apriori=point_geom,
                       adjusted=point_geom,
                       pointtype=2, # Would be 3 or 4 for ground
                       cam_type=cam_type)

@@ -237,7 +253,7 @@ def place_points_in_overlap(nodes, geom, cam_type="csm",
                image_coord = node.camera.groundToImage(gnd)
                sample, line = image_coord.samp, image_coord.line
            if cam_type == "isis":
                line, sample = isis.ground_to_image(node["image_path"], lon ,lat)
                line, sample = isis.ground_to_image(node["image_path"], updated_lon, updated_lat)

            point.measures.append(Measures(sample=sample,
                                           line=line,
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ def main(msg, config):

    print('Placing points in overlap', oid)
    points = place_points_in_overlap(nodes, geom, msg["cam_type"],
                                     msg['distribute_points_kwargs'])
                                     distribute_points_kwargs=msg['distribute_points_kwargs'])

    print('Adding {} points to the database.'.format(len(points)))
    Points.bulkadd(points)
+4 −4

File changed.

Contains only whitespace changes.