Computes the Coverage between two sets of point-clouds. Args: sample_pcs (numpy array SxKx3): the S point-clouds, each of K points that will be matched and compared to a set of "reference" point-clouds. ref_pcs (numpy array RxKx3): the R point-clouds, each of K poi
(sample_pcs, ref_pcs, batch_size, normalize=True, sess=None, verbose=False, use_sqrt=False, use_EMD=False,
ret_dist=False)
| 76 | |
| 77 | |
| 78 | def coverage(sample_pcs, ref_pcs, batch_size, normalize=True, sess=None, verbose=False, use_sqrt=False, use_EMD=False, |
| 79 | ret_dist=False): |
| 80 | '''Computes the Coverage between two sets of point-clouds. |
| 81 | Args: |
| 82 | sample_pcs (numpy array SxKx3): the S point-clouds, each of K points that will be matched |
| 83 | and compared to a set of "reference" point-clouds. |
| 84 | ref_pcs (numpy array RxKx3): the R point-clouds, each of K points that constitute the |
| 85 | set of "reference" point-clouds. |
| 86 | batch_size (int): specifies how large will the batches be that the compute will use to |
| 87 | make the comparisons of the sample-vs-ref point-clouds. |
| 88 | normalize (boolean): if True, the distances are normalized by diving them with |
| 89 | the number of the points of the point-clouds (n_pc_points). |
| 90 | use_sqrt (boolean): When the matching is based on Chamfer (default behavior), if True, |
| 91 | the Chamfer is computed based on the (not-squared) euclidean distances of the matched |
| 92 | point-wise euclidean distances. |
| 93 | sess (tf.Session): If None, it will make a new Session for this. |
| 94 | use_EMD (boolean): If true, the matchings are based on the EMD. |
| 95 | ret_dist (boolean): If true, it will also return the distances between each sample_pcs and |
| 96 | it's matched ground-truth. |
| 97 | Returns: the coverage score (int), |
| 98 | the indices of the ref_pcs that are matched with each sample_pc |
| 99 | and optionally the matched distances of the samples_pcs. |
| 100 | ''' |
| 101 | n_ref, n_pc_points, pc_dim = ref_pcs.shape |
| 102 | n_sam, n_pc_points_s, pc_dim_s = sample_pcs.shape |
| 103 | |
| 104 | if n_pc_points != n_pc_points_s or pc_dim != pc_dim_s: |
| 105 | raise ValueError('Incompatible Point-Clouds.') |
| 106 | |
| 107 | ref_pl, sample_pl, best_in_batch, loc_of_best, sess = minimum_mathing_distance_tf_graph(n_pc_points, |
| 108 | normalize=normalize, |
| 109 | sess=sess, |
| 110 | use_sqrt=use_sqrt, |
| 111 | use_EMD=use_EMD) |
| 112 | matched_gt = [] |
| 113 | matched_dist = [] |
| 114 | for i in xrange(n_sam): |
| 115 | best_in_all_batches = [] |
| 116 | loc_in_all_batches = [] |
| 117 | |
| 118 | if verbose and i % 50 == 0: |
| 119 | |
| 120 | i |
| 121 | |
| 122 | for ref_chunk in iterate_in_chunks(ref_pcs, batch_size): |
| 123 | feed_dict = {ref_pl: np.expand_dims(sample_pcs[i], 0), sample_pl: ref_chunk} |
| 124 | b, loc = sess.run([best_in_batch, loc_of_best], feed_dict=feed_dict) |
| 125 | best_in_all_batches.append(b) |
| 126 | loc_in_all_batches.append(loc) |
| 127 | |
| 128 | best_in_all_batches = np.array(best_in_all_batches) |
| 129 | b_hit = np.argmin(best_in_all_batches) # In which batch the minimum occurred. |
| 130 | matched_dist.append(np.min(best_in_all_batches)) |
| 131 | hit = np.array(loc_in_all_batches)[b_hit] |
| 132 | matched_gt.append(batch_size * b_hit + hit) |
| 133 | |
| 134 | cov = len(np.unique(matched_gt)) / float(n_ref) |
| 135 |
nothing calls this directly
no test coverage detected