我目前正在 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/