features.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:PCL-ROS-cluster-Segmentation 作者: jupidity 项目源码 文件源码
def compute_color_histograms(cloud, using_hsv=False):

    numBins = 64
    # Compute histograms for the clusters
    point_colors_list = []

    # Step through each point in the point cloud
    for point in pc2.read_points(cloud, skip_nans=True):
        rgb_list = float_to_rgb(point[3])
        if using_hsv:
            point_colors_list.append(rgb_to_hsv(rgb_list) * 255)
        else:
            point_colors_list.append(rgb_list)

    # Populate lists with color values
    channel_1_vals = []
    channel_2_vals = []
    channel_3_vals = []


    for color in point_colors_list:
        channel_1_vals.append(color[0])
        channel_2_vals.append(color[1])
        channel_3_vals.append(color[2])

    # Compute histograms for the colors in the point cloud
    channel1_hist = np.histogram(channel_1_vals, bins=numBins, range=(0, 256))
    channel2_hist = np.histogram(channel_2_vals, bins=numBins, range=(0, 256))
    channel3_hist = np.histogram(channel_3_vals, bins=numBins, range=(0, 256))



    # Concatenate and normalize the histograms
    hist_features = np.concatenate((channel1_hist[0],channel2_hist[0], channel3_hist[0])).astype(np.float64)
    normed_features = hist_features / np.sum(hist_features)
    return normed_features
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号