有谁知道如何检查OpenCV/C++中的EOF(文件结束)条件?例如,为了检查空文件条件,我们可以使用isEmpty()方法,该方法返回一个布尔值.是否有任何此类方法可以捕获EOF异常?
干杯.
还有一个类似的函数要求empty()您使用.查看:
VideoCapture cap("your_video.avi");
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat frame;
while(1) // looply reading frames from the video file
{
cap >> frame; // try to get an image frame
if (frame.empty())
{
// reach to the end of the video file
break;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7484 次 |
| 最近记录: |