Giter VIP home page Giter VIP logo

Comments (28)

kevinyamauchi avatar kevinyamauchi commented on May 24, 2024 5

Hello everyone! I have been trying to run the tutorial and I have run into this same issue. After running the tutorial as-is, I noticed there were different number of board detections in each video. I then trimmed the video down to the first 1200 frames and there are 1200 board detections in all three calibration videos (per the terminal outputt - see traceback below). I still received the same NoneType error. I have pasted the traceback and my conda environment info below. Also, I've attached the detections.pickle file.

traceback

Calibrating...
C:\Users\realtime\Downloads\hand-demo-unfilled-20201109T151316Z-001\hand-demo-unfilled\2019-08-02
C:\Users\realtime\Downloads\hand-demo-unfilled-20201109T151316Z-001\hand-demo-unfilled\2019-08-02\calibration\calibration.toml
C:\Users\realtime\Downloads\hand-demo-unfilled-20201109T151316Z-001\hand-demo-unfilled\2019-08-02\calibration\calib-charuco-trim-camA.mov
100%|█████████████████████████████| 1200/1200 [00:40<00:00, 29.36it/s]
1200 boards detected
C:\Users\realtime\Downloads\hand-demo-unfilled-20201109T151316Z-001\hand-demo-unfilled\2019-08-02\calibration\calib-charuco-trim-camB.mov
100%|█████████████████████████████| 1200/1200 [00:43<00:00, 27.56it/s]
1200 boards detected
C:\Users\realtime\Downloads\hand-demo-unfilled-20201109T151316Z-001\hand-demo-unfilled\2019-08-02\calibration\calib-charuco-trim-camC.mov
100%|█████████████████████████████| 1200/1200 [00:42<00:00, 28.08it/s]
1200 boards detected
defaultdict(<class 'int'>, {('A', 'B'): 1200, ('B', 'A'): 1200})
Traceback (most recent call last):
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\realtime\anaconda3\envs\anipose-dlc\Scripts\anipose.exe\__main__.py", line 7, in <module>
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\anipose\anipose.py", line 116, in calibrate
    calibrate_all(config)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\anipose\common.py", line 168, in fun
    return process_all(config, process_session, **args)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\anipose\common.py", line 153, in process_all
    output[past_folders] = process_session(config, path, **args)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\anipose\calibrate.py", line 203, in process_session
    verbose=True)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\aniposelib\cameras.py", line 1563, in calibrate_rows
    rvecs, tvecs = get_initial_extrinsics(rtvecs)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\aniposelib\utils.py", line 173, in get_initial_extrinsics
    pairs = find_calibration_pairs(graph, source=0)
  File "c:\users\realtime\anaconda3\envs\anipose-dlc\lib\site-packages\aniposelib\utils.py", line 156, in find_calibration_pairs
    for new in graph[item]:
TypeError: 'NoneType' object is not subscriptable

environment

# packages in environment at C:\Users\realtime\anaconda3\envs\anipose-dlc:
#
# Name                    Version                   Build  Channel
_tflow_select             2.1.0                       gpu
absl-py                   0.11.0           py37haa95532_0
anipose                   0.9.0                    pypi_0    pypi
aniposelib                0.4.1                    pypi_0    pypi
apptools                  4.5.0                      py_0
argon2-cffi               20.1.0           py37he774522_1
astor                     0.8.1                    py37_0
async_generator           1.10             py37h28b3542_0
attrs                     20.3.0             pyhd3eb1b0_0
backcall                  0.2.0                      py_0
blas                      1.0                         mkl
bleach                    3.2.1                      py_0
bzip2                     1.0.8                he774522_0
ca-certificates           2020.10.14                    0
certifi                   2020.6.20          pyhd3eb1b0_3
cffi                      1.14.3           py37h7a1dbc1_0
chardet                   3.0.4                    pypi_0    pypi
click                     7.1.2                    pypi_0    pypi
colorama                  0.4.4                      py_0
configobj                 5.0.6                    py37_1
cudatoolkit               10.0.130                      0
cudnn                     7.6.5                cuda10.0_0
curl                      7.71.1               h2a8f88b_1
cycler                    0.10.0                   pypi_0    pypi
decorator                 4.4.2                      py_0
deeplabcut                2.1.8.2                  pypi_0    pypi
defusedxml                0.6.0                      py_0
easydict                  1.9                      pypi_0    pypi
entrypoints               0.3                      py37_0
envisage                  4.9.2                      py_0
expat                     2.2.10               h33f27b4_2
ffmpeg                    4.2.2                he774522_0
freetype                  2.10.4               hd328e21_0
future                    0.18.2                   py37_1
gast                      0.4.0                      py_0
geos                      3.8.0                h33f27b4_0
grpcio                    1.31.0           py37he7da953_0
h5py                      2.10.0           py37h5e291fa_0
hdf4                      4.2.13               h712560f_2
hdf5                      1.10.4               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha925a31_3
idna                      2.10                     pypi_0    pypi
imageio                   2.9.0                    pypi_0    pypi
imageio-ffmpeg            0.4.2                    pypi_0    pypi
imgaug                    0.4.0                    pypi_0    pypi
importlib-metadata        2.0.0                      py_1
importlib_metadata        2.0.0                         1
intel-openmp              2019.0                   pypi_0    pypi
ipykernel                 5.3.4            py37h5ca1d4c_0
ipython                   7.19.0           py37hd4e2768_0
ipython_genutils          0.2.0                    py37_0
ipywidgets                7.5.1                      py_1
jedi                      0.17.2                   py37_0
jinja2                    2.11.2                     py_0
joblib                    0.17.0                   pypi_0    pypi
jpeg                      9b                   hb83a4c4_2
jsoncpp                   1.8.4                h74a9793_0
jsonschema                3.2.0                      py_2
jupyter                   1.0.0                    py37_7
jupyter_client            6.1.7                      py_0
jupyter_console           6.2.0                      py_0
jupyter_core              4.6.3                    py37_0
jupyterlab_pygments       0.1.2                      py_0
keras-applications        1.0.8                      py_1
keras-preprocessing       1.1.0                      py_1
kiwisolver                1.3.1                    pypi_0    pypi
krb5                      1.18.2               hc04afaa_0
libcurl                   7.71.1               h2a8f88b_1
libiconv                  1.15                 h1df5818_7
libnetcdf                 4.6.1                h411e497_2
libpng                    1.6.37               h2a8f88b_0
libprotobuf               3.13.0.1             h200bbdf_0
libsodium                 1.0.18               h62dcd97_0
libssh2                   1.9.0                h7a1dbc1_1
libtiff                   4.1.0                h56a325e_0
libxml2                   2.9.10               hb89e7f3_3
llvmlite                  0.33.0                   pypi_0    pypi
lz4-c                     1.8.1.2              h2fa13f4_0
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  3.3.2                    py37_0
markupsafe                1.1.1            py37hfa6e2cd_1
matplotlib                3.0.3                    pypi_0    pypi
mayavi                    4.7.1            py37h11817fe_2
mistune                   0.8.4           py37hfa6e2cd_1001
mkl                       2020.2                      256
mkl-service               2.3.0            py37hb782905_0
mkl_fft                   1.2.0            py37h45dec08_0
mkl_random                1.1.1            py37h47e9c7a_0
mock                      4.0.2                      py_0
moviepy                   1.0.1                    pypi_0    pypi
msgpack                   1.0.0                    pypi_0    pypi
msgpack-numpy             0.4.7.1                  pypi_0    pypi
msys2-conda-epoch         20160418                      1
nb_conda                  2.2.1                    py37_0
nb_conda_kernels          2.3.0                    py37_0
nbclient                  0.5.1                      py_0
nbconvert                 6.0.7                    py37_0
nbformat                  5.0.8                      py_0
nest-asyncio              1.4.1                      py_0
networkx                  2.5                      pypi_0    pypi
notebook                  6.1.4                    py37_0
numba                     0.50.1                   pypi_0    pypi
numexpr                   2.7.1                    pypi_0    pypi
numpy                     1.16.4                   pypi_0    pypi
numpy-base                1.19.2           py37ha3acd2a_0
opencv-contrib-python     3.4.11.45                pypi_0    pypi
openssl                   1.1.1h               he774522_0
packaging                 20.4                       py_0
pandas                    1.1.4                    pypi_0    pypi
pandoc                    2.11                 h9490d1a_0
pandocfilters             1.4.2                    py37_1
parso                     0.7.0                      py_0
patsy                     0.5.1                    pypi_0    pypi
pickleshare               0.7.5                 py37_1001
pillow                    8.0.1                    pypi_0    pypi
pip                       20.2.4           py37haa95532_0
proglog                   0.1.9                    pypi_0    pypi
prometheus_client         0.8.0                      py_0
prompt-toolkit            3.0.8                      py_0
prompt_toolkit            3.0.8                         0
protobuf                  3.13.0.1         py37ha925a31_1
psutil                    5.7.3                    pypi_0    pypi
pycparser                 2.20                       py_2
pyface                    7.1.0                    py37_1
pygments                  2.7.2              pyhd3eb1b0_0
pyparsing                 2.4.7                      py_0
pyqt                      5.9.2            py37h6538335_2
pyreadline                2.1                      py37_1
pyrsistent                0.17.3           py37he774522_0
python                    3.7.9                h60c2a47_0
python-dateutil           2.8.1                      py_0
pytz                      2020.4                   pypi_0    pypi
pywavelets                1.1.1                    pypi_0    pypi
pywin32                   227              py37he774522_1
pywinpty                  0.5.7                    py37_0
pyyaml                    5.3.1                    pypi_0    pypi
pyzmq                     19.0.2           py37ha925a31_1
qt                        5.9.7            vc14h73c81de_0
qtconsole                 4.7.7                      py_0
qtpy                      1.9.0                      py_0
requests                  2.24.0                   pypi_0    pypi
ruamel-yaml               0.16.12                  pypi_0    pypi
ruamel-yaml-clib          0.2.2                    pypi_0    pypi
scikit-image              0.17.2                   pypi_0    pypi
scikit-learn              0.23.2                   pypi_0    pypi
scikit-video              1.1.11                   pypi_0    pypi
scipy                     1.5.2            py37h9439919_0
send2trash                1.5.0                    py37_0
setuptools                50.3.1           py37haa95532_1
shapely                   1.7.1            py37h210f175_0
sip                       4.19.8           py37h6538335_0
six                       1.15.0                     py_0
sqlite                    3.33.0               h2a8f88b_0
statsmodels               0.12.1                   pypi_0    pypi
tables                    3.6.1                    pypi_0    pypi
tabulate                  0.8.7                    pypi_0    pypi
tbb                       2020.3               h74a9793_0
tensorboard               1.13.1           py37h33f27b4_0
tensorflow                1.13.1          gpu_py37h83e5d6a_0
tensorflow-base           1.13.1          gpu_py37h871c8ca_0
tensorflow-estimator      1.13.0                     py_0
tensorflow-gpu            1.13.1               h0d30ee6_0
tensorpack                0.10.1                   pypi_0    pypi
termcolor                 1.1.0                    py37_1
terminado                 0.9.1                    py37_0
testpath                  0.4.4                      py_0
threadpoolctl             2.1.0                    pypi_0    pypi
tifffile                  2020.10.1                pypi_0    pypi
toml                      0.10.2                   pypi_0    pypi
tornado                   6.0.4            py37he774522_1
tqdm                      4.51.0                   pypi_0    pypi
traitlets                 5.0.5                      py_0
traits                    6.1.1            py37he774522_0
traitsui                  7.1.0                      py_0
urllib3                   1.25.11                  pypi_0    pypi
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_3
vtk                       8.2.0           py37h1e53df8_200
wcwidth                   0.2.5                      py_0
webencodings              0.5.1                    py37_1
werkzeug                  1.0.1                      py_0
wheel                     0.35.1                     py_0
widgetsnbextension        3.5.1                    py37_0
wincertstore              0.2                      py37_0
winpty                    0.4.3                         4
wxpython                  4.0.4            py37ha925a31_0
xz                        5.2.5                h62dcd97_0
zeromq                    4.3.2                ha925a31_3
zipp                      3.4.0              pyhd3eb1b0_0
zlib                      1.2.11               h62dcd97_4
zstd                      1.3.7                h508b16e_0

detections.zip

Quick update: I rolled back to anipose==0.8.1 and aniposelib==0.3.7 and the calibration runs (I haven't had a chance to evaluate the results)

from anipose.

jonnew avatar jonnew commented on May 24, 2024 1

More narrowing. It seems the issue ultimately stems from this line:

https://github.com/lambdaloop/aniposelib/blob/5eaf84a617545767703517f140037e3c46fa7cdb/aniposelib/utils.py#L123

I'm hitting this condition and the get_calibration_graph function returns Nonetype and everything crashes from there. I'm not quite clear what these functions are doing, but my guess is they are finding frames that contain a valid detection in a least a sub-set of cameras for the purpose of co-optimization of calibration parameters. I guess my calibration set might have a case where there is not a single instance where a valid detection occurs during the same frame on some minimal number of cameras?

from anipose.

KonradDanielewski avatar KonradDanielewski commented on May 24, 2024 1

Ye, had the same issue, it makes detections worse. Rolling back 0.8.1 and 0.3.7 + upgrade calligator, for some reason, was the only way I got everything working fine and reproducible.

from anipose.

jonnew avatar jonnew commented on May 24, 2024

OK, I at least understand why this is happening. The rtvecs = extract_rtvecs(merged) routine (line 179 of boards.py), is returning rtvecs with bunch of nans.

Also, I note that the size of the merged parameter is more than the minimal number of detections across all my cameras, which seems a bit odd. I guess it could be looking for 2-camera frame combos with a good detection? Or perhaps this might be due to bogus detections. Is there any way to manually curate a few 10's of detections so that I know the detections I'm feeding the calibration stuff are good?

from anipose.

Guillermo-Hidalgo-Gadea avatar Guillermo-Hidalgo-Gadea commented on May 24, 2024

Hi,

looks like I'm having the same issue during calibration.
Any ideas?

(anipose) D:\Anipose\EmoFace>anipose calibrate
Calibrating...
D:\Anipose\EmoFace\session4
D:\Anipose\EmoFace\session4\calibration\calibration.toml
D:\Anipose\EmoFace\session4\calibration\calibration_camA.avi
100%|███████████████████████████████| 480/480 [00:25<00:00, 18.71it/s]
440 boards detected
D:\Anipose\EmoFace\session4\calibration\calibration_camB.avi
100%|███████████████████████████████| 480/480 [00:27<00:00, 17.58it/s]
460 boards detected
defaultdict(<class 'int'>, {})
Traceback (most recent call last):
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\hidalggc\Anaconda3\envs\anipose\Scripts\anipose.exe_main
.py", line 7, in
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 829, in call
return self.main(*args, **kwargs)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\anipose\anipose.py", line 116, in calibrate
calibrate_all(config)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\anipose\common.py", line 168, in fun
return process_all(config, process_session, **args)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\anipose\common.py", line 153, in process_all
output[past_folders] = process_session(config, path, **args)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\anipose\calibrate.py", line 203, in process_session
verbose=True)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\aniposelib\cameras.py", line 1563, in calibrate_rows
rvecs, tvecs = get_initial_extrinsics(rtvecs)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\aniposelib\utils.py", line 173, in get_initial_extrinsics
pairs = find_calibration_pairs(graph, source=0)
File "c:\users\hidalggc\anaconda3\envs\anipose\lib\site-packages\aniposelib\utils.py", line 156, in find_calibration_pairs
for new in graph[item]:
TypeError: 'NoneType' object is not subscriptable

from anipose.

omeleavitt avatar omeleavitt commented on May 24, 2024

I'm also experiencing the same error across different computers in my lab. I even tried re-doing the tutorial calibration and got the same results.

from anipose.

jonnew avatar jonnew commented on May 24, 2024

@omeleavitt that is good to know. That indicates that it might be a bug introduced after the tutorial was written. @lambdaloop, have you tested the tutorial calibration recently to make sure this issue is not occurring even with test standard data?

from anipose.

omeleavitt avatar omeleavitt commented on May 24, 2024

I'd be interested to know whether this is an issue with machine configuration--is everyone here using a Windows machine & Anaconda virtual environment?

from anipose.

Guillermo-Hidalgo-Gadea avatar Guillermo-Hidalgo-Gadea commented on May 24, 2024

I'd be interested to know whether this is an issue with machine configuration--is everyone here using a Windows machine & Anaconda virtual environment?

@omeleavitt , I'm using windows insider preview 20190.1000, conda == 4.9.1, anipose == 0.9.0, aniposelib == 0.4.1, and previous projects worked before upgrading anise

from anipose.

kevinyamauchi avatar kevinyamauchi commented on May 24, 2024

I am also on Windows 10 + anaconda!

from anipose.

lambdaloop avatar lambdaloop commented on May 24, 2024

This is very odd... Internally we have been running the tutorial in Anaconda on both Windows and Ubuntu so it shouldn't crash. Perhaps there has indeed been a new bug introduced.

I'll try to reproduce it this week and see. Thank you for the all the version numbers and specific details, this will be very helpful!

from anipose.

ZiyiZhang0912 avatar ZiyiZhang0912 commented on May 24, 2024

I am learning how to use anipose, so I tried to use the calibration video provided in the demo to calibrate, but I also encountered the same error……

from anipose.

backyardbiomech avatar backyardbiomech commented on May 24, 2024

I have some information that might help. This is Windows 10, miniconda, anipose=0.9, aniposelib=0.4.1.
I'm running on my own videos, using a 9x7 ChArUco board, and have not tried the tutorial videos.

I can run everything fine on one set of videos, and complete a full 3d analysis.
I tried moving the cameras, so I recorded another set of calibration and data videos. They are placed in a separate directory in the same project folder as the first set. I copied the config.toml over, so that is unchanged.
Those work fine as well.

Adjust cameras, record, save in another folder. When I run anipose calibrate, the detections run, the detections.pkl file is saved, and I get that error. No calibration.toml is saved. I can go back and run it in the folder that works (after deleting the outputs), and it still works there, so it's not a clear cut installation or version issue.

With manually_verify=true, many/most frames have good detections. Loading the detections.pkl file, it's clear that most frames have most corners detected. Both cameras have 2000 frames saved, and I'd guess at least 1800 of each have a fully visible detectable board.

Of 6 different sets (slightly different lighting and camera positions), calibration works in 3 of them without error.

I'd be happy to post any files or tracebacks that might be helpful.

from anipose.

KonradDanielewski avatar KonradDanielewski commented on May 24, 2024

Maybe this will be helpful. I tested this on hand-demo and my own data. When you switch board size width and height (for instance, like in demo data, from [10, 7] to [7, 10]) it solves the NoneType error and calibration works. Tested on anipose 0.9.0, aniposelib 0.4.1, Win10, anaconda 4.9.2

Not sure where this comes from, I don't know what was changed in the code during updates and currently don't have time to compare older versions with the new ones.

from anipose.

backyardbiomech avatar backyardbiomech commented on May 24, 2024

Switching the board shape didn't help on my own charuco board videos, and with manually verify on, I confirmed that it made detections worse (detections in the center of black squares instead of the corners).

What does work for me is clipping out frames from the video. I don't know what exactly is causing it, and can't find any specific thing to clip out, but simply saving out some subsection of frames (e.g. 1000 of 2000, even when all 2000 have good detections) seems to do it. The problem is finding the correct frames (or clipping out the frames causing the errors), which takes some trial and error.

from anipose.

backyardbiomech avatar backyardbiomech commented on May 24, 2024

That fixed it for me. Now I wonder (and don't have time to look at diffs) what changed between 0.8.1 and 0.9? Might be time to build two envs - one for calibration and one for analysis.

from anipose.

KonradDanielewski avatar KonradDanielewski commented on May 24, 2024

After all the changes I'm not sure. With newest version I think I wasn't able to set reference point and axes, so there may have been some changes there. I'm now in the middle of an experiment but after that I plan to sit on it a bit and check what exactly was changed.

from anipose.

backyardbiomech avatar backyardbiomech commented on May 24, 2024

Unfortunately, downgrading doesn't work on all data sets. I may have to just clips some of those videos or ignore those trials for now.

from anipose.

backyardbiomech avatar backyardbiomech commented on May 24, 2024

I did a little tracking and think the problem arises in get_connections in utils.py. There is a line looking for not nans that will return None, apparently if it can't find paired good detections. But I don't have the time to fully debug.

I'm giving it videos of 2000 frames, with 1800+ detections in each video, so I know I'm giving it plenty of detections to work with.

My preferred workaround at this point is to reduce the frames I'm passing in order to (hopefully and randomly) eliminate troublesome frames. Based on the way I take my calibration videos, trimming the start and end can eliminate all images in certain portions of the filming volume and increase errors - and sometimes the error persists suggesting it's a middle frame.
So, now I take every x-th frame and create a new video, which is the one I actually pass to anipose. Keeping just every 100th frame (I'm filming at 100 fps, so this leaves me with one frame per second, which provides decent coverage) seems to work for all my troublesome set ups, and actually reduces the reconstruction error slightly compared to other setups where I pass all frames.
To keep every x-th frame (change input.mov, x, and output.mov:
ffmpeg -i input.mov -vf select='not(mod(n\, x))' -vsync vfr output.mov

Then put those output videos (make sure to use the same camera naming pattern so anipose can detect) in the calibration folder, and hide the originals somewhere else (even in a folder in the calibration folder).

from anipose.

osskar12 avatar osskar12 commented on May 24, 2024

Hi, Is there any update or solution to this issue? I am struggling with the same error at the moment.
Thanks for the help!

from anipose.

omeleavitt avatar omeleavitt commented on May 24, 2024

It seems like the problem is that the code crashes when you are missing detection overlaps between a pair of cameras that leaves a hole in the detections, so you need to go through each pair individually and see where that overlap is missing: e.g. if you have 4 cameras (A - D), you need at least [[A B], [B C], [C D], [D A]] or some other combination that ends up with 4 overlaps. Thus, people have lots of workarounds depending on if their problem was the detection system, or with the calibration videos they made.

What ended up working for me was checking through each possible pair of videos with the following:

  1. Copy the code from the tutorial for aniposelib (not anipose) into a Spyder window. Save this file as a python script and edit the file names and calibration board settings to reflect what you have.
  2. Cut down the list of videos and cameras so you're only looking at 2 at a time and run the code
  3. Go through pairs of videos and see if there's a pair that crash the same way as when you run anipose calibrate
  4. Look back at your calibration videos and check if there are any frames where these two cameras overlap
  5. If there are, the issue might be board detection. If not, make a new calibration video.

from anipose.

osskar12 avatar osskar12 commented on May 24, 2024

Thanks a lot for the quick answer.
It makes sense that the calibration needs to find sets of frames with overlaps over all the cameras. By my understanding, this should only be an issue if the calibration board has not been detected in all of the frames.

Though in my case, the board has been detected in all frames of all calibration videos, as seen below.
With 'manual verification' enabled, i also checked all frames and for every frame, all checkerboard corners were detected correctly.
I suppose the error must be somewhere else than in the board detection, but where?

I also added my config.toml file below.

/home/nsquared1/Desktop/Masterarbeit/Anipose/hand_kin/session1/calibration/calibration_anipose_cam_0.avi
100%|██████████████████████████████| 599/599 [00:01<00:00, 320.46it/s]
599 boards detected
/home/nsquared1/Desktop/Masterarbeit/Anipose/hand_kin/session1/calibration/calibration_anipose_cam_1.avi
100%|██████████████████████████████| 599/599 [00:02<00:00, 234.66it/s]
599 boards detected
/home/nsquared1/Desktop/Masterarbeit/Anipose/hand_kin/session1/calibration/calibration_anipose_cam_2.avi
100%|██████████████████████████████| 599/599 [00:00<00:00, 786.26it/s]
599 boards detected
defaultdict(<class 'int'>, {})
Traceback (most recent call last):
File "/home/nsquared1/anaconda3/envs/anipose/bin/anipose", line 8, in
sys.exit(cli())
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1137, in call
return self.main(*args, **kwargs)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/click/decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/click/core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/anipose.py", line 115, in calibrate
calibrate_all(config)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/common.py", line 168, in fun
return process_all(config, process_session, **args)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/common.py", line 153, in process_all
output[past_folders] = process_session(config, path, **args)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/anipose/calibrate.py", line 187, in process_session
verbose=True)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/cameras.py", line 1560, in calibrate_rows
rvecs, tvecs = get_initial_extrinsics(rtvecs)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/utils.py", line 174, in get_initial_extrinsics
extrinsics = compute_camera_matrices(rtvecs, pairs)
File "/home/nsquared1/anaconda3/envs/anipose/lib/python3.7/site-packages/aniposelib/utils.py", line 164, in compute_camera_matrices
source = pairs[0][0]
IndexError: list index out of range

Config.toml:

project = 'hand_kin'

model_folder = '/home/nsquared1/Desktop/Masterarbeit/DLC/hand_kin-Marius-2021-06-02'

nesting = 1

video_extension = 'avi'

[calibration]

board_type = "checkerboard"

board_size = [7, 9]

board_square_side_length = 20 # mm

animal_calibration = false

fisheye = false

[labeling]
scheme = [
["Wrist","Thumb2","Thumb1","Thumb0"],
["Wrist","Index3","Index2","Index1","Index0"],
["Wrist","Middle3","Middle2","Middle1","Middle0"],
["Wrist","Ring3","Ring2","Ring1","Ring0"],
["Wrist","Pinkie3","Pinkie2","Pinkie1","Pinkie0"]
]

[triangulation]
triangulate = true
cam_regex = '-cam_([0-9])'
cam_align = "0"
ransac = false
optim = true
constraints = [
["Wrist", "Thumb2"], ["Thumb2", "Thumb1"], ["Thumb1", "Thumb0"],
["Wrist", "Index3"], ["Index3", "Index2"], ["Index2", "Index1"], ["Index1", "Index0"],
["Wrist", "Middle3"], ["Middle3", "Middle2"], ["Middle2", "Middle1"], ["Middle1", "Middle0"],
["Wrist", "Ring3"], ["Ring3", "Ring2"], ["Ring2", "Ring1"], ["Ring1", "Ring0"],
["Wrist", "Pinkie3"], ["Pinkie3", "Pinkie2"], ["Pinkie2", "Pinkie1"], ["Pinkie1", "Pinkie0"]
]
scale_smooth = 25
scale_length = 10
scale_length_weak = 2
reproj_error_threshold = 3
score_threshold = 0.6
n_deriv_smooth = 2

from anipose.

osskar12 avatar osskar12 commented on May 24, 2024

Solved my issue! Turns out the cam_regex variable was set wrong so it could not match my files correctly.

from anipose.

DuanWei-fudan avatar DuanWei-fudan commented on May 24, 2024

I can calibrate after change the version from 0.9 to 0.8.1. But when I labeled the video with 3D, an exception occurred:
_Traceback (most recent call last):
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\vtkmodules\vtkCommonCore.py", line 5, in
from .vtkCommonCorePython import *
ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\administrator\anaconda3\envs\anipose\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\administrator\anaconda3\envs\anipose\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\Administrator\Anaconda3\envs\anipose\Scripts\anipose.exe_main
.py", line 7, in
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 1137, in call
return self.main(*args, **kwargs)
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\click\core.py", line 763, in invoke
return _callback(*args, **kwargs)
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\anipose\anipose.py", line 246, in label_3d
from .label_videos_3d import label_videos_3d_all
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\anipose\label_videos_3d.py", line 3, in
from mayavi import mlab
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\mayavi\mlab.py", line 16, in
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\mayavi\tools\camera.py", line 24, in
from .engine_manager import get_engine
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\mayavi\tools\engine_manager.py", line 13, in
from mayavi.core.registry import registry
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\mayavi\core\registry.py", line 16, in
from mayavi.core.metadata import Metadata, import_symbol
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\mayavi\core\metadata.py", line 11, in
from mayavi.core.pipeline_info import PipelineInfo
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\mayavi\core\pipeline_info.py", line 12, in
from .utils import get_tvtk_dataset_name
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\mayavi\core\utils.py", line 2, in
import vtk
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\vtk.py", line 32, in
all_spec.loader.exec_module(all_m)
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\vtkmodules\all.py", line 7, in
from .vtkCommonCore import *
File "c:\users\administrator\anaconda3\envs\anipose\lib\site-packages\vtkmodules\vtkCommonCore.py", line 9, in
from vtkCommonCorePython import *
ModuleNotFoundError: No module named 'vtkCommonCorePython'

from anipose.

DuanWei-fudan avatar DuanWei-fudan commented on May 24, 2024

It's odd when I return to the 0.9, the label-3d can work normally!

from anipose.

lambdaloop avatar lambdaloop commented on May 24, 2024

I was finally able to reproduce the first issue in this thread!

It turns out that the camera initialization fails when there are less than 7 points in one frame. I'm not sure why it doesn't just ignore that frame.. but here we are.

This explains why the approach from @backyardbiomech above works, because presumably it removes some frame that has less than 7 points detected.

I believe this commit should fix the issue:
lambdaloop/aniposelib@f10b738

from anipose.

lambdaloop avatar lambdaloop commented on May 24, 2024

For failed camera overlaps, the error would be more like @osskar12 . I can't fix the issue when there are no overlapping frames, that's ultimately an issue with the calibration videos themselves.

However, I've added a better error message to help more clearly identify the issue:
#70

from anipose.

lambdaloop avatar lambdaloop commented on May 24, 2024

I think both of these fixes should handle the problems listed in this issue.
You can try them out by upgrading to aniposelib 0.4.3

Let me know if you still encounter calibration issues and I'll look into it again

from anipose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.