在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的行上遇到Acces违规
camera-> RetrieveResult(5000,ptrGrabResult,TimeoutHandling_ThrowException);
对于我为什么会发生此崩溃的信息,我将表示感谢。顺便说一下,当我将调用移到函数RetrieveResult上时 创建摄像机后立即转到构造函数,就不会崩溃。