@Override public void mousePressed(MouseEvent e) { gui.getImagePanel().grabFocus(); double scale = gui.getScale(); Point2D_F64 p = new Point2D_F64(e.getX()/scale,e.getY()/scale); System.out.printf("click %5.1f %5.1f\n",p.x,p.y); synchronized (detected) { for (int i = 0; i < detected.size; i++) { if( Intersection2D_F64.containConvex(detected.get(i).bounds,p) ) { selectedMarkerMouse(i,false); return; } } for (int i = 0; i < failures.size; i++) { if( Intersection2D_F64.containConvex(failures.get(i).bounds,p) ) { selectedMarkerMouse(i,true); return; } } } } });
/** * Finds the side which intersects the line on the shape. The line is assumed to pass through the shape * so if there is no intersection it is considered a bug */ int findSideIntersect( SquareNode n , LineSegment2D_F64 line , LineSegment2D_F64 storage ) { for (int i = 0; i < 4; i++) { int j = (i+1)%4; storage.a = n.corners.get(i); storage.b = n.corners.get(j); if( Intersection2D_F64.intersection(line,storage,intersection) != null ) { return i; } } // bug but I won't throw an exception to stop it from blowing up a bunch return -1; }
} else if( Intersection2D_F64.intersection(line, l, where) != null) { intersections.add((int)where.y); tmp.y = (y0+y1)/2.0; if( Intersection2D_F64.containConcave(polyF,tmp) ) { int width = y1-y0; if( width > largest ) {
@Override public void onDraw(Canvas canvas, Matrix imageToView) { if( touched) { applyToPoint(viewToImage,touch.x,touch.y,touch); } boolean selected = false; synchronized (lockGui) { canvas.concat(imageToView); for (int i = 0; i < numDetected; i++) { FiducialDetector.Detected d = detected[i]; if (validQuadrilateral(d.location)) { drawQuad(canvas, d.location, 3, paintBorder); drawQuad(canvas, d.location, 0, paintInside); if (touched && Intersection2D_F64.contains(d.location, touch)) { touchedFiducial.setTo(d.binary); selected = true; } } } } if( selected ) { // it's in the GUI thread already so this call is OK dialogAcceptFiducial("",""); } else { touched = false; } }
} else if( Intersection2D_F64.intersection(line, l, where) != null) { tmp.y = y; if( Intersection2D_F64.containConcave(polyF,tmp) ) { int width = x1-x0; if( width > largest && intersection(prevX0,prevX1,x0,x1) ) {
/** * Finds the side which intersects the line segment from the center of target to center of node */ protected int findIntersection( SquareNode target , SquareNode node ) { lineCenters.a = target.center; lineCenters.b = node.center; for (int i = 0; i < 4; i++) { int j = (i+1)%4; lineSide.a = target.corners.get(i); lineSide.b = target.corners.get(j); if(Intersection2D_F64.intersection(lineCenters,lineSide,dummy) != null ) { return i; } } return -1; }
for( int x = 0; x < image.getWidth(); x++ ) { p.x = x; p.y = y; if( !Intersection2D_F64.containConvex(poly, p) ) { copy.setRGB(x,y,rgb);
/** * Finds the intersections between the four lines and converts it into a quadrilateral * * @param lines Assumes lines are ordered */ public static boolean convert( LineGeneral2D_F64[] lines , Polygon2D_F64 poly ) { for (int i = 0; i < poly.size(); i++) { int j = (i + 1) % poly.size(); if( null == Intersection2D_F64.intersection(lines[i], lines[j], poly.get(j)) ) return false; } return true; } }
for( int x = 0; x < image.getWidth(); x++ ) { p.x = x; p.y = y; if( !Intersection2D_F64.containConvex(poly, p) ) { copy.setRGB(x,y,rgb);
void computeNodeInfo( List<Polygon2D_F64> squares ) { for (int i = 0; i < squares.size(); i++) { SquareNode n = nodes.grow(); n.reset(); n.corners = squares.get(i); if( n.corners.size() != 4 ) throw new RuntimeException("Sqaures have four corners not "+n.corners.size()); // does not assume CW or CCW ordering just that it is ordered lineA.a = n.corners.get(0); lineA.b = n.corners.get(2); lineB.a = n.corners.get(1); lineB.b = n.corners.get(3); // this will be the geometric center and invariant of perspective distortion Intersection2D_F64.intersection(lineA, lineB, n.center); for (int j = 0; j < 4; j++) { int k = (j+1)%4; double l = n.corners.get(j).distance(n.corners.get(k)); n.sideLengths[j] = l; n.largestSide = Math.max(n.largestSide,l); } } }
MiscUtil.renderPolygon(qr.bounds,path,canvas,colorDetected); if(touching && Intersection2D_F64.containConvex(qr.bounds,touched)) { selectedQR = qr.message;
if (null == Intersection2D_F64.intersection(line0, line1, intersection)) { if( verbose ) System.out.println(" SKIPPING no intersection");
/** * The passed in nodes should have the corner of the inner grid inside of them * The intersection of the true circle's center would be the same as true * corner's center, however since this is distorted it will only be approximate. * So the ellipse with a center that is classes is found */ protected NodeInfo selectInnerSeed( NodeInfo c00 , NodeInfo c01 , NodeInfo c10 , NodeInfo c11 ) { line0110.a.set(c01.ellipse.center); line0110.b.set(c10.ellipse.center); line0011.a.set(c00.ellipse.center); line0011.b.set(c11.ellipse.center); if( null == Intersection2D_F64.intersection(line0110, line0011,intersection) ) return null; // pick the best solution from two perspectives. Two perspectives are used // to provide additional robustness NodeInfo a = findClosestEdge(c00,intersection); NodeInfo b = findClosestEdge(c11,intersection); if( a == b ) return a; return null; }
/** * 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); }
if( null == Intersection2D_F64.intersection(lineLeft,lineRight,refined) ) return false;
if( Intersection2D_F64.intersection(general[k], general[i],tempA) != null && Intersection2D_F64.intersection(general[i], general[j],tempB) != null ) {
continue; if( null == Intersection2D_F64.intersection(lineA,lineB, location) ) { return false;