看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) Win10 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) visual studio c++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) opencv 問題(Question): 影片播到5秒時,就發生未處理的例外狀況 餵入的資料(Input): 一段mp4檔的影片約6秒多 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): https://i.imgur.com/SpeZpJ3.jpg https://i.imgur.com/ki7gDbM.jpg https://i.imgur.com/2NVf0Nk.jpg 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) #include "stdafx.h" #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { VideoCapture capture("27742.t.MP4"); while (1) { Mat frame; capture >> frame; imshow("cam", frame); waitKey(30); } return 0; } 補充說明(Supplement): 我想要解決那個例外狀況 在網路上有看到有人有類似問題,可是他的解決方法是重新下載,但是我的open cv最近 才剛重新下載,不知道該不該再重載一次。 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 42.72.68.206 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1526360895.A.5B9.html
Raymond0710: 可能影片播完了 判斷frame empty就break05/15 19:50
Lipraxde: waitKey(30); → waitKey(60);,這樣你應該就可以播1005/15 21:33
Lipraxde: 秒了05/15 21:33
hope2801: 那想請問為什麼會出現無法處理的例外狀況呢05/16 00:32
Lipraxde: 不是無法處理,是你沒有處理,你這段opencv的範例程式05/16 00:35
Lipraxde: 是哪來的?05/16 00:35
hope2801: 我自己打的05/16 00:36
hope2801: 我程式有打錯嗎?05/16 00:42
※ 編輯: hope2801 (42.72.68.206), 05/16/2018 00:46:30
ThomasHuang: while (1)是無限迴圈,迴圈內又沒有檢查影片是否播完 05/16 08:59
ThomasHuang: 的機制,影片完畢後無法離開迴圈繼續取得影像,因為 05/16 08:59
ThomasHuang: 沒有影響可以取得引發例外 05/16 08:59
hope2801: 原來是因為影片播完無法條出迴圈所以才導致例外狀況 05/19 12:35
hope2801: 感謝上面的各位教導小弟非常感謝 05/19 12:35