zhuanglj
2025-04-29 c402412da9e89c4927ac12b82ca2d8b7a4e0296b
添加推流分辨率参数
3个文件已修改
32 ■■■■■ 已修改文件
PreProcessFn.cpp 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
PreProcessFn.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.cpp 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
PreProcessFn.cpp
@@ -255,7 +255,7 @@
    //cout << current_time << endl;
    // 如果录制时间超过 10 秒,则停止录制
    if (seconds >= _recordtime) {
        cout << "已录制 10 秒视频,停止录制" << endl;
        std::cout << "已录制 10 秒视频,停止录制" << endl;
        video_writer.release();
    }
    else
@@ -284,7 +284,7 @@
        if (mysql_query(mysql, query.c_str()))
        {
            string err_string = mysql_error(mysql);
            cout << err_string << endl;
            std::cout << err_string << endl;
        }        
    }
}
@@ -321,7 +321,7 @@
        if (mysql_query(mysql, query.c_str()))
        {
            string err_string = mysql_error(mysql);
            cout << err_string << endl;
            std::cout << err_string << endl;
        }
    }
}
@@ -524,6 +524,7 @@
    return true;
}
//json转换字符串
std::string jsontostr(Json::Value& json)
{
    string return_str;
@@ -758,8 +759,6 @@
        std::string modelAnalysis ="";
        color_result = modelNode["color_result"].asString();//颜色反正值
        // std::string area = modelNode["threshold"].asString();//区域一
        // std::string area2 = modelNode.get("area2", "").asString();//区域二
        Json::Value rects = modelNode["point_rects"];////模型分析类型编码  
        for (auto k = 0; k < rects.size(); ++k) 
            {
@@ -795,11 +794,6 @@
                    {
                        beltarea.push_back(cv::Point(croodx, croody));
                    }
                    if (point_type=="workarea")
                    {
                        workarea.push_back(cv::Point(croodx, croody));
                    }
                }    
            }
@@ -823,7 +817,7 @@
                wfBelt.setCameraName(ipcname);
                wfBelt.setRtspUrl(ipcrtsppath);
                wfBelt.setAnalyse(modelType);
                //wfBelt.setAnalyseResult(modelAnalysis);
            wfBelt.setAnalyseResult(modelAnalysis);
        }
        if(modelCode=="2") //提升机运行检测模型
        {
@@ -906,7 +900,8 @@
        }
        if(modelCode=="6") //堆煤检测模型
        {
            if (!dm.initConfig(modelPath.c_str(), arr)) {
            if (!dm.initConfig(modelPath.c_str(), arr))
            {
                    printf("堆煤模型初始化失败\n");
                }
                else
@@ -1038,10 +1033,6 @@
            wfFire.setRtspUrl(ipcrtsppath);
            wfFire.setAnalyse(modelType);
            wfFire.setAnalyseResult(modelAnalysis);
        }
        if (modelCode == "12")//人员跌倒
        {
        }
    }    
@@ -2029,7 +2020,7 @@
/// @brief 推流到流媒体服务器
/// @param queJC2 处理完的视频流帧队列
/// @param ipccode 摄像机编号
void PreProcessFn::fnPushVideoToUrl(queue<Mat>& queJC2,string toRtsp, string fps, string ipccode)
void PreProcessFn::fnPushVideoToUrl(queue<Mat>& queJC2,string toRtsp, string fps, string video_size,string ipccode)
{    
    //定义接受帧
    Mat frame;
@@ -2042,7 +2033,7 @@
        "-f", "rawvideo",
        "-vcodec", "rawvideo",
        "-pix_fmt", "bgr24",
        "-s",  "1280x720",
        "-s",  video_size,
        "-r", fps,            
        "-i", "-",    
        "-pix_fmt", "yuv420p",
PreProcessFn.h
@@ -74,7 +74,7 @@
    void fnPushVideo(queue<Mat>& queJC2, string ipccode);
    void fnPushVideoToUrl(queue<Mat>& queJC2,string toRtsp, string fps,string ipccode);
    void fnPushVideoToUrl(queue<Mat>& queJC2,string toRtsp, string fps,string video_size,string ipccode);
};
main.cpp
@@ -37,6 +37,7 @@
            long skipN = stol(ipcNode["skipN"].asString()); 
            ppf.skipN = skipN;
            std::string push_type = ipcNode["push_type"].asString();
            std::string video_size = ipcNode["video_size"].asString();
            std::string fps = ipcNode["fps"].asString();
            std::string toRtmp = ipcNode["toRtmp"].asString();
            std::string interval = ipcNode["interval"].asString();
@@ -51,7 +52,7 @@
                    pushVideoTasks.push_back(std::async(std::launch::async, &PreProcessFn::fnPushVideoInRabbitMQ, &ppf, std::ref(queMatVec2[i]), ipccode));
               }
               else if (push_type == "stream") {
                   pushVideoTasks.push_back(std::async(std::launch::async, &PreProcessFn::fnPushVideoToUrl, &ppf, std::ref(queMatVec2[i]),toRtmp,fps, ipccode));
                   pushVideoTasks.push_back(std::async(std::launch::async, &PreProcessFn::fnPushVideoToUrl, &ppf, std::ref(queMatVec2[i]),toRtmp,fps,video_size, ipccode));
               }
            }