我有一个c++项目，关于开启相机取流并进行目标检测的项目，现在我有一个问题，我先将主要的代码文件提供给你，你先搞明白，我再将问题发给你。首先是detector.cpp文件代码
"Detector::Detector(__json &jsonData) : cfg(jsonData) {
    //检测模型路径名
    std::string modelPath = this->cfg["model_path"];
    if (!modelPath.find(".onnx")) {
        LOG__(LOG_E, "Model path must end with onnx!");
        utils::g_bExitSystem = true;
    }

    //加载模型
    this->net = cv::dnn::readNetFromONNX(modelPath);
    if ((bool)this->cfg["with_cuda"]) {
        this->net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA);
        this->net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA_FP16);
        LOG__(LOG_I, "Use CUDA.");
    } else {
        this->net.setPreferableBackend(cv::dnn::DNN_BACKEND_OPENCV);
        this->net.setPreferableTarget(cv::dnn::DNN_TARGET_CPU);
        LOG__(LOG_I, "Use CPU.");
    }

    //推理图像大小
    this->imgSize = {this->cfg["img_size"][0], this->cfg["img_size"][1]};
    std::vector<std::string> rtspList = cfg["rtsp_list"];

    if(cfg.find("class_name") != cfg.end()){
        classNames = cfg["class_name"].get<std::vector<std::string>>();
    }else{
        LOG__(LOG_E, "Class names not found");
    }

    //运行一次
    {

        LOG__(LOG_I, "Initializing ONNX model ......");
        int vid_num = rtspList.size();
        cv::Mat input({vid_num, 3, this->imgSize.height, this->imgSize.width}, CV_32F);
        this->net.setInput(input);
        std::vector<cv::Mat> outputs;
        this->net.forward(outputs, this->net.getUnconnectedOutLayersNames());
    }

    //初始化图像合并取流对象
    this->multiVideo = std::make_shared<MultiVideo>(rtspList, cfg["deal_span"]);
    this->multiVideo->registerCallback(this->ImgProcess, (void *)this); //注册回调

}

void Detector::start() {
    if (!this->detectThread) {
        //打开相机取流
        this->multiVideo->start("================= START =================");

        //开启线程
        this->runFlag = true;
        this->detectThread = new std::thread(this->detectFun, (void *)this);
    }
}

void Detector::stop() {
    if (this->detectThread) {
        //关闭线程
        this->runFlag = false;
        this->detectThread->join();
        delete this->detectThread;
        this->detectThread = nullptr;

        //关闭相机取流
        this->multiVideo->stop("================= STOP  =================");
    }
}

void Detector::ImgProcess(MultiData *multiData, void *pUser) {
    Detector *thiz = static_cast<Detector *>(pUser);

    //处理原图
    multiData->outList.resize(multiData->inList.size());
    for (size_t i = 0; i < multiData->inList.size(); i++) {
        //处理图像
        cv::Size new_size(640, 640);
        cv::resize(multiData->inList[i], multiData->outList[i], new_size);
        // cv::resize(multiData->inList[i], multiData->outList[i], multiData->inList[i].size() / 2);
        cv::copyMakeBorder(multiData->outList[i], multiData->outList[i], 2, 2, 0, 0, cv::BORDER_CONSTANT, cv::Scalar(0, 0, 0));
    }

    //生成blob
    cv::dnn::blobFromImages(multiData->outList, multiData->blobImg, 1 / 255.0, thiz->imgSize, cv::Scalar(0, 0, 0), true, false);
}

void *Detector::detectFun(void *args) {
    Detector *thiz = static_cast<Detector *>(args);

    DetData detData;                //检测输出数据
    std::vector<cv::Mat> model_out; //模型输出

    while (thiz->runFlag) {
        //获取图像
        if (!thiz->multiVideo->getData(detData.multiData)) {
            // std::cout << "iSGetData:" << thiz->multiVideo->getData(detData.multiData) << std::endl;
            msleep(1);
            continue;
        }
        if (thiz->detectFlag) {
            //推理

            thiz->net.setInput(detData.multiData.blobImg);
            thiz->net.forward(model_out, thiz->net.getUnconnectedOutLayersNames());

            //后处理
            getDetResults(model_out[0], thiz->cfg["conf_thresh"], thiz->cfg["nms_thresh"], detData.detRes);
            //测试一下
            for (const auto& res : detData.detRes) {
                for (size_t i = 0; i < res.boxes.size(); ++i) {
                    LOG__(LOG_I, "Detected " + classNames[res.classes[i]] + " with confidence " + std::to_string(res.confs[i]));
                }
            }
        
        } else {
            detData.detRes.clear();
        }

        //保存到队列
        thiz->detDataQueue.push(detData);
        msleep(1);
    }
    return nullptr;
}"