[OpenCV] Samples 11: image sequence
Opencv 11 Image sequence
2023-09-27 14:23:25 时间
一帧一帧地读取视频流。
- VideoCapture sequence(file_video);
- sequence >> image.
#include <opencv2/core/core.hpp> #include <opencv2/videoio/videoio.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> using namespace cv; using namespace std; static void help(char** argv) { cout << "\nThis sample shows you how to read a sequence of images using the VideoCapture interface.\n" << "Usage: " << argv[0] << " <image_mask> (example mask: example_%02d.jpg)\n" << "Image mask defines the name variation for the input images that have to be read as a sequence. \n" << "Using the mask example_%02d.jpg will read in images labeled as 'example_00.jpg', 'example_01.jpg', etc." << endl; } int main(int argc, char** argv) { cv::CommandLineParser parser(argc, argv, "{help h||}{@image| ../data/768x576.avi |}"); if (parser.has("help")) { help(argv); return 0; } string first_file = parser.get<string>("@image"); cout << "first_file = " << first_file << endl; if(first_file.empty()) { help(argv); return 1; } // Jeff --> read video stream. VideoCapture sequence(first_file); if (!sequence.isOpened()) { cerr << "Failed to open the image sequence!\n" << endl; return 1; } Mat image; namedWindow("Image sequence | press ESC to close", 1); for(;;) { // Read in image from sequence sequence >> image; // If no image was retrieved -> end of sequence if(image.empty()) { cout << "End of Sequence" << endl; break; } // Jeff --> we may control the speed here. imshow("Image sequence | press ESC to close", image); if(waitKey(500) == 27) break; } return 0; }
相关文章
- Windows10 + Visual Studio 2017 + CMake +OpenCV编译、开发环境配置及测试
- 图片转视频(opencv + python)
- 【计算机视觉】基于OpenCV的人脸识别
- opencv g-api notes
- 高反差保留滤镜学习OpenCV:滤镜系列(11)——高反差保留
- opencv java swing 图片灰度化 二值化
- OpenCV-2.4.6-android-sdk 人脸识别demo搭建
- opencv 图像阈值
- C# OpenCV OpenCVSharp应用实例--二值图孔洞填充方法与实现
- C# OpenCV EmguCV LSD直线检测使用Demo
- 使用Python,OpenCV捕获关键事件,并进行视频剪辑
- Python,OpenCV提取图片中的多个茄子种子轮廓,并按从左到右排序后显示
- 使用Python,OpenCV检测摄像机到标记对象的距离
- OpenCV Machine Learning 之 正态贝叶斯分类器 (Normal Bayes Classifier)
- opencv-Hough霍夫变换
- opencv-ellipse椭圆圆弧和椭圆扇形
- android studio 使用 jni 编译 opencv 完整实例 之 图像边缘检测!从此在andrid中自由使用 图像匹配、识别、检测