franzhong 2020-07-29 15:59 采纳率: 100%
浏览 228
已采纳

QT opencv darknet异常

图片说明

debug到载入网格的时候就异常退出了,该怎么知道错误原因呢?加try catch也没输出任何东西。QT中你们都是这样调试的吗?只能找到某一行,不知道具体出错原因?

【说明】:

(1)代码没有问题,相同代码在VS2019下运行正常。

(2)环境没有问题,相同环境,且QT正常配置了参数,编译前无语法错误,在dnn.hpp中有三个函数,见尾部引用。。。

(3)关于路径:三个训练文件都放在了,工程的build-MeDetection-Desktop_x86_windows_msvc2019_pe_64bit-Debug 文件夹下了,出错代码的上方代码为:

    std::string classesFile = "me.names";
    std::ifstream classNamesFile(classesFile.c_str());
    if (classNamesFile.is_open())
    {
        std::string className = "";
        while (std::getline(classNamesFile, className))
            classes.push_back(className);
    }
    else {
        std::cout << "can not open classNamesFile" << std::endl;
    }

上面的代码并没有输出“can not open classNamesFile”,说明me.names的路径是正确的,同理,另两个文件的路径应该也没有问题,但是cv::dnn::readNetFromDarknet(modelConfiguration, modelWeights)这句就是通过不了,还不能提示具体的原因怎么办???

-----------------------------谢谢

引用

/** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
    *  @param cfgFile      path to the .cfg file with text description of the network architecture.
    *  @param darknetModel path to the .weights file with learned network.
    *  @returns Network object that ready to do forward, throw an exception in failure cases.//没看到,不清楚failure细节被扔哪去了>.<~!
    *  @returns Net object.
    */
    CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String());

    /** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
     *  @param bufferCfg   A buffer contains a content of .cfg file with text description of the network architecture.
     *  @param bufferModel A buffer contains a content of .weights file with learned network.
     *  @returns Net object.
     */
    CV_EXPORTS_W Net readNetFromDarknet(const std::vector<uchar>& bufferCfg,
                                        const std::vector<uchar>& bufferModel = std::vector<uchar>());

    /** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
     *  @param bufferCfg   A buffer contains a content of .cfg file with text description of the network architecture.
     *  @param lenCfg      Number of bytes to read from bufferCfg
     *  @param bufferModel A buffer contains a content of .weights file with learned network.
     *  @param lenModel    Number of bytes to read from bufferModel
     *  @returns Net object.
     */
    CV_EXPORTS Net readNetFromDarknet(const char *bufferCfg, size_t lenCfg,
                                      const char *bufferModel = NULL, size_t lenModel = 0);
  • 写回答

1条回答 默认 最新

  • threenewbee 2020-07-29 16:56
    关注

    这种引用静态库的程序,需要严格匹配c++编译器的版本,否则就会各种报错,尽管可以编译。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况