我正试图在树莓派 3 上构建 OpenCV 3.3.0,但在 93% 处遇到了无效转换错误。以下是详细信息,非常感谢您提供任何帮助,请帮忙解决。
出现了这个错误信息。
/home/pi/opencv-3.3.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.3.0/modules/python/src2/cv2.cpp:854:34: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] char* str = PyString_AsString(obj);In file included from /home/pi/opencv-3.3.0/modules/python/src2/cv2.c
我尝试了这些命令:
cd ~/opencv-3.3.0/
$ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.3.0/modules \ -D BUILD_EXAMPLES=ON ..
#cv2.cpp代码在错误位置。
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;
}