This is absolutley illegal. I'm not sure why they would be taking pictures of you, did you recognize them at all? Were they involved in the case in any way? The court is actually responsible for making sure this does not happen, they are required to check everyones cell phone and pockets prior...