0
我有一个使用OpenCV lib在Python中编写的图像处理函数(IMP)。如何使用OpenCV将帧缓冲从C传递到Python
现在我想从C代码调用IMP:
#include "/usr/include/python2.7/Python.h"
int main()
{
PyObject *pName, *pModule, *pDict, *pFun, *pValue, main_module;
// Initialize the Python Interpreter
Py_Initialize();
// Build the name object
pName = PyString_FromString("test");
if(pName)printf("OK\n");
// Load the module object
pModule = PyImport_Import(pName);
// pFunc is also a borrowed reference
pFun = PyObject_GetAttrString(pModule, "IMP");
if (PyCallable_Check(pFun))
{
//PyObject_CallObject(pFun, NULL);
PyObject_CallFunction(pFun,"o",framebuffer);
}
else
{
PyErr_Print();
}
// Clean up
Py_DECREF(pModule);
Py_DECREF(pName);
Py_DECREF(pFun);
// Finish the Python Interpreter
Py_Finalize();
getchar();
return 0;
}
如何准备“帧缓冲”传递到我的IMP Python函数?
任何人都可以帮助向我展示一个封装在CV2理解的对象中的示例图像,并使用上面的示例C代码将它传递给IMP?非常感谢你的帮助。
你的'IMP'在做什么?它可能更容易,将其转移到C++。 – berak 2014-11-24 18:21:45
它只是试图识别某些功能并返回yes或no。由于它是在嵌入式系统中运行,所以我使用C作为目标代码,但CV2 C接口已弃用,因此我将直接调用我的Python代码进行开发。如果它被证明了,那么我将来可能会把它翻译成C++,并且稍后再C调用C++ dll。 – 2014-11-24 18:54:42