AB3DMOT icon indicating copy to clipboard operation
AB3DMOT copied to clipboard

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

Open lx-ynu opened this issue 2 years ago • 10 comments

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)

lx-ynu avatar Apr 09 '22 12:04 lx-ynu

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.

vishnumh avatar Apr 18 '22 00:04 vishnumh

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

YCAyca avatar Apr 20 '22 13:04 YCAyca

校准文件示例:

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

xyllq999 avatar Oct 24 '22 09:10 xyllq999

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

YCAyca avatar Oct 24 '22 10:10 YCAyca

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!

xyllq999 avatar Oct 24 '22 10:10 xyllq999

You're welcome!

YCAyca avatar Oct 24 '22 10:10 YCAyca

You're welcome!

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

xyllq999 avatar Oct 24 '22 12:10 xyllq999

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

Ting234 avatar Oct 28 '22 12:10 Ting234

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)

xyllq999 avatar Oct 31 '22 16:10 xyllq999

  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" R0_rect to R_rect r_velo_to_cam to r_velo_cam Tr_imu_to_velo to Tr_imu_velo

llxClover avatar Jul 09 '23 07:07 llxClover