派生自 development/c++

pansen
2019-03-07 d3b7bbe7102cd089680a828f5d8f6402c8cf6342
QiaoJiaSystem/VideoToImage/RtspCaptureElement.cpp
@@ -16,10 +16,14 @@
    m_capture = new CvCapture_FFMPEG(m_camId);
}
//定时执行,将
void RtspCaptureElement::timerFunc()
{
    u_char *data;
    int width = 0, height = 0, step = 0, cn = 0;
    u_char *data = nullptr;
    int width = 0;
    int height = 0;
    int step = 0;
    int cn = 0;
    DBG("GRABFrame "<<m_camId);
    bool ret = m_capture->grabFrame();
    if (!ret) {
@@ -44,14 +48,7 @@
        m_picCount.store(0);
    }
    //每个Cam的队列最多M_CAM_PIC_MAX_COUNT张
    {
        /*ClockTimer timer("RedisTime ");
        auto imageCount = m_redisTool.getSize(m_camId);
        if (imageCount > M_CAM_PIC_MAX_COUNT) {
            ERR("Too Much Pics In Cam " << m_camId << " QUeue");
            return;
        }*/
        ClockTimer timer("FrameToImage");
        m_capture->retrieveFrame(0, &data, &step, &width, &height, &cn);
@@ -59,10 +56,6 @@
        cv::Mat copyMat;
        img.copyTo(copyMat);
        std::string imageName = m_capture->GetImageName();
        /*ClockTimer SetImageValueTimer("RedisTimeSetKey ");
        m_redisTool.setKeyImage(imageName, copyMat);
        ClockTimer SetImageNameTimer("RedisTimeSetKey ");
        m_redisTool.listLpush(m_camId, imageName);*/
    }
    fireConnectors();
}
@@ -102,14 +95,22 @@
    if(m_gpuIndex>=0){
        setenv("CUDA_VISIBLE_DEVICES", std::to_string(m_gpuIndex).c_str(),0);
    }
    m_capture->open(m_path.c_str(),m_gpuIndex>=0);
    bool bResult = m_capture->open(m_path.c_str(),m_gpuIndex>=0);
    if(bResult)
    {
        INFO("GPUIndex: "<<m_gpuIndex<<" VideoPath:"<<m_path<<" Succeed");
    } else{
        ERR("GPUIndex: "<<m_gpuIndex<<" VideoPath:"<<m_path<<" Failed");
    }
}
//线程启动之前调用,
void RtspCaptureElement::threadInitial()
{
    openVideo();
}
//线程结束的时候调用,关闭ffmpeg流
void RtspCaptureElement::threadClosing()
{
    m_capture->close();
@@ -117,8 +118,10 @@
    m_capture = nullptr;
}
//设置保存视频的最小和最大时长
void RtspCaptureElement::SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds)
{
    INFO("VideoMinSeconds: "<<minSeconds<<" VideoMaxSeconds: "<<maxSeconds);
    m_capture->SetMinMaxVideoSeconds(minSeconds,maxSeconds);
}