Bug in macos camera device?


Firstly, thank you for (re)adding webcam support for MacOS!
I’ve now had some more time to give it go, and have stumbled upon a bit of weirdness when trying to flip the incoming image left/right or up/down with the following code:

void PluginEditor::imageReceived(const Image& image)
    if (! image.isValid())
    Image newImage = image;

    /* L/R */
        Image mirrorImage = newImage;
        Graphics g(mirrorImage);
        AffineTransform m_LR;
        m_LR = AffineTransform(-1, 0, mirrorImage.getWidth(),
                               0, 1, 0);
        g.drawImageTransformed(mirrorImage, m_LR);
        newImage = mirrorImage;

    /* U/D */
        Image mirrorImage = newImage;
        Graphics g(mirrorImage);
        AffineTransform m_UD;
        m_UD = AffineTransform(1, 0, 0,
                               0, -1, mirrorImage.getHeight());
        //m_UD = AffineTransform().verticalFlip(mirrorImage.getHeight()); // same result
        g.drawImageTransformed(mirrorImage, m_UD);
        newImage = mirrorImage;

    incomingImage = newImage;

Original image (using the built-in Facetime webcam on the new MacbookPro 16in, 10.15):
Screenshot 2020-07-29 at 9.58.55

Flip left/right (expecting the mug to move right->left):
Screenshot 2020-07-29 at 9.58.44

Flip left/right and up/down (expecting the mug to move right->left, and go from upright->upside-down):
Screenshot 2020-07-29 at 9.58.32

As you can see, the image is instead mirrored, and not flipped.
(Note also that "AffineTransform().verticalFlip()"gives the same result. There is no horizontalFlip() counterpart btw, which is a curious omission)

On Windows, the above code flips incoming images correctly and if I recall correctly, also back when cameras were supported on macos 2 years ago, the images were being flipped correctly too.

Therefore, I presume that either there is bug in the new camera code, or there is a bug in my code (which has accidentally worked for Windows, and also previously on mac).

Any help would be much appreciated! : )

"Version 6.0.2

  • Updated macOS camera capture API"

Not entirely sure if it was this recent update, the changes I’ve made since, or a combination of the two… But the mirroring is now working as expected (and how it is on Windows).