簡體   English   中英

OpenCV / C ++-從視頻文件讀取的幀在視頻結束后重新啟動

[英]OpenCV/C++ - frames read from video file restart after end of the video

我正在嘗試使用OpenCV從mp4視頻中獲取每一幀。 我遵循了標准示例,但是由於某種原因,當讀取最后一幀時,循環不會終止,而是實際上再次開始。 這是代碼:

while (1) {
        inputVideo.read(inputFrame);
        nFrames = inputVideo.get(CV_CAP_PROP_POS_FRAMES);
        cout << "Frame: " << nFrames << endl;
        n++;
    }

處理完所有幀后為什么不停止?

您可以使用inputVideo.get()來檢測框架在文件中的位置,並使用它在結尾處斷開

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM