Category : python

I am trying to use a C++ object in Python that has in argument a cv::Mat. Here is my code : //simplelib.h #ifdef SIMPLELIB_EXPORTS #define SIMPLELIB_API __declspec(dllexport) #else #define SIMPLELIB_API __declspec(dllimport) #endif #ifdef _DEBUG #undef _DEBUG #include <Python.h> #include <boost/python.hpp> class simplelib { private: cv::Mat input; public: /*Constructor for the simplelib class*/ SIMPLELIB_API simplelib(cv::Mat input); ..

Read more

Using ctypes in python can convert C struct to python object. But if C++ struct like this (maybe using socket to transfer C++ struct to python): struct Struct { int a; vector<int> b; } I’m wondering how to convert C++ struct bytes with variable vector to python object. Thanks Source: Windows Que..

Read more

I’m trying to communicate with an Arduino via serial with Python and I keep getting this error: AttributeError: ‘Serial’ object has no attribute ‘write’ This doesn’t just happen with the write method, it also happens with read(). I’ve used this serial module before an have not experienced any of these problems. Strangely enough, it has ..

Read more

I’m trying to communicate with an Arduino via serial with Python and I keep getting this error: >PS C:DevelopmentAllenInterface> python3 .test.py Traceback (most recent call last): File "C:DevelopmentAllenInterfacetest.py", line 11, in <module> ser.write([0, 0]) AttributeError: ‘Serial’ object has no attribute ‘write’ This doesn’t just happen with the write method, it also happens with read(). I’ve ..

Read more

I am semi-succesfull in typemapping C++ std::vector into Python list. Here is my .i file %module swigstvo %include "std_vector.i" %typemap(out) std::vector<int>* { $result = PyList_New(3); } namespace std { %template(vectori) vector<int>; }; When I call thisPython code which is pretty simple from swigstvo import vectori value = vectori() print(value) I get an output like this: ..

Read more