// This is called by the camera device when a new image arrives void imageReceived (const Image& image) override { // In this app we just want to take one image, so as soon as this happens, // we'll unregister ourselves as a listener. if (cameraDevice != nullptr) cameraDevice->removeListener (this); // This callback won't be on the message thread, so to get the image back to // the message thread, we'll stash a pointer to it (which is reference-counted in // a thead-safe way), and trigger an async callback which will then display the // new image.. incomingImage = image; triggerAsyncUpdate(); }