[問題] vector + opencv 解構時會crash

看板C_and_CPP (C/C++)作者 (I'm not Beloved)時間12年前 (2013/11/07 21:50), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Windows 7 + Visual Studio 2008 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) STL + OpenCV 問題(Question): 使用OpenCV的findContours函數查找圖形中的邊緣存出 其中contour輸出資料結構是 一個多維陣列 debug發現程式在對此結構進行destruction的時後就會crash 餵入的資料(Input): 任一張影像 預期的正確結果(Expected Output): 解構完成釋放記憶體 錯誤結果(Wrong Output): VS跳出錯誤訊息 在對該contour vector解構時發現指標無效的指標 程式碼(Code):(請善用置底文網頁, 記得排版) #include <vector> #include <cxcore> class Detector { private: std::vector< std::vector< cv::Point > > _ContourOut; public: void find_contour(const cv::Mat&); } Detector::Detector() { } void Detector::find_contour(const cv::Mat& img) { cv::findContours(img, _ContourOut, cv::CV_RETR_LIST, cv::CHAIN_APPROX_NONE); } Detector::~Detector() { //離開這個右括號時crash } 補充說明(Supplement): 使用VS的debug tool逐行除錯發現在destruct時有不合法的位址 其中_ContourOut的結構是 <每個contour <一個contour上的點 <點座標> > > 請問有人碰過類似的問題嗎? @@" 謝謝 m(__ __)m -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.251.155.124

11/08 07:57, , 1F
你的img是甚麼格式? http://goo.gl/aZW9Pk
11/08 07:57, 1F
文章代碼(AID): #1IUvghT5 (C_and_CPP)
文章代碼(AID): #1IUvghT5 (C_and_CPP)