- 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/
无法使用 Hive 版本 1.1.0 HBase 版本 0.94.8 和 hadoop 版本 2.7.0 从 hive 创建 Hbase 表 hive (default)> CREATE TABLE
我试图为 electron app 创建可执行文件但面临这个问题 Unable to determine Electron version. Please specify an Electron ve
我正在尝试让自适应阈值在 python 绑定(bind)到 opencv 中工作(swig 一个 - 无法让 opencv 2.0 工作,因为我正在使用 beagleboard 因为交叉编译还没有工作
我一直在 linux 机器上使用 JMeter,在命令行下使用了一段时间。工作正常。 今天,我在 Windows 机器(新客户端等)上尝试了它,它确实可以工作,但在控制台窗口中输出有很大不同。 Lin
在我的编码环境中,我通常使用最新版本的 Java 和 Eclipse。当我编写源代码时,我不会注意我使用的 API 方法或类是否向后兼容旧版本的 Java 或 Eclipse。在 javadoc 中存
问题是关于版本的特定组合,但更普遍。 我刚刚从 Kubuntu 12.04 升级到 14.04。现在,当我想编译 CUDA 代码(使用 CUDA 6.5)时,我得到: #error -- unsupp
我目前正在对我的一些应用程序进行沙箱处理,看来我必须删除一些功能才能满足 Mac App Store 沙箱(和其他)规则。 显然用户不会因为失去功能而感到高兴,我担心他们不会指责苹果制定了愚蠢的规则,
我用 flash 和 js 版本创建了一个动画横幅。 是否可以检测低于版本 9 的 ie 版本,然后提供 Flash 横幅,否则提供 js 横幅。 最佳答案 您可以使用条件注释来检测 IE 版本
我有一个处理不同位置的数据库的应用程序,我想检查这些数据库是否使用 Firebird 2.5 或更高版本打开。我们最近从 Firebird 2.0 迁移到了 2.5,我们有很多数据库可以响应 sele
我正在开发一个应用程序,我使用托管在我的服务器上的 Java 和 Jersey 构建了后端部分。我在服务器上使用 Tomcat7 来调用 Web 服务。 我以前有一台安装了 Ubuntu 的计算机,我
我可以使用 GetVersionEx() 函数来获取 Windows 版本,但是这个函数将返回一个数字而不是一个字符串。但是没有问题,因为我可以将数字转换为字符串,例如: if (osvi.dwMaj
我已经在我的系统中安装了 Anaconda 2 & 3。 Anaconda 2 包含 python 2.7 & Anaconda 3 包含 python 3.6。 我需要使用命令提示符运行我的 pyt
我正在尝试构建一个 Android 项目,但发生了以下错误 Error:(10, 1) A problem occurred evaluating project ':app'. > Failed t
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 4 年前。 Improve this qu
在降级我的 GCC 之前,我想知道是否有办法确定我的机器中的哪些程序/框架或依赖项会中断,以及是否有更好的方法来执行 openpose 安装? (例如,在 CMake 中更改某些内容) 有没有办法在不
我已经在终端的代码sudo apt-get install Shadowsocks-qt5中安装了Shadowsocks-Qt5,然后我可以通过搜索找到启动图标,但是它当我点击图标时打不开。然后我尝试
在网络上找到的文档说,MLLP V2(第 2 版)是用于传输 HL7 版本 3 内容的所有消息传输协议(protocol)的要求。似乎 MLLP 第 2 版主要用于 HL7 第 3 版。 我们可以/应
我正在使用带有 selinium webdriver 的 Protractor 。我的chromeDriver版本是78.0.1,chrome版本是78.0.3904.97。两个版本都匹配,应该不会有
我正在按照教程设置 mysql 数据库并做一些事情。我无法找到数据库资源管理器。我读了很多,但在 Window->show View-> Dataxxx 或右侧上部选项卡中无法正常工作。 最佳答案 从
我已经在 KDE 桌面上安装了 Anaconda 2.0.1。当我运行 python 并看到所有已安装的模块时,我收到此消息“无法将不兼容的 Qt 库(版本 0x40801)与该库(版本 0x4080
我是一名优秀的程序员,十分优秀!