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
This is my python code
Py_SetPythonHome (L "D://anaconda//envs//pytorch");
Py_Initialize ();//before use python, to invoke Py_Initialize (); This function to initialize the
PyRun_SimpleString (" import sys ");
PyRun_SimpleString (" sys. Path. Append (" C:/Users/erzhao qi/Desktop/Centernet3DPred/Centernet3DPred/') ");
//PyRun_SimpleString (" print (sys. Path) ");
The PyObject * mypModule=NULL;
The PyObject * mypFunc=NULL;
The PyObject * pDict=NULL;
MyFuc mypModule=PyImport_ImportModule (" ");//here to call python file name
If (NULL==mypModule)
{
STD: : cout & lt; & lt; "Test import model failed!" & lt; & lt; STD: : endl;
Py_Finalize ();
return;
}
PDict=PyModule_GetDict (mypModule);
The PyObject * pFuncTwo=PyDict_GetItemString (pDict, "Lesion_detection");//call the function name
If (NULL==pFuncTwo)
{
STD: : cout & lt; & lt; "PFuncTwo is null" & lt; & lt; STD: : endl;
Py_Finalize ();
return;
}
The PyObject * FuncTwoBack=PyObject_CallObject (pFuncTwo nullptr);//returns the List
If (NULL==FuncTwoBack)
{
STD: : cout & lt; & lt; "FuncTwoBack is null" & lt; & lt; STD: : endl;
Py_Finalize ();
return;
}
This is my c + + code, why my PyObject_CallObject returned object is always empty, can not correctly return list like, python code running ok