I am absolutely newbie in multithreading and using OpenMP. but I am trying to develop a program with two function.
function1(){
get the data from the camera and save it into memory for 1000fps
}
functio2(){
display and refresh the screen each 100ms
}
I think the OpenMP should be something like this
#pragma omp sections
{
{ function1(); }
#pragma omp section
{ function2(); }
}
but I am not sure how can I actually implement this in code (c++)? if somebody know can you please let me know. I have end up with the following code, but now I want to make the second section sleep every 100ms, how can I do it?
lastPicNr = 0;
if(Fg_AcquireEx(fg,nCamPort,GRAB_INFINITE,ACQ_STANDARD,_memoryAllc)<0){
CExceptionHandler::GrabberErrorMessage(fg,"Can not start Acquiring images .");
}else{
//Declaring a parallel region that will be broken down into disctinct parallel sections
#pragma omp parallel sections
{
#pragma omp section
{
while((lastPicNr = Fg_getLastPicNumberBlockingEx(fg,lastPicNr+1,nCamPort,10,_memoryAllc))<= MaxPics){
iPtr=(unsigned char*)Fg_getImagePtrEx(fg,lastPicNr,0,_memoryAllc);
_PointVector.push_back(iPtr);
_lastPicNumber.push_back(lastPicNr);
}
}
#pragma omp section
{
cv::Mat _matrixImage(cv::Size(w,h), CV_8UC1,iPtr , cv::Mat::AUTO_STEP);
cv::imshow("test",_matrixImage);
cv::waitKey(10);
}
}
PauseClickMode(hDlg);
}