当前位置: 首页>>代码示例>>C++>>正文


C++ VideoBuffer::getLatestFrame方法代码示例

本文整理汇总了C++中VideoBuffer::getLatestFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoBuffer::getLatestFrame方法的具体用法?C++ VideoBuffer::getLatestFrame怎么用?C++ VideoBuffer::getLatestFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VideoBuffer的用法示例。


在下文中一共展示了VideoBuffer::getLatestFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
            }

        }
    }
    else if (filename == "webcam")
    {
        int framenum = 0;
        cv::VideoCapture cap(0);
        if (!cap.isOpened())
        {
            std::cout << "Error opening webcam" << std::endl;
            return 1;
        }

        while (cap.read(frame))
        {
            detectandshow(&alpr, frame, "", outputJson);
            usleep(1000);
            framenum++;
        }
    }
    else if (startsWith(filename, "http://") || startsWith(filename, "https://"))
    {
        int framenum = 0;

        VideoBuffer videoBuffer;

        videoBuffer.connect(filename, 5);

        cv::Mat latestFrame;

        while (program_active)
        {
            int response = videoBuffer.getLatestFrame(&latestFrame);

            if (response != -1)
            {
                detectandshow( &alpr, latestFrame, "", outputJson);
            }

            // Sleep 10ms
            usleep(10000);
        }

        videoBuffer.disconnect();

        std::cout << "Video processing ended" << std::endl;
    }
    else if (hasEndingInsensitive(filename, ".avi") || hasEndingInsensitive(filename, ".mp4") || hasEndingInsensitive(filename, ".webm") ||
             hasEndingInsensitive(filename, ".flv") || hasEndingInsensitive(filename, ".mjpg") || hasEndingInsensitive(filename, ".mjpeg"))
    {
        if (fileExists(filename.c_str()))
        {
            int framenum = 0;

            cv::VideoCapture cap=cv::VideoCapture();
            cap.open(filename);
            cap.set(CV_CAP_PROP_POS_MSEC, seektoms);

            while (cap.read(frame))
            {
                if (SAVE_LAST_VIDEO_STILL)
                {
                    cv::imwrite(LAST_VIDEO_STILL_LOCATION, frame);
                }
                std::cout << "Frame: " << framenum << std::endl;
开发者ID:HSOFEUP,项目名称:openalpr,代码行数:67,代码来源:main.cpp

示例2: main


//.........这里部分代码省略.........
        webcamnumber = atoi(filename.substr(WEBCAM_PREFIX.length()).c_str());
      }
      
      int framenum = 0;
      cv::VideoCapture cap(webcamnumber);
      if (!cap.isOpened())
      {
        std::cerr << "Error opening webcam" << std::endl;
        return 1;
      }

      while (cap.read(frame))
      {
        if (framenum == 0)
          motiondetector.ResetMotionDetection(&frame);
        detectandshow(&alpr, frame, "", outputJson);
        sleep_ms(10);
        framenum++;
      }
    }
    else if (startsWith(filename, "http://") || startsWith(filename, "https://"))
    {
      int framenum = 0;

      VideoBuffer videoBuffer;

      videoBuffer.connect(filename, 5);

      cv::Mat latestFrame;

      while (program_active)
      {
        std::vector<cv::Rect> regionsOfInterest;
        int response = videoBuffer.getLatestFrame(&latestFrame, regionsOfInterest);

        if (response != -1)
        {
          if (framenum == 0)
            motiondetector.ResetMotionDetection(&latestFrame);
          detectandshow(&alpr, latestFrame, "", outputJson);
        }

        // Sleep 10ms
        sleep_ms(10);
        framenum++;
      }

      videoBuffer.disconnect();

      std::cout << "Video processing ended" << std::endl;
    }
    else if (hasEndingInsensitive(filename, ".avi") || hasEndingInsensitive(filename, ".mp4") ||
                                                       hasEndingInsensitive(filename, ".webm") ||
                                                       hasEndingInsensitive(filename, ".flv") || hasEndingInsensitive(filename, ".mjpg") ||
                                                       hasEndingInsensitive(filename, ".mjpeg") ||
             hasEndingInsensitive(filename, ".mkv")
        )
    {
      if (fileExists(filename.c_str()))
      {
        int framenum = 0;

        cv::VideoCapture cap = cv::VideoCapture();
        cap.open(filename);
        cap.set(CV_CAP_PROP_POS_MSEC, seektoms);
开发者ID:AndyTsangChun,项目名称:openalpr,代码行数:66,代码来源:main.cpp


注:本文中的VideoBuffer::getLatestFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。