gpt4 book ai didi

python - 在 Raspberry PI 上构建时出现 OpenCV 错误

转载 作者:太空宇宙 更新时间:2023-11-03 22:37:01 25 4
gpt4 key购买 nike

我在树莓派上使用cmake构建opencv-3.2.0时,安装到99%时遇到了奇怪的错误。

我没有更改任何东西以免弄乱任何东西,但这看起来像是一个简单的代码错误。

这是我终端出现的错误

/home/pi/opencv-3.2.0/modules/python/src2/cv2.cpp: In function 
‘bool pyopencv_to(PyObject*, T&, const char*) [with T =
cv::String; PyObject = _object]’:
/home/pi/opencv-3.2.0/modules/python/src2/cv2.cpp:730:34: error:
invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive]
char* str = PyString_AsString(obj);
In file included from /home/pi/opencv-
3.2.0/modules/python/src2/cv2.cpp:1362:

这是cv2.cpp中的pyopencv_to函数

template<>
bool pyopencv_to(PyObject* obj, String& value, const char* name)
{
(void)name;
if(!obj || obj == Py_None)
return true;
char* str = PyString_AsString(obj);
if(!str)
return false;
value = String(str);
return true;
}

我应该手动更改代码吗?

最佳答案

这似乎是 OpenCV 中的一个错误;在我对 opencv3/modules/python/src2/cv2.cpp 做了以下更改后,它为我编译了。改变...

char* str = PyString_AsString(obj);

const char* str = PyString_AsString(obj);

关于python - 在 Raspberry PI 上构建时出现 OpenCV 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57289402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com