- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 Python 代码嵌入到 C++ 应用程序中。问题是,如果我在 C++ 代码中使用 OpenCV 函数,也在我嵌入的 python 函数中使用内存损坏。只需注释下面代码中的所有 opencv 函数即可解决问题。一件事是我的 C++ OpenCV 是 4.5.0(动态链接),从源代码编译,而 python 中使用的版本是 3.1.0(使用 python wheel 安装)。
查看回溯(但我不是这方面的专家)在我看来,python 中的调整大小函数在某种程度上依赖于 OpenCV 4.5.0 库来释放内存,导致两个版本之间存在某种冲突。Python 是 3.5.2 版本。
这是一个最小的例子。
我的主要cpp代码:
#include <iostream>
#include <Python.h>
#include <opencv2/opencv.hpp>
using namespace std;
int main()
{
cv::Mat test = cv::imread("/home/rocco/repo/cpp_python/current.jpg");
cv::Mat test_res;
cv::resize(test,test_res,cv::Size(),0.5,0.5);
cv::imwrite("resized.jpg",test_res);
std::string path = "/home/rocco/repo/cpp_python/current.jpg";
std::string filename = "script";
std::string function_name = "myfunction";
std::string wkd = "/home/rocco/repo/cpp_python";
auto script_name = PyUnicode_FromString(filename.c_str());
Py_Initialize();
PyObject *sys_path = PySys_GetObject("path");
PyList_Insert(sys_path, 0, PyUnicode_FromString(wkd.c_str()));
PySys_SetObject("path", sys_path);
PyObject *pModule;
pModule = PyImport_Import(script_name);
auto pFunc = PyObject_GetAttrString(pModule, function_name.c_str());
PyObject * pValue = NULL, * pArgs = NULL;
pArgs = PyTuple_New(2);
auto pFilename = PyUnicode_FromString(path.c_str());
PyTuple_SetItem(pArgs, 0, pFilename);
pValue = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
Py_DECREF(pFunc);
Py_DECREF(pModule);
Py_DECREF(pFilename);
Py_Finalize();
return 0;
}
我的 python 脚本:
import cv2
def myfunction(filename):
img = cv2.imread(filename, cv2.IMREAD_UNCHANGED)
scale_percent = 0.5 # percent of original size
img = cv2.resize(img, None, fx=scale_percent, fy=scale_percent)
cv2.imwrite('resized2.jpg',img)
myfunction('current.jpg')
此处提供回溯:
*** Error in `/home/rocco/repo/cpp_python/cpp_python': free(): invalid next size (fast): 0x0000000002447670 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777f5)[0x7f1a8c9807f5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8038a)[0x7f1a8c98938a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f1a8c98d58c]
/home/rocco/.local/lib/python3.5/site-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so(+0x103b8c)[0x7f1a8639bb8c]
/home/rocco/dynamic_libraries/opencv_4-5/lib/libopencv_core.so.4.5(_ZN2cv3Mat10deallocateEv+0x100)[0x7f1a8d5aa140]
/home/rocco/.local/lib/python3.5/site-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so(+0x114fe8)[0x7f1a863acfe8]
/home/rocco/.local/lib/python3.5/site-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so(+0x1154d4)[0x7f1a863ad4d4]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyCFunction_Call+0xe9)[0x7f1a90686049]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalFrameEx+0x7555)[0x7f1a90792135]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalFrameEx+0x79d9)[0x7f1a907925b9]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(+0x24ac6c)[0x7f1a90822c6c]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalCodeEx+0x23)[0x7f1a90822d43]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalCode+0x1b)[0x7f1a9078a94b]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(+0x1bf5fd)[0x7f1a907975fd]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyCFunction_Call+0xc9)[0x7f1a90686029]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalFrameEx+0x8c0e)[0x7f1a907937ee]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(+0x24ac6c)[0x7f1a90822c6c]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalFrameEx+0x62d9)[0x7f1a90790eb9]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalFrameEx+0x79d9)[0x7f1a907925b9]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalFrameEx+0x79d9)[0x7f1a907925b9]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalFrameEx+0x79d9)[0x7f1a907925b9]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(+0x24ac6c)[0x7f1a90822c6c]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyEval_EvalCodeEx+0x23)[0x7f1a90822d43]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(+0xd2ac8)[0x7f1a906aaac8]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyObject_Call+0x6e)[0x7f1a9075f46e]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(_PyObject_CallMethodIdObjArgs+0x1bf)[0x7f1a9073d95f]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyImport_ImportModuleLevelObject+0x864)[0x7f1a907c98d4]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(+0x1be638)[0x7f1a90796638]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyCFunction_Call+0xe9)[0x7f1a90686049]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyObject_Call+0x6e)[0x7f1a9075f46e]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyObject_CallFunction+0xcf)[0x7f1a9075f5cf]
/usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0(PyImport_Import+0xe6)[0x7f1a907c9d66]
/home/rocco/repo/cpp_python/cpp_python[0x402291]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f1a8c929840]
/home/rocco/repo/cpp_python/cpp_python[0x401e89]
======= Memory map: ========
00400000-00407000 r-xp 00000000 08:04 9180205 /home/rocco/repo/cpp_python/cpp_python
00606000-00607000 r--p 00006000 08:04 9180205 /home/rocco/repo/cpp_python/cpp_python
00607000-00608000 rw-p 00007000 08:04 9180205 /home/rocco/repo/cpp_python/cpp_python
01e0d000-0251f000 rw-p 00000000 00:00 0 [heap]
7f1a64000000-7f1a64021000 rw-p 00000000 00:00 0
7f1a64021000-7f1a68000000 ---p 00000000 00:00 0
7f1a690f0000-7f1a690f1000 rw-p 00000000 00:00 0
7f1a690f1000-7f1a6a74d000 rw-p 00000000 00:00 0
7f1a6a74d000-7f1a6beeb000 rw-p 00000000 00:00 0
7f1a6beeb000-7f1a6bf7f000 r-xp 00000000 08:04 530555 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_generator.cpython-35m-x86_64-linux-gnu.so
7f1a6bf7f000-7f1a6c17f000 ---p 00094000 08:04 530555 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_generator.cpython-35m-x86_64-linux-gnu.so
7f1a6c17f000-7f1a6c1a3000 rw-p 00094000 08:04 530555 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_generator.cpython-35m-x86_64-linux-gnu.so
7f1a6c1a3000-7f1a6c1a5000 rw-p 00000000 00:00 0
7f1a6c1a5000-7f1a6c1b0000 r-xp 00000000 08:04 530563 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_sfc64.cpython-35m-x86_64-linux-gnu.so
7f1a6c1b0000-7f1a6c3af000 ---p 0000b000 08:04 530563 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_sfc64.cpython-35m-x86_64-linux-gnu.so
7f1a6c3af000-7f1a6c3b1000 rw-p 0000a000 08:04 530563 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_sfc64.cpython-35m-x86_64-linux-gnu.so
7f1a6c3b1000-7f1a6c3bf000 r-xp 00000000 08:04 530561 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_pcg64.cpython-35m-x86_64-linux-gnu.so
7f1a6c3bf000-7f1a6c5bf000 ---p 0000e000 08:04 530561 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_pcg64.cpython-35m-x86_64-linux-gnu.so
7f1a6c5bf000-7f1a6c5c1000 rw-p 0000e000 08:04 530561 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_pcg64.cpython-35m-x86_64-linux-gnu.so
7f1a6c5c1000-7f1a6c5d2000 r-xp 00000000 08:04 530566 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_philox.cpython-35m-x86_64-linux-gnu.so
7f1a6c5d2000-7f1a6c7d1000 ---p 00011000 08:04 530566 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_philox.cpython-35m-x86_64-linux-gnu.so
7f1a6c7d1000-7f1a6c7d3000 rw-p 00010000 08:04 530566 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_philox.cpython-35m-x86_64-linux-gnu.so
7f1a6c7d3000-7f1a6c7d4000 rw-p 00000000 00:00 0
7f1a6c7d4000-7f1a6c7eb000 r-xp 00000000 08:04 530559 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_mt19937.cpython-35m-x86_64-linux-gnu.so
7f1a6c7eb000-7f1a6c9eb000 ---p 00017000 08:04 530559 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_mt19937.cpython-35m-x86_64-linux-gnu.so
7f1a6c9eb000-7f1a6c9ed000 rw-p 00017000 08:04 530559 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_mt19937.cpython-35m-x86_64-linux-gnu.so
7f1a6c9ed000-7f1a6ca3b000 r-xp 00000000 08:04 530556 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_bounded_integers.cpython-35m-x86_64-linux-gnu.so
7f1a6ca3b000-7f1a6cc3b000 ---p 0004e000 08:04 530556 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_bounded_integers.cpython-35m-x86_64-linux-gnu.so
7f1a6cc3b000-7f1a6cc3d000 rw-p 0004e000 08:04 530556 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_bounded_integers.cpython-35m-x86_64-linux-gnu.so
7f1a6cc3d000-7f1a6ce58000 r-xp 00000000 08:04 9437776 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f1a6ce58000-7f1a6d057000 ---p 0021b000 08:04 9437776 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f1a6d057000-7f1a6d073000 r--p 0021a000 08:04 9437776 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f1a6d073000-7f1a6d07f000 rw-p 00236000 08:04 9437776 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
7f1a6d07f000-7f1a6d082000 rw-p 00000000 00:00 0
7f1a6d082000-7f1a6d088000 r-xp 00000000 08:04 7086087 /usr/lib/python3.5/lib-dynload/_hashlib.cpython-35m-x86_64-linux-gnu.so
7f1a6d088000-7f1a6d287000 ---p 00006000 08:04 7086087 /usr/lib/python3.5/lib-dynload/_hashlib.cpython-35m-x86_64-linux-gnu.so
7f1a6d287000-7f1a6d288000 r--p 00005000 08:04 7086087 /usr/lib/python3.5/lib-dynload/_hashlib.cpython-35m-x86_64-linux-gnu.so
7f1a6d288000-7f1a6d289000 rw-p 00006000 08:04 7086087 /usr/lib/python3.5/lib-dynload/_hashlib.cpython-35m-x86_64-linux-gnu.so
7f1a6d289000-7f1a6d2b9000 r-xp 00000000 08:04 530568 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_common.cpython-35m-x86_64-linux-gnu.so
7f1a6d2b9000-7f1a6d4b8000 ---p 00030000 08:04 530568 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_common.cpython-35m-x86_64-linux-gnu.so
7f1a6d4b8000-7f1a6d4ba000 rw-p 0002f000 08:04 530568 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_common.cpython-35m-x86_64-linux-gnu.so
7f1a6d4ba000-7f1a6d4bb000 rw-p 00000000 00:00 0
7f1a6d4bb000-7f1a6d4e0000 r-xp 00000000 08:04 530557 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_bit_generator.cpython-35m-x86_64-linux-gnu.so
7f1a6d4e0000-7f1a6d6e0000 ---p 00025000 08:04 530557 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_bit_generator.cpython-35m-x86_64-linux-gnu.so
7f1a6d6e0000-7f1a6d6e5000 rw-p 00025000 08:04 530557 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/_bit_generator.cpython-35m-x86_64-linux-gnu.so
7f1a6d6e5000-7f1a6d6e6000 rw-p 00000000 00:00 0
7f1a6d6e6000-7f1a6d75e000 r-xp 00000000 08:04 530558 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/mtrand.cpython-35m-x86_64-linux-gnu.so
7f1a6d75e000-7f1a6d95d000 ---p 00078000 08:04 530558 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/mtrand.cpython-35m-x86_64-linux-gnu.so
7f1a6d95d000-7f1a6d983000 rw-p 00077000 08:04 530558 /home/rocco/.local/lib/python3.5/site-packages/numpy/random/mtrand.cpython-35m-x86_64-linux-gnu.so
7f1a6d983000-7f1a6d985000 rw-p 00000000 00:00 0
7f1a6d985000-7f1a6d99b000 r-xp 00000000 08:04 529217 /home/rocco/.local/lib/python3.5/site-packages/numpy/fft/_pocketfft_internal.cpython-35m-x86_64-linux-gnu.so
7f1a6d99b000-7f1a6db9a000 ---p 00016000 08:04 529217 /home/rocco/.local/lib/python3.5/site-packages/numpy/fft/_pocketfft_internal.cpython-35m-x86_64-linux-gnu.so
7f1a6db9a000-7f1a6db9b000 rw-p 00015000 08:04 529217 /home/rocco/.local/lib/python3.5/site-packages/numpy/fft/_pocketfft_internal.cpython-35m-x86_64-linux-gnu.so
7f1a6db9b000-7f1a6dbd2000 r-xp 00000000 08:04 6824744 /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7f1a6dbd2000-7f1a6ddd1000 ---p 00037000 08:04 6824744 /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7f1a6ddd1000-7f1a6ddd2000 r--p 00036000 08:04 6824744 /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7f1a6ddd2000-7f1a6ddd3000 rw-p 00037000 08:04 6824744 /usr/lib/x86_64-linux-gnu/libmpdec.so.2.4.2
7f1a6ddd3000-7f1a6ddf7000 r-xp 00000000 08:04 7150229 /usr/lib/python3.5/lib-dynload/_decimal.cpython-35m-x86_64-linux-gnu.so
7f1a6ddf7000-7f1a6dff6000 ---p 00024000 08:04 7150229 /usr/lib/python3.5/lib-dynload/_decimal.cpython-35m-x86_64-linux-gnu.so
7f1a6dff6000-7f1a6dff7000 r--p 00023000 08:04 7150229 /usr/lib/python3.5/lib-dynload/_decimal.cpython-35m-x86_64-linux-gnu.so
7f1a6dff7000-7f1a6e000000 rw-p 00024000 08:04 7150229 /usr/lib/python3.5/lib-dynload/_decimal.cpython-35m-x86_64-linux-gnu.so
7f1a6e000000-7f1a70000000 rw-p 00000000 00:00 0
7f1a70000000-7f1a70021000 rw-p 00000000 00:00 0
7f1a70021000-7f1a74000000 ---p 00000000 00:00 0
7f1a74000000-7f1a78000000 rw-p 00000000 00:00 0
7f1a78000000-7f1a78021000 rw-p 00000000 00:00 0
7f1a78021000-7f1a7c000000 ---p 00000000 00:00 0
7f1a7c010000-7f1a7c190000 rw-p 00000000 00:00 0
7f1a7c190000-7f1a7c197000 r-xp 00000000 08:04 7136401 /usr/lib/python3.5/lib-dynload/_lzma.cpython-35m-x86_64-linux-gnu.so
7f1a7c197000-7f1a7c396000 ---p 00007000 08:04 7136401 /usr/lib/python3.5/lib-dynload/_lzma.cpython-35m-x86_64-linux-gnu.so
7f1a7c396000-7f1a7c397000 r--p 00006000 08:04 7136401 /usr/lib/python3.5/lib-dynload/_lzma.cpython-35m-x86_64-linux-gnu.so
7f1a7c397000-7f1a7c399000 rw-p 00007000 08:04 7136401 /usr/lib/python3.5/lib-dynload/_lzma.cpython-35m-x86_64-linux-gnu.so
7f1a7c399000-7f1a7c3a8000 r-xp 00000000 08:04 9437491 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f1a7c3a8000-7f1a7c5a7000 ---p 0000f000 08:04 9437491 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f1a7c5a7000-7f1a7c5a8000 r--p 0000e000 08:04 9437491 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f1a7c5a8000-7f1a7c5a9000 rw-p 0000f000 08:04 9437491 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
7f1a7c5a9000-7f1a7c5ad000 r-xp 00000000 08:04 7136410 /usr/lib/python3.5/lib-dynload/_bz2.cpython-35m-x86_64-linux-gnu.so
7f1a7c5ad000-7f1a7c7ac000 ---p 00004000 08:04 7136410 /usr/lib/python3.5/lib-dynload/_bz2.cpython-35m-x86_64-linux-gnu.so
7f1a7c7ac000-7f1a7c7ad000 r--p 00003000 08:04 7136410 /usr/lib/python3.5/lib-dynload/_bz2.cpython-35m-x86_64-linux-gnu.so
7f1a7c7ad000-7f1a7c7ae000 rw-p 00004000 08:04 7136410 /usr/lib/python3.5/lib-dynload/_bz2.cpython-35m-x86_64-linux-gnu.so
7f1a7c7ae000-7f1a7c8ae000 rw-p 00000000 00:00 0
7f1a7c8ae000-7f1a7c8d9000 r-xp 00000000 08:04 530149 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/_umath_linalg.cpython-35m-x86_64-linux-gnu.so
7f1a7c8d9000-7f1a7cad9000 ---p 0002b000 08:04 530149 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/_umath_linalg.cpython-35m-x86_64-linux-gnu.so
7f1a7cad9000-7f1a7cadb000 rw-p 0002b000 08:04 530149 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/_umath_linalg.cpython-35m-x86_64-linux-gnu.so
7f1a7cadb000-7f1a7cade000 rw-p 000d4000 08:04 530149 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/_umath_linalg.cpython-35m-x86_64-linux-gnu.so
7f1a7cade000-7f1a7cae2000 r-xp 00000000 08:04 530150 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so
7f1a7cae2000-7f1a7cce2000 ---p 00004000 08:04 530150 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so
7f1a7cce2000-7f1a7cce3000 rw-p 00004000 08:04 530150 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so
7f1a7cce3000-7f1a7cce5000 rw-p 00019000 08:04 530150 /home/rocco/.local/lib/python3.5/site-packages/numpy/linalg/lapack_lite.cpython-35m-x86_64-linux-gnu.so
7f1a7cce5000-7f1a7cda5000 rw-p 00000000 00:00 0
7f1a7cda5000-7f1a7cdc7000 r-xp 00000000 08:04 7136407 /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so
7f1a7cdc7000-7f1a7cfc6000 ---p 00022000 08:04 7136407 /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so
7f1a7cfc6000-7f1a7cfc7000 r--p 00021000 08:04 7136407 /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so
7f1a7cfc7000-7f1a7cfcb000 rw-p 00022000 08:04 7136407 /usr/lib/python3.5/lib-dynload/_ctypes.cpython-35m-x86_64-linux-gnu.so
7f1a7cfcb000-7f1a7cfcc000 rw-p 00000000 00:00 0
7f1a7cfcc000-7f1a7cfeb000 r-xp 00000000 08:04 530237 /home/rocco/.local/lib/python3.5/site-packages/numpy/core/_multiarray_tests.cpython-35m-x86_64-linux-gnu.so
7f1a7cfeb000-7f1a7d1eb000 ---p 0001f000 08:04 530237 /home/rocco/.local/lib/python3.5/site-packages/numpy/core/_multiarray_tests.cpython-35m-x86_64-linux-gnu.so
7f1a7d1eb000-7f1a7d1ed000 rw-p 0001f000 08:04 530237 /home/rocco/.local/lib/python3.5/site-packages/numpy/core/_multiarray_tests.cpython-35m-x86_64-linux-gnu.so
7f1a7d1ed000-7f1a7d26d000 rw-p 00000000 00:00 0
7f1a7d26d000-7f1a7d26e000 ---p 00000000 00:00 0
7f1a7d26e000-7f1a7da6e000 rw-p 00000000 00:00 0
7f1a7da6e000-7f1a7f564000 r-xp 00000000 08:04 532531 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libopenblasp-r0-34a18dc3.3.7.so
7f1a7f564000-7f1a7f763000 ---p 01af6000 08:04 532531 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libopenblasp-r0-34a18dc3.3.7.so
7f1a7f763000-7f1a7f77c000 rw-p 01af5000 08:04 532531 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libopenblasp-r0-34a18dc3.3.7.so
7f1a7f77c000-7f1a7f787000 rw-p 00000000 00:00 0
7f1a7f787000-7f1a7f7ff000 rw-p 01be1000 08:04 532531 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libopenblasp-r0-34a18dc3.3.7.so
7f1a7f7ff000-7f1a7f800000 ---p 00000000 00:00 0
7f1a7f800000-7f1a80000000 rw-p 00000000 00:00 0
7f1a80000000-7f1a80021000 rw-p 00000000 00:00 0
7f1a80021000-7f1a84000000 ---p 00000000 00:00 0
7f1a8401d000-7f1a840dd000 rw-p 00000000 00:00 0
7f1a840fe000-7f1a841be000 rw-p 00000000 00:00 0
7f1a841be000-7f1a841bf000 ---p 00000000 00:00 0
7f1a841bf000-7f1a849bf000 rw-p 00000000 00:00 0
7f1a849bf000-7f1a849c0000 ---p 00000000 00:00 0
7f1a849c0000-7f1a851c0000 rw-p 00000000 00:00 0
7f1a851c0000-7f1a852b0000 r-xp 00000000 08:04 532291 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libgfortran-ed201abd.so.3.0.0
7f1a852b0000-7f1a854af000 ---p 000f0000 08:04 532291 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libgfortran-ed201abd.so.3.0.0
7f1a854af000-7f1a854b1000 rw-p 000ef000 08:04 532291 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libgfortran-ed201abd.so.3.0.0
7f1a854b1000-7f1a854b2000 rw-p 00000000 00:00 0
7f1a854b2000-7f1a854ba000 rw-p 000f2000 08:04 532291 /home/rocco/.local/lib/python3.5/site-packages/numpy.libs/libgfortran-ed201abd.so.3.0.0
7f1a854ba000-7f1a8585f000 r-xp 00000000 08:04 530243 /home/rocco/.local/lib/python3.5/site-packages/numpy/core/_multiarray_umath.cpython-35m-x86_64-linux-gnu.so
7f1a8585f000-7f1a85a5e000 ---p 003a5000 08:04 530243 /home/rocco/.local/lib/python3.5/site-packages/numpy/core/_multiarray_umath.cpython-35m-x86_64-linux-gnu.so
7f1a85a5e000-7f1a85a7d000 rw-p 003a4000 08:04 530243 /home/rocco/.local/lib/python3.5/site-packages/numpy/core/_multiarray_umath.cpython-35m-x86_64-linux-gnu.so
7f1a85a7d000-7f1a85a9e000 rw-p 00000000 00:00 0
7f1a85a9e000-7f1a85aa5000 rw-p 01474000 08:04 530243 /home/rocco/.local/lib/python3.5/site-packages/numpy/core/_multiarray_umath.cpython-35m-x86_64-linux-gnu.so
7f1a85aa5000-7f1a85ae5000 rw-p 00000000 00:00 0
7f1a85ae5000-7f1a85b53000 r-xp 00000000 08:04 9441868 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f1a85b53000-7f1a85d53000 ---p 0006e000 08:04 9441868 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f1a85d53000-7f1a85d54000 r--p 0006e000 08:04 9441868 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f1a85d54000-7f1a85d55000 rw-p 0006f000 08:04 9441868 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7f1a85d55000-7f1a85e64000 r-xp 00000000 08:04 9437261 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7f1a85e64000-7f1a86063000 ---p 0010f000 08:04 9437261 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7f1a86063000-7f1a86064000 r--p 0010e000 08:04 9437261 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7f1a86064000-7f1a86065000 rw-p 0010f000 08:04 9437261 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7f1a86065000-7f1a86066000 rw-p 00000000 00:00 0
7f1a86066000-7f1a86067000 r-xp 00000000 08:04 6819030 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7f1a86067000-7f1a86266000 ---p 00001000 08:04 6819030 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7f1a86266000-7f1a86267000 r--p 00000000 08:04 6819030 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7f1a86267000-7f1a86268000 rw-p 00001000 08:04 6819030 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7f1a86298000-7f1a870f2000 r-xp 00000000 08:04 528776 /home/rocco/.local/lib/python3.5/site-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so
7f1a870f2000-7f1a872f1000 ---p 00e5a000 08:04 528776 /home/rocco/.local/lib/python3.5/site-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so
7f1a872f1000-7f1a8733f000 rw-p 00e59000 08:04 528776 /home/rocco/.local/lib/python3.5/site-packages/cv2/cv2.cpython-35m-x86_64-linux-gnu.so
7f1a8733f000-7f1a87465000 rw-p 00000000 00:00 0
7f1a87465000-7f1a8773f000 r--p 00000000 08:04 6816127 /usr/lib/locale/locale-archive
7f1a8773f000-7f1a87740000 ---p 00000000 00:00 0
7f1a87740000-7f1a87f40000 rw-p 00000000 00:00 0
7f1a87f40000-7f1a87f41000 ---p 00000000 00:00 0
7f1a87f41000-7f1a8a336000 rw-p 00000000 00:00 0
7f1a8a336000-7f1a8a33b000 r-xp 00000000 08:04 6823807 /usr/lib/x86_64-linux-gnu/libIlmThread-2_2.so.12.0.0
7f1a8a33b000-7f1a8a53b000 ---p 00005000 08:04 6823807 /usr/lib/x86_64-linux-gnu/libIlmThread-2_2.so.12.0.0
编辑
经过一些测试,我尝试将 python 更新到版本 3.6.13,但问题仍然存在,此外我意识到问题与 cv2.resize 函数无关,而是与一般的 opencv 相关,无论我从 python 调用什么 opencv 函数,它调用我的动态链接 opencv 4.5 库进行释放,导致问题。
编辑
在 C++ 中使用静态链接的 OpenCV,一切都按预期工作。这有什么原因吗?
最佳答案
这似乎是一个链接问题。
Python 使用“dlopen”动态加载库,尝试更改 flags传递给这个函数。例如,使用 RTLD_DEEPBIND,您可以指定首选加载对象包含的符号(而不是具有相同名称的全局符号)。
使用这两行:
import os
print(os.RTLD_DEEPBIND | os.RTLD_NOW)
您可以获得这些标志的int代码,即10。
然后您可以通过调用 sys.setdlopenflags(10)
更改 dlopen 使用的标志:
void setFlags()
{
auto flag = PyLong_FromLong(10);
auto setdl = PySys_GetObject("setdlopenflags");
auto arg = PyTuple_New(1);
PyTuple_SetItem(arg, 0, flag);
PyObject_CallObject(setdl, arg);
}
它必须在 PyImport_Import
之前使用。
关于python - 在已经使用 OpenCV 但版本不同的 C++ 中将 Python 与 OpenCV 嵌入内存损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66297277/
我正在尝试从我的系统中完全删除 opencv。我试图学习 ROS,而在教程中我遇到了一个问题。创建空工作区后,我调用catkin_make 它给出了一个常见错误,我在 answers.ros 中搜索并
我在尝试逐步转移对warpAffine的调用时遇到崩溃(不是异常): void rotateImage( const Mat& source, double degree, Mat& output )
如何处理opencv gpu异常?是否有用于opencvgpu异常处理的特定错误代码集api? 我尝试了很多搜索,但只有1个错误代码,即CV_GpuNotSupported。 请帮帮我。 最佳答案 虽
笔记 我是 OpenCV(或计算机视觉)的新手,所以告诉我搜索查询会很有帮助! 我想问什么 我想编写一个从图片中提取名片的程序。 我能够提取粗略的轮廓,但反射光会变成噪点,我无法提取准确的轮廓。请告诉
我想根据像素的某个阈值将Mono16类型的Mat转换为二进制图像。我尝试使用以下内容: 阈值(img,ret,0.1,1,CV_THRESH_BINARY); 尝试编译时,出现make错误,提示: 错
我对使用GPU加速的OpenCV中的卷积函数有疑问。 使用GPU的卷积速度大约快3.5 运行时: convolve(src_32F, kernel, cresult, false, cbuffer);
我正在尝试使用非对称圆圈网格执行相机校准。 我通常找不到适合CirclesGridFinder的文档,尤其是findHoles()函数的文档。 如果您有关于此功能如何工作以及其参数含义的信息,将不胜感
在计算机上绘图和在 OpenCV 的投影仪上投影之间有什么区别吗? 一种选择是投影显示所有内容的计算机屏幕。但也许也有这样的选择,即在投影仪上精确地绘制和投影图像,仅使用计算机作为计算机器。如果我能做
我将Processing(processing.org)用于需要人脸跟踪的项目。现在的问题是由于for循环,程序将耗尽内存。我想停止循环或至少解决内存不足的问题。这是代码。 import hyperm
我有下面的代码: // Image Processing.cpp : Defines the entry point for the console application. // //Save
我正在为某些项目使用opencv。并有应解决的任务。 任务很简单。我有一张主图片,并且有一个模板,而不是将主图片与模板进行比较。我使用matchTemplate()函数。我只是好奇一下。 在文档中,我
我正在尝试使用以下命令创建级联分类器: haartraining -data haarcascade -vec samples.vec -bg negatives.dat -nstages 20 -n
我试图使用OpenCV检测黑色图像中一组形状的颜色,为此我使用了Canny检测。但是,颜色输出总是返回为黑色。 std::vector > Asteroids::DetectPoints(const
我正在尝试使用OpenCv 2.4.5从边缘查找渐变方向,但是我在使用cvSobel()时遇到问题,以下是错误消息和我的代码。我在某处读到它可能是由于浮点(??)之间的转换,但我不知道如何解决它。有帮
我正在尝试构建循环关闭算法,但是在开始开发之前,我想测试哪种功能描述符在真实数据集上效果更好。 我有两个在两个方向拍摄的走廊图像,一个进入房间,另一个离开同一个房间。因此它们代表相同的场景,但具有2个
有没有一种方法可以比较直方图,但例如要排除白色,因此白色不会影响比较。 最佳答案 白色像素有 饱和度 , S = 0 .因此,在创建直方图时很容易从计数中删除白色像素。请执行下列操作: 从 BGR 转
就像本主题的标题一样,如何在OpenCV中确定图像的特定像素(灰度或彩色)是否饱和(例如,亮度过高)? 先感谢您。 最佳答案 根据定义,饱和像素是指与强度(即灰度值或颜色分量之一)等于255相关联的像
我是OpenCV的新用户,正在从事大学项目。程序会获取输入图像,对其进行综合模糊处理,然后对其进行模糊处理。当对合成模糊图像进行反卷积时,会生成边界伪像,因为...好吧,到目前为止,我还没有实现边界条
我想知道OpenCV是haar特征还是lbp是在多尺度搜索过程中缩放图像还是像论文中提到的那样缩放特征本身? 编辑:事实证明,检测器可以缩放图像,而不是功能。有人知道为什么吗?通过缩放功能可以更快。
我在openCv中使用SVM.train命令(已定义了适当的参数)。接下来,我要使用我的算法进行分类,而不是使用svm.predict。 可能吗?我可以访问训练时生成的支持 vector 吗?如果是这
我是一名优秀的程序员,十分优秀!