Question#01 -- How can we get all the Points under Line, after running FitLine ? As we don't have LineIterator available for Java, is there way we can convert from Mat of line to Points and use each point under pointPolygonTest? Checking for fitline: https://docs.opencv.org/3.4/js_contour_features_fitLine.html).
RotatedRect boundedLeaf = Imgproc.minAreaRect(new MatOfPoint2f(max_contour.toArray()));
Mat line = new Mat();
Imgproc.fitLine(max_contour,line,CV_DIST_L2,0,0.01,0.01);
Question#02 -- Need to finally find distance of each point on line from the edge of the contour using Imgproc.pointPolygonTest. I was able to find the distance using center of rotated rectangle but the width of the rectangle has to be adjusted to the min width of the object, therefore the requirement. (Open for suggestions as well, on how to fit a rectangle to min width of a object detected.)
double dist = Imgproc.pointPolygonTest(new MatOfPoint2f(max_contour.toArray()), boundedLeaf.center, true);
Input Image:
Output Image: