They looked like they were permanently fixed, however since I only saw a quick glance, I am not sure.
Are they cameras or something else, if cameras, what are they for?
Quite a few of Queensland Rail's suburban trains and the new A-City trains for Adelaide are all fitted with dash-cams.The 3000/3100 class DEMUs in Adelaide have also had retro-fitted forward-facing and side-mounted cameras (facing "backwards" near each cab) for quite a few years now. Some footage from both types was used in a recent safety campaign video:
It's a dash-cam trial fitted to the leading motors of that six-car XTrapolis. The intermediate cabs do not have the cameras fitted, and the two three-car sets are not to be separated. Initially they were also fitted to a six-carriage Comeng set, and a 3VL but have since been removed.
If there are two forward-facing cameras on each end of the set in Melbourne, this may indicate the trial is part of a competitive tender process.
If it's anything like the radio system they should be installed in about 5 years, by which time the technology will be well out of date and obsolete so maintenance costs can be kept at a very nice premium for the installer.