![](/img/trans.png)
[英]OpenCV VideoCapture says video has 0 frames (C++ and Python)
[英]Passing frames to c++ from python VideoCapture()
我将 usb 相机读取为 cv2.VideoCapture() function 并显示帧。 我需要一些 c++ 应用程序从 python 应用程序读取帧。
我怎么能做这个?
脚步:
You can use embedding python in C++ and call python function in a C++ program. 放入 python 模块并在此模块中定义一个字典,其中包含文件中的帧数据,例如 test.py。
#include <Python.h>
int main(int argc, char *argv[])
{
Py_Initialize();
pName = PyString_FromString("test.py");
pModule = PyImport_Import(pName);
pDict = PyModule_GetDict(pModule);
pFunc = PyDict_GetItemString(pDict, "frame");
if (PyCallable_Check(pFunc))
{
PyObject_CallObject(pFunc, NULL);
}
else
{
PyErr_Print();
}
// Clean up
Py_DECREF(pModule);
Py_DECREF(pName);
// Finish the Python Interpreter
Py_Finalize();
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.