线程代码:
.h 文件
//抓取结果数据指针
Pylon::CGrabResultPtr ptrGrabResultM[MAX_IMAGE_RANGE];
.cpp文件
//抓拍线程
void GigeCamera::run()
{
try {
// 开始抓取c_countOfImagesToGrab images.
//相机默认设置连续抓取模式
cameraM.StartGrabbing();
while (cameraM.IsGrabbing())
{
// 等待接收和恢复图像,超时时间设置为1000 ms.
imgLockM[grabIndexM].lock();
cameraM.RetrieveResult(1000, ptrGrabResultM[grabIndexM], Pylon::TimeoutHandling_ThrowException);
imgLockM[grabIndexM].unlock();
grabIndexM += 1;
if (grabIndexM >= MAX_IMAGE_RANGE)
grabIndexM = 0;
}
cameraM.StopGrabbing();
//Pylon::PylonTerminate();
}
catch (GenICam::GenericException &e)
{
// Error handling.
std::cout << "An exception occurred." << std::endl
<< e.GetDescription() << std::endl;
cameraM.StopGrabbing();
Pylon::PylonTerminate();
return;
}
}
//获取线程中图片函数
int GigeCamera::SavePhoto(QImage& grabImg)
{
Pylon::CPylonImage pylonImage;
imgLockM[g