(CNN) The highest-ranked official at New Zealand's embassy in the US planted a hidden camera in a unisex bathroom in 2017, a crown prosecutor has said in his opening address in court.

Alfred Keating, a former New Zealand naval commodore, appeared in Auckland District Court Monday to face trial for a charge of attempting to intentionally make an intimate visual recording. If convicted, he could face up to a year and a half in prison.

According to court documents , the recording device -- which was mounted inside a heating duct in the Washington D.C. embassy's bathroom -- was discovered on July 27, 2017, when it fell to the floor. There was a thick layer of dust on the platform the camera was mounted on, indicating the device had been in place for many months, according to court documents.

According to the court documents, Keating's DNA allegedly matched the DNA found on the camera's SD card.

At the time of the discovery, Keating was the highest-ranked New Zealand official at the embassy, according to CNN affiliate Radio NZ, and had immunity from prosecution in the United States. Keating no longer works for the Royal New Zealand Navy.

Read More