Yes, there is. And it's used quite often.
For example, take unreasonable searches and seizures. Generally, if the police want to search someone's home, they normally have to obtain a warrant. In Canada, this can often be obtained by a Justice of the Peace. For some background, the Canadian Charter of Rights and Freedoms says this:
Everyone has the right to be secure against unreasonable search or seizure.
So what happens if someone was searched unreasonably?
In such cases, the court would throw out the evidence. If the police searched someones home, and found a firearm, but they didn't obtain a warrant (and they didn't provide justification for not having done so), the evidence would be thrown out of court. This is to make sure that the rights of the accused are kept, and that a fair trial is run.
In R v Feeney  2 SCR 13, the Supreme Court of Canada ruled that searching a house without a warrant constitutes an unreasonable search:
The police, during a murder investigation in 1991, entered the accused’s house (an equipment trailer) without permission. When they received no answer at the door, they entered, roused the accused, touched his leg, ordered him to get up and took him to the front of the trailer for better lighting. ...
Warrantless arrests in dwelling houses are in general prohibited. Prior to such an arrest, the police officer must obtain judicial authorization for the arrest by obtaining a warrant to enter the dwelling house for the purpose of arrest. Such a warrant will only be authorized if there are reasonable grounds for the arrest, and reasonable grounds to believe that the person will be found at the address named, thus providing individuals’ privacy interests in an arrest situation with the protection this Court has required with respect to searches and seizures. Requiring a warrant prior to arrest avoids the ex post facto analysis of the reasonableness of an intrusion and invasive arrests without a basis of reasonable and probable grounds are prevented, rather than remedied after the fact.
The protection of privacy does not end with a warrant; before forcibly entering a dwelling house to make an arrest with a warrant for an indictable offence, proper announcement must be made.
When a request to exclude evidence is made, a voir dire will often be held, with the jury absent, to determine if the evidence is admissible into court.
To respond to your second paragraph, "targeting" of individuals can happen, but the justice system normally has a lot of integrity. That's not a result of the justice system - it's more psychological and political if anything. Courts are impartial, and look at all aspects of the alleged crime that they are trying. I'm not aware of any charges that have been biased, at least here in Canada. There are many steps to keep the justice system transparent and accountable, so if any incident like that were to occur, it would be extremely rare and dealt with promptly.
You may have fun reading Judge blasts Toronto police over 'Kafkaesque' traffic stop:
A judge has acquitted a man of failing to provide a breath sample, rebuking Toronto police officers’ “aggressive” and “verbally abusive” conduct following a simple traffic stop, which included telling the man he needed to exit his car because he had come to a “high drug” area.
Calling the encounter, which was captured on the police’s in-car camera system, “truly Kafkaesque,” Ontario Court Justice Sandra Bacchus was also critical of the officers for turning off their microphones during “key seconds.”
Those seconds were just before officers decided to ask the man for a breath sample after repeatedly demanding he exit his vehicle, despite there being no valid reason to do so.