lambdaloop / anipose

🐜🐀🐒🚶 A toolkit for robust markerless 3D pose estimation
http://anipose.org
BSD 2-Clause "Simplified" License
351 stars 66 forks source link

'NoneType' object is not subscriptable in the process of calibrate #64

Closed DuanWei-fudan closed 3 years ago

DuanWei-fudan commented 3 years ago

I used the Anipose in a python enviroment of Anaconda. I tested the demo in Google Driver. But when I calibrate the camer,there is a typeerror:

_Calibrating... F:\hand-demo-unfilled\2019-08-02 F:\hand-demo-unfilled\2019-08-02\calibration\calibration.toml F:\hand-demo-unfilled\2019-08-02\calibration\calib-charuco-camA.MOV 100%|█████████████████████████████| 5274/5274 [03:47<00:00, 23.19it/s] 5274 boards detected F:\hand-demo-unfilled\2019-08-02\calibration\calib-charuco-camB.MOV 100%|█████████████████████████████| 5264/5264 [03:36<00:00, 24.28it/s] 4986 boards detected F:\hand-demo-unfilled\2019-08-02\calibration\calib-charuco-camC.MOV 100%|█████████████████████████████| 5265/5265 [03:20<00:00, 26.25it/s] 4724 boards detected defaultdict(<class 'int'>, {('A', 'B'): 4937, ('B', 'A'): 4937}) Traceback (most recent call last): File "e:\anaconda\envs\dlc-cpu\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "e:\anaconda\envs\dlc-cpu\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "E:\Anaconda\envs\DLC-CPU\Scripts\anipose.exe__main.py", line 7, in File "e:\anaconda\envs\dlc-cpu\lib\site-packages\click\core.py", line 1137, in call return self.main(*args, kwargs) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\click\core.py", line 1062, in main rv = self.invoke(ctx) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\click\core.py", line 1668, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\click\core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\click\core.py", line 763, in invoke return callback(*args, kwargs) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\click\decorators.py", line 84, in new_func return ctx.invoke(f, obj, *args, *kwargs) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\click\core.py", line 763, in invoke return __callback(args, kwargs) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\anipose\anipose.py", line 116, in calibrate calibrate_all(config) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\anipose\common.py", line 168, in fun return process_all(config, process_session, args) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\anipose\common.py", line 153, in process_all output[past_folders] = process_session(config, path, args) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\anipose\calibrate.py", line 203, in process_session verbose=True) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\aniposelib\cameras.py", line 1563, in calibrate_rows rvecs, tvecs = get_initial_extrinsics(rtvecs) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\aniposelib\utils.py", line 173, in get_initial_extrinsics pairs = find_calibration_pairs(graph, source=0) File "e:\anaconda\envs\dlc-cpu\lib\site-packages\aniposelib\utils.py", line 156, in find_calibrationpairs for new in graph[item]: TypeError: 'NoneType' object is not subscriptable

How can I solve it?

lambdaloop commented 3 years ago

Yes, I think it's same as the issue listed here: https://github.com/lambdaloop/anipose/issues/48#issuecomment-724170389

For now, try a lower version of anipose as the commenter there suggested.

I will look into this issue more carefully next as it does seem like a lot of people are running into this.

jonmatthis commented 3 years ago

Yes, this is a very very common cause for failure in freemocap recordings -

I'm trying to track down the exact cause, but I think that you could side step most of this problem by providing better checks earlier in the anipose process and provide the user with meaningful feedback when something goes wrong with the charuco point detection BEFORE the data is sent along to the deeper parts of the code.

For example - this set of videos throws that same None type is not subscriptable error - https://www.dropbox.com/sh/u54fnrhe3wbbbeh/AADsFmbMjrk_QBJnVuVHy2dla?dl=0

I have been able to determine that (I think?) the error arrises because rtvecs in calibrate_rows has all nans for one of the cameras. However, this is confusing, because that camera DOES have detected charuco markers earlier in the pipeline.

Unfortunately, with the way the code is written its very difficulty to diagnose problems when the failure happens this deep into the processing pipeline. Clearly something went wrong earlier in the process (to produce the NaN's) but the error doesn't show up to until much later.

It would be incredibly helpful if you could put a couple checks at each stage of the processing pipeline that will throw errors (or at least warnings) when one or more of the cameras produces bad or empty data.

Thanks!