Py_BuildValue()返回为NULL,请大佬帮我看看

调试看一下pyClassInstance是否有效

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

SegmentDynObject::SegmentDynObject(){
    printf("22222");//rick test 2021.4.20
    std::cout << "Importing YOLO Settings..." << std::endl;
    ImportSettings();
    Py_Initialize();
    PyRun_SimpleString("import sys \n");
    PyRun_SimpleString("sys.path.append('/home/rick/3_1ORB_SLAM2_del_point_map/src/YOLO/')");//absolute path
    this->py_module = PyImport_ImportModule("detect");//this->module_name.c_str());//"MaskRCNN");将detect.py文件导入模块py_module
    if (!py_module) {
        printf("Can not open python module\n");
    printf("rick test");
    }
    this->cvt = new NDArrayConverter();
    this->py_class = PyObject_GetAttrString(this->py_module, this->class_name.c_str()); //py_module.class_name.c_str() 
    if (!py_class) {
        printf("py_class wrong\n");
    printf("rick test");
    }
    this->pyClassInstance = PyObject_CallObject(this->py_class, NULL);//类实例化
    //PyObject *pyClassInstance = PyObject_CallObject(py_class, NULL);//类实例化
    if (!pyClassInstance) {
        printf("PyClassInstance wrong\n");
    printf("rick test");
    }
    assert(this->pyClassInstance!=NULL);
    this->net = PyObject_GetAttrString(py_class,this->get_dyn_seg.c_str());//this指针
    assert(this->net!=NULL);
    // rdc edit 得到框框图
    this->image_result_rdc_fun = PyObject_GetAttrString(py_class,this->get_dyn_img.c_str());
    assert(this->image_result_rdc_fun!=NULL);
    // zq rdc edit 得到sematic图
    this->image_sematic_rdc_fun = PyObject_GetAttrString(py_class,this->get_dyn_sematic.c_str());
    assert(this->image_sematic_rdc_fun!=NULL);

非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!

速戳参与调研>>>https://t.csdnimg.cn/Kf0y