We all in agreement that it's the first section of the code that this situation may apply to:
California Penal Code 647 :
(j) (1) Any person who looks through a hole or opening, into, or otherwise views, by means of any instrumentality, including, but not limited to, a periscope, telescope, binoculars, camera, motion picture camera, camcorder, or mobile phone, the interior of a bedroom, bathroom, changing room, fitting room, dressing room, or tanning booth, or the interior of any other area in which the occupant has a reasonable expectation of privacy, with the intent to invade the privacy of a person or persons inside. This subdivision shall not apply to those areas of a private business used to count currency or other negotiable instruments.
Order of events:
Students get stuff stolen.
Student hides in locker and observes teacher rummaging through the student's bags
Student sets up cameras to record the teacher in the act.
Reasonable expectation of privacy: Students have the reasonable expectation of privacy within the locker room and their own lockers. That's why random locker searches are unconstitutional. As the common area within the locker room is for students, that area is to be private to the extent of same-sex privacy. The teacher has their own area- their office. I remember in my PE classes, the teachers were always in their offices when we changed.
The intent was not to invade privacy. Having established the teacher had been stealing, the student had the right to record for evidenciary purposes. The teacher has no reasonable expectation of privacy in the common locker room area. The court has decided that cameras in the locker room violate the student's right to privacy. They say nothing of the teacher's right to privacy in that area.