Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extrinsics is not getting calculated #93

Open
hmejbri opened this issue Apr 12, 2024 · 6 comments
Open

Extrinsics is not getting calculated #93

hmejbri opened this issue Apr 12, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@hmejbri
Copy link

hmejbri commented Apr 12, 2024

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)
@davidpagnon
Copy link
Collaborator

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.

@hmejbri
Copy link
Author

hmejbri commented Apr 12, 2024

Yup overwrite_intrinsics is set to false

@davidpagnon
Copy link
Collaborator

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 davidpagnon added the bug Something isn't working label Apr 12, 2024
@hmejbri
Copy link
Author

hmejbri commented Apr 15, 2024

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
Copy link
Author

hmejbri commented Apr 15, 2024

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

@davidpagnon
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants