(self, points, gt_boxes=None)
total_num_points = 0
        for i in range(self._max_num_points):
            num = np.sum(num_points.astype(np.int64) == i)
            total_num_points += num * i
            if num > 0:
                print(f"num={i} have {num} voxels")
        print("total_num_points", points.shape[0], total_num_points)
total_num_points = 0
        for i in range(self._max_num_points):
            num = np.sum(num_points.astype(np.int64) == i)
            total_num_points += num * i
            if num > 0:
                print(f"num={i} have {num} voxels")
        print("total_num_points", points.shape[0], total_num_points)
total_num_points = 0 for i in range ( self . _max_num_points ) : num = np . sum ( num_points . astype ( np . int64 ) == i ) total_num_points + = num * i if num > 0 : print ( f num = { i } have { num } voxels ) print ( total_num_points points . shape [ 0 ] total_num_points )
def draw_voxels(self, points, gt_boxes=None):
        pos_color = self.w_config.get("PosVoxelColor")[:3]
        pos_color = (*pos_color, self.w_config.get("PosVoxelAlpha"))
        neg_color = self.w_config.get("NegVoxelColor")[:3]
        neg_color = (*neg_color, self.w_config.get("NegVoxelAlpha"))

        voxel_size = np.array(self.w_config.get("VoxelSize"), dtype=np.float32)
        coors_range = np.array(
            self.w_config.get("CoorsRange"), dtype=np.float32)
        voxels, coors, num_points = points_to_voxel(
            points,
            voxel_size,
            coors_range,
            self._max_num_points,
            reverse_index=True,
            max_voxels=self._max_voxels)
        # print("num_voxels", num_points.shape[0])
        """
        total_num_points = 0
        for i in range(self._max_num_points):
            num = np.sum(num_points.astype(np.int64) == i)
            total_num_points += num * i
            if num > 0:
                print(f"num={i} have {num} voxels")
        print("total_num_points", points.shape[0], total_num_points)
        """
        grid_size = (coors_range[3:] - coors_range[:3]) / voxel_size
        grid_size = np.round(grid_size).astype(np.int64)

        shift = coors_range[:3]
        voxel_origins = coors[:, ::-1] * voxel_size + shift
        voxel_maxs = voxel_origins + voxel_size
        voxel_boxes = np.concatenate([voxel_origins, voxel_maxs], axis=1)
        voxel_box_corners = box_np_ops.minmax_to_corner_3d(voxel_boxes)
        pos_only = self.w_config.get("DrawPositiveVoxelsOnly")
        if gt_boxes is not None:
            labels = box_np_ops.assign_label_to_voxel(
                gt_boxes, coors, voxel_size, coors_range).astype(np.bool)
            if pos_only:
                voxel_box_corners = voxel_box_corners[labels]
            colors = np.zeros([voxel_box_corners.shape[0], 4])
            if pos_only:
                colors[:] = pos_color
            else:
                colors[np.logical_not(labels)] = neg_color
                colors[labels] = pos_color
        else:
            if not pos_only:
                colors = np.zeros([voxel_box_corners.shape[0], 4])
                colors[:] = neg_color
            else:
                voxel_box_corners = np.zeros((0, 8, 3))
                colors = np.zeros((0, 4))
        self.boxes3d("voxels", voxel_box_corners, colors)
def draw_voxels ( self , points , gt_boxes = None ) : pos_color = self . w_config . get ( "PosVoxelColor" ) [ : 3 ] pos_color = ( * pos_color , self . w_config . get ( "PosVoxelAlpha" ) ) neg_color = self . w_config . get ( "NegVoxelColor" ) [ : 3 ] neg_color = ( * neg_color , self . w_config . get ( "NegVoxelAlpha" ) ) voxel_size = np . array ( self . w_config . get ( "VoxelSize" ) , dtype = np . float32 ) coors_range = np . array ( self . w_config . get ( "CoorsRange" ) , dtype = np . float32 ) voxels , coors , num_points = points_to_voxel ( points , voxel_size , coors_range , self . _max_num_points , reverse_index = True , max_voxels = self . _max_voxels ) # print("num_voxels", num_points.shape[0]) grid_size = ( coors_range [ 3 : ] - coors_range [ : 3 ] ) / voxel_size grid_size = np . round ( grid_size ) . astype ( np . int64 ) shift = coors_range [ : 3 ] voxel_origins = coors [ : , : : - 1 ] * voxel_size + shift voxel_maxs = voxel_origins + voxel_size voxel_boxes = np . concatenate ( [ voxel_origins , voxel_maxs ] , axis = 1 ) voxel_box_corners = box_np_ops . minmax_to_corner_3d ( voxel_boxes ) pos_only = self . w_config . get ( "DrawPositiveVoxelsOnly" ) if gt_boxes is not None : labels = box_np_ops . assign_label_to_voxel ( gt_boxes , coors , voxel_size , coors_range ) . astype ( np . bool ) if pos_only : voxel_box_corners = voxel_box_corners [ labels ] colors = np . zeros ( [ voxel_box_corners . shape [ 0 ] , 4 ] ) if pos_only : colors [ : ] = pos_color else : colors [ np . logical_not ( labels ) ] = neg_color colors [ labels ] = pos_color else : if not pos_only : colors = np . zeros ( [ voxel_box_corners . shape [ 0 ] , 4 ] ) colors [ : ] = neg_color else : voxel_box_corners = np . zeros ( ( 0 , 8 , 3 ) ) colors = np . zeros ( ( 0 , 4 ) ) self . boxes3d ( "voxels" , voxel_box_corners , colors )