Closed EmanuelWicki closed 6 months ago
Hi,
It's telling you that the length of K is lesser than i. K comes from the previous intrinsic calibration you have done. Can you check your calibration file and see if you have as many cameras as the number in your extrinsics folder?
my calib_board.toml "[int_cam01_img] name = "int_cam01_img" size = [ 1920.0, 1088.0] matrix = [ [ 1665.8086662960393, 0.0, 959.5], [ 0.0, 1676.4957228942644, 543.5], [ 0.0, 0.0, 1.0]] distortions = [ -0.04141344589689808, 0.07623007428998166, 0.002190791974704825, 0.0025334756418212917] rotation = [ -0.028717891075011447, -2.1733186665096875, -2.259349446007465] translation = [ -1.1092073314704791, 0.8169849411116984, 2.947136342466439] fisheye = false
[int_cam02_img] name = "int_cam02_img" size = [ 1920.0, 1088.0] matrix = [ [ 1667.3666363291732, 0.0, 959.5], [ 0.0, 1675.9873681252775, 543.5], [ 0.0, 0.0, 1.0]] distortions = [ -0.045115671761216065, 0.0881454168156573, 0.0047135447214286495, -0.0006271002821147498] rotation = [ -1.0960041663577, 1.1158102553797193, 1.2824616425271775] translation = [ 0.11288934582699561, 0.6848357402632919, 3.5472627091515085] fisheye = false
[metadata] adjusted = false error = 0.0 " I'm encountering an issue with how the system accesses the int_cam01_img folder during the extrinsic calibration, as noted in the message below. To prevent this, I deleted the folders within the intrinsic directory so they couldn't be accessed during the external calibration, and this process proceeded without errors. Could this approach have caused the previous error ?
Moreover, whenever there are files in the int_cam01_img folder, they are automatically used for extrinsic calibration. Since I used a checkerboard for intrinsic calibration, I believe its not necessary to identify checkerboard corners during the extrinsic calibration, right.
"Retrieving intrinsic parameters from file. Set "overwrite_intrinsics" to true in Config.toml to recalculate them.
Calculating extrinsic parameters...
Camera int_cam01_img: Extracting frames... Test 0002_Miqus_15_22269_00000.png: Corners found. Installed qt5 event loop hook. Test 0002_Miqus_15_22269_00050.png: Corners found. Test 0002_Miqus_15_22269_00100.png: Corners found. Test 0002_Miqus_15_22269_00150.png: Corners found."
That may be the cause, try to retrieve the intrinsic camera folders, and to set overwrite_intrinsics
to false instead.
Or are you telling me that even with this parameter, it is trying to recalculate the intrinsic parameters anyway?
I have now done the whole process again: intrinsic and extrinsic calibration - that way it worked fine but even now i had to calibrate intrinsics twice as can be seen below. Before I had overwrite_intrinsics to false but it still tried to access the images in the int_cam01_img.
"Calculating intrinsic parameters...
Camera int_cam01_img: Test 0002_Miqus_15_22269_00000.png: Corners found. Test 0002_Miqus_15_22269_00050.png: Corners found. Test 0002_Miqus_15_22269_00100.png: Corners found. Test 0002_Miqus_15_22269_00150.png: Corners found. Test 0002_Miqus_15_22269_00200.png: Corners found. Test 0002_Miqus_15_22269_00250.png: Corners found. Test 0002_Miqus_15_22269_00300.png: Corners found. Test 0002_Miqus_15_22269_00350.png: Corners found. Test 0002_Miqus_15_22269_00400.png: Corners found. Test 0002_Miqus_15_22269_00450.png: Corners found. Test 0002_Miqus_15_22269_00500.png: Corners found. Test 0002_Miqus_15_22269_00550.png: Corners found. Test 0002_Miqus_15_22269_00600.png: Corners found. Test 0002_Miqus_15_22269_00650.png: Corners found. Test 0002_Miqus_15_22269_00700.png: Corners found. Test 0002_Miqus_15_22269_00750.png: Corners found. Test 0002_Miqus_15_22269_00800.png: Corners found. Test 0002_Miqus_15_22269_00850.png: Corners found. Test 0002_Miqus_15_22269_00900.png: Corners found. Test 0002_Miqus_15_22269_00950.png: Corners found. Test 0002_Miqus_15_22269_01000.png: Corners found. Test 0002_Miqus_15_22269_01050.png: Corners found. Test 0002_Miqus_15_22269_01100.png: Corners found. Test 0002_Miqus_15_22269_01150.png: Corners found. Test 0002_Miqus_15_22269_01200.png: Corners found. Test 0002_Miqus_15_22269_01250.png: Corners found. Test 0002_Miqus_15_22269_01300.png: Corners found. Test 0002_Miqus_15_22269_01350.png: Corners found. Test 0002_Miqus_15_22269_01400.png: Corners found. Test 0002_Miqus_15_22269_01450.png: Corners found. Intrinsics error: 0.211 px for each cameras.
Camera int_cam02_img: Test 0004_Miqus_16_22270_00000.png: Corners found. Test 0004_Miqus_16_22270_00100.png: Corners found. Test 0004_Miqus_16_22270_00200.png: Corners found. Test 0004_Miqus_16_22270_00300.png: Corners found. Test 0004_Miqus_16_22270_00400.png: Corners found. Test 0004_Miqus_16_22270_00500.png: Corners found. Test 0004_Miqus_16_22270_00600.png: Corners found. Test 0004_Miqus_16_22270_00700.png: Corners found. Test 0004_Miqus_16_22270_00800.png: Corners found. Test 0004_Miqus_16_22270_00900.png: Corners found. Test 0004_Miqus_16_22270_01000.png: Corners found. Test 0004_Miqus_16_22270_01100.png: Corners found. Test 0004_Miqus_16_22270_01200.png: Corners found. Test 0004_Miqus_16_22270_01300.png: Corners found. Test 0004_Miqus_16_22270_01400.png: Corners found. Corners were detected only on 8 images for camera int_cam02_img. Calibration of intrinsic parameters may not be accurate with fewer than 10 good images of the board. Intrinsics error: 0.248 px for each cameras.
Calculating extrinsic parameters...
Camera int_cam01_img: Test 0002_Miqus_15_22269_00000.png: Corners found. Test 0002_Miqus_15_22269_00050.png: Corners found. Test 0002_Miqus_15_22269_00100.png: Corners found. Test 0002_Miqus_15_22269_00150.png: Corners found. Test 0002_Miqus_15_22269_00200.png: Corners found. Test 0002_Miqus_15_22269_00250.png: Corners found. Test 0002_Miqus_15_22269_00300.png: Corners found. Test 0002_Miqus_15_22269_00350.png: Corners found. Test 0002_Miqus_15_22269_00400.png: Corners found. Test 0002_Miqus_15_22269_00450.png: Corners found. Test 0002_Miqus_15_22269_00500.png: Corners found. Test 0002_Miqus_15_22269_00550.png: Corners found. Test 0002_Miqus_15_22269_00600.png: Corners found. Test 0002_Miqus_15_22269_00650.png: Corners found. Test 0002_Miqus_15_22269_00700.png: Corners found. Test 0002_Miqus_15_22269_00750.png: Corners found. Test 0002_Miqus_15_22269_00800.png: Corners found. Test 0002_Miqus_15_22269_00850.png: Corners found. Test 0002_Miqus_15_22269_00900.png: Corners found. Test 0002_Miqus_15_22269_00950.png: Corners found. Test 0002_Miqus_15_22269_01000.png: Corners found. Test 0002_Miqus_15_22269_01050.png: Corners found. Test 0002_Miqus_15_22269_01100.png: Corners found. Test 0002_Miqus_15_22269_01150.png: Corners found. Test 0002_Miqus_15_22269_01200.png: Corners found. Test 0002_Miqus_15_22269_01250.png: Corners found. Test 0002_Miqus_15_22269_01300.png: Corners found. Test 0002_Miqus_15_22269_01350.png: Corners found. Test 0002_Miqus_15_22269_01400.png: Corners found. Test 0002_Miqus_15_22269_01450.png: Corners found. Intrinsics error: 0.211 px for each cameras.
Camera int_cam02_img: Test 0004_Miqus_16_22270_00000.png: Corners found. Test 0004_Miqus_16_22270_00100.png: Corners found. Test 0004_Miqus_16_22270_00200.png: Corners found. Test 0004_Miqus_16_22270_00300.png: Corners found. Test 0004_Miqus_16_22270_00400.png: Corners found. Test 0004_Miqus_16_22270_00500.png: Corners found. Test 0004_Miqus_16_22270_00600.png: Corners found. Test 0004_Miqus_16_22270_00700.png: Corners found. Test 0004_Miqus_16_22270_00800.png: Corners found. Test 0004_Miqus_16_22270_00900.png: Corners found. Test 0004_Miqus_16_22270_01000.png: Corners found. Test 0004_Miqus_16_22270_01100.png: Corners found. Test 0004_Miqus_16_22270_01200.png: Corners found. Test 0004_Miqus_16_22270_01300.png: Corners found. Test 0004_Miqus_16_22270_01400.png: Corners found. Corners were detected only on 8 images for camera int_cam02_img. Calibration of intrinsic parameters may not be accurate with fewer than 10 good images of the board. Intrinsics error: 0.248 px for each cameras.
Calculating extrinsic parameters...
Camera ext_cam01_img: BOARD EXECUTED !!!!!!!
Camera ext_cam02_img: BOARD EXECUTED !!!!!!!
--> Residual (RMS) calibration errors for each camera are respectively [5.594, 3.867] px, which corresponds to [10.682, 8.547] mm. "
That's strange, did you change the code? Can you try on the demo data to check if it does it there too?
I dont remember chaning the code and yes also with the demo it happens... I will clone the repo again and try if it still happens
Okay, keep me updated, and if it still happens I will dive a bit more into the code!
(this may also help narrowing down the problem: you installed it via cloning the repo rather than with pip install pose2sim
?)
I cloned the repo (also before) and tried to run the demo but I cant calculate personAssociation for the Batch Sesion file, the BODY25b model is selected and neck is tracked...
Project directory: C:\Users...\S00_Demo_BatchSession\S00_P00_SingleParticipant\S00_P00_T00_StaticTrial
IndexError Traceback (most recent call last) Cell In[4], line 1 ----> 1 Pose2Sim.personAssociation()
File C:\ProgramData\anaconda3\envs\Pose2Sim\lib\site-packages\Pose2Sim\Pose2Sim.py:348, in personAssociation(config)
345 logging.info("---------------------------------------------------------------------")
346 logging.info(f"\nProject directory: {project_dir}")
--> 348 track_2d_all(config_dict)
350 end = time.time()
351 elapsed = end-start
File C:\ProgramData\anaconda3\envs\Pose2Sim\lib\site-packages\Pose2Sim\personAssociation.py:436, in track_2d_all(config) 434 except: 435 raise NameError('Model not found in skeletons.py nor in Config.toml') --> 436 tracked_keypointid = [node.id for , _, node in RenderTree(model) if node.name==tracked_keypoint][0] 438 # 2d-pose files selection 439 pose_listdirs_names = next(os.walk(pose_dir))[1]
IndexError: list index out of range"
For the S01_Demo_Single_Trial i tried as well but for Pose2Sim.calibration() i got the error "Cell In[3], line 1 ----> 1 Pose2Sim.calibration()
File C:\ProgramData\anaconda3\envs\Pose2Sim\lib\site-packages\Pose2Sim\Pose2Sim.py:190, in calibration(config)
180 '''
181 Cameras calibration from checkerboards or from qualisys files.
182
(...)
185 or the function can be called without an argument, in which case it the config directory is the current one.
186 '''
188 from Pose2Sim.calibration import calibrate_cams_all
--> 190 level, config_dicts = read_config_files(config)
191 config_dict = config_dicts[0]
192 session_dir = os.path.realpath([os.getcwd() if level==3 else os.path.join(os.getcwd(), '..') if level==2 else os.path.join(os.getcwd(), '..', '..')][0])
File C:\ProgramData\anaconda3\envs\Pose2Sim\lib\site-packages\Pose2Sim\Pose2Sim.py:129, in read_config_files(config)
127 # Trial level
128 if level == 1:
--> 129 session_config_dict = toml.load(os.path.join(config_dir, '..','..','Config.toml'))
130 participant_config_dict = toml.load(os.path.join(config_dir, '..','Config.toml'))
131 trial_config_dict = toml.load(os.path.join(config_dir, 'Config.toml'))
File C:\ProgramData\anaconda3\envs\Pose2Sim\lib\site-packages\toml\decoder.py:133, in load(f, _dict, decoder) 114 """Parses named file or files as toml and returns a dictionary 115 116 Args: (...) 129 (Python 2 / Python 3) file paths is passed 130 """ 132 if _ispath(f): --> 133 with io.open(_getpath(f), encoding='utf-8') as ffile: 134 return loads(ffile.read(), _dict, decoder) 135 elif isinstance(f, list):
FileNotFoundError: [Errno 2] No such file or directory: '.\..\..\Config.toml'"
Hi again, You haven't told me how calibration went, did it solve it? I suppose you ran personAssociation() directly from S00_P00_T00_StaticTrial? I may have found a bug that I introduced in the last release, can you tell me if it works now?
Hi David, yes i ran personAssiciation() directly from S00_P00_T00_StaticTrial but it still didnt work just now. I still got the following error (For the Demo files):
"Project directory: C:\Users...\S00_Demo_BatchSession\S00_P00_SingleParticipant\S00_P00_T00_StaticTrial
IndexError Traceback (most recent call last) Cell In[4], line 1 ----> 1 Pose2Sim.personAssociation()
File C:\ProgramData\anaconda3\envs\Pose2Sim\lib\site-packages\Pose2Sim\Pose2Sim.py:348, in personAssociation(config)
345 logging.info("---------------------------------------------------------------------")
346 logging.info(f"\nProject directory: {project_dir}")
--> 348 track_2d_all(config_dict)
350 end = time.time()
351 elapsed = end-start
File C:\ProgramData\anaconda3\envs\Pose2Sim\lib\site-packages\Pose2Sim\personAssociation.py:436, in track_2d_all(config) 434 except: 435 raise NameError('Model not found in skeletons.py nor in Config.toml') --> 436 tracked_keypointid = [node.id for , _, node in RenderTree(model) if node.name==tracked_keypoint][0] 438 # 2d-pose files selection 439 pose_listdirs_names = next(os.walk(pose_dir))[1]
IndexError: list index out of range"
With my own data it works. The only thing is that I still have negative z coordinates even though I use scene now and set the coordinates of the points in a RH coordinate system...
Hi, it is strange that it does not work on the demo data, since I run automatic tests after each upload which did not report any error, and to be on the safe side I tried it also by myself. Maybe you could manually totally delete your pose2sim folder in your environnent (type pip show pose2sim
to find its location, as well as the demo folders??
Anyway, I'm glad it works on your demo data! If the coordinates are still upside down, you just need to label the extrinsics the other way around. For example If you go left and then up, try left and then down.
thank you very much, this resolved the issue !
Hi Daniel, I am encountering a problem while trying to calculate my extrinsics using a scene. I have 11 points in my scene (all on the floor -> 2D) and after clicking on all the points in my scene I'm getting the following error. Do I have to change the index range?
Also the calibration part of my calib.toml file is attached here: