Issue with OpenCV and too many descriptors in matching
Closed this issue · 1 comments
mhhd2020 commented
When uploading an A0 sketch map, the following error message appears. Probably due to too many descriptors (cf. https://stackoverflow.com/questions/20432403/error-215-traindesccollectioniidx-python-opencv)
Arguments: {'hostname': 'celery@H0108', 'id': 'a3a9bc42-27a9-4792-a65d-9cce615c278b', 'name': 'sketch_map_tool.tasks.digitize_sketches', 'exc': 'error("OpenCV(4.7.0) /io/opencv/modules/features2d/src/matchers.cpp:860: error: (-215:Assertion failed) trainDescCollection[iIdx].rows < IMGIDX_ONE in function 'knnMatchImpl'\n")', 'traceback': 'Traceback (most recent call last):
File "/home/matthias/.cache/pypoetry/virtualenvs/sketch-map-tool-SFkv235P-py3.11/lib/python3.11/site-packages/celery/app/trace.py", line 451, in trace_task
R = retval = fun(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/home/matthias/work/smt/sketch_map_tool/__init__.py", line 46, in __call__
return self.run(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/matthias/work/smt/sketch_map_tool/tasks.py", line 146, in digitize_sketches
[process(file_id, name) for file_id, name in zip(file_ids, file_names)]
File "/home/matthias/work/smt/sketch_map_tool/tasks.py", line 146, in <listcomp>
[process(file_id, name) for file_id, name in zip(file_ids, file_names)]
^^^^^^^^^^^^^^^^^^^^^^
File "/home/matthias/work/smt/sketch_map_tool/tasks.py", line 132, in process
r = clip(r, map_frame)
^^^^^^^^^^^^^^^^^^
File "/home/matthias/work/smt/sketch_map_tool/upload_processing/clip.py", line 28, in clip
matches = list(matcher.match(desc1, desc2, None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.7.0) /io/opencv/modules/features2d/src/matchers.cpp:860: error: (-215:Assertion failed) trainDescCollection[iIdx].rows < IMGIDX_ONE in function 'knnMatchImpl'
', 'args': "([14], ['Screenshot_2023-07-05_at_14-35-05_untitled_-_sketch-map-18.pdf_copy_4.png'], array([[[154, 204, 169],
[199, 232, 217],
[232, 253, 253],
...,
[118, 118, 118],
[118, 118, 118],
[ 55, 55, 55]],
[[154, 204, 169],
[217, 246, 247],
[232, 253, 253],
...,
[255, 255, 255],
[255, 255, 255],
[119, 119, 119]],
[[170, 196, 197],
[217, 246, 247],
[232, 253, 253],
...,
[255, 255, 255],
[255, 255, 255],
[119, 119, 119]],
...,
[[199, 206, 214],
[199, 206, 214],
[201, 208, 216],
...,
[201, 208, 216],
[201, 208, 216],
[201, 208, 216]],
[[199, 206, 214],
[199, 206, 214],
[199, 206, 214],
...,
[201, 208, 216],
[201, 208, 216],
[201, 208, 216]],
[[199, 206, 214],
[201, 208, 216],
[199, 206, 214],
...,
[201, 208, 216],
[201, 208, 216],
[201, 208, 216]]], dtype=uint8), Bbox(lon_min=964668.3060772641, lat_min=6343605.938051963, lon_max=967431.3455614758, lat_max=6345832.086898304))", 'kwargs': '{}', 'description': 'raised unexpected', 'internal': False}
matthiasschaub commented
Is fixed by limiting the keypoints.