-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Segmentation fault when inheriting from openCV cpp-classes in Python #15804
Description
System information (version)
- OpenCV => 4.1.0
- Operating System / Platform => macOS 10.15
- Compiler => homebrew
Detailed description
I get a segmentation fault when calling a python class which inherits from a openCV-cpp-class (similar to the issue described here: https://github.com/microsoft/ptvsd/issues/1410). This makes extending openCV-classes in Python unreliable. I'm not even sure if it should be possible to inherit openCV classes (as superclass) in Python because the .create()-policy to instantiate a new instance will always return the pure cpp-class not the inherited python class. Instantiation without .create() (like foo = PyDerivedClass()) will lead to a TypeError (incorrect type of self ...) when trying to call the inherited cpp-methods.
All in all, it might be worth rethinking which classes etc. should have python bindings (e.g. cv2.ml_StatModel can be called in python but its pretty much useless) and/or make a note somewhere in the documentation.
Steps to reproduce
```.py
import cv2
class DerivedClass(cv2.ml_NormalBayesClassifier):
def __init__(self):
super().__init__()
for i in range(3):
foo = DerivedClass()
```