efedoganay
efedoganay

Reputation: 133

OpenCV Error while building on Raspberry PI

When I use cmake to build opencv-3.2.0 on Raspberry Pi, I encountered a weird error at the 99% of installation.

I did not change anything to not mess anything up, however it seems like a simple code error.

Here is the error appeared in my terminal

/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:

and this is the pyopencv_to function in 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;
}

Should i manually change the code ?

Upvotes: 2

Views: 1033

Answers (1)

Void
Void

Reputation: 581

It appears to be a bug in OpenCV; after I did the following change at opencv3/modules/python/src2/cv2.cpp, it compiled for me. Change...

char* str = PyString_AsString(obj);

to

const char* str = PyString_AsString(obj);

Upvotes: 1

Related Questions