当前位置:   article > 正文

6D位姿估计-ObjectDatasetTools环境配置及生成linemod真实数据集记录

6D位姿估计-ObjectDatasetTools环境配置及生成linemod真实数据集记录

ObjectDatasetTools环境配置及使用记录


环境配置

  1. 安装miniconda
  • 下载 Miniconda 安装脚本:

打开终端,并使用 wget 下载 Miniconda 安装脚本。可以在 Miniconda 的官方网站上找到最新的安装脚本链接。例如:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
  • 1
  • 运行安装脚本:
    使用以下命令运行 Miniconda 安装脚本:
bash Miniconda3-latest-Linux-x86_64.sh
  • 1

这将启动安装程序,按照提示进行操作。你需要按 Enter 键阅读许可协议,然后按 yes 同意。接下来,选择安装位置,默认情况下安装在用户的home目录下。

  • 激活 Miniconda 环境:

安装完成后,需要激活 Miniconda。关闭当前终端窗口并打开一个新的终端窗口,或者运行以下命令:

source ~/.bashrc
  • 1
  1. 创建odt虚拟环境并激活
  • 注意python版本,我用的是python3.6(试了2.7bug有点多)
conda create --name odt python=3.6
  • 1
  • 创建后激活环境
conda activate odt    
  • 1
  1. 安装依赖
  • 安装meshlab
sudo apt-get update
sudo apt-get upgrade

sudo apt install build-essential cmake git pkg-config libssl-dev libgl1-mesa-glx
sudo apt-get install meshlab
  • 1
  • 2
  • 3
  • 4
  • 5
  • python包
 pip install numpy pypng scipy scikit-learn open3d=0.9.0.0 scikit-image tqdm pykdtree opencv-python==4.6.0.66 opencv-contrib-python==4.6.0.66 trimesh pyrealsense2 matplotlib pyyaml plyfile -i https://mirror.baidu.com/pypi/simple/
  • 1


数据采集

  1. 克隆仓库
git clone https://github.com/F2Wang/ObjectDatasetTools.git
  • 1
  1. 进入ObjectDatasetTools路径把arucomarker⽂件夹⾥的⼆维码都打印剪裁出来,围着要拍摄的物体贴⼀圈
    贴标签
  2. 执行以下命令后,使用相机围绕目标物体拍摄一圈获取rgb和深度图
python record2.py LINEMOD/enco
  • 1

建议不要修改LINEMOD文件名,否则后面会报错
在这里插入图片描述

  1. 计算transform
python compute_gt_poses.py LINEMOD/enco
  • 1

执行该命令后得到在该路径下得到transforms.npy如上图所示

  1. 场景重建
 python register_scene.py LINEMOD/enco
  • 1

执行后得到registeredScene.ply

  1. meshlab处理
    在终端中输入meshlab打开,然后import刚刚生成的registeredScene.ply主要是裁剪掉除目标以外的其他点云以及做一些平滑修补处理。
    1) 删除不感兴趣的背景,
    2) 执行表面重建并完成缺失的一侧,反之亦然,
    3) 处理重建的网格(您可能需要切除部分并重新完成缺失的一侧),
    4)确保处理后的网格没有任何孤立的噪声。
    参考教程meshlab点云处理教程。处理完成后将导出的ply文件重新命名为registeredScene.ply替换掉之前那个

  2. 生成label

python create_label_files.py LINEMOD/enco
  • 1

会得到mask、labels等文件。每个txt文件中有21个数字,21个数字分别对应以下内容:
第1个数字:类标签,第2个数字:x0(质心的x坐标),第3个数字:y0(质心的y坐标),第4个数字:x1(质心的x坐标)第 5 个数字:y1(第一个角点的 y 坐标),…,第 18 个数字:x8(第八个角点的 x 坐标),第 19 个数字:y8(第八个角点的 y 坐标) ,第 20 个数字:x 范围,第 21 个数字:y 范围。(reference)

  1. 查看效果
python inspectMasks.py LINEMOD/enco
  • 1

在这里插入图片描述


bug 记录

  1. ‘This PNG file has no IDAT chunks.’
raise FormatError('This PNG file has no IDAT chunks.')
png.FormatError: FormatError: This PNG file has no IDAT chunks.
  • 1
  • 2

可能是采数据的时候被提前中断了,在record2.py中将采集时间改成十秒后重新运行。(只是测试流程的时候采10秒,后续需要多采)

RECORD_LENGTH = 10
  • 1
  1. NameError: name ‘registration’ is not defined
pose_graph = registration.PoseGraph()
NameError: name 'registration' is not defined
  • 1
  • 2

open3d包的问题,换成0.9.0.0版本应该不会再报错

pip install open3d==0.9.0.0 -i https://mirror.baidu.com/pypi/simple/
  • 1
  1. ValueError: not enough values to unpack (expected 3, got 2)
Traceback (most recent call last):
  File "create_label_files.py", line 155, in <module>
    cv2.CHAIN_APPROX_SIMPLE)
ValueError: not enough values to unpack (expected 3, got 2)
  • 1
  • 2
  • 3
  • 4

将报错的这一行做如下修改:

_, contours, _ = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
                                              cv2.CHAIN_APPROX_SIMPLE)
#####   to  #########
contours, _ = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
                                              cv2.CHAIN_APPROX_SIMPLE)
  • 1
  • 2
  • 3
  • 4
  • 5
  1. 在虚拟机中的时候遇到报错:RuntimeError:No device connected
    在这里插入图片描述
    我这里使用librealsense中的realsense-viewer命令是可以看到相机的,使用lsusb命令也能看到设备(usb3.0口),很奇怪仍然报这个错,后来运行了一下sudo apt-get update命令,然后重新插拔了一下相机,就不报这个错了。

  • LINEMOD/enco的最终目录结构
.
├── depth
├── intrinsics.json
├── JPEGImages
├── labels
├── mask
├── registeredScene1.ply
├── registeredScene.ply
├── transforms
└── transforms.npy
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 环境的pip list
Package                       Version
----------------------------- ------------
actionlib                     1.14.0
addict                        2.4.0
angles                        1.9.13
anyio                         3.6.2
argon2-cffi                   21.3.0
argon2-cffi-bindings          21.2.0
async-generator               1.10
attrs                         22.2.0
Babel                         2.11.0
backcall                      0.2.0
bleach                        4.1.0
bondpy                        1.8.6
camera-calibration            1.17.0
camera-calibration-parsers    1.12.0
catkin                        0.8.10
certifi                       2021.5.30
cffi                          1.15.1
charset-normalizer            2.0.12
comm                          0.1.4
contextvars                   2.4
controller-manager            0.19.6
controller-manager-msgs       0.19.6
cv-bridge                     1.16.2
cycler                        0.11.0
dataclasses                   0.8
decorator                     4.4.2
defusedxml                    0.7.1
deprecation                   2.1.0
diagnostic-analysis           1.11.0
diagnostic-common-diagnostics 1.11.0
diagnostic-updater            1.11.0
dynamic-reconfigure           1.7.3
entrypoints                   0.4
gazebo_plugins                2.9.2
gazebo_ros                    2.9.2
gencpp                        0.7.0
geneus                        3.0.0
genlisp                       0.4.18
genmsg                        0.6.0
gennodejs                     2.0.2
genpy                         0.6.15
idna                          3.6
image-geometry                1.16.2
imageio                       2.15.0
immutables                    0.19
importlib-metadata            4.8.3
importlib-resources           5.4.0
interactive-markers           1.12.0
ipykernel                     5.5.6
ipython                       7.16.3
ipython-genutils              0.2.0
ipywidgets                    7.8.1
jedi                          0.17.2
Jinja2                        3.0.3
joblib                        1.1.1
joint-state-publisher         1.15.1
joint-state-publisher-gui     1.15.1
json5                         0.9.14
jsonschema                    4.0.0
jupyter-client                7.1.2
jupyter-core                  4.9.2
jupyter-packaging             0.10.6
jupyter-server                1.13.1
jupyterlab                    3.2.9
jupyterlab-pygments           0.1.2
jupyterlab-server             2.10.3
jupyterlab-widgets            1.1.7
kiwisolver                    1.3.1
laser_geometry                1.6.7
MarkupSafe                    2.0.1
matplotlib                    3.3.4
message-filters               1.16.0
mistune                       0.8.4
nbclassic                     0.3.5
nbclient                      0.5.9
nbconvert                     6.0.7
nbformat                      5.1.3
nest-asyncio                  1.5.8
networkx                      2.5.1
notebook                      6.4.10
numpy                         1.19.5
open3d                        0.9.0.0
opencv-contrib-python         4.6.0.66
opencv-python                 4.6.0.66
packaging                     21.3
pandas                        1.1.5
pandocfilters                 1.5.0
parso                         0.7.1
pexpect                       4.9.0
pickleshare                   0.7.5
Pillow                        8.4.0
pip                           21.2.2
plyfile                       0.8
prometheus-client             0.17.1
prompt-toolkit                3.0.36
ptyprocess                    0.7.0
pycparser                     2.21
Pygments                      2.14.0
pykdtree                      1.3.4
pyparsing                     3.1.1
pypng                         0.20220715.0
pyquaternion                  0.9.9
pyrealsense2                  2.53.1.4623
pyrsistent                    0.18.0
python-dateutil               2.8.2
python-qt-binding             0.4.4
pytz                          2023.3.post1
PyWavelets                    1.1.1
PyYAML                        6.0.1
pyzmq                         25.1.2
qt-dotgraph                   0.4.2
qt-gui                        0.4.2
qt-gui-cpp                    0.4.2
qt-gui-py-common              0.4.2
requests                      2.27.1
resource_retriever            1.12.7
rosbag                        1.16.0
rosboost-cfg                  1.15.8
rosclean                      1.15.8
roscreate                     1.15.8
rosgraph                      1.16.0
roslaunch                     1.16.0
roslib                        1.15.8
roslint                       0.12.0
roslz4                        1.16.0
rosmake                       1.15.8
rosmaster                     1.16.0
rosmsg                        1.16.0
rosnode                       1.16.0
rosparam                      1.16.0
rospy                         1.16.0
rosservice                    1.16.0
rostest                       1.16.0
rostopic                      1.16.0
rosunit                       1.15.8
roswtf                        1.16.0
rqt_action                    0.4.9
rqt_bag                       0.5.1
rqt_bag_plugins               0.5.1
rqt-console                   0.4.12
rqt_dep                       0.4.12
rqt_graph                     0.4.14
rqt_gui                       0.5.3
rqt_gui_py                    0.5.3
rqt-image-view                0.4.17
rqt_launch                    0.4.9
rqt-logger-level              0.4.12
rqt-moveit                    0.5.11
rqt_msg                       0.4.10
rqt_nav_view                  0.5.7
rqt_plot                      0.4.13
rqt_pose_view                 0.5.11
rqt_publisher                 0.4.10
rqt_py_common                 0.5.3
rqt_py_console                0.4.10
rqt-reconfigure               0.5.5
rqt-robot-dashboard           0.5.8
rqt-robot-monitor             0.5.15
rqt_robot_steering            0.5.12
rqt-runtime-monitor           0.5.10
rqt-rviz                      0.7.0
rqt_service_caller            0.4.10
rqt_shell                     0.4.11
rqt_srv                       0.4.9
rqt-tf-tree                   0.6.4
rqt_top                       0.4.10
rqt_topic                     0.4.13
rqt_web                       0.4.10
rviz                          1.14.20
scikit-image                  0.17.2
scikit-learn                  0.24.2
scipy                         1.5.4
Send2Trash                    1.8.2
sensor-msgs                   1.13.1
setuptools                    58.0.4
six                           1.16.0
smach                         2.5.2
smach-ros                     2.5.2
smclib                        1.8.6
sniffio                       1.2.0
terminado                     0.13.0
testpath                      0.6.0
tf                            1.13.2
tf-conversions                1.13.2
tf2-geometry-msgs             0.7.6
tf2-kdl                       0.7.6
tf2-py                        0.7.6
tf2-ros                       0.7.6
threadpoolctl                 3.1.0
tifffile                      2020.9.3
tomlkit                       0.11.6
topic-tools                   1.16.0
tornado                       6.1
tqdm                          4.64.1
traitlets                     4.3.3
trimesh                       3.23.5
typing_extensions             4.1.1
urllib3                       1.26.18
wcwidth                       0.2.13
webencodings                  0.5.1
websocket-client              1.3.1
wheel                         0.37.1
widgetsnbextension            3.6.6
xacro                         1.14.16
zipp                          3.6.0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207

Reference

  1. 6d位姿估计—制作自己的LINEMOD数据集过程记录(ObjectDatasetTools)
  2. 23赛季华南虎工程视觉开源仓库
  3. LineMod算法介绍
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/202401?site
推荐阅读
相关标签
  

闽ICP备14008679号