/** * Given segment information create a line in general notation which has been normalized */ private void createLine( int index0 , int index1 , List<Point2D_I32> contour , LineGeneral2D_F64 line ) { if( index1 < 0 ) System.out.println("SHIT"); Point2D_I32 p0 = contour.get(index0); Point2D_I32 p1 = contour.get(index1); // System.out.println("createLine "+p0+" "+p1); work.a.set(p0.x, p0.y); work.b.set(p1.x, p1.y); UtilLine2D_F64.convert(work,line); // ensure A*A + B*B = 1 line.normalize(); } }
/** * Returns true if point p1 and p2 are close to the line defined by points p0 and p3. */ boolean areMiddlePointsClose( Point2D_F64 p0 , Point2D_F64 p1 , Point2D_F64 p2 , Point2D_F64 p3 ) { UtilLine2D_F64.convert(p0,p3,line); // (computed expected length of a square) * (fractional tolerance) double tol1 = p0.distance(p1)*distanceTol; // see if inner points are close to the line if(Distance2D_F64.distance(line, p1) > tol1 ) return false; double tol2 = p2.distance(p3)*distanceTol; if( Distance2D_F64.distance(lineB, p2) > tol2 ) return false; //------------ Now see if the line defined by one side of a square is close to the closest point on the same // side on the other square UtilLine2D_F64.convert(p0,p1,line); if(Distance2D_F64.distance(line, p2) > tol2 ) return false; UtilLine2D_F64.convert(p3,p2,line); if(Distance2D_F64.distance(line, p1) > tol1 ) return false; return true; }
return false; UtilLine2D_F64.convert(linePolar,line);
/** * Return the intersection of two lines defined by opposing corners. This should also be the geometric center * @param which Fiducial's index * @param location (output) Storage for the transform. modified. */ @Override public void getImageLocation(int which, Point2D_F64 location) { FoundFiducial f = alg.getFound().get(which); distToUndist.compute(f.distortedPixels.a.x,f.distortedPixels.a.y, undistQuad.a); distToUndist.compute(f.distortedPixels.b.x,f.distortedPixels.b.y, undistQuad.b); distToUndist.compute(f.distortedPixels.c.x,f.distortedPixels.c.y, undistQuad.c); distToUndist.compute(f.distortedPixels.d.x,f.distortedPixels.d.y, undistQuad.d); // compute intersection in undistorted pixels so that the intersection is the true // geometric center of the square UtilLine2D_F64.convert(undistQuad.a, undistQuad.c,line02); UtilLine2D_F64.convert(undistQuad.b, undistQuad.d,line13); Intersection2D_F64.intersection(line02,line13,location); // apply lens distortion to the point so that it appears in the correct location undistToDist.compute(location.x,location.y, location); }
throw new RuntimeException("All weights were zero, bug some place"); UtilLine2D_F64.convert(polar, found);
UtilLine2D_F64.convert(lineCenters,general);
Point2D_F64 a = seed.get(i); Point2D_F64 b = seed.get(j); UtilLine2D_F64.convert(a,b,general[i]);