Closed sameerparekh closed 11 years ago
The semaphore must be unlocked only one time when the smart pointer (img_buffer_ptr) points to an image. So If the empty condition is true (so the pointer points to an image) then the semaphore is unlocked. After when you will check if an image is arrived with the "newImageReceived()" method, the main thread will try to lock this semaphore and will wait until the reception of an image. By this way, you ever have the last received image assigned to the img_buffer_ptr.
Thanks-- unfortunately I'm still not understanding. It appears to me from reading the code that empty is true when the img_buffer_ptr does -not- point to an image:
if(img_buffer_ptr.get() == 0) {
empty = true;
}
Am I misreading this snippet?
-s
Indeed, empty is true when the img_buffer_ptr does -not- point to an image. But, when the image is obtained from this buffer with the "getLastImageFromBuffer()" after the "newImageReceived" method returned true (and locked the semaphore), the smart pointer is cleared (img_buffer_ptr.reset();). So, img_buffer_ptr.get() returns 0 when an image was read by the main thread or no image was read before.
I just merged your modifications for the launch files and your others cleanups (I don't understand why it doesn’t appear in the network page ... I think, I made a bad manipulation during the merge process).
Thank you,
Ronan
The one important change here is that it unlocks the semaphore if the received frame is not empty, not if it is empty. The rest are minor cleanups.