def Lesion_detection():
pred_bboxes = pd.read_csv(os.path.join('temp', 'pred_bboxes.csv'))
# print (pred_bboxes.values)
IntegerList = pred_bboxes.values.tolist()
return IntegerList
這是我的python代碼
Py_SetPythonHome(L"D://anaconda//envs//pytorch");
Py_Initialize();//使用python之前,要呼叫Py_Initialize();這個函式進行初始化
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append('C:/Users/erzhao.qi/Desktop/Centernet3DPred/Centernet3DPred/')");
//PyRun_SimpleString("print(sys.path)");
PyObject* mypModule = NULL;
PyObject* mypFunc = NULL;
PyObject* pDict = NULL;
mypModule = PyImport_ImportModule("MyFuc");//這里是要呼叫python的檔案名
if (NULL == mypModule)
{
std::cout << "test import model failed!" << std::endl;
Py_Finalize();
return;
}
pDict = PyModule_GetDict(mypModule);
PyObject *pFuncTwo = PyDict_GetItemString(pDict, "Lesion_detection"); //呼叫的函式名
if (NULL == pFuncTwo)
{
std::cout << "pFuncTwo is null" << std::endl;
Py_Finalize();
return;
}
PyObject *FuncTwoBack = PyObject_CallObject(pFuncTwo, nullptr);//回傳List物件
if (NULL == FuncTwoBack)
{
std::cout << "FuncTwoBack is null" << std::endl;
Py_Finalize();
return;
}
這是我的c++代碼,為什么我的PyObject_CallObject回傳的物件總是空,不能正確回傳list隊像,python代碼運行沒問題
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/227406.html
標籤:工具平臺和程序庫
上一篇:我的dev c++變成這樣了,好像是下了個32位壓縮軟體被改了,改不回來了,我該怎么改回來?
下一篇:嵌入式開發需要學哪些課程
