Denys Rozumnyi
commited on
Commit
·
b130371
1
Parent(s):
a20b5fb
update
Browse files- geom_solver.py +12 -7
- testing.ipynb +0 -0
geom_solver.py
CHANGED
|
@@ -17,8 +17,9 @@ class GeomSolver(object):
|
|
| 17 |
|
| 18 |
def __init__(self):
|
| 19 |
self.min_vertices = 18
|
| 20 |
-
self.kmeans_th =
|
| 21 |
-
self.point_dist_th =
|
|
|
|
| 22 |
self.clr_th = 2.5
|
| 23 |
self.device = 'cuda:0'
|
| 24 |
self.return_edges = False
|
|
@@ -63,8 +64,8 @@ class GeomSolver(object):
|
|
| 63 |
selected_points[visible_counts < 1] = False
|
| 64 |
|
| 65 |
pnts = torch.from_numpy(self.xyz[selected_points].astype(np.float32))[None]
|
| 66 |
-
bdists, inds, nn = ball_query(pnts, pnts, K=3, radius=
|
| 67 |
-
dense_pnts = (bdists[0] > 0).sum(1) ==
|
| 68 |
|
| 69 |
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 200, 0.3)
|
| 70 |
flags = cv2.KMEANS_RANDOM_CENTERS
|
|
@@ -75,7 +76,7 @@ class GeomSolver(object):
|
|
| 75 |
for tempi in range(1, 20):
|
| 76 |
retval, temp_bestLabels, temp_centers = cv2.kmeans(self.xyz[selected_points][dense_pnts].astype(np.float32), tempi, None, criteria, 200,flags)
|
| 77 |
cpnts = torch.from_numpy(temp_centers.astype(np.float32))[None]
|
| 78 |
-
bdists, inds, nn = ball_query(cpnts, cpnts, K=
|
| 79 |
if bdists.max() > 0:
|
| 80 |
closest_nn = (bdists[bdists>0].min()**0.5).item()
|
| 81 |
else:
|
|
@@ -87,11 +88,15 @@ class GeomSolver(object):
|
|
| 87 |
centers, bestLabels = temp_centers, temp_bestLabels
|
| 88 |
|
| 89 |
point_inds = np.arange(self.xyz.shape[0])
|
|
|
|
| 90 |
for ci in range(centers.shape[0]):
|
| 91 |
assigned_inds = point_inds[selected_points][dense_pnts][bestLabels[:,0] == ci]
|
|
|
|
|
|
|
|
|
|
| 92 |
assigned_points.append(assigned_inds)
|
| 93 |
-
|
| 94 |
-
return
|
| 95 |
|
| 96 |
|
| 97 |
def process_vertices(self):
|
|
|
|
| 17 |
|
| 18 |
def __init__(self):
|
| 19 |
self.min_vertices = 18
|
| 20 |
+
self.kmeans_th = 130
|
| 21 |
+
self.point_dist_th = 60
|
| 22 |
+
self.th_min_support = 3
|
| 23 |
self.clr_th = 2.5
|
| 24 |
self.device = 'cuda:0'
|
| 25 |
self.return_edges = False
|
|
|
|
| 64 |
selected_points[visible_counts < 1] = False
|
| 65 |
|
| 66 |
pnts = torch.from_numpy(self.xyz[selected_points].astype(np.float32))[None]
|
| 67 |
+
bdists, inds, nn = ball_query(pnts, pnts, K=3, radius=40)
|
| 68 |
+
dense_pnts = (bdists[0] > 0).sum(1) == 3
|
| 69 |
|
| 70 |
criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 200, 0.3)
|
| 71 |
flags = cv2.KMEANS_RANDOM_CENTERS
|
|
|
|
| 76 |
for tempi in range(1, 20):
|
| 77 |
retval, temp_bestLabels, temp_centers = cv2.kmeans(self.xyz[selected_points][dense_pnts].astype(np.float32), tempi, None, criteria, 200,flags)
|
| 78 |
cpnts = torch.from_numpy(temp_centers.astype(np.float32))[None]
|
| 79 |
+
bdists, inds, nn = ball_query(cpnts, cpnts, K=2, radius=1.2*self.kmeans_th)
|
| 80 |
if bdists.max() > 0:
|
| 81 |
closest_nn = (bdists[bdists>0].min()**0.5).item()
|
| 82 |
else:
|
|
|
|
| 88 |
centers, bestLabels = temp_centers, temp_bestLabels
|
| 89 |
|
| 90 |
point_inds = np.arange(self.xyz.shape[0])
|
| 91 |
+
centers_selected = []
|
| 92 |
for ci in range(centers.shape[0]):
|
| 93 |
assigned_inds = point_inds[selected_points][dense_pnts][bestLabels[:,0] == ci]
|
| 94 |
+
if len(assigned_inds) < self.th_min_support:
|
| 95 |
+
continue
|
| 96 |
+
centers_selected.append(centers[ci])
|
| 97 |
assigned_points.append(assigned_inds)
|
| 98 |
+
centers_selected = np.stack(centers_selected)
|
| 99 |
+
return centers_selected, assigned_points
|
| 100 |
|
| 101 |
|
| 102 |
def process_vertices(self):
|
testing.ipynb
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|