Hello,
what achieved now seemed to work but on the long run I think there are some problems:
in the secondary thread that is in charge of grabbing images sometimes I get an error called "stream out of sync" that results in some frame lost. To me this error is dued to the fact that inside that thread I'm doing too much stuff: namely there is a critical section inside where I'm doing the conversion (that takes time I suppose).
I would like to try to go back to my previous approach: the secondary thread acquires the frame then, through an event, notifies the primary thread of the grabbed frame and it is now the main thread that is in charge of converting the image. The problem was that I couldn't pass the frame to the main thread through the event. In particular I think that the buffer is released right after the secondary thread as finisched (thus the main thread cannot find anything). I would like to make a copy of the buffer and check if that works but I'm making some mistake:
retrieve the buffer
Code: Select all
pImageBuffer = (unsigned char *) ptrGrabResult->GetBuffer();
find out the length of the array and make the copy
Code: Select all
int myLength = sizeof(pImageBuffer)/sizeof(*pImageBuffer);
memcpy(pImageBuffer,copyImageBuffer, myLength*4);
I multiply by 4 because I think it is the size of unsigned char..but it doesn't work! Thanks for any help!