PCL:python pcl解码RGB- point_cloud2.read_points rgb
生活随笔
收集整理的這篇文章主要介紹了
PCL:python pcl解码RGB- point_cloud2.read_points rgb
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
參考:https://answers.ros.org/question/344096/subscribe-pointcloud-and-convert-it-to-numpy-in-python/
rgb在C++中的解碼方式為:???
unsigned long rgb = *reinterpret_cast<int*>(&cloud->points[i].rgb); int r = (rgb >> 16) & 0x0000ff; int g = (rgb >> 8) & 0x0000ff; int b = (rgb) & 0x0000ff;當然可以直接使用 data.r 方式獲取,編碼簡單,速度稍慢一些。
python代碼段:
test = x[3] # cast float32 to int so that bitwise operations are possibles = struct.pack('>f' ,test)i = struct.unpack('>l',s)[0]# you can get back the float value by the inverse operationspack = ctypes.c_uint32(i).valuer = (pack & 0x00FF0000)>> 16g = (pack & 0x0000FF00)>> 8b = (pack & 0x000000FF)# prints r,g,b values in the 0-255 range# x,y,z can be retrieved from the x[0],x[1],x[2]xyz = np.append(xyz,[[x[0],x[1],x[2]]], axis = 0)rgb = np.append(rgb,[[r,g,b]], axis = 0)可以解析出rgb
?
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的PCL:python pcl解码RGB- point_cloud2.read_points rgb的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 烟雨江湖丹青怎么用 带烟雨的诗句大全
- 下一篇: 贴贴怎么删照片(贴贴是什么梗)