[英]Basler Pylon camera API
在 pylon API 的 c++ 文檔中,他們使用循環來顯示抓取的圖像。 此代碼工作正常:
//Basler-Pylon 示例
main()
{
CInstantCamera camera(
CTlFactory::GetInstance().CreateFirstDevice());
camera.StartGrabbing( c_countOfImagesToGrab);
while ( camera.IsGrabbing())
{
// Wait for an image and then retrieve it. A timeout of
5000 ms is used.
camera.RetrieveResult( 5000, ptrGrabResult,
TimeoutHandling_ThrowException);
Pylon::DisplayImage(1, ptrGrabResult);
}
}
在我的應用程序中,我通過實現一個 UseBasler 類來使用 API,它在構造函數中實例化相機,然后使用一個函數一次顯示一幀:
class UseBasler()
{
public:
CInstantCamera* camera;
void DisplayOneFrame();
}
UseBasler::UseBasler()
{
camera = new CInstantCamera(CTlFactory::GetInstance().CreateFirstDevice());
camera->StartGrabbing( c_countOfImagesToGrab);
}
void UseBasler::DisplayOneFrame()
{
if ( camera->IsGrabbing())
{
// Wait for an image and then retrieve it. A timeout of 5000 ms is used.
camera->RetrieveResult( 5000, ptrGrabResult, TimeoutHandling_ThrowException);
//Display image
}
}
我在該行的函數 DisplayFrame 中遇到訪問沖突
camera->RetrieveResult(5000, ptrGrabResult, TimeoutHandling_ThrowException);
我會很感激我為什么會遇到這個崩潰的輸入。 順便說一句,當我在創建相機后將對函數 RetrieveResult 的調用移動到構造函數時,我沒有遇到這種崩潰。
您的包裝類實現錯過了 Pylon::CGrabResultPtr ptrGrabResult聲明。 從中創建私有類字段。
我會很高興在析構函數上添加一些清理,例如camera->Close() 。 通常,您的類實例擁有對真實設備的訪問權限,即有時會斷開連接。 Pylon API 為您提供了幾個選項來跟蹤要由包裝器實現的這些更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.