Reputation: 785
As mentioned, I'm trying to get the distance between two indistinct lines from an image with applied edge detection. As an example please look at the below image for clarification.
As you can see, the lines are misshaped. Ideally what I would like is to get the furthest points from each line as displayed above, and calculate their distance from that. Is this possible with OpenCV? I know I can use the magnitude function to calculate the distance appropriately, but the issue comes with actually trying to find the furthest points in the first place.
Would anyone have an idea as to how I might go about this?
Upvotes: 2
Views: 1828
Reputation: 2321
If you know two points on those lines then you can calculate the distance using below code in OpenCV.
public double euclideanDistance(Point a, Point b){
double distance = 0.0;
try{
if(a != null && b != null){
double xDiff = a.x - b.x;
double yDiff = a.y - b.y;
distance = Math.sqrt(Math.pow(xDiff,2) + Math.pow(yDiff, 2));
}
}catch(Exception e){
System.err.println("Something went wrong in euclideanDistance function in "+Utility.class+" "+e.getMessage());
}
return distance;
}
I hope this helps.
Upvotes: 1