A perverted deputy headteacher installed a hidden camera to spy on children going to the toilet for sexual kicks, a court has heard.
Gareth Williams, 47, appeared before magistrates in Cardiff where he pleaded guilty to three voyeurism charges.
Prosecutor David Cooke said the disgraced and suspended Ysgol Gyfun Gymraeg Glantaf teacher placed a pinhole camera in a house so he could look at the genitals of the teenagers.
Police later recovered memory sticks containing files of five children going to the loo - which Williams had watched "for sexual gratification".
Mr Cooke also said the images had been "catalogued" on the storage devices.
The dates of the offences, Cardiff Magistrates Court heard, were between January 1 2009 and January 22 2014.
Following the guilty pleas, District Judge Bodfan Jenkins said his sentencing powers were not sufficient enough and committed the case to Cardiff Crown Court on February 21.
Defending solicitor Marilyn Bishop said no bail application would be made and Williams, of Rhiwbina, was remanded into custody.
Ysgol Glantaf has around 1,500 pupils and is the largest Welsh medium school in Wales.
It was opened in 1978 and its past pupils include actors Ioan Gruffudd and Matthew Rhys, TV presenter Gethin Jones and Cardiff Blues and Wales rugby star Jamie Roberts.