Cylinder3D icon indicating copy to clipboard operation
Cylinder3D copied to clipboard

Visualization

Open derkaczda opened this issue 3 years ago • 16 comments

Hey, thank you for the great paper and code! Does there exist code to visualize the predictions? I couldn't find it.

Thanks in advance!

derkaczda avatar Aug 26 '21 09:08 derkaczda

We use Open3D to visulize the results and the color map is shown in the yaml;

Another alternative is to utilize the visualization method shown in SECOND repo.

xinge008 avatar Aug 27 '21 01:08 xinge008

Thanks for the quick response! For the Open3D approach do you have code published for this project?

derkaczda avatar Aug 27 '21 08:08 derkaczda

Thanks for the quick response! For the Open3D approach do you have code published for this project? I just have a simple one for viz. you need it?

OuyangJunyuan avatar Sep 16 '21 07:09 OuyangJunyuan

Thanks @OuyangJunyuan, I would like to have the code for your simple viz. You can send it via mail [email protected]. Thank you very much :)

derkaczda avatar Sep 17 '21 07:09 derkaczda

Thanks @OuyangJunyuan, I would like to have the code for your simple viz. You can send it via mail [email protected]. Thank you very much :)

hi, could you please share it with me? thanks a lot! my email is : [email protected]

Carl12138aka avatar Sep 25 '21 13:09 Carl12138aka

Thanks @OuyangJunyuan, I would like to have the code for your simple viz. You can send it via mail [email protected]. Thank you very much :)

hi, could you please share it with me? thanks a lot! my email is : [email protected]

of course~

OuyangJunyuan avatar Sep 25 '21 14:09 OuyangJunyuan

Thanks for the quick response! For the Open3D approach do you have code published for this project? I just have a simple one for viz. you need it?

hi, Sorry for bother you.. but could you send it to me? my email is : [email protected]

gwag00 avatar Sep 26 '21 08:09 gwag00

@OuyangJunyuan hi,could you please share it with me ? My email is [email protected] Thank you very much!!!

artofstate avatar Sep 29 '21 13:09 artofstate

Thanks for the quick response! For the Open3D approach do you have code published for this project? I just have a simple one for viz. you need it?

hi, could you please share the vis code with me? My email is [email protected] Thank you very much!!!

TimGor1997 avatar Oct 29 '21 11:10 TimGor1997

Thanks @OuyangJunyuan, I would like to have the code for your simple viz. You can send it via mail [email protected]. Thank you very much :)

hi, could you please share the vis code with me? My email is [email protected] Thank you very much!!!

TimGor1997 avatar Oct 29 '21 11:10 TimGor1997

If possible, could you please post the visualization code on the issue for us to do quick visual with Open3D

Kin-Zhang avatar Nov 05 '21 15:11 Kin-Zhang

I already wrote @OuyangJunyuan about that couple of weeks ago but did not get any reply, I don't want to post his code without his consent.

derkaczda avatar Nov 05 '21 17:11 derkaczda

I already wrote @OuyangJunyuan about that couple of weeks ago but did not get any reply, I don't want to post his code without his consent.

oh!it's rarely to check my email. I will show it flowing ,just very simple and crude one:

import numpy as np
import yaml
import open3d
from pathlib import Path

 
points_dir = Path('/home/ou/Documents/dataset/my_pvrcnn_dataset(gazebo)/kitti/object/training/velodyne') # path to .bin data
label_dir = Path('/home/ou/workspace/code/Cylinder3D-master/my_result') # path to .label data

label_filter = [40, 48, 70, 72]    # object's label which you wan't to show
# label_filter = []
with open('/home/ou/workspace/code/Cylinder3D-master/config/label_mapping/semantic-kitti.yaml', 'r') as stream: # label_mapping configuration file
    label_mapping = yaml.safe_load(stream)
    color_dict = label_mapping['color_map']


def get_rgb_list(_label):
    c = color_dict[_label]
    return np.array((c[2], c[1], c[0]))


def draw_pc(pc_xyzrgb):
    pc = open3d.geometry.PointCloud()
    pc.points = open3d.utility.Vector3dVector(pc_xyzrgb[:, 0:3])
    pc.colors = open3d.utility.Vector3dVector(pc_xyzrgb[:, 3:6] / 255.)

    def custom_draw_geometry_with_key_callback(pcd):
        def change_background_to_black(vis):
            opt = vis.get_render_option()
            opt.background_color = np.asarray([0, 0, 0])
            opt.point_size = 1
            return False

        key_to_callback = {}
        key_to_callback[ord("K")] = change_background_to_black
        open3d.visualization.draw_geometries_with_key_callbacks([pcd], key_to_callback)

    custom_draw_geometry_with_key_callback(pc)


def concate_color(_points, _label):
    color = np.zeros((_points.shape[0], 3))
    label_id = np.unique(_label)
    for cls in label_id:
        if label_filter.__len__() == 0:
            color[_label == cls] = get_rgb_list(cls)
        elif label_filter.count(cls) == 0:
            color[_label == cls] = get_rgb_list(cls)
    _points = np.concatenate([_points, color], axis=1)
    return _points


for it in label_dir.iterdir():
    label_file = it
    points_file = points_dir / (str(it.stem) + '.bin')
    label = np.fromfile(label_file, dtype=np.uint32)
    points = np.fromfile(points_file, dtype=np.float32).reshape((-1, 4))[:, 0:3]
    print(label.shape, points.shape)
    colorful_points = concate_color(points, label)
    draw_pc(colorful_points)

OuyangJunyuan avatar Nov 06 '21 04:11 OuyangJunyuan

Dear Junyuan,

Glad to hear from you! Thanks for your kindly reply!

Your help is greatly appreciated!

Best regards,

Tim

------------------ 原始邮件 ------------------ 发件人: "xinge008/Cylinder3D" @.>; 发送时间: 2021年11月6日(星期六) 中午12:54 @.>; @.@.>; 主题: Re: [xinge008/Cylinder3D] Visualization (#73)

I already wrote @OuyangJunyuan about that couple of weeks ago but did not get any reply, I don't want to post his code without his consent.

oh!it's rarely to check my email. I will show it flowing ,just very simple and crude one: import numpy as np import yaml import open3d from pathlib import Path points_dir = Path('/home/ou/Documents/dataset/my_pvrcnn_dataset(gazebo)/kitti/object/training/velodyne') # path to .bin data label_dir = Path('/home/ou/workspace/code/Cylinder3D-master/my_result') # path to .label data label_filter = [40, 48, 70, 72] # object's label which you wan't to show # label_filter = [] with open('/home/ou/workspace/code/Cylinder3D-master/config/label_mapping/semantic-kitti.yaml', 'r') as stream: # label_mapping configuration file label_mapping = yaml.safe_load(stream) color_dict = label_mapping['color_map'] def get_rgb_list(_label): c = color_dict[_label] return np.array((c[2], c[1], c[0])) def draw_pc(pc_xyzrgb): pc = open3d.geometry.PointCloud() pc.points = open3d.utility.Vector3dVector(pc_xyzrgb[:, 0:3]) pc.colors = open3d.utility.Vector3dVector(pc_xyzrgb[:, 3:6] / 255.) def custom_draw_geometry_with_key_callback(pcd): def change_background_to_black(vis): opt = vis.get_render_option() opt.background_color = np.asarray([0, 0, 0]) opt.point_size = 1 return False key_to_callback = {} key_to_callback[ord("K")] = change_background_to_black open3d.visualization.draw_geometries_with_key_callbacks([pcd], key_to_callback) custom_draw_geometry_with_key_callback(pc) def concate_color(_points, _label): color = np.zeros((_points.shape[0], 3)) label_id = np.unique(_label) for cls in label_id: if label_filter.len() == 0: color[_label == cls] = get_rgb_list(cls) elif label_filter.count(cls) == 0: color[_label == cls] = get_rgb_list(cls) _points = np.concatenate([_points, color], axis=1) return _points for it in label_dir.iterdir(): label_file = it points_file = points_dir / (str(it.stem) + '.bin') label = np.fromfile(label_file, dtype=np.uint32) points = np.fromfile(points_file, dtype=np.float32).reshape((-1, 4))[:, 0:3] print(label.shape, points.shape) colorful_points = concate_color(points, label) draw_pc(colorful_points)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

TimGor1997 avatar Nov 24 '21 01:11 TimGor1997

几周前我已经写过@OuyangJunyuan,但没有得到任何回复,我不想在未经他同意的情况下发布他的代码。

哦!很少查看我的电子邮件。我会展示它的流动性,只是非常简单粗暴的一个:

import  numpy  as  np 
import  yaml 
import  open3d 
from  pathlib  import  Path

 
points_dir  =  Path ( '/home/ou/Documents/dataset/my_pvrcnn_dataset(gazebo)/kitti/object/training/velodyne' ) # .bin 数据的路径
label_dir  =  Path ( '/home/ou/workspace/code/Cylinder3D- master/my_result' ) # .label 数据的路径

label_filter  = [ 40 , 48 , 70 , 72 ]     # 你不想显示的对象标签
# label_filter = [] 
with  open ( '/home/ou/workspace/code/Cylinder3D-master/config/label_mapping/semantic-kitti .yaml' , 'r' ) as  stream : # label_mapping 配置文件
    label_mapping  =  yaml . 安全加载(流)
     color_dict  =  label_mapping [ 'color_map' ]


def  get_rgb_list ( _label ):
     c  =  color_dict [ _label ]
    返回 np。数组(( c [ 2 ], c [ 1 ], c [ 0 ]))


def  draw_pc ( pc_xyzrgb ):
     pc  =  open3d。几何。点云()
    个人电脑。点 =  open3d。实用程序。Vector3dVector ( pc_xyzrgb [:, 0 : 3 ])
    个人计算机。颜色 =  open3d。实用程序。Vector3dVector ( pc_xyzrgb [:, 3 : 6 ] /  255. )

    def  custom_draw_geometry_with_key_callback ( pcd ):
         def  change_background_to_black ( vis ):
             opt  =  vis。get_render_option ()
            选择。背景颜色 =  np。asarray ([ 0 , 0 , 0 ])
            选择。point_size  =  1
            返回 False

        key_to_callback  = {}
         key_to_callback [ ord ( "K" )] =  change_background_to_black 
        open3d。可视化。draw_geometries_with_key_callbacks ([ pcd ], key_to_callback )

    custom_draw_geometry_with_key_callback ( pc )


def  concate_color ( _points , _label ):
     color  =  np。零(( _points . shape [ 0 ], 3 ))
     label_id  =  np。label_id中cls的唯一(_label)
     :
        如果label_filter。__len__ () == 0 :
            颜色[ _label == cls ] =        get_rgb_list ( cls )
         elif  label_filter。计数( cls ) ==  0 :
            颜色[ _label  ==  cls ] =  get_rgb_list ( cls )
     _points  =  np。连接([ _points , color ], axis = 1 )
    返回 _points


 在label_dir中为它 。iterdir ():
     label_file = it points_file = points_dir / ( str ( it.stem ) + ' .bin ' ) label =
     np . fromfile ( label_file , dtype = np . uint32 )
    点= np . fromfile ( points_file , dtype = np . float32   
            )。reshape (( - 1 , 4 ))[:, 0 : 3 ]
     print ( label . shape , points . shape )
     colourful_points  =  concate_color ( points , label )
     draw_pc ( colourful_points )

Is it a point cloud with only one color?

zhaodejian avatar Apr 20 '22 15:04 zhaodejian

@OuyangJunyuan

zhaodejian avatar Apr 20 '22 15:04 zhaodejian