A former Philadelphia police officer was sentenced to six months in federal prison this week for extorting what he thought were prescription pain pills from a suspected drug dealer and then ingesting one while on duty.

Thomas Vitanovitz, 31, a married father of three, was also sentenced Tuesday to two years' supervised release, the first three months of which he is to serve under home confinement.

In an interview when his arrest was announced in June, Vitanovitz spoke of how two shoulder surgeries from on-the-job injuries led him down the path to drug addiction. He said his arrest saved his life.

"By the time I needed help, I was scared, extremely scared," he said. "I was embarrassed and ashamed to be a cop that has a pill problem."

On July 21, 2015, Vitanovitz, a 10-year veteran of the force, was on duty and in uniform when he stopped a pedestrian he believed to be a drug dealer and stole what he thought were 50 OxyContin pills from the man, according to court documents.

Vitanovitz "even took one of the pills while still working" unaware that they were actually placebos, the U.S. Attorney's Office said in court documents.

"The thought of a drug-addicted, armed police officer using illegal narcotics while on duty is frightening," Assistant U.S. Attorneys Richard P. Barrett and Joseph A. Labar wrote in their sentencing memo.

After his shift, Vitanovitz was confronted by federal agents, and admitted he had an addiction problem. He told the agents that it was the second time he had kept pills he seized during a stop, court documents said.

The following day, Vitanovitz checked himself into rehab.

Vitanovitz's attorney, Nicholas V. Pinto, said that since then, his client has been speaking weekly at a drug-treatment program for other first responders.

"He's sort of become a role model for others because of the devastating consequences this charge and his addiction have had on his life," Pinto said.