c++ - 如何在 OpenCV 中读取 ".jpg"图像序列?

标签 c++ opencv image-processing

我目前正在 OpenCV 中尝试 BackgroundSubtractorMOG 和 BackgroundSubtractorMOG2,我想尝试将 jpg 图像序列作为我的帧的来源

frame = imread("C:\images\001-capture.jpg");
    if(!frame.data){
    //error in opening the first image
    cerr << "Unable to open first image frame: " << fistFrameFilename << endl;
    //exit(EXIT_FAILURE);
}

也因为当我使用 VideoCapture 访问我的 .avi 视频剪辑时出现错误。

VideoCapture capture("C:\movie1.avi");
if(!capture.isOpened()){
    //error in opening the video input
    cerr << "Unable to open video file: " << videoFilename << endl;
    exit(EXIT_FAILURE);
}
//read input data. ESC or 'q' for quitting
while( (char)keyboard != 'q' && (char)keyboard != 27 ){
//read the current frame
if(!capture.read(frame)) {
  cerr << "Unable to read next frame." << endl;
  cerr << "Exiting..." << endl;
  exit(EXIT_FAILURE);
}

最佳答案

  • 尝试 VideoCapture 捕获("C:/movie1.avi");//使用单个“/”或双“\”!
  • 如果编号正确,VideoCapture 也可以读取图像序列:

    VideoCapture 捕获("C:/images/%3d-capture.jpg");//顺便说一句,与上面相同的斜杠概率

关于c++ - 如何在 OpenCV 中读取 ".jpg"图像序列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19877680/

相关文章:

java - 如何使用基于均方误差的基于像素的图像比较度量来比较 java 中的图像集?

c++ - 如何将 compressed_sparse_row_graph 和 dijkstra 与 BOOST 图形库一起使用

c++ - 用于容器/类型名转发的递归模板类型

c++ - cv :Mat with large resolution(say 1920x1080x3) 的 queue.push() 和 queue.pop() 有多重

image-processing - 计算图像中的模式

image-processing - 使用 EC2 按需调整存储在 S3 上的图像大小

c++ - gcc/c++ v2.96 上不存在 wstring

c++ - 如何杀死 MFC 向导按钮的焦点

algorithm - 从图像中提取稳健的线

c++ - 使用 OpenCV 进行箭头形状检测