fitLine java

asked 2014-10-31 12:48:17 -0600

I was wondering how do I properly setup the fitLine function and then extract the individual values in the output line matrix for java. I know that the input for fitLine has to be a MatOfPoint but I'm not sure how to convert a black/white image to an MatOfPoint either.

void fit(Mat img){
  Imgproc.threshold(img, img, 225, 255, Imgproc.THRESH_BINARY);
  MatOfPoint mPoints = new MatOfPoint(img);
  Mat line = new Mat();
  Imgproc.fitLine(mPoints, line, Imgproc.CV_DIST_L2, 0, 0.01, 0.01);
  float vx = line.get(0, 0);
}

I know there is error in the code above but it highlight what I'm trying to do. I'm not exactly sure about the syntax regarding the matrix operations.

edit retag flag offensive close merge delete

Comments

maybe, - http://docs.opencv.org/java/org/opencv/imgproc/Imgproc.html#findContours(org.opencv.core.Mat,%20java.util.List,%20org.opencv.core.Mat,%20int,%20int)

berak gravatar imageberak ( 2014-11-01 02:03:21 -0600 )edit