3 ms·
I don't know much about Python's C API, but this is the line in the OpenCV Python bindings that drops the GIL: https://github.com/opencv/opencv/blob/4.5.0/modul
by drothlis 6y ago
I don't know much about Python's C API, but this is the line in the OpenCV Python bindings that drops the GIL:
https://github.com/opencv/opencv/blob/4.5.0/modules/python/src2/cv2.cpp#L123 https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...
(see https://docs.python.org/3/c-api/init.html#releasing-the-gil-from-extension-code https://docs.python.org/3/c-api/init.html#releasing-the-gil-... in the Python C API manual).
That's only called from the ERRWRAP2 macro here:
https://github.com/opencv/opencv/blob/4.5.0/modules/python/src2/cv2.cpp#L158 https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...
That macro, in turn, is called from gen_template_func_body in gen2.py:
https://github.com/opencv/opencv/blob/4.5.0/modules/python/src2/gen2.py https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...
And that seems to be a code generator that is generating the bindings for all the OpenCV functions:
https://github.com/opencv/opencv/blob/4.5.0/modules/python/src2/gen2.py#L1096-L1103 https://github.com/opencv/opencv/blob/4.5.0/modules/python/s...
As to testing this, on Linux I'd run `atop` to see if your program is using all available CPUs.
- mgradowski 6y agoNice spelunking! If there is hope of avoiding C++ altogether, then I'll try testing it again on something beefier than my laptop. Thanks for taking the time and effort.