Ask Your Question

The Terrible Child's profile - activity

2014-10-31 12:48:17 -0600 asked a question fitLine java

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.

2014-10-29 01:12:28 -0600 received badge  Editor (source)
2014-10-29 01:11:52 -0600 asked a question Android line fit

I am having some trouble using the fitLine function for the library for android.

public void fit(Mat image){
        Imgproc.Canny(image, image, 80, 90);
        Top topHalf = image.submat(0, image.rows()/2, 0, image.cols());
        Mat fittedLine = new MatOfFloat4();
        Imgproc.fitLine(topHalf, fittedLine, Imgproc.CV_DIST_L2, 0, 0.01, 0.01);
}

Everytime my App runs the fitLine function, it stops working. I was wondering how exactly do I set up the fitLine function. I feel that I did not setup the "fittedLine" variable correctly. If possible, a simple example would be great.