Skip to content

fitline in Android results in a wrong line #4903

@opencv-pushbot

Description

@opencv-pushbot

Transferred from http://code.opencv.org/issues/4113

|| Abe Weiss on 2015-01-11 13:43
|| Priority: High
|| Affected: 2.4.9 (latest release)
|| Category: android
|| Tracker: Bug
|| Difficulty: 
|| PR: 
|| Platform: Any / Android

fitline in Android results in a wrong line

the fitline method produces a direction vector. the following android code results in a wrong direction vector (the result is (1,0) which is definitely wrong, the real line is nearly vertical)

        List<org.opencv.core.Point>points = new ArrayList<org.opencv.core.Point>();
        org.opencv.core.Point p1 = new org.opencv.core.Point(1224.0, 576.0);
        points.add(p1);
        p1= new org.opencv.core.Point(1234.0, 683.0);
        points.add(p1);
        p1= new org.opencv.core.Point(1215.0, 471.0);
        points.add(p1);
        p1= new org.opencv.core.Point(1184.0, 137.0);
        points.add(p1);
        p1= new org.opencv.core.Point(1079.0, 377.0);
        points.add(p1);
        p1= new org.opencv.core.Point(1239.0, 788.0);
        points.add(p1);
        MatOfPoint2f mPointsMat = new MatOfPoint2f();
        mPointsMat.fromList(points);//copy list into the Mat
        Size pSize2 = mPointsMat.size();
        Mat mLineMat = new Mat();
        Imgproc.fitLine(mPointsMat, mLineMat, Imgproc.CV_DIST_WELSCH, 0, 0.01, 0.01);//when used CV_DIST_HUBER - it is ok.
        double[] p_1 = mLineMat.get(0,0);//normalized direction x
        double[] p_2 = mLineMat.get(1,0);//normalized direction y
        double[] p_3 = mLineMat.get(2,0);//point on line x
        double[] p_4 = mLineMat.get(3,0);//point on line y

History

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions