pose2sim icon indicating copy to clipboard operation
pose2sim copied to clipboard

Extrinsics is not getting calculated

Open hmejbri opened this issue 10 months ago • 6 comments

When I try to perform calibration while I have the .toml file in the calibration folder I should only calculate extrinsics but instead I get the intrinsics frames.

I had to take a look inside the calibration.py and I noticed this block of code :

# calculate extrinsics
if calculate_extrinsics:
    logging.info(f'\nCalculating extrinsic parameters...')
    
    # check that the number of cameras is consistent
    nb_cams_extrinsics = len(next(os.walk(os.path.join(calib_dir, 'extrinsics')))[1])
    if nb_cams_intrinsics != nb_cams_extrinsics:
        raise Exception(f'Error: The number of cameras is not consistent:\
                Found {nb_cams_intrinsics} cameras based on the number of intrinsic folders or on calibration file data,\
                and {nb_cams_extrinsics} cameras based on the number of extrinsic folders.')

    ret, C, S, D, K, R, T = calibrate_intrinsics(calib_dir, intrinsics_config_dict)

# calculate extrinsics
if calculate_extrinsics:
    logging.info(f'\nCalculating extrinsic parameters...')
    ret, C, S, D, K, R, T = calibrate_extrinsics(calib_dir, extrinsics_config_dict, C, S, K, D)

and I don't know why the intrinsics are being calculated once more, Correct me if i'm wrong but I think it should be like this

# calculate extrinsics
if calculate_extrinsics:
    logging.info(f'\nCalculating extrinsic parameters...')
    
    # check that the number of cameras is consistent
    nb_cams_extrinsics = len(next(os.walk(os.path.join(calib_dir, 'extrinsics')))[1])
    if nb_cams_intrinsics != nb_cams_extrinsics:
        raise Exception(f'Error: The number of cameras is not consistent:\
                Found {nb_cams_intrinsics} cameras based on the number of intrinsic folders or on calibration file data,\
                and {nb_cams_extrinsics} cameras based on the number of extrinsic folders.')

    logging.info(f'\nCalculating extrinsic parameters...')
    ret, C, S, D, K, R, T = calibrate_extrinsics(calib_dir, extrinsics_config_dict, C, S, K, D)

hmejbri avatar Apr 12 '24 12:04 hmejbri

Hi, before I check that, are you sure that you did not set overwrite_intrinsics = true in your Config.toml? It should be set to false in order not to recalculate intrinsic parameters.

davidpagnon avatar Apr 12 '24 13:04 davidpagnon

Yup overwrite_intrinsics is set to false

hmejbri avatar Apr 12 '24 13:04 hmejbri

Yes you're right, I must have overwritten something by mistake... I'll fix this and push the change as well as a bunch of others tonight or during the week-end!

davidpagnon avatar Apr 12 '24 13:04 davidpagnon

I just tested the latest version of the code and its still causing problems. This time it loads the extrinsics frame but after labeling the corners of the first camera by hand I get this error :

Traceback (most recent call last): File "/home/ubuntu/pfe_mocap/main.py", line 52, in asyncio.run(main()) File "/opt/conda/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/opt/conda/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete return future.result() File "/home/ubuntu/pfe_mocap/main.py", line 36, in main await calibration_utils.calibrate_cams() File "/home/ubuntu/pfe_mocap/Scripts/Calibration/calibration_utils.py", line 59, in calibrate_cams await Pose2Sim.calibration() File "/opt/conda/lib/python3.10/site-packages/Pose2Sim/Pose2Sim.py", line 207, in calibration calibrate_cams_all(config_dict) File "/opt/conda/lib/python3.10/site-packages/Pose2Sim/calibration.py", line 1344, in calibrate_cams_all ret, C, S, D, K, R, T = calib_fun(*args_calib_fun) File "/opt/conda/lib/python3.10/site-packages/Pose2Sim/calibration.py", line 526, in calib_calc_fun ret, C, S, D, K, R, T = calibrate_extrinsics(calib_dir, extrinsics_config_dict, C, S, K, D) File "/opt/conda/lib/python3.10/site-packages/Pose2Sim/calibration.py", line 688, in calibrate_extrinsics if imgp == []: ValueError: operands could not be broadcast together with shapes (28,1,2) (0,)

hmejbri avatar Apr 15 '24 10:04 hmejbri

Update : I replaced imgp == [] with len(imgp) == 0 and it works now

hmejbri avatar Apr 15 '24 11:04 hmejbri

Hi, thanks! Sorry I had a few merge issues but I'll make the fixes tonight.

davidpagnon avatar Apr 15 '24 16:04 davidpagnon