The Galaxy S9 is equipped with the latest iteration of the 12MP 1/2.55" sensor that debuted on the Galaxy S7. Same large 1.4µm pixels that also double as phase detection agents (hence dual pixel autofocus) sit in front of a new lens. This time it can switch between an f/1.5 and an f/2.4 aperture - a unique feature for a smartphone at the time being. The lens is once again stabilized.
Xperias haven't been big on OIS and the XZ2 doesn't change that. The 25mm-equivalent lens has an f/2.0 aperture that lets light through to the 1/2.3" sensor familiar from the company's flagships since the XZs. It's got 1.22µm pixels and their total number is close to 21 million but you'll either be getting 19MP 4:3 photos (5,056x3792px) or 17MP 16:9 ones (5,504x3x096px) - it's a multi-aspect sensor. The Xperia relies on a combination of phase detection and laser autofocus.
There are no fancy dual cameras on these two, it's like we're back in the good old days. If only it were that easy.
As for selfies, on paper the Galaxy's setup is in a whole different league compared to the Xperia's. Not only is the S9's selfie camera higher-res (8MP vs. 5MP), the sensor is also much larger (1/3.6" vs. 1/5") and the aperture is wider (f/1.7 vs. f/2.2). The one good thing about the specs of the Xperia's front-facing cam is the focal length - a 23mm equivalent lens will get several of your pals or most of the scenery behind you in the frame, though the Galaxy's 25mm isn't too bad in this respect either.
Everyone has gradually shifted towards a swipeable interface for their camera apps, and the Xperia XZ2 and the Galaxy S9 are staying on top of trends. The two go about it differently though, with both approaches having their pros and cons.
The Galaxy's latest app is a bit too much like Apple's camera app. Side swipes switch between shooting modes, including Auto, Portrait, Panorama, Pro, and Super slow-mo, and you can add, remove and rearrange the modes. What you can't do, however, is have a dedicated video mode - yes, holding down on the record button in both Auto and Pro will give you a preview, but what's so terribly wrong with video having its own mode and a viewfinder which will allow you to accurately frame your video before you've touched this shutter button?
An up/down swipe will switch between front and rear cameras, which is handy and we feel should be the default action in every camera app.
There's also a Pro mode which lets you adjust pretty much all photographic parameters, including (and that's unique to the S9 and S9+) aperture.
Sony's equivalent is called Manual and you can tweak the same stuff minus aperture - the Xperia doesn't have the hardware for that. The settings ranges differ - for example, Sony's shutter speed can be set between 1/4000s and 1s, while the Galaxy's range is wider on both ends - 1/24000s to 10s. The Xperia can set ISO all the way up to 12800, while the S9 is capped at ISO 800 in Pro mode; both have ISO 50 as the lowest setting.
The Xperia only has 4 presets for white balance in Manual mode - the Galaxy matches those, but allows tweaking by light temperature too.
One thing the Xperia XZ2 does much better than the Galaxy S9 is resetting all parameters in Manual mode - a single button will do that for you, while on the S9 you need to switch each one to Auto individually.
Manual mode is one of the side-swipeable modes on the Xperia - the others are Superior Auto, Video and Camera apps. Superior Auto is Sony's intelligent mode that recognizes the scene and adjust parameters accordingly and it's been around since forever - before it was cool and everyone started doing AI-powered camera apps.
Video here is a separate mode, unlike on the Galaxy, and Camera apps is where Panorama is, alongside some novel modes.