VideoCapture sequence为什么读取图像序列失败

Fred Johnson 2016-03-09 04:25:05
int main(int argc, char** argv)
{
string first_file = "Campus\\trees%04d.bmp";
VideoCapture sequence(first_file);

if (!sequence.isOpened())
{
cerr << "Failed to open the image sequence!\n" << endl;

system("pause");
return 1;
}

Mat image;
namedWindow("Image sequence", 1);

for(;;)
{

sequence >> image;

if(image.empty())
{
cout << "End of Sequence" << endl;
break;
}

imshow("Image sequence", image);
waitKey(0);
}
}
文件夹Campus在当前工程中,文件夹中的文件名为trees1000.bmp,trees1001.bmp,trees1002.bmp。。。序列图像。请问为什么运行后Failed to open the image sequence!
...全文
401 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2016-03-09
  • 打赏
  • 举报
回复
string first_file = "Campus\\trees%04d.bmp"; 改为 string first_file = "Campus\\trees1%03d.bmp";
赵4老师 2016-03-09
  • 打赏
  • 举报
回复
int main(int argc, char** argv)
{
        char files[256];
        int i;
        for (i=1000;i<1010;i++) {
            sprintf(files,"Campus\\trees%04d.bmp",i);
            VideoCapture sequence(files);
            if (!sequence.isOpened())
            {
                    cerr << "Failed to open the image sequence" << files << "!\n" << endl;
                    system("pause");
                    return 1;
            }
            Mat image;
            namedWindow("Image sequence", 1);
            sequence >> image;
            if(image.empty())
            {
                    cout << "End of Sequence" << endl;
                    break;
            }
            imshow("Image sequence", image);
            waitKey(0);
        }
}

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧