pyobject

C++ to numpy and back to C++, tuple PyObject

南笙酒味 提交于 2021-02-10 12:12:33
问题 I am implementing a Visual C++ code (MS VStudio 2013) that acquires an image from a camera, processes the image, sends pre-processed data (an array 2 or more doubles) to python through a PyObject, and gets numpy-processed results back from python (a tuple of 3 doubles in py, which is becomes an array of 3 doubles in C++). I tested the py function as a standalone script. However, I keep getting a null as a return from PyObject_CallObject(). python and the VC++ project reside in the same

C++ to numpy and back to C++, tuple PyObject

夙愿已清 提交于 2021-02-10 12:12:27
问题 I am implementing a Visual C++ code (MS VStudio 2013) that acquires an image from a camera, processes the image, sends pre-processed data (an array 2 or more doubles) to python through a PyObject, and gets numpy-processed results back from python (a tuple of 3 doubles in py, which is becomes an array of 3 doubles in C++). I tested the py function as a standalone script. However, I keep getting a null as a return from PyObject_CallObject(). python and the VC++ project reside in the same

C++ to numpy and back to C++, tuple PyObject

走远了吗. 提交于 2021-02-10 12:11:00
问题 I am implementing a Visual C++ code (MS VStudio 2013) that acquires an image from a camera, processes the image, sends pre-processed data (an array 2 or more doubles) to python through a PyObject, and gets numpy-processed results back from python (a tuple of 3 doubles in py, which is becomes an array of 3 doubles in C++). I tested the py function as a standalone script. However, I keep getting a null as a return from PyObject_CallObject(). python and the VC++ project reside in the same

How can convert PyObject variable to Mat in c++ opencv code

跟風遠走 提交于 2020-05-01 09:16:52
问题 I have a c++ facerecognition code and a python code in opencv. In python code i read frames from a robot and i want to send this fram to my c++ code. I use this link tho call python function in c++ function. my c++ function is embed.cpp: #include <Python.h> #include <stdlib.h> #include "opencv2/core/core.hpp" #include "opencv2/contrib/contrib.hpp" #include "opencv2/highgui/highgui.hpp" #include <iostream> #include <fstream> #include <sstream> #include </home/nao/Desktop/python/boost_1_61_0

How can convert PyObject variable to Mat in c++ opencv code

假装没事ソ 提交于 2020-05-01 09:15:27
问题 I have a c++ facerecognition code and a python code in opencv. In python code i read frames from a robot and i want to send this fram to my c++ code. I use this link tho call python function in c++ function. my c++ function is embed.cpp: #include <Python.h> #include <stdlib.h> #include "opencv2/core/core.hpp" #include "opencv2/contrib/contrib.hpp" #include "opencv2/highgui/highgui.hpp" #include <iostream> #include <fstream> #include <sstream> #include </home/nao/Desktop/python/boost_1_61_0

how to deal with the PyObject* from C++ in Python

ぐ巨炮叔叔 提交于 2020-01-21 03:50:10
问题 I create DLL wrote in C++ , the exporting function returns PyObject * .Then I use ctypes to import the DLL in Python . Now , how can I get the real PyObject ?? here's some part of c++ code: PyObject* _stdcall getList(){ PyObject * PList = NULL; PyObject * PItem = NULL; PList = PyList_New(10); vector <int> intVector; int i; for(int i=0;i<10;i++){ intVector.push_back(i); } for(vector<int>::const_iterator it=intVector.begin();it<intVector.end();it++){ PItem = Py_BuildValue("i", &it); PyList

error: value of type 'PyObject' (aka '_object') is not contextually convertible to 'bool'

喜夏-厌秋 提交于 2019-12-25 02:55:08
问题 I am passing a python module to C as a PyObject . I want to check to see if this value is NONE in my C code, using this form: int func(PyObject tmp) { if(tmp) { // etc I am getting the following error. How can I convert from a PyObject to boolean value, simillar to the way Python's if function behaves. It is worth noting that when tmp is a boost::python::object variable this command works as expected. ex_program.cpp:72:7: error: value of type 'PyObject' (aka '_object') is not contextually

Python 3.4 / GTK / Async

人走茶凉 提交于 2019-12-22 12:38:31
问题 I use tkinter with a async funktion. Now I will use gtk3 in stead of tkinkter. Is there also a way to run my async function? How should I adapt the code Here are some code fragments: async def _event_loop(app, interval=0.05): try: while True: app.update() await asyncio.sleep(interval) except tkinter.TclError as exc: if "application has been destroyed" not in exc.args[0]: raise class SSHFrame(tkinter.Frame): def __init__(self, parent): super().__init__(parent) ... ... async def _run(self, host

How can I use PyObject_IsInstance with a non-builtin class as second argument?

荒凉一梦 提交于 2019-12-22 06:34:29
问题 In C/C++, I want to see if a PyObject is an instance. Unfortunately, the PyInstance_Check macro doesn't work with new-style classes. So, according to forums posts that I read, PyObject_IsInstance could solve the problem. However, all the examples that I have found are demonstrating comparisons with built-in types, like ints and strings. I want to know how I can construct a PyObject that represents a class of a type, so I can pass it to the second argument of PyObject_IsInstance . Can you help

Check if PyObject is None

本小妞迷上赌 提交于 2019-12-20 17:34:09
问题 I would just like to check if a PyObject that I have is None . I naively expected that any None Pyobject * returned from a function would be a NULL pointer, but that doesn't seem to be the case. So: how do I check if a PyObject * of mine points to a None object? I know that there are macros like PyInt_Check(PyObject *) around, but I couldn't find anything like PyNone_Check . I thought I could just check the equality between my PyObject and Py_None , but turns out I don't even know how to make