A former top naval officer from New Zealand has been accused of hiding a secret camera in the toilet of the country's embassy in Washington.

Ex-Commodore Alfred Keating was serving as the embassy's senior defence attaché when the camera was found last July.

He has been charged with attempting to make an intimate visual recording and faces a maximum of 18 months in prison if convicted.

Mr Keating has pleaded not guilty to the charges.

New Zealand's High Court dismissed an appeal by Mr Keating to have his name suppressed, with the ex-officer saying his family would face "extreme hardship" if his identity was revealed.

The camera was discovered when it fell onto the floor from inside a heating duct of a unisex bathroom.

"It had been purposely mounted at a height and direction that captured recordings from people who arrived and used the toilet," said Judge Grant Powell, according to court documents seen by AFP.

The camera had a thick layer of dust in its mounting, indicating that it had been in place for months.

The toilet in which the camera was placed was used by approximately 60 people who worked at the embassy.