TORONTO (Reuters) - The Canadian Supreme Court on Thursday unanimously ruled in favor of students in a case involving an Ontario teacher accused of recording female students’ upper bodies with a hidden pen camera and found him guilty of voyeurism.

Ryan Jarvis, an English teacher at a high school, was charged by police with voyeurism after it was revealed he secretly recorded 27 female students ranging from ages 14 to 18 in common areas of the school without their knowledge. The videos taken from 2010 to 2011 focused on the faces and chests of the students.

Chief Justice Richard Wagner said in a written ruling that Jarvis had “betrayed the trust invested in him by his students.”

The Supreme Court decision overturned two Ontario court rulings that were in favor of Jarvis.

“Each of these features of the videos is significant and ...the videos were made in breach of the reasonable expectations of privacy that would arise in such circumstances,” Judge Wagner said.

A trial judge with the Ontario Superior Court acquitted Jarvis in 2015 because the judge believed there was insufficient evidence to prove Jarvis recorded the videos for a sexual purpose.

The Ontario Court of Appeal upheld the acquittal in a majority decision.

Wagner said privacy is not an “all-or-nothing concept” that negates privacy in public spaces. He said schools are not entirely public spaces and that the use of a hidden camera was not similar to the school’s security cameras and also raised concerns about the videos that focused on the breasts of the students.

Jarvis’s lawyers had argued that the pen cameras used by their client was not very different from security cameras used by the school.

Brenda McPhail of the Canadian Civil Liberties Association, an organization that was an intervener in the case, said she was pleased with the ruling. She added that the ruling is significant “because it recognizes the further evolution of technology on our privacy.”