I've a code from the basler video capture program as below which i want to make it as a thread to run it parallel to my main program:
for (uint32_t i = 0; i < c_countOfImagesToGrab && cameras.IsGrabbing(); ++i)
{
cameras.RetrieveResult(5000, ptrGrabResult, TimeoutHandling_ThrowException);
intptr_t cameraContextValue = ptrGrabResult->GetCameraContext();
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(cameraContextValue, ptrGrabResult);
#endif
cout << "Camera " << cameraContextValue << ": " <<
cameras[cameraContextValue].GetDeviceInfo().GetModelName() << endl;
cout << "GrabSucceeded: " << ptrGrabResult->GrabSucceeded() << endl;
cout << "SizeX: " << ptrGrabResult->GetWidth() << endl;
cout << "SizeY: " << ptrGrabResult->GetHeight() << endl;
const uint8_t* pImageBuffer = (uint8_t*)ptrGrabResult->GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t)pImageBuffer[0] << endl << endl;
}
I've made a thread as below and place it in the While loop of my main program:
std::thread t1([&](uint32_t i) {
for (uint32_t i = 0; i < c_countOfImagesToGrab && cameras.IsGrabbing(); ++i)
{
cameras.RetrieveResult(5000, ptrGrabResult, TimeoutHandling_ThrowException);
intptr_t cameraContextValue = ptrGrabResult->GetCameraContext();
#ifdef PYLON_WIN_BUILD
Pylon::DisplayImage(cameraContextValue, ptrGrabResult);
#endif
cout << "Camera " << cameraContextValue << ": " <<
cameras[cameraContextValue].GetDeviceInfo().GetModelName() << endl;
cout << "GrabSucceeded: " << ptrGrabResult->GrabSucceeded() << endl;
cout << "SizeX: " << ptrGrabResult->GetWidth() << endl;
cout << "SizeY: " << ptrGrabResult->GetHeight() << endl;
const uint8_t* pImageBuffer = (uint8_t*)ptrGrabResult->GetBuffer();
cout << "Gray value of first pixel: " << (uint32_t)pImageBuffer[0] << endl << endl;
}
}, & ptrGrabResult);
But when compile the program i had 2 errors:
C2672:'std::invoke no matching overloaded function found'
C2893:'Failed to specialize function template 'unknown-type std::invoke(Callable &&,_Types&&...)''
What I have tried:
I've trying 2 method to create this thread. Function pointer and lambda method but it remained the same result as 2 errors happened after each time compiling