A Perth primary school teacher has pleaded guilty to installing a camera in a toilet and recording his students while they were getting changed.

The 58-year-old teacher was charged earlier this year after another staff member found the pen camera suspended in a disabled toilet at the school.

He was identified using footage recorded by the camera, which also captured his students getting changed for swimming lessons.

Appearing in the Perth Magistrates Court, the man pleaded guilty to 10 charges of using an optical device to record a private activity and 42 charges of indecently recording, or attempting to indecently record, children.

Neither the teacher nor the school where he taught can be identified, so as to protect the identity of the students.

The man was released on bail until he appears in the District Court later this year.

He was stood down from teaching when the offences came to light.