xinshuoweng / AB3DMOT

(IROS 2020, ECCVW 2020) Official Python Implementation for "3D Multi-Object Tracking: A Baseline and New Evaluation Metrics"
http://www.xinshuoweng.com/
Other
1.66k stars 403 forks source link

ValueError: not enough values to unpack (expected 2, got 1) #101

Open lx-ynu opened 2 years ago

lx-ynu commented 2 years ago

Hello, when I use the KITTI benchmark dataset and run "main.py", the following error is reported and I would like to know how to fix it. Traceback (most recent call last): File "main.py", line 140, in main(args) File "main.py", line 129, in main ID_start = main_per_cat(cfg, cat, log, ID_start) File "main.py", line 48, in main_per_cat tracker, frame_list = initialize(cfg, trk_root, save_dir, subfolder, seq_name, cat, ID_start, hw, log) File "/media/AB3DMOT/AB3DMOT_libs/utils.py", line 93, in initialize calib = Calibration(calib) File "/media/AB3DMOT/AB3DMOT_libs/kitti_calib.py", line 57, in init calibs = self.read_calib_file(calib_filepath) File "/media/AB3DMOT/AB3DMOT_libs/kitti_calib.py", line 95, in read_calib_file key, value = line.split(':', 1) ValueError: not enough values to unpack (expected 2, got 1)

vishnumh commented 2 years ago

There has been changes in the KITTI dataset, please see the calibration dataset there is an : missing in the R_rect, Tr_velo_cam and Tr_imu_velo and key names are different in the code given in the repo. Making these changes will lead to successful execution.

YCAyca commented 2 years ago

An example of calibration file:

P0: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 0.000000000000e+00 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P1: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.875744000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P2: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 4.485728000000e+01 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.163791000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.745884000000e-03
P3: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.395242000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.199936000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.729905000000e-03
R_rect 9.999239000000e-01 9.837760000000e-03 -7.445048000000e-03 -9.869795000000e-03 9.999421000000e-01 -4.278459000000e-03 7.402527000000e-03 4.351614000000e-03 9.999631000000e-01
Tr_velo_cam 7.533745000000e-03 -9.999714000000e-01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e-03 1.480755000000e-02 -2.717806000000e-01
Tr_imu_velo 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000e-01

Since you don't have : character for splitting R_rect Tr_velo_cam Tr_imu_velo it gives you error. You can simply add : to continue with the same code as follows R_rect: 9.999239000000e-01 9.837760000000e-03 -7.445048000000e-03 -9.869795000000e-03 9.999421000000e-01 -4.278459000000e-03 7.402527000000e-03 4.351614000000e-03 9.999631000000e-01
Tr_velo_cam: 7.533745000000e-03 -9.999714000000e-01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e-03 1.480755000000e-02 -2.717806000000e-01
Tr_imu_velo: 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000e-01

xyllq999 commented 1 year ago

校准文件示例:

P0:7.2153770000E+02 0.0000000000E+00 6.0955930000EE+02 0.0000000000EE+00 0.0000000000E+00 7.2153777000000 E+02 1.7285400000000000000000000000000000000000000000000000000000000000000来 P1:7.2153770000E+02 0.0000000000E+00 6.095593000000E+02 -3.8757444000000 EE+02 0.0000000000E+00 7.215377000000 EE+02 1.728540000000000000000000000000000000000000000000000000000000000000000来00 P2: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 4.485728000000e+01 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.163791000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.745884000000e- 03 P3: 7.215377000000e+02 0.000000000000e+00 6.095593000000e+02 -3.395242000000e+02 0.000000000000e+00 7.215377000000e+02 1.728540000000e+02 2.199936000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 2.729905000000e- 03 R_rect 9.999239000000e-01 9.837760000000e-03 -7.445048000000e-03 -9.869795000000e-03 9.999421000000e-01 -4.278459000000e-03 7.402527000000e-03 4.351614000000e-03 9.999631000000e-01 Tr_velo_cam 7.533745000000e-03 -9.999714000000e- 01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e-03 1.480755000000e-02 -2.717806000000e-01 Tr_imu_velo 9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 - 7.997231000000e-01

由于您没有 : 用于拆分 R_rect Tr_velo_cam Tr_imu_velo 的字符,因此它会给您错误。您可以简单地添加:继续使用与以下相同的代码 R_RECT : 9.9992390000EE-01 9.83776000000000E-03 -03 -7.4450480000E-03 -9.86979795000000 EE-03 9.999994210000 EE-01001001-27787001001-27888888770001001-27888887001-2788887400001001-27888870000000000000000000000000000000000000000000000来9.999631000000e-01 Tr_velo_cam : 7.533745000000e-03 -9.999714000000e-01 -6.166020000000e-04 -4.069766000000e-03 1.480249000000e-02 7.280733000000e-04 -9.998902000000e-01 -7.631618000000e-02 9.998621000000e-01 7.523790000000e- 03 1.480755000000e-02 -2.717806000000e-01 Tr_imu_velo :9.999976000000e-01 7.553071000000e-04 -2.035826000000e-03 -8.086759000000e-01 -7.854027000000e-04 9.998898000000e-01 -1.482298000000e-02 3.195559000000e-01 2.024406000000e-03 1.482454000000e-02 9.998881000000e-01 -7.997231000000 e-01

Can you please give me a more detailed guide, I don't know how to do it

YCAyca commented 1 year ago

You have to arrange the calibration file strings like this P0: value P1: value P2: value P3: value R_rect: value Tr_velo_cam: value Tr_imu_velo: value

So just add ":" without any space

xyllq999 commented 1 year ago

You have to arrange the calibration file strings like this P0: value P1: value P2: value P3: value R_rect: value Tr_velo_cam: value Tr_imu_velo: value

So just add ":" without any space

Got it, thanks a lot!

YCAyca commented 1 year ago

You're welcome!

xyllq999 commented 1 year ago

You're welcome!

I encountered a new problem in the new join:later. KeyError: 'Tr_velo_to_cam'

Ting234 commented 1 year ago

You're welcome!

I encountered a new problem in the new join:later. KeyError: 'Tr_velo_to_cam'

Modify the Tr_velo_to_cam to Tr_velo_cam in kitti_calib.py

xyllq999 commented 1 year ago

I wrote a script to make it easier to change the format, you just need to change the parent_path。 `import os parent_path = "" for filename in os.listdir(parent_path):

print(filename)

path = os.path.join(parent_path, filename)
f = open(path, 'r')
file_data = ""
lines = f.readlines()
for line in lines:
    title = line.split(' ')[0]
    if title in ['R_rect', 'Tr_velo_cam', 'Tr_imu_velo']:
        line = line.replace(title, title + ":")
    file_data += line
with open(path, "w" ,encoding="utf-8") as f:
    f.write(file_data)`
llxClover commented 1 year ago
  1. first create a new script as fellow:
import os 
# **need to change** 
parent_path = "/home/llx/ROS_WS/3D_MOT_lidar_ws/src/real_time_tracking_AB3DMOT/src/AB3DMOT/data/KITTI/tracking/testing/calib" 
for filename in os.listdir(parent_path): 
    # print(filename) 
    path = os.path.join(parent_path, filename) 
    f = open(path, 'r') 
    file_data = "" 
    lines = f.readlines()
    flag = 1 
    for line in lines: 
        title = line.split(' ')[0] 
        if title in ['R_rect', 'Tr_velo_cam', 'Tr_imu_velo']: 
            line = line.replace(title, title + ":") 

        file_data = line 

        with open(path, "a+" ,encoding="utf-8") as f:
            if (flag == 1):
                f.truncate(0)
                flag = 0
            f.write(file_data)
  1. change codes in "/AB3DMOT/AB3DMOT_libs/kitti_calib.py" _R0rect to _Rrect _r_velo_tocam to _r_velocam Tr_imu_to_velo to _Tr_imuvelo