kopia lustrzana https://github.com/OpenDroneMap/ODM
Avoid using delaney when bounds are actually a box
rodzic
276e53ba80
commit
ae1e36d829
|
@ -36,12 +36,37 @@ class PolyBounds(object):
|
|||
def corners(self):
|
||||
return self._corners
|
||||
|
||||
def points(self):
|
||||
return self.__points
|
||||
|
||||
class BoxBounds(PolyBounds):
|
||||
class BoxBounds(object):
|
||||
def __init__(self, x_min, x_max, y_min, y_max):
|
||||
super(BoxBounds, self).__init__([[x_min, y_max], [x_max, y_max], [x_max, y_min], [x_min, y_min]])
|
||||
self._corners = (x_min, x_max, y_min, y_max)
|
||||
|
||||
def keep_points_inside(self, point_cloud):
|
||||
"""Return a new point cloud with the points from the given cloud that are inside the bounds"""
|
||||
mask = self.calculate_mask(point_cloud)
|
||||
return point_cloud[mask]
|
||||
|
||||
def percentage_of_points_inside(self, points):
|
||||
if isinstance(points, PointCloud):
|
||||
points = points.get_xy()
|
||||
mask = self.calculate_mask(points)
|
||||
return np.count_nonzero(mask) * 100 / points.shape[0]
|
||||
|
||||
def calculate_mask(self, points):
|
||||
"""Calculate the mask that would filter out the points outside the bounds"""
|
||||
if isinstance(points, PointCloud):
|
||||
points = points.get_xy()
|
||||
(x_min, x_max, y_min, y_max) = self._corners
|
||||
min = np.array([x_min, y_min])
|
||||
max = np.array([x_max, y_max])
|
||||
|
||||
return np.all(np.logical_and(min <= points, points <= max), axis=1)
|
||||
|
||||
def center(self):
|
||||
(x_min, x_max, y_min, y_max) = self._corners
|
||||
return ((x_min + x_max) / 2, (y_min + y_max) / 2)
|
||||
|
||||
def corners(self):
|
||||
return self._corners
|
||||
|
||||
def area(self):
|
||||
(x_min, x_max, y_min, y_max) = self._corners
|
||||
|
|
|
@ -60,15 +60,8 @@ class SurroundingPartitions(PartitionPlan):
|
|||
closest_y_idx = np.argmin(np.abs(y - center_y))
|
||||
|
||||
# Calculate the direction to where the box should grow
|
||||
x_dir = np.sign(center_x - x[closest_x_idx])
|
||||
y_dir = np.sign(center_y - y[closest_y_idx])
|
||||
|
||||
# Handle corner case where center is between min and max
|
||||
if x_min <= center_x and center_x <= x_max:
|
||||
x_dir *= -1
|
||||
if y_min <= center_y and center_y <= y_max:
|
||||
y_dir *= -1
|
||||
|
||||
x_dir = -1 if closest_x_idx == 0 else 1
|
||||
y_dir = -1 if closest_y_idx == 0 else 1
|
||||
|
||||
bounding_box = BoxBounds(x[0], x[1], y[0], y[1])
|
||||
while bounding_box.area() < min_area:
|
||||
|
|
Ładowanie…
Reference in New Issue