1、幀指針的錯誤使用
void BaslerCam::OnImageGrabbed(Pylon::CInstantCamera& camera, const Pylon::CGrabResultPtr& ptrGrabResult) { //幀獲取時會有這樣的操作:When overwriting the current CGrabResultPtr, the previous result will automatically be released if (ptrGrabResult->GrabSucceeded()) //幀獲取成功 { m_ptrGrabResult=ptrGrabResult; } }
回調函數的代碼中ptrGrabResult、m_ptrGrabResult分別是相機獲取的幀指針、自己創建的指針。這個代碼段會在拉流的過程中不斷執行。
【錯誤點】
① m_ptrGrabResult沒必要每次都指向ptrGrabResult,一次就可以了。
② ptrGrabResult獲取幀失敗,那麼m_ptrGrabResult依然指向失敗的內存。也就是說if條件失效。