SimpleBlobDetector crash

cv2.SimpleBlobDetector().detect(…)
coredumps trying to dereference address zero.

	Peace
		--Devon

P.S. Any cure for the annoying echo of every input line?

$ lldb python3
lldb python3
(lldb) target create "python3"
Current executable set to 'python3' (x86_64).
(lldb) run
run
Process 34431 launched: '/Library/Frameworks/Python.framework/Versions/3.7/bin/python3' (x86_64)
Process 34431 stopped
* thread #2, stop reason = exec
    frame #0: 0x0000000100004000 dyld`_dyld_start
dyld`_dyld_start:
->  0x100004000 <+0>: popq   %rdi
    0x100004001 <+1>: pushq  $0x0
    0x100004003 <+3>: movq   %rsp, %rbp
    0x100004006 <+6>: andq   $-0x10, %rsp
Target 0: (Python) stopped.
(lldb) continue
continue
Process 34431 resuming
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
import cv2
print(cv2.__version__)
im = cv2.imread("/tmp/portrait.jpg", cv2.IMREAD_GRAYSCALE)
print(im)
print(cv2.SimpleBlobDetector().detect(im))

>>> import cv2
>>> print(cv2.__version__)
4.5.1
>>> im = cv2.imread("/tmp/portrait.jpg", cv2.IMREAD_GRAYSCALE)
>>> print(im)
[[ 23  23  23 ...  13  13  13]
 [ 23  23  23 ...  13  13  13]
 [ 23  23  23 ...  13  13  13]
 ...
 [254 254 254 ... 144 145 145]
 [254 254 254 ... 147 146 146]
 [254 254 254 ... 150 148 148]]
>>> print(cv2.SimpleBlobDetector().detect(im))
Process 34431 stopped
* thread #2, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000102cf1432 cv2.cpython-37m-darwin.so`pyopencv_cv_Feature2D_detect(_object*, _object*, _object*) + 386
cv2.cpython-37m-darwin.so`pyopencv_cv_Feature2D_detect:
->  0x102cf1432 <+386>: movq   (%rdi), %rax
    0x102cf1435 <+389>: movq   0x40(%rax), %rax
    0x102cf1439 <+393>: movq   $0x0, -0xb0(%rbp)
    0x102cf1444 <+404>: movl   $0x1010000, -0xc0(%rbp)   ; imm = 0x1010000 
Target 0: (Python) stopped.
(lldb) bt all
bt all
* thread #2, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000102cf1432 cv2.cpython-37m-darwin.so`pyopencv_cv_Feature2D_detect(_object*, _object*, _object*) + 386
    frame #1: 0x00000001000f05ed Python`_PyMethodDef_RawFastCallKeywords + 685
    frame #2: 0x00000001000f6152 Python`_PyMethodDescr_FastCallKeywords + 82
    frame #3: 0x00000001001ae5dc Python`call_function + 780
    frame #4: 0x00000001001ab55c Python`_PyEval_EvalFrameDefault + 25164
    frame #5: 0x00000001001af0d6 Python`_PyEval_EvalCodeWithName + 2422
    frame #6: 0x00000001001a5234 Python`PyEval_EvalCode + 100
    frame #7: 0x00000001001e24e7 Python`PyRun_InteractiveOneObjectEx + 599
    frame #8: 0x00000001001e1d52 Python`PyRun_InteractiveLoopFlags + 226
    frame #9: 0x00000001001e1c3c Python`PyRun_AnyFileExFlags + 60
    frame #10: 0x0000000100201ac6 Python`pymain_main + 7110
    frame #11: 0x0000000100201f2a Python`_Py_UnixMain + 58
    frame #12: 0x00007fff685773d5 libdyld.dylib`start + 1
  thread #3
    frame #0: 0x00007fff686ac322 libsystem_kernel.dylib`swtch_pri + 10
    frame #1: 0x00007fff6876de90 libsystem_pthread.dylib`sched_yield + 11
    frame #2: 0x00000001099eb1bb libopenblas.0.dylib`blas_thread_server + 123
    frame #3: 0x00007fff6876b2eb libsystem_pthread.dylib`_pthread_body + 126
    frame #4: 0x00007fff6876e249 libsystem_pthread.dylib`_pthread_start + 66
    frame #5: 0x00007fff6876a40d libsystem_pthread.dylib`thread_start + 13
(lldb)

you aren’t instantiating correctly.

OpenCV always needs you to use the create method of a class to create an instance. This goes for the C++ API as well as the Python API.

cv2.SimpleBlobDetector.create().detect(…) # python
cv2.SimpleBlobDetector_create().detect(…) # python, alternative

and it would be a very good idea to keep a reference to that instance, i.e.:

detector = cv2.SimpleBlobDetector.create()
detector.detect(...)

Thanks, that works. Was it always so? I see no mention of create in the SimpleBlobDetector docs and “tested” examples.

what docs and examples would those be? are you working with v2.4 docs? you really must not do that. if it’s not v2.4 docs you’re talking about, I would very much like to know very specifically what you’re referring to. links at least, or citations. not a rhetorical question.

current docs on that class have pretty much one (static) method and it is create (others inherited/overridden from superclasses) and even the docs for v3.0.0 have it. even v2.4 docs show use of cv::Ptr in most places.
OpenCV: cv::SimpleBlobDetector Class Reference

Thanks for the link but it’s time to go meta. Robo-docs are worse than useless, and this one in particular doesn’t even mention the methods I initially used. The mere existence of create suggests no such requirement to anyone who missed OpenCV summer camp, especially given the examples I followed (alas, those browser tabs are gone) and consequent cryptic coredump message. A link to the source might be a slight improvement but actual examples are best. How to add examples to that skimpy Class Reference? I need to find or make a libre OpenCV IDE with auto completion, auto chaining, electric documentation, the works — does it exist?