Helper Objects
The cv::TermCriteria class
- 算法的終止類(Many algorithms require a stopping condition to know when to quit)
- 三個參數:int type, int maxCount, double epsilon
- cv::TermCriteria::COUNT與cv::TermCriteria::MAX_ITER相同。
- 設定了EPS後,算法的聚合(收斂?)低於該值時停止。
The cv::Range class
- 用於指定一個連續的整數序列
- 兩個參數:int start, int end
- 舉例:Range(0,4):0,1,2,3
The cv::Ptr template and Garbage Collection 101
- 智能指針?
- cv::Ptr p = makePtr()或cv::Ptr p
- 有和普通指針一樣的功能,根據引用計數器釋放內存
- addref() and release():計數增加與減少
- empty() :
- 對象已經被釋放時釋放指針
- 智能指針內部的對象指針正好爲NULL時觸發(etc. 調用的函數正好返回NULL)
- delete_obj():引用計數爲零時自動被調用(用於釋放指針?)。必要時需要自定義內容
The cv::Exception class and exception handling
- 異常類,和標準庫的異常類似
- 成員:
- code: 數字表示的錯誤代碼
- err:string指示生成異常的錯誤的性質
- func:string表示發生異常的函數名稱
- file:string表示發生異常的文件名
- line:int表示錯誤發生的行數
- CV_Error( errorcode, description ):用一種固定的文本描述生成異常
- CV_Error_( errorcode, printf_fmt_str, [printf-args] ):使用printf格式輸出
- CV_Assert( condition ) and CV_DbgAssert( condition ):測試條件不滿足時拋出異常
The cv::DataType<> template
- 數據模板,用於函數間傳遞特殊的數據類型
- 同時包含該類型的運行時信息和在編譯時指向相同類型