| | |
| | | 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) { |
| | |
| | | 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); |
| | | |
| | |
| | | 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(); |
| | | } |
| | |
| | | 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(); |
| | |
| | | m_capture = nullptr; |
| | | } |
| | | |
| | | //设置保存视频的最小和最大时长 |
| | | void RtspCaptureElement::SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds) |
| | | { |
| | | INFO("VideoMinSeconds: "<<minSeconds<<" VideoMaxSeconds: "<<maxSeconds); |
| | | m_capture->SetMinMaxVideoSeconds(minSeconds,maxSeconds); |
| | | } |
| | | |