perfanalytics / pose2sim

Markerless kinematics with any cameras — From 2D Pose estimation to 3D OpenSim motion
https://perfanalytics.github.io/pose2sim/
BSD 3-Clause "New" or "Revised" License
271 stars 50 forks source link

Calibration keeps restarting #109

Closed hmejbri closed 5 months ago

hmejbri commented 5 months ago

Im trying to perform camera calibration and the intrinsics keeps restarting even though the intrinsics error is less than 0.5px, this is the output :

Calculating intrinsic parameters...
INFO:root:
Camera int_cam_2_img:
INFO:root:cam2_36_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_72_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_108_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_144_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_180_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_216_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_252_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_288_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_324_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_360_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:Intrinsics error: 0.485 px for each cameras.
INFO:root:
Camera int_cam_1_img:
INFO:root:cam1_36_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_72_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_108_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_144_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_180_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_216_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_252_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_288_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_324_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam1_360_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:Intrinsics error: 0.482 px for each cameras.
INFO:root:
Calculating extrinsic parameters...
INFO:root:
Camera int_cam_2_img:
INFO:root:cam2_36_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_72_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_108_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_144_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_180_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_216_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_252_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_288_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_324_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam2_360_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:Intrinsics error: 0.417 px for each cameras.
INFO:root:
Camera int_cam_1_img:
INFO:root:cam1_36_int.png: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
davidpagnon commented 5 months ago

This is strange. Does it work with the Demo data? (make sure to set calibration_type = 'convert' and overwrite_intrinsics = true).

hmejbri commented 5 months ago

This is strange. Does it work with the Demo data? (make sure to set calibration_type = 'convert' and overwrite_intrinsics = true).

You mean calculate ?

davidpagnon commented 5 months ago

Sorry yes!

hmejbri commented 5 months ago

Yes calibration_type = 'calculate' and overwrite_intrinsics = true, what i'm suspecting is 0.48 intrinsics error is getting rounded up to 0.5 which results in restarting calibration

davidpagnon commented 5 months ago

I don't remember having set up a loop like that, but it is possible that I have introduced a bug in the last version. Are you using the last Pose2Sim version? (Do pip show pose2sim)

My question is, does it also loop with the Demo files?

hmejbri commented 5 months ago

I tried with the demo files and after finishing the intrinsics calculations it says 'Calculating extrinsic parameters' but still displays the instrinsics frames

Calculating intrinsic parameters...
INFO:root:
Camera int_cam_3_img:
INFO:root:cam03_01_int.jpg: Corners found.
INFO:root:cam03_02_int.jpg: Corners found.
INFO:root:cam03_03_int.jpg: Corners found.
INFO:root:cam03_04_int.jpg: Corners found.
INFO:root:cam03_05_int.jpg: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam03_06_int.jpg: Corners found.
INFO:root:cam03_07_int.jpg: Corners found.
INFO:root:Corners were detected only on 6 images for camera int_cam_3_img. Calibration of intrinsic parameters may not be accurate with fewer than 10 good images of the board.
INFO:root:Intrinsics error: 0.271 px for each cameras.
INFO:root:
Camera int_cam_2_img:
INFO:root:cam02_01_int.jpg: Corners found.
INFO:root:cam02_02_int.jpg: Corners found.
INFO:root:cam02_03_int.jpg: Corners found.
INFO:root:cam02_04_int.jpg: Corners found.
INFO:root:cam02_05_int.jpg: Corners found.
INFO:root:cam02_06_int.jpg: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam02_07_int.jpg: Corners found.
INFO:root:Corners were detected only on 6 images for camera int_cam_2_img. Calibration of intrinsic parameters may not be accurate with fewer than 10 good images of the board.
INFO:root:Intrinsics error: 0.255 px for each cameras.
INFO:root:
Camera int_cam_4_img:
INFO:root:cam04_01_int.jpg: Corners found.
INFO:root:cam04_02_int.jpg: Corners found.
INFO:root:cam04_03_int.jpg: Corners found.
INFO:root:cam04_04_int.jpg: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam04_05_int.jpg: Corners found.
INFO:root:cam04_06_int.jpg: Corners found.
INFO:root:cam04_07_int.jpg: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:Corners were detected only on 5 images for camera int_cam_4_img. Calibration of intrinsic parameters may not be accurate with fewer than 10 good images of the board.
INFO:root:Intrinsics error: 0.302 px for each cameras.
INFO:root:
Camera int_cam_1_img:
INFO:root:cam01_01_int.jpg: Corners found.
INFO:root:cam01_02_int.jpg: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam01_03_int.jpg: Corners found.
INFO:root:cam01_04_int.jpg: Corners found.
INFO:root:cam01_05_int.jpg: Corners found.
INFO:root:cam01_06_int.jpg: Corners not found. To label them by hand, set "show_detection_intrinsics" to true in the Config.toml file.
INFO:root:cam01_07_int.jpg: Corners found.
INFO:root:Corners were detected only on 5 images for camera int_cam_1_img. Calibration of intrinsic parameters may not be accurate with fewer than 10 good images of the board.
INFO:root:Intrinsics error: 0.266 px for each cameras.
INFO:root:
Calculating extrinsic parameters...
INFO:root:
Camera int_cam_3_img:
INFO:root:cam03_01_int.jpg: Corners found.
davidpagnon commented 5 months ago

Sorry, I can't right now but I'll have a look tonight

davidpagnon commented 5 months ago

Hi, I tried it again and I don't see any bug.

Can you do pip show pose2sim and check that we both work on version 0.8.3?

I should probably add a carriage return, but you can see that in the first loop it is calculating intrinsic parameters, while in the second one it works on extrinsic ones. (I also need to explicitly sort the folders by alphabetical order, but that is not the issue).

Now, what I cannot figure out is why it is still working on intrinsic parameters while in the extrinsic loop. I don't have this problem on my side.

Did you edit the code at some point? In [calibration.calculate.extrinsics], did you set 'board' or 'scene'?

hmejbri commented 5 months ago

I upgraded pose2sim and the last problem got fixed and a new problem risen. I used demo data but for extrinsics calculations i used the same frames of intrinsics and i set [calibration.calculate.extrinsics] to 'board' (one frame for each camera), the problem is it only displays the cam3 frame then it stops.

davidpagnon commented 5 months ago

Hi @hmejbri, I tried the Demo calibration again and did not face any issue. Here is what I changed:

Did you do anything differently?

hmejbri commented 5 months ago

I copied the first frame of each camera from their intrinsics folder into the respective extrinsics folder (S00_Calibration\extcam[cam_id]_img)

davidpagnon commented 5 months ago

I think that's what as well. Did you make sure the "extrinsic_extension" was right? Another hypothesis, did you close the window instead of hitting 'Y'?

hmejbri commented 5 months ago

Yes the extension of the images and in the config.toml file are both right. I repeated the process several times so i'm sure I hit 'Y'

davidpagnon commented 5 months ago

Can you tell me again what's going on, copy-paste the precise error, and whether you did anything non-standard?

davidpagnon commented 5 months ago

Hi @hmejbri, Sis you post and then deleted your comment? I don't see what the problem is, could you maybe send me your data so that I can try it out?

hmejbri commented 5 months ago

Yes I deleted the comment because the problem got fixed.