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条件失效。