Download modules/python/src2/cv2_util.hpp from tgollogly/test: direct link, hf CLI and curl.
- Browser
- Download file 3.41 kB
-
https://huggingface.co/tgollogly/test/resolve/main/modules/python/src2/cv2_util.hpp
- Command line
-
hf download hf://tgollogly/test/modules/python/src2/cv2_util.hpp
-
curl -L -o cv2_util.hpp https://huggingface.co/tgollogly/test/resolve/main/modules/python/src2/cv2_util.hpp
3.41 kB
| //====================================================================================================================== | |
| bool isPythonBindingsDebugEnabled(); | |
| void emit_failmsg(PyObject * exc, const char *msg); | |
| int failmsg(const char *fmt, ...); | |
| PyObject* failmsgp(const char *fmt, ...); | |
| //====================================================================================================================== | |
| class PyAllowThreads | |
| { | |
| public: | |
| PyAllowThreads() : _state(PyEval_SaveThread()) {} | |
| ~PyAllowThreads() | |
| { | |
| PyEval_RestoreThread(_state); | |
| } | |
| private: | |
| PyThreadState* _state; | |
| }; | |
| class PyEnsureGIL | |
| { | |
| public: | |
| PyEnsureGIL() : _state(PyGILState_Ensure()) {} | |
| ~PyEnsureGIL() | |
| { | |
| PyGILState_Release(_state); | |
| } | |
| private: | |
| PyGILState_STATE _state; | |
| }; | |
| /** | |
| * Light weight RAII wrapper for `PyObject*` owning references. | |
| * In comparison to C++11 `std::unique_ptr` with custom deleter, it provides | |
| * implicit conversion functions that might be useful to initialize it with | |
| * Python functions those returns owning references through the `PyObject**` | |
| * e.g. `PyErr_Fetch` or directly pass it to functions those want to borrow | |
| * reference to object (doesn't extend object lifetime) e.g. `PyObject_Str`. | |
| */ | |
| class PySafeObject | |
| { | |
| public: | |
| PySafeObject() : obj_(NULL) {} | |
| explicit PySafeObject(PyObject* obj) : obj_(obj) {} | |
| ~PySafeObject() | |
| { | |
| Py_CLEAR(obj_); | |
| } | |
| operator PyObject*() | |
| { | |
| return obj_; | |
| } | |
| operator PyObject**() | |
| { | |
| return &obj_; | |
| } | |
| operator bool() { | |
| return obj_ != nullptr; | |
| } | |
| PyObject* release() | |
| { | |
| PyObject* obj = obj_; | |
| obj_ = NULL; | |
| return obj; | |
| } | |
| private: | |
| PyObject* obj_; | |
| // Explicitly disable copy operations | |
| PySafeObject(const PySafeObject*); // = delete | |
| PySafeObject& operator=(const PySafeObject&); // = delete | |
| }; | |
| //====================================================================================================================== | |
| extern PyObject* opencv_error; | |
| void pyRaiseCVException(const cv::Exception &e); | |
| //====================================================================================================================== | |
| extern cv::TLSData<std::vector<std::string> > conversionErrorsTLS; | |
| inline void pyPrepareArgumentConversionErrorsStorage(std::size_t size) | |
| { | |
| std::vector<std::string>& conversionErrors = conversionErrorsTLS.getRef(); | |
| conversionErrors.clear(); | |
| conversionErrors.reserve(size); | |
| } | |
| void pyRaiseCVOverloadException(const std::string& functionName); | |
| void pyPopulateArgumentConversionErrors(); | |
| //====================================================================================================================== | |
| PyObject *pycvRedirectError(PyObject*, PyObject *args, PyObject *kw); | |