Home > other >  PyObject_CallObject always returns null
PyObject_CallObject always returns null

Time:11-26

Objective: c + + python function called read CSV file
Problem: PyObject_CallObject always returns null

MyFuc mypModule=PyImport_ImportModule (" ");//here to call python file name

If (NULL==mypModule)
{
STD: : cout & lt; <"Test import model failed!" Py_Finalize ();
return;
}
PDict=PyModule_GetDict (mypModule);
STD: : string sFuncName="Lesion_detection";
The PyObject * pFuncTwo=PyDict_GetItemString (pDict, "Lesion_detection");//call the function name
If (NULL==pFuncTwo)
{
STD: : cout & lt; <"PFuncTwo is null" & lt; Py_Finalize ();
return;
}
The PyObject * FuncTwoBack=PyObject_CallObject (pFuncTwo nullptr);//returns the List
If (NULL==FuncTwoBack)
{
STD: : cout & lt; <"FuncTwoBack is null" & lt; Py_Finalize ();
return;
}

Python code:
The from test_pred_3d import do_testing
The import pandas as pd
The import numpy as np
The import OS

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 code to run is no problem, if you write a pandas reads the data structure is also no problem, a read CSV file PyObject_CallObject always returns null
  • Related