Skip to content

Segmentation fault on KalmanFilter class inheritance (Python) #21697

@ernstleierzopf

Description

@ernstleierzopf

I have already posted this issue to the pytest project, but this seems to be opencv related: pytest-dev/pytest#9738

System information (version)
  • opencv-python => 4.5.4.58 (installed with pip)
  • Operating System / Platform => Linux Mint 20.3
Detailed description

Inheritance of the OpenCV KalmanFilter leads to a segmentation fault.

Steps to reproduce
from cv2 import cv2


class KalmanFilter1(cv2.KalmanFilter):
    def __init__(self):
        super(KalmanFilter1, self).__init__()
        pass


def test():
    kf = KalmanFilter1()


def test2():
    kf = KalmanFilter1()


if __name__ == "__main__":
    test()
    test2()

Running this code with pytest or as normal python program produces following error (sometimes you have to run the code multiple times to produce the segmentation fault):

platform linux -- Python 3.8.10, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /home/ernst/Documents/git_projects/jetson-nano-facerecognition
collected 2 items                                                                                                                                                                                                                                                                                                            

test.py ..Fatal Python error: Segmentation fault

Current thread 0x00007f21b26ac740 (most recent call first):
  File "/usr/local/lib/python3.8/dist-packages/_pytest/terminal.py", line 1173 in _set_main_color
  File "/usr/local/lib/python3.8/dist-packages/_pytest/terminal.py", line 1150 in _get_main_color
  File "/usr/local/lib/python3.8/dist-packages/_pytest/terminal.py", line 619 in _write_progress_information_filling_space
  File "/usr/local/lib/python3.8/dist-packages/_pytest/terminal.py", line 592 in pytest_runtest_logfinish
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/local/lib/python3.8/dist-packages/_pytest/runner.py", line 110 in pytest_runtest_protocol
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/local/lib/python3.8/dist-packages/_pytest/main.py", line 348 in pytest_runtestloop
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/local/lib/python3.8/dist-packages/_pytest/main.py", line 323 in _main
  File "/usr/local/lib/python3.8/dist-packages/_pytest/main.py", line 269 in wrap_session
  File "/usr/local/lib/python3.8/dist-packages/_pytest/main.py", line 316 in pytest_cmdline_main
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_callers.py", line 39 in _multicall
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/usr/local/lib/python3.8/dist-packages/pluggy/_hooks.py", line 265 in __call__
  File "/usr/local/lib/python3.8/dist-packages/_pytest/config/__init__.py", line 162 in main
  File "/usr/local/lib/python3.8/dist-packages/_pytest/config/__init__.py", line 185 in console_main
  File "/usr/local/lib/python3.8/dist-packages/pytest/__main__.py", line 5 in <module>
  File "/usr/lib/python3.8/runpy.py", line 87 in _run_code
  File "/usr/lib/python3.8/runpy.py", line 194 in _run_module_as_main
Segmentation fault (core dumped)
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions