CameraDevice preview - prevent always on top

Hi there

I’m finding that if I use
std::unique_ptr <CameraDevice> camDev;
std::unique_ptr<Component> camPreviewComponent;

and then:
camPreviewComponent.reset (camDev->createViewerComponent());
addAndMakeVisible (camPreviewComponent.get());

I get a nice camera preview on MacOS and on iOS but I can not for the life of me get any other graphical component to be visually on top of it. Even the method .setAlwaysOnTop(true) can’t put a graphical component above the preview.

My guess is this is because the preview is OS provided as some sort of an overlay.

My question is how would one place components above the camera preview eg like a HUD? Is there some aspect of the cameraPreview that I’m misunderstanding?

Many thanks in advance!

Jeff

Yes the camera preview is a native heavyweight window so JUCE can’t draw any components over it. You could use another window on the desktop for something like a HUD though.

Thanks for the quick reply @ed95. By another window you mean off to the side yes?

To check I’m understanding this correctly: to make something like simple AR stuff in JUCE, my guess now is a preview would never do. You would have to pull the camera data in frame by frame, process and redraw the combined rendered results as fast as possible. Aka way more cpu overhead.

Is this a reasonable understanding?

Ah the good old video days when genlock was still a thing lol :wink:

I’ve noticed that the CameraDemo on iOS doesn’t extend to the full width of the phone. Is there something we need to do to make the CameraDevice::ViewerComponent’s previewLayer be full width of the mobile device’s display? I saw nothing in JuceCameraDeviceViewerClass that resized the previewLayer if the UIView itself was resized…