repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/SnapToEllipseEdge.java
SnapToEllipseEdge.change
protected static double change( EllipseRotated_F64 a , EllipseRotated_F64 b ) { double total = 0; total += Math.abs(a.center.x - b.center.x); total += Math.abs(a.center.y - b.center.y); total += Math.abs(a.a - b.a); total += Math.abs(a.b - b.b); // only care about the change of angle when it is not a circle double weight = Math.min(4,2.0*(a.a/a.b-1.0)); total += weight*UtilAngle.distHalf(a.phi , b.phi); return total; }
java
protected static double change( EllipseRotated_F64 a , EllipseRotated_F64 b ) { double total = 0; total += Math.abs(a.center.x - b.center.x); total += Math.abs(a.center.y - b.center.y); total += Math.abs(a.a - b.a); total += Math.abs(a.b - b.b); // only care about the change of angle when it is not a circle double weight = Math.min(4,2.0*(a.a/a.b-1.0)); total += weight*UtilAngle.distHalf(a.phi , b.phi); return total; }
[ "protected", "static", "double", "change", "(", "EllipseRotated_F64", "a", ",", "EllipseRotated_F64", "b", ")", "{", "double", "total", "=", "0", ";", "total", "+=", "Math", ".", "abs", "(", "a", ".", "center", ".", "x", "-", "b", ".", "center", ".", ...
Computes a numerical value for the difference in parameters between the two ellipses
[ "Computes", "a", "numerical", "value", "for", "the", "difference", "in", "parameters", "between", "the", "two", "ellipses" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/SnapToEllipseEdge.java#L116-L129
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java
FactoryVisualOdometry.monoPlaneInfinity
public static <T extends ImageGray<T>> MonocularPlaneVisualOdometry<T> monoPlaneInfinity(int thresholdAdd, int thresholdRetire, double inlierPixelTol, int ransacIterations, PointTracker<T> tracker, ImageType<T> imageType) { //squared pixel error double ransacTOL = inlierPixelTol * inlierPixelTol; ModelManagerSe2_F64 manager = new ModelManagerSe2_F64(); DistancePlane2DToPixelSq distance = new DistancePlane2DToPixelSq(); GenerateSe2_PlanePtPixel generator = new GenerateSe2_PlanePtPixel(); ModelMatcher<Se2_F64, PlanePtPixel> motion = new Ransac<>(2323, manager, generator, distance, ransacIterations, ransacTOL); VisOdomMonoPlaneInfinity<T> alg = new VisOdomMonoPlaneInfinity<>(thresholdAdd, thresholdRetire, inlierPixelTol, motion, tracker); return new MonoPlaneInfinity_to_MonocularPlaneVisualOdometry<>(alg, distance, generator, imageType); }
java
public static <T extends ImageGray<T>> MonocularPlaneVisualOdometry<T> monoPlaneInfinity(int thresholdAdd, int thresholdRetire, double inlierPixelTol, int ransacIterations, PointTracker<T> tracker, ImageType<T> imageType) { //squared pixel error double ransacTOL = inlierPixelTol * inlierPixelTol; ModelManagerSe2_F64 manager = new ModelManagerSe2_F64(); DistancePlane2DToPixelSq distance = new DistancePlane2DToPixelSq(); GenerateSe2_PlanePtPixel generator = new GenerateSe2_PlanePtPixel(); ModelMatcher<Se2_F64, PlanePtPixel> motion = new Ransac<>(2323, manager, generator, distance, ransacIterations, ransacTOL); VisOdomMonoPlaneInfinity<T> alg = new VisOdomMonoPlaneInfinity<>(thresholdAdd, thresholdRetire, inlierPixelTol, motion, tracker); return new MonoPlaneInfinity_to_MonocularPlaneVisualOdometry<>(alg, distance, generator, imageType); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "MonocularPlaneVisualOdometry", "<", "T", ">", "monoPlaneInfinity", "(", "int", "thresholdAdd", ",", "int", "thresholdRetire", ",", "double", "inlierPixelTol", ",", "int", "ransacIterations"...
Monocular plane based visual odometry algorithm which uses both points on the plane and off plane for motion estimation. @see VisOdomMonoPlaneInfinity @param thresholdAdd New points are spawned when the number of on plane inliers drops below this value. @param thresholdRetire Tracks are dropped when they are not contained in the inlier set for this many frames in a row. Try 2 @param inlierPixelTol Threshold used to determine inliers in pixels. Try 1.5 @param ransacIterations Number of RANSAC iterations. Try 200 @param tracker Image feature tracker @param imageType Type of input image it processes @param <T> @return New instance of
[ "Monocular", "plane", "based", "visual", "odometry", "algorithm", "which", "uses", "both", "points", "on", "the", "plane", "and", "off", "plane", "for", "motion", "estimation", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java#L94-L118
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java
FactoryVisualOdometry.monoPlaneOverhead
public static <T extends ImageGray<T>> MonocularPlaneVisualOdometry<T> monoPlaneOverhead(double cellSize, double maxCellsPerPixel, double mapHeightFraction , double inlierGroundTol, int ransacIterations , int thresholdRetire , int absoluteMinimumTracks, double respawnTrackFraction, double respawnCoverageFraction, PointTracker<T> tracker , ImageType<T> imageType ) { ImageMotion2D<T,Se2_F64> motion2D = FactoryMotion2D.createMotion2D( ransacIterations,inlierGroundTol*inlierGroundTol,thresholdRetire, absoluteMinimumTracks,respawnTrackFraction,respawnCoverageFraction,false,tracker,new Se2_F64()); VisOdomMonoOverheadMotion2D<T> alg = new VisOdomMonoOverheadMotion2D<>(cellSize, maxCellsPerPixel, mapHeightFraction, motion2D, imageType); return new MonoOverhead_to_MonocularPlaneVisualOdometry<>(alg, imageType); }
java
public static <T extends ImageGray<T>> MonocularPlaneVisualOdometry<T> monoPlaneOverhead(double cellSize, double maxCellsPerPixel, double mapHeightFraction , double inlierGroundTol, int ransacIterations , int thresholdRetire , int absoluteMinimumTracks, double respawnTrackFraction, double respawnCoverageFraction, PointTracker<T> tracker , ImageType<T> imageType ) { ImageMotion2D<T,Se2_F64> motion2D = FactoryMotion2D.createMotion2D( ransacIterations,inlierGroundTol*inlierGroundTol,thresholdRetire, absoluteMinimumTracks,respawnTrackFraction,respawnCoverageFraction,false,tracker,new Se2_F64()); VisOdomMonoOverheadMotion2D<T> alg = new VisOdomMonoOverheadMotion2D<>(cellSize, maxCellsPerPixel, mapHeightFraction, motion2D, imageType); return new MonoOverhead_to_MonocularPlaneVisualOdometry<>(alg, imageType); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "MonocularPlaneVisualOdometry", "<", "T", ">", "monoPlaneOverhead", "(", "double", "cellSize", ",", "double", "maxCellsPerPixel", ",", "double", "mapHeightFraction", ",", "double", "inlierGr...
Monocular plane based visual odometry algorithm which creates a synthetic overhead view and tracks image features inside this synthetic view. @see VisOdomMonoOverheadMotion2D @param cellSize (Overhead) size of ground cells in overhead image in world units @param maxCellsPerPixel (Overhead) Specifies the minimum resolution. Higher values allow lower resolutions. Try 20 @param mapHeightFraction (Overhead) Truncates the overhead view. Must be from 0 to 1.0. 1.0 includes the entire image. @param inlierGroundTol (RANSAC) RANSAC tolerance in overhead image pixels @param ransacIterations (RANSAC) Number of iterations used when estimating motion @param thresholdRetire (2D Motion) Drop tracks if they are not in inliers set for this many turns. @param absoluteMinimumTracks (2D Motion) Spawn tracks if the number of inliers drops below the specified number @param respawnTrackFraction (2D Motion) Spawn tracks if the number of tracks has dropped below this fraction of the original number @param respawnCoverageFraction (2D Motion) Spawn tracks if the total coverage drops below this relative fraction @param tracker Image feature tracker @param imageType Type of image being processed @return MonocularPlaneVisualOdometry
[ "Monocular", "plane", "based", "visual", "odometry", "algorithm", "which", "creates", "a", "synthetic", "overhead", "view", "and", "tracks", "image", "features", "inside", "this", "synthetic", "view", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java#L145-L170
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java
FactoryVisualOdometry.stereoDepth
public static <T extends ImageGray<T>> StereoVisualOdometry<T> stereoDepth(double inlierPixelTol, int thresholdAdd, int thresholdRetire , int ransacIterations , int refineIterations , boolean doublePass , StereoDisparitySparse<T> sparseDisparity, PointTrackerTwoPass<T> tracker , Class<T> imageType) { // Range from sparse disparity StereoSparse3D<T> pixelTo3D = new StereoSparse3D<>(sparseDisparity, imageType); Estimate1ofPnP estimator = FactoryMultiView.pnp_1(EnumPNP.P3P_FINSTERWALDER,-1,2); final DistanceFromModelMultiView<Se3_F64,Point2D3D> distance = new PnPDistanceReprojectionSq(); ModelManagerSe3_F64 manager = new ModelManagerSe3_F64(); EstimatorToGenerator<Se3_F64,Point2D3D> generator = new EstimatorToGenerator<>(estimator); // 1/2 a pixel tolerance for RANSAC inliers double ransacTOL = inlierPixelTol * inlierPixelTol; ModelMatcher<Se3_F64, Point2D3D> motion = new Ransac<>(2323, manager, generator, distance, ransacIterations, ransacTOL); RefinePnP refine = null; if( refineIterations > 0 ) { refine = FactoryMultiView.pnpRefine(1e-12,refineIterations); } VisOdomPixelDepthPnP<T> alg = new VisOdomPixelDepthPnP<>(thresholdAdd, thresholdRetire, doublePass, motion, pixelTo3D, refine, tracker, null, null); return new WrapVisOdomPixelDepthPnP<>(alg, pixelTo3D, distance, imageType); }
java
public static <T extends ImageGray<T>> StereoVisualOdometry<T> stereoDepth(double inlierPixelTol, int thresholdAdd, int thresholdRetire , int ransacIterations , int refineIterations , boolean doublePass , StereoDisparitySparse<T> sparseDisparity, PointTrackerTwoPass<T> tracker , Class<T> imageType) { // Range from sparse disparity StereoSparse3D<T> pixelTo3D = new StereoSparse3D<>(sparseDisparity, imageType); Estimate1ofPnP estimator = FactoryMultiView.pnp_1(EnumPNP.P3P_FINSTERWALDER,-1,2); final DistanceFromModelMultiView<Se3_F64,Point2D3D> distance = new PnPDistanceReprojectionSq(); ModelManagerSe3_F64 manager = new ModelManagerSe3_F64(); EstimatorToGenerator<Se3_F64,Point2D3D> generator = new EstimatorToGenerator<>(estimator); // 1/2 a pixel tolerance for RANSAC inliers double ransacTOL = inlierPixelTol * inlierPixelTol; ModelMatcher<Se3_F64, Point2D3D> motion = new Ransac<>(2323, manager, generator, distance, ransacIterations, ransacTOL); RefinePnP refine = null; if( refineIterations > 0 ) { refine = FactoryMultiView.pnpRefine(1e-12,refineIterations); } VisOdomPixelDepthPnP<T> alg = new VisOdomPixelDepthPnP<>(thresholdAdd, thresholdRetire, doublePass, motion, pixelTo3D, refine, tracker, null, null); return new WrapVisOdomPixelDepthPnP<>(alg, pixelTo3D, distance, imageType); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "StereoVisualOdometry", "<", "T", ">", "stereoDepth", "(", "double", "inlierPixelTol", ",", "int", "thresholdAdd", ",", "int", "thresholdRetire", ",", "int", "ransacIterations", ",", "in...
Stereo vision based visual odometry algorithm which runs a sparse feature tracker in the left camera and estimates the range of tracks once when first detected using disparity between left and right cameras. @see VisOdomPixelDepthPnP @param thresholdAdd Add new tracks when less than this number are in the inlier set. Tracker dependent. Set to a value &le; 0 to add features every frame. @param thresholdRetire Discard a track if it is not in the inlier set after this many updates. Try 2 @param sparseDisparity Estimates the 3D location of features @param imageType Type of image being processed. @return StereoVisualOdometry
[ "Stereo", "vision", "based", "visual", "odometry", "algorithm", "which", "runs", "a", "sparse", "feature", "tracker", "in", "the", "left", "camera", "and", "estimates", "the", "range", "of", "tracks", "once", "when", "first", "detected", "using", "disparity", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java#L185-L222
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java
FactoryVisualOdometry.depthDepthPnP
public static <Vis extends ImageGray<Vis>, Depth extends ImageGray<Depth>> DepthVisualOdometry<Vis,Depth> depthDepthPnP(double inlierPixelTol, int thresholdAdd, int thresholdRetire , int ransacIterations , int refineIterations , boolean doublePass , DepthSparse3D<Depth> sparseDepth, PointTrackerTwoPass<Vis> tracker , Class<Vis> visualType , Class<Depth> depthType ) { // Range from sparse disparity ImagePixelTo3D pixelTo3D = new DepthSparse3D_to_PixelTo3D<>(sparseDepth); Estimate1ofPnP estimator = FactoryMultiView.pnp_1(EnumPNP.P3P_FINSTERWALDER,-1,2); final DistanceFromModelMultiView<Se3_F64,Point2D3D> distance = new PnPDistanceReprojectionSq(); ModelManagerSe3_F64 manager = new ModelManagerSe3_F64(); EstimatorToGenerator<Se3_F64,Point2D3D> generator = new EstimatorToGenerator<>(estimator); // 1/2 a pixel tolerance for RANSAC inliers double ransacTOL = inlierPixelTol * inlierPixelTol; ModelMatcher<Se3_F64, Point2D3D> motion = new Ransac<>(2323, manager, generator, distance, ransacIterations, ransacTOL); RefinePnP refine = null; if( refineIterations > 0 ) { refine = FactoryMultiView.pnpRefine(1e-12,refineIterations); } VisOdomPixelDepthPnP<Vis> alg = new VisOdomPixelDepthPnP<> (thresholdAdd, thresholdRetire, doublePass, motion, pixelTo3D, refine, tracker, null, null); return new VisOdomPixelDepthPnP_to_DepthVisualOdometry<> (sparseDepth, alg, distance, ImageType.single(visualType), depthType); }
java
public static <Vis extends ImageGray<Vis>, Depth extends ImageGray<Depth>> DepthVisualOdometry<Vis,Depth> depthDepthPnP(double inlierPixelTol, int thresholdAdd, int thresholdRetire , int ransacIterations , int refineIterations , boolean doublePass , DepthSparse3D<Depth> sparseDepth, PointTrackerTwoPass<Vis> tracker , Class<Vis> visualType , Class<Depth> depthType ) { // Range from sparse disparity ImagePixelTo3D pixelTo3D = new DepthSparse3D_to_PixelTo3D<>(sparseDepth); Estimate1ofPnP estimator = FactoryMultiView.pnp_1(EnumPNP.P3P_FINSTERWALDER,-1,2); final DistanceFromModelMultiView<Se3_F64,Point2D3D> distance = new PnPDistanceReprojectionSq(); ModelManagerSe3_F64 manager = new ModelManagerSe3_F64(); EstimatorToGenerator<Se3_F64,Point2D3D> generator = new EstimatorToGenerator<>(estimator); // 1/2 a pixel tolerance for RANSAC inliers double ransacTOL = inlierPixelTol * inlierPixelTol; ModelMatcher<Se3_F64, Point2D3D> motion = new Ransac<>(2323, manager, generator, distance, ransacIterations, ransacTOL); RefinePnP refine = null; if( refineIterations > 0 ) { refine = FactoryMultiView.pnpRefine(1e-12,refineIterations); } VisOdomPixelDepthPnP<Vis> alg = new VisOdomPixelDepthPnP<> (thresholdAdd, thresholdRetire, doublePass, motion, pixelTo3D, refine, tracker, null, null); return new VisOdomPixelDepthPnP_to_DepthVisualOdometry<> (sparseDepth, alg, distance, ImageType.single(visualType), depthType); }
[ "public", "static", "<", "Vis", "extends", "ImageGray", "<", "Vis", ">", ",", "Depth", "extends", "ImageGray", "<", "Depth", ">", ">", "DepthVisualOdometry", "<", "Vis", ",", "Depth", ">", "depthDepthPnP", "(", "double", "inlierPixelTol", ",", "int", "thresh...
Depth sensor based visual odometry algorithm which runs a sparse feature tracker in the visual camera and estimates the range of tracks once when first detected using the depth sensor. @see VisOdomPixelDepthPnP @param thresholdAdd Add new tracks when less than this number are in the inlier set. Tracker dependent. Set to a value &le; 0 to add features every frame. @param thresholdRetire Discard a track if it is not in the inlier set after this many updates. Try 2 @param sparseDepth Extracts depth of pixels from a depth sensor. @param visualType Type of visual image being processed. @param depthType Type of depth image being processed. @return StereoVisualOdometry
[ "Depth", "sensor", "based", "visual", "odometry", "algorithm", "which", "runs", "a", "sparse", "feature", "tracker", "in", "the", "visual", "camera", "and", "estimates", "the", "range", "of", "tracks", "once", "when", "first", "detected", "using", "the", "dept...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java#L238-L275
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java
FactoryVisualOdometry.stereoDualTrackerPnP
public static <T extends ImageGray<T>, Desc extends TupleDesc> StereoVisualOdometry<T> stereoDualTrackerPnP(int thresholdAdd, int thresholdRetire, double inlierPixelTol, double epipolarPixelTol, int ransacIterations, int refineIterations, PointTracker<T> trackerLeft, PointTracker<T> trackerRight, DescribeRegionPoint<T,Desc> descriptor, Class<T> imageType) { EstimateNofPnP pnp = FactoryMultiView.pnp_N(EnumPNP.P3P_FINSTERWALDER, -1); DistanceFromModelMultiView<Se3_F64,Point2D3D> distanceMono = new PnPDistanceReprojectionSq(); PnPStereoDistanceReprojectionSq distanceStereo = new PnPStereoDistanceReprojectionSq(); PnPStereoEstimator pnpStereo = new PnPStereoEstimator(pnp,distanceMono,0); ModelManagerSe3_F64 manager = new ModelManagerSe3_F64(); EstimatorToGenerator<Se3_F64,Stereo2D3D> generator = new EstimatorToGenerator<>(pnpStereo); // Pixel tolerance for RANSAC inliers - euclidean error squared from left + right images double ransacTOL = 2*inlierPixelTol * inlierPixelTol; ModelMatcher<Se3_F64, Stereo2D3D> motion = new Ransac<>(2323, manager, generator, distanceStereo, ransacIterations, ransacTOL); RefinePnPStereo refinePnP = null; Class<Desc> descType = descriptor.getDescriptionType(); ScoreAssociation<Desc> scorer = FactoryAssociation.defaultScore(descType); AssociateStereo2D<Desc> associateStereo = new AssociateStereo2D<>(scorer, epipolarPixelTol, descType); // need to make sure associations are unique AssociateDescription2D<Desc> associateUnique = associateStereo; if( !associateStereo.uniqueDestination() || !associateStereo.uniqueSource() ) { associateUnique = new EnforceUniqueByScore.Describe2D<>(associateStereo, true, true); } if( refineIterations > 0 ) { refinePnP = new PnPStereoRefineRodrigues(1e-12,refineIterations); } Triangulate2ViewsMetric triangulate = FactoryMultiView.triangulate2ViewMetric( new ConfigTriangulation(ConfigTriangulation.Type.GEOMETRIC)); VisOdomDualTrackPnP<T,Desc> alg = new VisOdomDualTrackPnP<>(thresholdAdd, thresholdRetire, epipolarPixelTol, trackerLeft, trackerRight, descriptor, associateUnique, triangulate, motion, refinePnP); return new WrapVisOdomDualTrackPnP<>(pnpStereo, distanceMono, distanceStereo, associateStereo, alg, refinePnP, imageType); }
java
public static <T extends ImageGray<T>, Desc extends TupleDesc> StereoVisualOdometry<T> stereoDualTrackerPnP(int thresholdAdd, int thresholdRetire, double inlierPixelTol, double epipolarPixelTol, int ransacIterations, int refineIterations, PointTracker<T> trackerLeft, PointTracker<T> trackerRight, DescribeRegionPoint<T,Desc> descriptor, Class<T> imageType) { EstimateNofPnP pnp = FactoryMultiView.pnp_N(EnumPNP.P3P_FINSTERWALDER, -1); DistanceFromModelMultiView<Se3_F64,Point2D3D> distanceMono = new PnPDistanceReprojectionSq(); PnPStereoDistanceReprojectionSq distanceStereo = new PnPStereoDistanceReprojectionSq(); PnPStereoEstimator pnpStereo = new PnPStereoEstimator(pnp,distanceMono,0); ModelManagerSe3_F64 manager = new ModelManagerSe3_F64(); EstimatorToGenerator<Se3_F64,Stereo2D3D> generator = new EstimatorToGenerator<>(pnpStereo); // Pixel tolerance for RANSAC inliers - euclidean error squared from left + right images double ransacTOL = 2*inlierPixelTol * inlierPixelTol; ModelMatcher<Se3_F64, Stereo2D3D> motion = new Ransac<>(2323, manager, generator, distanceStereo, ransacIterations, ransacTOL); RefinePnPStereo refinePnP = null; Class<Desc> descType = descriptor.getDescriptionType(); ScoreAssociation<Desc> scorer = FactoryAssociation.defaultScore(descType); AssociateStereo2D<Desc> associateStereo = new AssociateStereo2D<>(scorer, epipolarPixelTol, descType); // need to make sure associations are unique AssociateDescription2D<Desc> associateUnique = associateStereo; if( !associateStereo.uniqueDestination() || !associateStereo.uniqueSource() ) { associateUnique = new EnforceUniqueByScore.Describe2D<>(associateStereo, true, true); } if( refineIterations > 0 ) { refinePnP = new PnPStereoRefineRodrigues(1e-12,refineIterations); } Triangulate2ViewsMetric triangulate = FactoryMultiView.triangulate2ViewMetric( new ConfigTriangulation(ConfigTriangulation.Type.GEOMETRIC)); VisOdomDualTrackPnP<T,Desc> alg = new VisOdomDualTrackPnP<>(thresholdAdd, thresholdRetire, epipolarPixelTol, trackerLeft, trackerRight, descriptor, associateUnique, triangulate, motion, refinePnP); return new WrapVisOdomDualTrackPnP<>(pnpStereo, distanceMono, distanceStereo, associateStereo, alg, refinePnP, imageType); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ",", "Desc", "extends", "TupleDesc", ">", "StereoVisualOdometry", "<", "T", ">", "stereoDualTrackerPnP", "(", "int", "thresholdAdd", ",", "int", "thresholdRetire", ",", "double", "inlierPixelTo...
Creates a stereo visual odometry algorithm that independently tracks features in left and right camera. @see VisOdomDualTrackPnP @param thresholdAdd When the number of inliers is below this number new features are detected @param thresholdRetire When a feature has not been in the inlier list for this many ticks it is dropped @param inlierPixelTol Tolerance in pixels for defining an inlier during robust model matching. Typically 1.5 @param epipolarPixelTol Tolerance in pixels for enforcing the epipolar constraint @param ransacIterations Number of iterations performed by RANSAC. Try 300 or more. @param refineIterations Number of iterations done during non-linear optimization. Try 50 or more. @param trackerLeft Tracker used for left camera @param trackerRight Tracker used for right camera @param imageType Type of image being processed @return Stereo visual odometry algorithm.
[ "Creates", "a", "stereo", "visual", "odometry", "algorithm", "that", "independently", "tracks", "features", "in", "left", "and", "right", "camera", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryVisualOdometry.java#L293-L340
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java
UtilLepetitEPnP.computeCameraControl
public static void computeCameraControl(double beta[], List<Point3D_F64> nullPts[], FastQueue<Point3D_F64> cameraPts , int numControl ) { cameraPts.reset(); for( int i = 0; i < numControl; i++ ) { cameraPts.grow().set(0,0,0); } for( int i = 0; i < numControl; i++ ) { double b = beta[i]; // System.out.printf("%7.3f ", b); for( int j = 0; j < numControl; j++ ) { Point3D_F64 s = cameraPts.get(j); Point3D_F64 p = nullPts[i].get(j); s.x += b*p.x; s.y += b*p.y; s.z += b*p.z; } } }
java
public static void computeCameraControl(double beta[], List<Point3D_F64> nullPts[], FastQueue<Point3D_F64> cameraPts , int numControl ) { cameraPts.reset(); for( int i = 0; i < numControl; i++ ) { cameraPts.grow().set(0,0,0); } for( int i = 0; i < numControl; i++ ) { double b = beta[i]; // System.out.printf("%7.3f ", b); for( int j = 0; j < numControl; j++ ) { Point3D_F64 s = cameraPts.get(j); Point3D_F64 p = nullPts[i].get(j); s.x += b*p.x; s.y += b*p.y; s.z += b*p.z; } } }
[ "public", "static", "void", "computeCameraControl", "(", "double", "beta", "[", "]", ",", "List", "<", "Point3D_F64", ">", "nullPts", "[", "]", ",", "FastQueue", "<", "Point3D_F64", ">", "cameraPts", ",", "int", "numControl", ")", "{", "cameraPts", ".", "r...
Computes the camera control points as weighted sum of null points. @param beta Beta values which describe the weights of null points @param nullPts Null points that the camera point is a weighted sum of @param cameraPts The output
[ "Computes", "the", "camera", "control", "points", "as", "weighted", "sum", "of", "null", "points", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L41-L63
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java
UtilLepetitEPnP.constraintMatrix6x3
public static void constraintMatrix6x3( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x3 ) { int index = 0; for( int i = 0; i < 6; i++ ) { L_6x3.data[index++] = L_6x10.get(i,0); L_6x3.data[index++] = L_6x10.get(i,1); L_6x3.data[index++] = L_6x10.get(i,4); } }
java
public static void constraintMatrix6x3( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x3 ) { int index = 0; for( int i = 0; i < 6; i++ ) { L_6x3.data[index++] = L_6x10.get(i,0); L_6x3.data[index++] = L_6x10.get(i,1); L_6x3.data[index++] = L_6x10.get(i,4); } }
[ "public", "static", "void", "constraintMatrix6x3", "(", "DMatrixRMaj", "L_6x10", ",", "DMatrixRMaj", "L_6x3", ")", "{", "int", "index", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "{", "L_6x3", ".", "da...
Extracts the linear constraint matrix for case 2 from the full 6x10 constraint matrix.
[ "Extracts", "the", "linear", "constraint", "matrix", "for", "case", "2", "from", "the", "full", "6x10", "constraint", "matrix", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L82-L90
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java
UtilLepetitEPnP.constraintMatrix6x6
public static void constraintMatrix6x6( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x6 ) { int index = 0; for( int i = 0; i < 6; i++ ) { L_6x6.data[index++] = L_6x10.get(i,0); L_6x6.data[index++] = L_6x10.get(i,1); L_6x6.data[index++] = L_6x10.get(i,2); L_6x6.data[index++] = L_6x10.get(i,4); L_6x6.data[index++] = L_6x10.get(i,5); L_6x6.data[index++] = L_6x10.get(i,7); } }
java
public static void constraintMatrix6x6( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x6 ) { int index = 0; for( int i = 0; i < 6; i++ ) { L_6x6.data[index++] = L_6x10.get(i,0); L_6x6.data[index++] = L_6x10.get(i,1); L_6x6.data[index++] = L_6x10.get(i,2); L_6x6.data[index++] = L_6x10.get(i,4); L_6x6.data[index++] = L_6x10.get(i,5); L_6x6.data[index++] = L_6x10.get(i,7); } }
[ "public", "static", "void", "constraintMatrix6x6", "(", "DMatrixRMaj", "L_6x10", ",", "DMatrixRMaj", "L_6x6", ")", "{", "int", "index", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "6", ";", "i", "++", ")", "{", "L_6x6", ".", "da...
Extracts the linear constraint matrix for case 3 from the full 6x10 constraint matrix.
[ "Extracts", "the", "linear", "constraint", "matrix", "for", "case", "3", "from", "the", "full", "6x10", "constraint", "matrix", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L95-L106
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java
UtilLepetitEPnP.constraintMatrix3x3
public static void constraintMatrix3x3( DMatrixRMaj L_3x6 , DMatrixRMaj L_6x3 ) { int index = 0; for( int i = 0; i < 3; i++ ) { L_6x3.data[index++] = L_3x6.get(i,0); L_6x3.data[index++] = L_3x6.get(i,1); L_6x3.data[index++] = L_3x6.get(i,3); } }
java
public static void constraintMatrix3x3( DMatrixRMaj L_3x6 , DMatrixRMaj L_6x3 ) { int index = 0; for( int i = 0; i < 3; i++ ) { L_6x3.data[index++] = L_3x6.get(i,0); L_6x3.data[index++] = L_3x6.get(i,1); L_6x3.data[index++] = L_3x6.get(i,3); } }
[ "public", "static", "void", "constraintMatrix3x3", "(", "DMatrixRMaj", "L_3x6", ",", "DMatrixRMaj", "L_6x3", ")", "{", "int", "index", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "L_6x3", ".", "dat...
Extracts the linear constraint matrix for planar case 2 from the full 4x6 constraint matrix.
[ "Extracts", "the", "linear", "constraint", "matrix", "for", "planar", "case", "2", "from", "the", "full", "4x6", "constraint", "matrix", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L194-L203
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java
UtilLepetitEPnP.constraintMatrix3x6
public static void constraintMatrix3x6( DMatrixRMaj L , DMatrixRMaj y , FastQueue<Point3D_F64> controlWorldPts , List<Point3D_F64> nullPts[] ) { int row = 0; for( int i = 0; i < 3; i++ ) { Point3D_F64 ci = controlWorldPts.get(i); Point3D_F64 vai = nullPts[0].get(i); Point3D_F64 vbi = nullPts[1].get(i); Point3D_F64 vci = nullPts[2].get(i); for( int j = i+1; j < 3; j++ , row++) { Point3D_F64 cj = controlWorldPts.get(j); Point3D_F64 vaj = nullPts[0].get(j); Point3D_F64 vbj = nullPts[1].get(j); Point3D_F64 vcj = nullPts[2].get(j); y.set(row,0,ci.distance2(cj)); double xa = vai.x-vaj.x; double ya = vai.y-vaj.y; double za = vai.z-vaj.z; double xb = vbi.x-vbj.x; double yb = vbi.y-vbj.y; double zb = vbi.z-vbj.z; double xc = vci.x-vcj.x; double yc = vci.y-vcj.y; double zc = vci.z-vcj.z; double da = xa*xa + ya*ya + za*za; double db = xb*xb + yb*yb + zb*zb; double dc = xc*xc + yc*yc + zc*zc; double dab = xa*xb + ya*yb + za*zb; double dac = xa*xc + ya*yc + za*zc; double dbc = xb*xc + yb*yc + zb*zc; L.set(row,0,da); L.set(row,1,2*dab); L.set(row,2,2*dac); L.set(row,3,db); L.set(row,4,2*dbc); L.set(row,5,dc); } } }
java
public static void constraintMatrix3x6( DMatrixRMaj L , DMatrixRMaj y , FastQueue<Point3D_F64> controlWorldPts , List<Point3D_F64> nullPts[] ) { int row = 0; for( int i = 0; i < 3; i++ ) { Point3D_F64 ci = controlWorldPts.get(i); Point3D_F64 vai = nullPts[0].get(i); Point3D_F64 vbi = nullPts[1].get(i); Point3D_F64 vci = nullPts[2].get(i); for( int j = i+1; j < 3; j++ , row++) { Point3D_F64 cj = controlWorldPts.get(j); Point3D_F64 vaj = nullPts[0].get(j); Point3D_F64 vbj = nullPts[1].get(j); Point3D_F64 vcj = nullPts[2].get(j); y.set(row,0,ci.distance2(cj)); double xa = vai.x-vaj.x; double ya = vai.y-vaj.y; double za = vai.z-vaj.z; double xb = vbi.x-vbj.x; double yb = vbi.y-vbj.y; double zb = vbi.z-vbj.z; double xc = vci.x-vcj.x; double yc = vci.y-vcj.y; double zc = vci.z-vcj.z; double da = xa*xa + ya*ya + za*za; double db = xb*xb + yb*yb + zb*zb; double dc = xc*xc + yc*yc + zc*zc; double dab = xa*xb + ya*yb + za*zb; double dac = xa*xc + ya*yc + za*zc; double dbc = xb*xc + yb*yc + zb*zc; L.set(row,0,da); L.set(row,1,2*dab); L.set(row,2,2*dac); L.set(row,3,db); L.set(row,4,2*dbc); L.set(row,5,dc); } } }
[ "public", "static", "void", "constraintMatrix3x6", "(", "DMatrixRMaj", "L", ",", "DMatrixRMaj", "y", ",", "FastQueue", "<", "Point3D_F64", ">", "controlWorldPts", ",", "List", "<", "Point3D_F64", ">", "nullPts", "[", "]", ")", "{", "int", "row", "=", "0", ...
Linear constraint matrix for case 4 in the planar case @param L Constraint matrix @param y Vector containing distance between world control points @param controlWorldPts List of world control points @param nullPts Null points
[ "Linear", "constraint", "matrix", "for", "case", "4", "in", "the", "planar", "case" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L213-L259
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java
UtilLepetitEPnP.jacobian_Control4
public static void jacobian_Control4( DMatrixRMaj L_full , double beta[] , DMatrixRMaj A ) { int indexA = 0; double b0 = beta[0]; double b1 = beta[1]; double b2 = beta[2]; double b3 = beta[3]; final double ld[] = L_full.data; for( int i = 0; i < 6; i++ ) { int li = L_full.numCols*i; A.data[indexA++] = 2*ld[li+0]*b0 + ld[li+1]*b1 + ld[li+2]*b2 + ld[li+3]*b3; A.data[indexA++] = ld[li+1]*b0 + 2*ld[li+4]*b1 + ld[li+5]*b2 + ld[li+6]*b3; A.data[indexA++] = ld[li+2]*b0 + ld[li+5]*b1 + 2*ld[li+7]*b2 + ld[li+8]*b3; A.data[indexA++] = ld[li+3]*b0 + ld[li+6]*b1 + ld[li+8]*b2 + 2*ld[li+9]*b3; } }
java
public static void jacobian_Control4( DMatrixRMaj L_full , double beta[] , DMatrixRMaj A ) { int indexA = 0; double b0 = beta[0]; double b1 = beta[1]; double b2 = beta[2]; double b3 = beta[3]; final double ld[] = L_full.data; for( int i = 0; i < 6; i++ ) { int li = L_full.numCols*i; A.data[indexA++] = 2*ld[li+0]*b0 + ld[li+1]*b1 + ld[li+2]*b2 + ld[li+3]*b3; A.data[indexA++] = ld[li+1]*b0 + 2*ld[li+4]*b1 + ld[li+5]*b2 + ld[li+6]*b3; A.data[indexA++] = ld[li+2]*b0 + ld[li+5]*b1 + 2*ld[li+7]*b2 + ld[li+8]*b3; A.data[indexA++] = ld[li+3]*b0 + ld[li+6]*b1 + ld[li+8]*b2 + 2*ld[li+9]*b3; } }
[ "public", "static", "void", "jacobian_Control4", "(", "DMatrixRMaj", "L_full", ",", "double", "beta", "[", "]", ",", "DMatrixRMaj", "A", ")", "{", "int", "indexA", "=", "0", ";", "double", "b0", "=", "beta", "[", "0", "]", ";", "double", "b1", "=", "...
Computes the Jacobian given 4 control points.
[ "Computes", "the", "Jacobian", "given", "4", "control", "points", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L316-L332
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java
UtilLepetitEPnP.jacobian_Control3
public static void jacobian_Control3( DMatrixRMaj L_full , double beta[] , DMatrixRMaj A) { int indexA = 0; double b0 = beta[0]; double b1 = beta[1]; double b2 = beta[2]; final double ld[] = L_full.data; for( int i = 0; i < 3; i++ ) { int li = L_full.numCols*i; A.data[indexA++] = 2*ld[li+0]*b0 + ld[li+1]*b1 + ld[li+2]*b2; A.data[indexA++] = ld[li+1]*b0 + 2*ld[li+3]*b1 + ld[li+4]*b2; A.data[indexA++] = ld[li+2]*b0 + ld[li+4]*b1 + 2*ld[li+5]*b2; } }
java
public static void jacobian_Control3( DMatrixRMaj L_full , double beta[] , DMatrixRMaj A) { int indexA = 0; double b0 = beta[0]; double b1 = beta[1]; double b2 = beta[2]; final double ld[] = L_full.data; for( int i = 0; i < 3; i++ ) { int li = L_full.numCols*i; A.data[indexA++] = 2*ld[li+0]*b0 + ld[li+1]*b1 + ld[li+2]*b2; A.data[indexA++] = ld[li+1]*b0 + 2*ld[li+3]*b1 + ld[li+4]*b2; A.data[indexA++] = ld[li+2]*b0 + ld[li+4]*b1 + 2*ld[li+5]*b2; } }
[ "public", "static", "void", "jacobian_Control3", "(", "DMatrixRMaj", "L_full", ",", "double", "beta", "[", "]", ",", "DMatrixRMaj", "A", ")", "{", "int", "indexA", "=", "0", ";", "double", "b0", "=", "beta", "[", "0", "]", ";", "double", "b1", "=", "...
Computes the Jacobian given 3 control points.
[ "Computes", "the", "Jacobian", "given", "3", "control", "points", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/UtilLepetitEPnP.java#L337-L352
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/flow/DenseOpticalFlowBlockPyramid.java
DenseOpticalFlowBlockPyramid.process
public void process( ImagePyramid<T> pyramidPrev , ImagePyramid<T> pyramidCurr ) { InputSanityCheck.checkSameShape(pyramidPrev, pyramidCurr); int numLayers = pyramidPrev.getNumLayers(); for( int i = numLayers-1; i >= 0; i-- ) { T prev = pyramidPrev.getLayer(i); T curr = pyramidCurr.getLayer(i); flowCurrLayer.reshape(prev.width, prev.height); int N = prev.width*prev.height; if( scores.length < N ) scores = new float[N]; // mark all the scores as being very large so that if it has not been processed its score // will be set inside of checkNeighbors. Arrays.fill(scores,0,N,Float.MAX_VALUE); int x1 = prev.width-regionRadius; int y1 = prev.height-regionRadius; if( i == numLayers-1 ) { // the top most layer in the pyramid has no hint for( int y = regionRadius; y < y1; y++ ) { for( int x = regionRadius; x < x1; x++ ) { extractTemplate(x,y,prev); float score = findFlow(x,y,curr,tmp); if( tmp.isValid() ) checkNeighbors(x,y,tmp, flowCurrLayer,score); else flowCurrLayer.unsafe_get(x, y).markInvalid(); } } } else { // for all the other layers use the hint of the previous layer to start its search double scale = pyramidPrev.getScale(i+1)/pyramidPrev.getScale(i); for( int y = regionRadius; y < y1; y++ ) { for( int x = regionRadius; x < x1; x++ ) { // grab the flow in higher level pyramid ImageFlow.D p = flowPrevLayer.get((int)(x/scale),(int)(y/scale)); if( !p.isValid() ) continue; // get the template around the current point in this layer extractTemplate(x,y,prev); // add the flow from the higher layer (adjusting for scale and rounding) as the start of // this search int deltaX = (int)(p.x*scale+0.5); int deltaY = (int)(p.y*scale+0.5); int startX = x + deltaX; int startY = y + deltaY; float score = findFlow(startX,startY,curr,tmp); // find flow only does it relative to the starting point tmp.x += deltaX; tmp.y += deltaY; if( tmp.isValid() ) checkNeighbors(x,y,tmp, flowCurrLayer,score); else flowCurrLayer.unsafe_get(x,y).markInvalid(); } } } // swap the flow images ImageFlow tmp = flowPrevLayer; flowPrevLayer = flowCurrLayer; flowCurrLayer = tmp; } }
java
public void process( ImagePyramid<T> pyramidPrev , ImagePyramid<T> pyramidCurr ) { InputSanityCheck.checkSameShape(pyramidPrev, pyramidCurr); int numLayers = pyramidPrev.getNumLayers(); for( int i = numLayers-1; i >= 0; i-- ) { T prev = pyramidPrev.getLayer(i); T curr = pyramidCurr.getLayer(i); flowCurrLayer.reshape(prev.width, prev.height); int N = prev.width*prev.height; if( scores.length < N ) scores = new float[N]; // mark all the scores as being very large so that if it has not been processed its score // will be set inside of checkNeighbors. Arrays.fill(scores,0,N,Float.MAX_VALUE); int x1 = prev.width-regionRadius; int y1 = prev.height-regionRadius; if( i == numLayers-1 ) { // the top most layer in the pyramid has no hint for( int y = regionRadius; y < y1; y++ ) { for( int x = regionRadius; x < x1; x++ ) { extractTemplate(x,y,prev); float score = findFlow(x,y,curr,tmp); if( tmp.isValid() ) checkNeighbors(x,y,tmp, flowCurrLayer,score); else flowCurrLayer.unsafe_get(x, y).markInvalid(); } } } else { // for all the other layers use the hint of the previous layer to start its search double scale = pyramidPrev.getScale(i+1)/pyramidPrev.getScale(i); for( int y = regionRadius; y < y1; y++ ) { for( int x = regionRadius; x < x1; x++ ) { // grab the flow in higher level pyramid ImageFlow.D p = flowPrevLayer.get((int)(x/scale),(int)(y/scale)); if( !p.isValid() ) continue; // get the template around the current point in this layer extractTemplate(x,y,prev); // add the flow from the higher layer (adjusting for scale and rounding) as the start of // this search int deltaX = (int)(p.x*scale+0.5); int deltaY = (int)(p.y*scale+0.5); int startX = x + deltaX; int startY = y + deltaY; float score = findFlow(startX,startY,curr,tmp); // find flow only does it relative to the starting point tmp.x += deltaX; tmp.y += deltaY; if( tmp.isValid() ) checkNeighbors(x,y,tmp, flowCurrLayer,score); else flowCurrLayer.unsafe_get(x,y).markInvalid(); } } } // swap the flow images ImageFlow tmp = flowPrevLayer; flowPrevLayer = flowCurrLayer; flowCurrLayer = tmp; } }
[ "public", "void", "process", "(", "ImagePyramid", "<", "T", ">", "pyramidPrev", ",", "ImagePyramid", "<", "T", ">", "pyramidCurr", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "pyramidPrev", ",", "pyramidCurr", ")", ";", "int", "numLayers", "=", ...
Computes the optical flow form 'prev' to 'curr' and stores the output into output @param pyramidPrev Previous image @param pyramidCurr Current image
[ "Computes", "the", "optical", "flow", "form", "prev", "to", "curr", "and", "stores", "the", "output", "into", "output" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/flow/DenseOpticalFlowBlockPyramid.java#L103-L179
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/spherical/EquirectangularDistortBase_F64.java
EquirectangularDistortBase_F64.setDirection
public void setDirection(double yaw, double pitch, double roll ) { ConvertRotation3D_F64.eulerToMatrix(EulerType.YZX,pitch,yaw,roll,R); }
java
public void setDirection(double yaw, double pitch, double roll ) { ConvertRotation3D_F64.eulerToMatrix(EulerType.YZX,pitch,yaw,roll,R); }
[ "public", "void", "setDirection", "(", "double", "yaw", ",", "double", "pitch", ",", "double", "roll", ")", "{", "ConvertRotation3D_F64", ".", "eulerToMatrix", "(", "EulerType", ".", "YZX", ",", "pitch", ",", "yaw", ",", "roll", ",", "R", ")", ";", "}" ]
Specifies the rotation offset from the canonical location using yaw and pitch. @param yaw Radian from -pi to pi @param pitch Radian from -pi/2 to pi/2 @param roll Radian from -pi to pi
[ "Specifies", "the", "rotation", "offset", "from", "the", "canonical", "location", "using", "yaw", "and", "pitch", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/spherical/EquirectangularDistortBase_F64.java#L69-L71
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/spherical/EquirectangularDistortBase_F64.java
EquirectangularDistortBase_F64.declareVectors
protected void declareVectors( int width , int height ) { this.outWidth = width; if( vectors.length < width*height ) { Point3D_F64[] tmp = new Point3D_F64[width*height]; System.arraycopy(vectors,0,tmp,0,vectors.length); for (int i = vectors.length; i < tmp.length; i++) { tmp[i] = new Point3D_F64(); } vectors = tmp; } }
java
protected void declareVectors( int width , int height ) { this.outWidth = width; if( vectors.length < width*height ) { Point3D_F64[] tmp = new Point3D_F64[width*height]; System.arraycopy(vectors,0,tmp,0,vectors.length); for (int i = vectors.length; i < tmp.length; i++) { tmp[i] = new Point3D_F64(); } vectors = tmp; } }
[ "protected", "void", "declareVectors", "(", "int", "width", ",", "int", "height", ")", "{", "this", ".", "outWidth", "=", "width", ";", "if", "(", "vectors", ".", "length", "<", "width", "*", "height", ")", "{", "Point3D_F64", "[", "]", "tmp", "=", "...
Declares storage for precomputed pointing vectors to output image @param width output image width @param height output image height
[ "Declares", "storage", "for", "precomputed", "pointing", "vectors", "to", "output", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/spherical/EquirectangularDistortBase_F64.java#L87-L99
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
GaliosFieldTableOps.polyScale
public void polyScale(GrowQueue_I8 input , int scale , GrowQueue_I8 output) { output.resize(input.size); for (int i = 0; i < input.size; i++) { output.data[i] = (byte)multiply(input.data[i]&0xFF, scale); } }
java
public void polyScale(GrowQueue_I8 input , int scale , GrowQueue_I8 output) { output.resize(input.size); for (int i = 0; i < input.size; i++) { output.data[i] = (byte)multiply(input.data[i]&0xFF, scale); } }
[ "public", "void", "polyScale", "(", "GrowQueue_I8", "input", ",", "int", "scale", ",", "GrowQueue_I8", "output", ")", "{", "output", ".", "resize", "(", "input", ".", "size", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "input", ".", ...
Scales the polynomial. <p>Coefficients for largest powers are first, e.g. 2*x**3 + 8*x**2+1 = [2,8,0,1]</p> @param input Input polynomial. @param scale scale @param output Output polynomial.
[ "Scales", "the", "polynomial", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L129-L136
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
GaliosFieldTableOps.polyAdd
public void polyAdd(GrowQueue_I8 polyA , GrowQueue_I8 polyB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); // compute offset that would align the smaller polynomial with the larger polynomial int offsetA = Math.max(0,polyB.size-polyA.size); int offsetB = Math.max(0,polyA.size-polyB.size); int N = output.size; for (int i = 0; i < offsetB; i++) { output.data[i] = polyA.data[i]; } for (int i = 0; i < offsetA; i++) { output.data[i] = polyB.data[i]; } for (int i = Math.max(offsetA,offsetB); i < N; i++) { output.data[i] = (byte)((polyA.data[i-offsetA]&0xFF) ^ (polyB.data[i-offsetB]&0xFF)); } }
java
public void polyAdd(GrowQueue_I8 polyA , GrowQueue_I8 polyB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); // compute offset that would align the smaller polynomial with the larger polynomial int offsetA = Math.max(0,polyB.size-polyA.size); int offsetB = Math.max(0,polyA.size-polyB.size); int N = output.size; for (int i = 0; i < offsetB; i++) { output.data[i] = polyA.data[i]; } for (int i = 0; i < offsetA; i++) { output.data[i] = polyB.data[i]; } for (int i = Math.max(offsetA,offsetB); i < N; i++) { output.data[i] = (byte)((polyA.data[i-offsetA]&0xFF) ^ (polyB.data[i-offsetB]&0xFF)); } }
[ "public", "void", "polyAdd", "(", "GrowQueue_I8", "polyA", ",", "GrowQueue_I8", "polyB", ",", "GrowQueue_I8", "output", ")", "{", "output", ".", "resize", "(", "Math", ".", "max", "(", "polyA", ".", "size", ",", "polyB", ".", "size", ")", ")", ";", "//...
Adds two polynomials together. output = polyA + polyB <p>Coefficients for largest powers are first, e.g. 2*x**3 + 8*x**2+1 = [2,8,0,1]</p> @param polyA (Input) First polynomial @param polyB (Input) Second polynomial @param output (Output) Results of addition
[ "Adds", "two", "polynomials", "together", ".", "output", "=", "polyA", "+", "polyB" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L147-L164
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
GaliosFieldTableOps.polyAdd_S
public void polyAdd_S(GrowQueue_I8 polyA , GrowQueue_I8 polyB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); int M = Math.min(polyA.size, polyB.size); for (int i = M; i < polyA.size; i++) { output.data[i] = polyA.data[i]; } for (int i = M; i < polyB.size; i++) { output.data[i] = polyB.data[i]; } for (int i = 0; i < M; i++) { output.data[i] = (byte)((polyA.data[i]&0xFF) ^ (polyB.data[i]&0xFF)); } }
java
public void polyAdd_S(GrowQueue_I8 polyA , GrowQueue_I8 polyB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); int M = Math.min(polyA.size, polyB.size); for (int i = M; i < polyA.size; i++) { output.data[i] = polyA.data[i]; } for (int i = M; i < polyB.size; i++) { output.data[i] = polyB.data[i]; } for (int i = 0; i < M; i++) { output.data[i] = (byte)((polyA.data[i]&0xFF) ^ (polyB.data[i]&0xFF)); } }
[ "public", "void", "polyAdd_S", "(", "GrowQueue_I8", "polyA", ",", "GrowQueue_I8", "polyB", ",", "GrowQueue_I8", "output", ")", "{", "output", ".", "resize", "(", "Math", ".", "max", "(", "polyA", ".", "size", ",", "polyB", ".", "size", ")", ")", ";", "...
Adds two polynomials together. <p>Coefficients for smallest powers are first, e.g. 2*x**3 + 8*x**2+1 = [1,0,2,8]</p> @param polyA (Input) First polynomial @param polyB (Input) Second polynomial @param output (Output) Results of addition
[ "Adds", "two", "polynomials", "together", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L175-L189
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
GaliosFieldTableOps.polyAddScaleB
public void polyAddScaleB(GrowQueue_I8 polyA , GrowQueue_I8 polyB , int scaleB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); // compute offset that would align the smaller polynomial with the larger polynomial int offsetA = Math.max(0,polyB.size-polyA.size); int offsetB = Math.max(0,polyA.size-polyB.size); int N = output.size; for (int i = 0; i < offsetB; i++) { output.data[i] = polyA.data[i]; } for (int i = 0; i < offsetA; i++) { output.data[i] = (byte)multiply(polyB.data[i]&0xFF,scaleB); } for (int i = Math.max(offsetA,offsetB); i < N; i++) { output.data[i] = (byte)((polyA.data[i-offsetA]&0xFF) ^ multiply(polyB.data[i-offsetB]&0xFF,scaleB)); } }
java
public void polyAddScaleB(GrowQueue_I8 polyA , GrowQueue_I8 polyB , int scaleB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); // compute offset that would align the smaller polynomial with the larger polynomial int offsetA = Math.max(0,polyB.size-polyA.size); int offsetB = Math.max(0,polyA.size-polyB.size); int N = output.size; for (int i = 0; i < offsetB; i++) { output.data[i] = polyA.data[i]; } for (int i = 0; i < offsetA; i++) { output.data[i] = (byte)multiply(polyB.data[i]&0xFF,scaleB); } for (int i = Math.max(offsetA,offsetB); i < N; i++) { output.data[i] = (byte)((polyA.data[i-offsetA]&0xFF) ^ multiply(polyB.data[i-offsetB]&0xFF,scaleB)); } }
[ "public", "void", "polyAddScaleB", "(", "GrowQueue_I8", "polyA", ",", "GrowQueue_I8", "polyB", ",", "int", "scaleB", ",", "GrowQueue_I8", "output", ")", "{", "output", ".", "resize", "(", "Math", ".", "max", "(", "polyA", ".", "size", ",", "polyB", ".", ...
Adds two polynomials together while scaling the second. <p>Coefficients for largest powers are first, e.g. 2*x**3 + 8*x**2+1 = [2,8,0,1]</p> @param polyA (Input) First polynomial @param polyB (Input) Second polynomial @param scaleB (Input) Scale factor applied to polyB @param output (Output) Results of addition
[ "Adds", "two", "polynomials", "together", "while", "scaling", "the", "second", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L201-L218
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
GaliosFieldTableOps.polyEval
public int polyEval(GrowQueue_I8 input , int x ) { int y = input.data[0]&0xFF; for (int i = 1; i < input.size; i++) { y = multiply(y,x) ^ (input.data[i]&0xFF); } return y; }
java
public int polyEval(GrowQueue_I8 input , int x ) { int y = input.data[0]&0xFF; for (int i = 1; i < input.size; i++) { y = multiply(y,x) ^ (input.data[i]&0xFF); } return y; }
[ "public", "int", "polyEval", "(", "GrowQueue_I8", "input", ",", "int", "x", ")", "{", "int", "y", "=", "input", ".", "data", "[", "0", "]", "&", "0xFF", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "input", ".", "size", ";", "i", "++...
Evaluate the polynomial using Horner's method. Avoids explicit calculating the powers of x. <p>01x**4 + 0fx**3 + 36x**2 + 78x + 40 = (((01 x + 0f) x + 36) x + 78) x + 40</p> <p>Coefficients for largest powers are first, e.g. 2*x**3 + 8*x**2+1 = [2,8,0,1]</p> @param input Polynomial being evaluated @param x Value of x @return Output of function
[ "Evaluate", "the", "polynomial", "using", "Horner", "s", "method", ".", "Avoids", "explicit", "calculating", "the", "powers", "of", "x", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L295-L303
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
GaliosFieldTableOps.polyEvalContinue
public int polyEvalContinue( int previousOutput, GrowQueue_I8 part , int x ) { int y = previousOutput; for (int i = 0; i < part.size; i++) { y = multiply(y,x) ^ (part.data[i]&0xFF); } return y; }
java
public int polyEvalContinue( int previousOutput, GrowQueue_I8 part , int x ) { int y = previousOutput; for (int i = 0; i < part.size; i++) { y = multiply(y,x) ^ (part.data[i]&0xFF); } return y; }
[ "public", "int", "polyEvalContinue", "(", "int", "previousOutput", ",", "GrowQueue_I8", "part", ",", "int", "x", ")", "{", "int", "y", "=", "previousOutput", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "part", ".", "size", ";", "i", "++", ...
Continue evaluating a polynomial which has been broken up into multiple arrays. @param previousOutput Output from the evaluation of the prior part of the polynomial @param part Additional segment of the polynomial @param x Point it's being evaluated at @return results
[ "Continue", "evaluating", "a", "polynomial", "which", "has", "been", "broken", "up", "into", "multiple", "arrays", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L335-L342
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java
GaliosFieldTableOps.polyDivide
public void polyDivide(GrowQueue_I8 dividend , GrowQueue_I8 divisor , GrowQueue_I8 quotient, GrowQueue_I8 remainder ) { // handle special case if( divisor.size > dividend.size ) { remainder.setTo(dividend); quotient.resize(0); return; } else { remainder.resize(divisor.size-1); quotient.setTo(dividend); } int normalizer = divisor.data[0]&0xFF; int N = dividend.size-divisor.size+1; for (int i = 0; i < N; i++) { quotient.data[i] = (byte)divide(quotient.data[i]&0xFF,normalizer); int coef = quotient.data[i]&0xFF; if( coef != 0 ) { // division by zero is undefined. for (int j = 1; j < divisor.size; j++) { // skip the first coeffient in synthetic division int div_j = divisor.data[j]&0xFF; if( div_j != 0 ) {// log(0) is undefined. quotient.data[i+j] ^= multiply(div_j,coef); } } } } // quotient currently contains the quotient and remainder. Copy remainder into it's own polynomial System.arraycopy(quotient.data,quotient.size-remainder.size,remainder.data,0,remainder.size); quotient.size -= remainder.size; }
java
public void polyDivide(GrowQueue_I8 dividend , GrowQueue_I8 divisor , GrowQueue_I8 quotient, GrowQueue_I8 remainder ) { // handle special case if( divisor.size > dividend.size ) { remainder.setTo(dividend); quotient.resize(0); return; } else { remainder.resize(divisor.size-1); quotient.setTo(dividend); } int normalizer = divisor.data[0]&0xFF; int N = dividend.size-divisor.size+1; for (int i = 0; i < N; i++) { quotient.data[i] = (byte)divide(quotient.data[i]&0xFF,normalizer); int coef = quotient.data[i]&0xFF; if( coef != 0 ) { // division by zero is undefined. for (int j = 1; j < divisor.size; j++) { // skip the first coeffient in synthetic division int div_j = divisor.data[j]&0xFF; if( div_j != 0 ) {// log(0) is undefined. quotient.data[i+j] ^= multiply(div_j,coef); } } } } // quotient currently contains the quotient and remainder. Copy remainder into it's own polynomial System.arraycopy(quotient.data,quotient.size-remainder.size,remainder.data,0,remainder.size); quotient.size -= remainder.size; }
[ "public", "void", "polyDivide", "(", "GrowQueue_I8", "dividend", ",", "GrowQueue_I8", "divisor", ",", "GrowQueue_I8", "quotient", ",", "GrowQueue_I8", "remainder", ")", "{", "// handle special case", "if", "(", "divisor", ".", "size", ">", "dividend", ".", "size",...
Performs polynomial division using a synthetic division algorithm. <p>Coefficients for largest powers are first, e.g. 2*x**3 + 8*x**2+1 = [2,8,0,1]</p> @param dividend (Input) Polynomial dividend @param divisor (Input) Polynomial divisor @param quotient (Output) Division's quotient @param remainder (Output) Divisions's remainder
[ "Performs", "polynomial", "division", "using", "a", "synthetic", "division", "algorithm", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldTableOps.java#L354-L388
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/factory/fiducial/ConfigQrCode.java
ConfigQrCode.fast
public static ConfigQrCode fast() { // A global threshold is faster than any local algorithm // plus it will generate a simpler set of internal contours speeding up that process ConfigQrCode config = new ConfigQrCode(); config.threshold = ConfigThreshold.global(ThresholdType.GLOBAL_OTSU); return config; }
java
public static ConfigQrCode fast() { // A global threshold is faster than any local algorithm // plus it will generate a simpler set of internal contours speeding up that process ConfigQrCode config = new ConfigQrCode(); config.threshold = ConfigThreshold.global(ThresholdType.GLOBAL_OTSU); return config; }
[ "public", "static", "ConfigQrCode", "fast", "(", ")", "{", "// A global threshold is faster than any local algorithm", "// plus it will generate a simpler set of internal contours speeding up that process", "ConfigQrCode", "config", "=", "new", "ConfigQrCode", "(", ")", ";", "confi...
Default configuration for a QR Code detector which is optimized for speed
[ "Default", "configuration", "for", "a", "QR", "Code", "detector", "which", "is", "optimized", "for", "speed" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/factory/fiducial/ConfigQrCode.java#L96-L102
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/feature/AssociationScorePanel.java
AssociationScorePanel.drawDistribution
private void drawDistribution( Graphics2D g2 , List<Point2D_F64> candidates , int offX, int offY , double scale) { findStatistics(); // draw all the features, adjusting their size based on the first score g2.setColor(Color.RED); g2.setStroke(new BasicStroke(3)); double normalizer; if( scorer.getScoreType().isZeroBest() ) normalizer = best*containmentFraction; else normalizer = Math.abs(best)*(Math.exp(-1.0/containmentFraction)); for( int i = 0; i < candidates.size(); i++ ) { Point2D_F64 p = candidates.get(i); double s = associationScore[i]; // scale the circle based on how bad it is double ratio = 1-Math.abs(s-best)/normalizer; if( ratio < 0 ) continue; int r = maxCircleRadius - (int)(maxCircleRadius*ratio); if( r > 0 ) { int x = (int)(p.x*scale+offX); int y = (int)(p.y*scale+offY); g2.drawOval(x-r,y-r,r*2+1,r*2+1); } } // draw the best feature g2.setColor(Color.GREEN); g2.setStroke(new BasicStroke(10)); int w = maxCircleRadius*2+1; Point2D_F64 p = candidates.get(indexBest); int x = (int)(p.x*scale+offX); int y = (int)(p.y*scale+offY); g2.drawOval(x-maxCircleRadius,y-maxCircleRadius,w,w); }
java
private void drawDistribution( Graphics2D g2 , List<Point2D_F64> candidates , int offX, int offY , double scale) { findStatistics(); // draw all the features, adjusting their size based on the first score g2.setColor(Color.RED); g2.setStroke(new BasicStroke(3)); double normalizer; if( scorer.getScoreType().isZeroBest() ) normalizer = best*containmentFraction; else normalizer = Math.abs(best)*(Math.exp(-1.0/containmentFraction)); for( int i = 0; i < candidates.size(); i++ ) { Point2D_F64 p = candidates.get(i); double s = associationScore[i]; // scale the circle based on how bad it is double ratio = 1-Math.abs(s-best)/normalizer; if( ratio < 0 ) continue; int r = maxCircleRadius - (int)(maxCircleRadius*ratio); if( r > 0 ) { int x = (int)(p.x*scale+offX); int y = (int)(p.y*scale+offY); g2.drawOval(x-r,y-r,r*2+1,r*2+1); } } // draw the best feature g2.setColor(Color.GREEN); g2.setStroke(new BasicStroke(10)); int w = maxCircleRadius*2+1; Point2D_F64 p = candidates.get(indexBest); int x = (int)(p.x*scale+offX); int y = (int)(p.y*scale+offY); g2.drawOval(x-maxCircleRadius,y-maxCircleRadius,w,w); }
[ "private", "void", "drawDistribution", "(", "Graphics2D", "g2", ",", "List", "<", "Point2D_F64", ">", "candidates", ",", "int", "offX", ",", "int", "offY", ",", "double", "scale", ")", "{", "findStatistics", "(", ")", ";", "// draw all the features, adjusting th...
Visualizes score distribution. Larger circles mean its closer to the best fit score.
[ "Visualizes", "score", "distribution", ".", "Larger", "circles", "mean", "its", "closer", "to", "the", "best", "fit", "score", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/feature/AssociationScorePanel.java#L138-L178
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.process
public void process(List<ChessboardCorner> corners ) { this.corners = corners; // reset internal data structures vertexes.reset(); edges.reset(); clusters.reset(); // Create a vertex for each corner for (int idx = 0; idx < corners.size(); idx++) { Vertex v = vertexes.grow(); v.reset(); v.index = idx; } // Initialize nearest-neighbor search. nn.setPoints(corners,true); // Connect corners to each other based on relative distance on orientation for (int i = 0; i < corners.size(); i++) { findVertexNeighbors(vertexes.get(i),corners); } // If more than one vertex's are near each other, pick one and remove the others handleAmbiguousVertexes(corners); // printDualGraph(); // Prune connections which are not mutual for (int i = 0; i < vertexes.size; i++) { Vertex v = vertexes.get(i); v.pruneNonMutal(EdgeType.PARALLEL); v.pruneNonMutal(EdgeType.PERPENDICULAR); } // printDualGraph(); // Select the final 2 to 4 connections from perpendicular set // each pair of adjacent perpendicular edge needs to have a matching parallel edge between them // Use each perpendicular edge as a seed and select the best one for (int idx = 0; idx < vertexes.size(); idx++) { selectConnections(vertexes.get(idx)); } // printConnectionGraph(); // Connects must be mutual to be accepted. Keep track of vertexes which were modified dirtyVertexes.clear(); for (int i = 0; i < vertexes.size; i++) { Vertex v = vertexes.get(i); int before = v.connections.size(); v.pruneNonMutal(EdgeType.CONNECTION); if( before != v.connections.size() ) { dirtyVertexes.add(v); v.marked = true; } } // printConnectionGraph(); // attempt to recover from poorly made decisions in the past from the greedy algorithm repairVertexes(); // Prune non-mutual edges again. Only need to consider dirty edges since it makes sure that the new // set of connections is a super set of the old for (int i = 0; i < dirtyVertexes.size(); i++) { dirtyVertexes.get(i).pruneNonMutal(EdgeType.CONNECTION); dirtyVertexes.get(i).marked = false; } // Final clean up to return just valid grids disconnectInvalidVertices(); // Name says it all convertToOutput(corners); }
java
public void process(List<ChessboardCorner> corners ) { this.corners = corners; // reset internal data structures vertexes.reset(); edges.reset(); clusters.reset(); // Create a vertex for each corner for (int idx = 0; idx < corners.size(); idx++) { Vertex v = vertexes.grow(); v.reset(); v.index = idx; } // Initialize nearest-neighbor search. nn.setPoints(corners,true); // Connect corners to each other based on relative distance on orientation for (int i = 0; i < corners.size(); i++) { findVertexNeighbors(vertexes.get(i),corners); } // If more than one vertex's are near each other, pick one and remove the others handleAmbiguousVertexes(corners); // printDualGraph(); // Prune connections which are not mutual for (int i = 0; i < vertexes.size; i++) { Vertex v = vertexes.get(i); v.pruneNonMutal(EdgeType.PARALLEL); v.pruneNonMutal(EdgeType.PERPENDICULAR); } // printDualGraph(); // Select the final 2 to 4 connections from perpendicular set // each pair of adjacent perpendicular edge needs to have a matching parallel edge between them // Use each perpendicular edge as a seed and select the best one for (int idx = 0; idx < vertexes.size(); idx++) { selectConnections(vertexes.get(idx)); } // printConnectionGraph(); // Connects must be mutual to be accepted. Keep track of vertexes which were modified dirtyVertexes.clear(); for (int i = 0; i < vertexes.size; i++) { Vertex v = vertexes.get(i); int before = v.connections.size(); v.pruneNonMutal(EdgeType.CONNECTION); if( before != v.connections.size() ) { dirtyVertexes.add(v); v.marked = true; } } // printConnectionGraph(); // attempt to recover from poorly made decisions in the past from the greedy algorithm repairVertexes(); // Prune non-mutual edges again. Only need to consider dirty edges since it makes sure that the new // set of connections is a super set of the old for (int i = 0; i < dirtyVertexes.size(); i++) { dirtyVertexes.get(i).pruneNonMutal(EdgeType.CONNECTION); dirtyVertexes.get(i).marked = false; } // Final clean up to return just valid grids disconnectInvalidVertices(); // Name says it all convertToOutput(corners); }
[ "public", "void", "process", "(", "List", "<", "ChessboardCorner", ">", "corners", ")", "{", "this", ".", "corners", "=", "corners", ";", "// reset internal data structures", "vertexes", ".", "reset", "(", ")", ";", "edges", ".", "reset", "(", ")", ";", "c...
Processes corners and finds clusters of chessboard patterns @param corners Detected chessboard patterns. Not modified.
[ "Processes", "corners", "and", "finds", "clusters", "of", "chessboard", "patterns" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L137-L208
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.printDualGraph
public void printDualGraph() { System.out.println("============= Dual"); int l = BoofMiscOps.numDigits(vertexes.size); String format = "%"+l+"d"; for( Vertex n : vertexes.toList() ) { ChessboardCorner c = corners.get(n.index); System.out.printf("["+format+"] {%3.0f, %3.0f} -> 90[ ",n.index,c.x,c.y); for (int i = 0; i < n.perpendicular.size(); i++) { Edge e = n.perpendicular.get(i); System.out.printf(format+" ",e.dst.index); } System.out.println("]"); System.out.print(" -> 180[ "); for (int i = 0; i < n.parallel.size(); i++) { Edge e = n.parallel.get(i); System.out.printf(format+" ",e.dst.index); } System.out.println("]"); } }
java
public void printDualGraph() { System.out.println("============= Dual"); int l = BoofMiscOps.numDigits(vertexes.size); String format = "%"+l+"d"; for( Vertex n : vertexes.toList() ) { ChessboardCorner c = corners.get(n.index); System.out.printf("["+format+"] {%3.0f, %3.0f} -> 90[ ",n.index,c.x,c.y); for (int i = 0; i < n.perpendicular.size(); i++) { Edge e = n.perpendicular.get(i); System.out.printf(format+" ",e.dst.index); } System.out.println("]"); System.out.print(" -> 180[ "); for (int i = 0; i < n.parallel.size(); i++) { Edge e = n.parallel.get(i); System.out.printf(format+" ",e.dst.index); } System.out.println("]"); } }
[ "public", "void", "printDualGraph", "(", ")", "{", "System", ".", "out", ".", "println", "(", "\"============= Dual\"", ")", ";", "int", "l", "=", "BoofMiscOps", ".", "numDigits", "(", "vertexes", ".", "size", ")", ";", "String", "format", "=", "\"%\"", ...
Prints the graph. Used for debugging the code.
[ "Prints", "the", "graph", ".", "Used", "for", "debugging", "the", "code", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L213-L233
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.findVertexNeighbors
void findVertexNeighbors(Vertex target , List<ChessboardCorner> corners ) { // if( target.index == 18 ) { // System.out.println("Vertex Neighbors "+target.index); // } ChessboardCorner targetCorner = corners.get(target.index); // distance is Euclidean squared double maxDist = Double.MAX_VALUE==maxNeighborDistance?maxNeighborDistance:maxNeighborDistance*maxNeighborDistance; nnSearch.findNearest(corners.get(target.index),maxDist,maxNeighbors,nnResults); // storage distances here to find median distance of closest neighbors distanceTmp.reset(); for (int i = 0; i < nnResults.size; i++) { NnData<ChessboardCorner> r = nnResults.get(i); if( r.index == target.index) continue; distanceTmp.add( r.distance ); double oriDiff = UtilAngle.distHalf( targetCorner.orientation , r.point.orientation ); Edge edge = edges.grow(); boolean parallel; if( oriDiff <= orientationTol) { // see if it's parallel parallel = true; } else if( Math.abs(oriDiff-Math.PI/2.0) <= orientationTol) { // see if it's perpendicular parallel = false; } else { edges.removeTail(); continue; } // Use the relative angles of orientation and direction to prune more obviously bad matches double dx = r.point.x - targetCorner.x; double dy = r.point.y - targetCorner.y; edge.distance = Math.sqrt(r.distance); edge.dst = vertexes.get(r.index); edge.direction = Math.atan2(dy,dx); double direction180 = UtilAngle.boundHalf(edge.direction); double directionDiff = UtilAngle.distHalf(direction180,r.point.orientation); boolean remove; EdgeSet edgeSet; if( parallel ) { // test to see if direction and orientation are aligned or off by 90 degrees remove = directionDiff > 2* directionTol && Math.abs(directionDiff-Math.PI/2.0) > 2* directionTol; edgeSet = target.parallel; } else { // should be at 45 degree angle remove = Math.abs(directionDiff-Math.PI/4.0) > 2* directionTol; edgeSet = target.perpendicular; } if( remove ) { edges.removeTail(); continue; } edgeSet.add(edge); } // Compute the distance of the closest neighbors. This is used later on to identify ambiguous corners. // If it's a graph corner there should be at least 3 right next to the node. if( distanceTmp.size == 0 ) { target.neighborDistance = 0; } else { sorter.sort(distanceTmp.data, distanceTmp.size); int idx = Math.min(3,distanceTmp.size-1); target.neighborDistance = Math.sqrt(distanceTmp.data[idx]); // NN distance is Euclidean squared } }
java
void findVertexNeighbors(Vertex target , List<ChessboardCorner> corners ) { // if( target.index == 18 ) { // System.out.println("Vertex Neighbors "+target.index); // } ChessboardCorner targetCorner = corners.get(target.index); // distance is Euclidean squared double maxDist = Double.MAX_VALUE==maxNeighborDistance?maxNeighborDistance:maxNeighborDistance*maxNeighborDistance; nnSearch.findNearest(corners.get(target.index),maxDist,maxNeighbors,nnResults); // storage distances here to find median distance of closest neighbors distanceTmp.reset(); for (int i = 0; i < nnResults.size; i++) { NnData<ChessboardCorner> r = nnResults.get(i); if( r.index == target.index) continue; distanceTmp.add( r.distance ); double oriDiff = UtilAngle.distHalf( targetCorner.orientation , r.point.orientation ); Edge edge = edges.grow(); boolean parallel; if( oriDiff <= orientationTol) { // see if it's parallel parallel = true; } else if( Math.abs(oriDiff-Math.PI/2.0) <= orientationTol) { // see if it's perpendicular parallel = false; } else { edges.removeTail(); continue; } // Use the relative angles of orientation and direction to prune more obviously bad matches double dx = r.point.x - targetCorner.x; double dy = r.point.y - targetCorner.y; edge.distance = Math.sqrt(r.distance); edge.dst = vertexes.get(r.index); edge.direction = Math.atan2(dy,dx); double direction180 = UtilAngle.boundHalf(edge.direction); double directionDiff = UtilAngle.distHalf(direction180,r.point.orientation); boolean remove; EdgeSet edgeSet; if( parallel ) { // test to see if direction and orientation are aligned or off by 90 degrees remove = directionDiff > 2* directionTol && Math.abs(directionDiff-Math.PI/2.0) > 2* directionTol; edgeSet = target.parallel; } else { // should be at 45 degree angle remove = Math.abs(directionDiff-Math.PI/4.0) > 2* directionTol; edgeSet = target.perpendicular; } if( remove ) { edges.removeTail(); continue; } edgeSet.add(edge); } // Compute the distance of the closest neighbors. This is used later on to identify ambiguous corners. // If it's a graph corner there should be at least 3 right next to the node. if( distanceTmp.size == 0 ) { target.neighborDistance = 0; } else { sorter.sort(distanceTmp.data, distanceTmp.size); int idx = Math.min(3,distanceTmp.size-1); target.neighborDistance = Math.sqrt(distanceTmp.data[idx]); // NN distance is Euclidean squared } }
[ "void", "findVertexNeighbors", "(", "Vertex", "target", ",", "List", "<", "ChessboardCorner", ">", "corners", ")", "{", "//\t\tif( target.index == 18 ) {", "//\t\t\tSystem.out.println(\"Vertex Neighbors \"+target.index);", "//\t\t}", "ChessboardCorner", "targetCorner", "=", "co...
Use nearest neighbor search to find closest corners. Split those into two groups, parallel and perpendicular.
[ "Use", "nearest", "neighbor", "search", "to", "find", "closest", "corners", ".", "Split", "those", "into", "two", "groups", "parallel", "and", "perpendicular", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L255-L326
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.handleAmbiguousVertexes
void handleAmbiguousVertexes(List<ChessboardCorner> corners) { List<Vertex> candidates = new ArrayList<>(); for (int idx = 0; idx < vertexes.size(); idx++) { Vertex target = vertexes.get(idx); // median distance was previously found based on the closer neighbors. In an actual chessboard // there are solid white and black squares with no features, in theory double threshold = target.neighborDistance *ambiguousTol; candidates.clear(); // only need to search parallel since perpendicular nodes won't be confused for the target for (int i = 0; i < target.parallel.size(); i++) { Edge c = target.parallel.get(i); if( c.distance <= threshold ) { candidates.add(c.dst); } } if( candidates.size() > 0 ) { candidates.add(target); int bestIndex = -1; double bestScore = 0; // System.out.println("==== Resolving ambiguity. src="+target.index); for (int i = 0; i < candidates.size(); i++) { Vertex v = candidates.get(i); // System.out.println(" candidate = "+v.index); double intensity = corners.get(v.index).intensity; if( intensity > bestScore ) { bestScore = intensity; bestIndex = i; } } // System.out.println("==== Resolved ambiguity. Selected "+candidates.get(bestIndex).index); for (int i = 0; i < candidates.size(); i++) { if( i == bestIndex ) continue; removeReferences(candidates.get(i),EdgeType.PARALLEL); removeReferences(candidates.get(i),EdgeType.PERPENDICULAR); } } } }
java
void handleAmbiguousVertexes(List<ChessboardCorner> corners) { List<Vertex> candidates = new ArrayList<>(); for (int idx = 0; idx < vertexes.size(); idx++) { Vertex target = vertexes.get(idx); // median distance was previously found based on the closer neighbors. In an actual chessboard // there are solid white and black squares with no features, in theory double threshold = target.neighborDistance *ambiguousTol; candidates.clear(); // only need to search parallel since perpendicular nodes won't be confused for the target for (int i = 0; i < target.parallel.size(); i++) { Edge c = target.parallel.get(i); if( c.distance <= threshold ) { candidates.add(c.dst); } } if( candidates.size() > 0 ) { candidates.add(target); int bestIndex = -1; double bestScore = 0; // System.out.println("==== Resolving ambiguity. src="+target.index); for (int i = 0; i < candidates.size(); i++) { Vertex v = candidates.get(i); // System.out.println(" candidate = "+v.index); double intensity = corners.get(v.index).intensity; if( intensity > bestScore ) { bestScore = intensity; bestIndex = i; } } // System.out.println("==== Resolved ambiguity. Selected "+candidates.get(bestIndex).index); for (int i = 0; i < candidates.size(); i++) { if( i == bestIndex ) continue; removeReferences(candidates.get(i),EdgeType.PARALLEL); removeReferences(candidates.get(i),EdgeType.PERPENDICULAR); } } } }
[ "void", "handleAmbiguousVertexes", "(", "List", "<", "ChessboardCorner", ">", "corners", ")", "{", "List", "<", "Vertex", ">", "candidates", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "vertexes", ...
Identify ambiguous vertexes which are too close to each other. Select the corner with the highest intensity score and remove the rest
[ "Identify", "ambiguous", "vertexes", "which", "are", "too", "close", "to", "each", "other", ".", "Select", "the", "corner", "with", "the", "highest", "intensity", "score", "and", "remove", "the", "rest" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L332-L376
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.disconnectInvalidVertices
void disconnectInvalidVertices() { // add elements with 1 or 2 edges openVertexes.clear(); for (int idxVert = 0; idxVert < vertexes.size; idxVert++) { Vertex n = vertexes.get(idxVert); if( n.connections.size() == 1 || n.connections.size()==2) { openVertexes.add(n); } } // continue until there are no changes while( !openVertexes.isEmpty() ) { dirtyVertexes.clear(); for (int idxVert = 0; idxVert < openVertexes.size(); idxVert++) { boolean remove = false; Vertex n = openVertexes.get(idxVert); if( n.connections.size() == 1 ) { remove = true; } else if( n.connections.size() == 2 ) { Edge ea = n.connections.get(0); Edge eb = n.connections.get(1); // Look for a common vertex that isn't 'n' remove = true; for (int i = 0; i < ea.dst.connections.size(); i++) { Vertex va = ea.dst.connections.get(i).dst; if( va == n ) continue; for (int j = 0; j < eb.dst.connections.size(); j++) { Vertex vb = ea.dst.connections.get(j).dst; if( va == vb ) { remove = false; break; } } } } if( remove ) { // only go through the subset referenced the disconnected. Yes there could be duplicates // not worth the time to fix that for (int i = 0; i < n.connections.size(); i++) { dirtyVertexes.add( n.connections.get(i).dst ); } removeReferences(n,EdgeType.CONNECTION); } } openVertexes.clear(); openVertexes.addAll(dirtyVertexes); } }
java
void disconnectInvalidVertices() { // add elements with 1 or 2 edges openVertexes.clear(); for (int idxVert = 0; idxVert < vertexes.size; idxVert++) { Vertex n = vertexes.get(idxVert); if( n.connections.size() == 1 || n.connections.size()==2) { openVertexes.add(n); } } // continue until there are no changes while( !openVertexes.isEmpty() ) { dirtyVertexes.clear(); for (int idxVert = 0; idxVert < openVertexes.size(); idxVert++) { boolean remove = false; Vertex n = openVertexes.get(idxVert); if( n.connections.size() == 1 ) { remove = true; } else if( n.connections.size() == 2 ) { Edge ea = n.connections.get(0); Edge eb = n.connections.get(1); // Look for a common vertex that isn't 'n' remove = true; for (int i = 0; i < ea.dst.connections.size(); i++) { Vertex va = ea.dst.connections.get(i).dst; if( va == n ) continue; for (int j = 0; j < eb.dst.connections.size(); j++) { Vertex vb = ea.dst.connections.get(j).dst; if( va == vb ) { remove = false; break; } } } } if( remove ) { // only go through the subset referenced the disconnected. Yes there could be duplicates // not worth the time to fix that for (int i = 0; i < n.connections.size(); i++) { dirtyVertexes.add( n.connections.get(i).dst ); } removeReferences(n,EdgeType.CONNECTION); } } openVertexes.clear(); openVertexes.addAll(dirtyVertexes); } }
[ "void", "disconnectInvalidVertices", "(", ")", "{", "// add elements with 1 or 2 edges", "openVertexes", ".", "clear", "(", ")", ";", "for", "(", "int", "idxVert", "=", "0", ";", "idxVert", "<", "vertexes", ".", "size", ";", "idxVert", "++", ")", "{", "Verte...
Disconnect the edges from invalid vertices. Invalid ones have only one edge or two edges which do not connect to a common vertex, i.e. they are point 180 degrees away from each other.
[ "Disconnect", "the", "edges", "from", "invalid", "vertices", ".", "Invalid", "ones", "have", "only", "one", "edge", "or", "two", "edges", "which", "do", "not", "connect", "to", "a", "common", "vertex", "i", ".", "e", ".", "they", "are", "point", "180", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L382-L433
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.removeReferences
void removeReferences( Vertex remove , EdgeType type ) { EdgeSet removeSet = remove.getEdgeSet(type); for (int i = removeSet.size()-1; i >= 0; i--) { Vertex v = removeSet.get(i).dst; EdgeSet setV = v.getEdgeSet(type); // remove the connection from v to 'remove'. Be careful since the connection isn't always mutual // at this point int ridx = setV.find(remove); if( ridx != -1 ) setV.edges.remove(ridx); } removeSet.reset(); }
java
void removeReferences( Vertex remove , EdgeType type ) { EdgeSet removeSet = remove.getEdgeSet(type); for (int i = removeSet.size()-1; i >= 0; i--) { Vertex v = removeSet.get(i).dst; EdgeSet setV = v.getEdgeSet(type); // remove the connection from v to 'remove'. Be careful since the connection isn't always mutual // at this point int ridx = setV.find(remove); if( ridx != -1 ) setV.edges.remove(ridx); } removeSet.reset(); }
[ "void", "removeReferences", "(", "Vertex", "remove", ",", "EdgeType", "type", ")", "{", "EdgeSet", "removeSet", "=", "remove", ".", "getEdgeSet", "(", "type", ")", ";", "for", "(", "int", "i", "=", "removeSet", ".", "size", "(", ")", "-", "1", ";", "...
Go through all the vertexes that 'remove' is connected to and remove that link. if it is in the connected list swap it with 'replaceWith'.
[ "Go", "through", "all", "the", "vertexes", "that", "remove", "is", "connected", "to", "and", "remove", "that", "link", ".", "if", "it", "is", "in", "the", "connected", "list", "swap", "it", "with", "replaceWith", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L439-L451
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.selectConnections
void selectConnections( Vertex target ) { // There needs to be at least two corners if( target.perpendicular.size() <= 1 ) return; // if( target.index == 16 ) { // System.out.println("ASDSAD"); // } // System.out.println("======= Connecting "+target.index); double bestError = Double.MAX_VALUE; List<Edge> bestSolution = target.connections.edges; // Greedily select one vertex at a time to connect to. findNext() looks at all possible // vertexes it can connect too and minimizes an error function based on projectively invariant features for (int i = 0; i < target.perpendicular.size(); i++) { Edge e = target.perpendicular.get(i); solution.clear(); solution.add(e); double sumDistance = solution.get(0).distance; double minDistance = sumDistance; if( !findNext(i,target.parallel,target.perpendicular,Double.NaN,results) ) { continue; } solution.add(target.perpendicular.get(results.index)); sumDistance += solution.get(1).distance; minDistance = Math.min(minDistance,solution.get(1).distance); // Use knowledge that solution[0] and solution[2] form a line. // Lines are straight under projective distortion if( findNext(results.index,target.parallel,target.perpendicular,solution.get(0).direction,results) ) { solution.add(target.perpendicular.get(results.index)); sumDistance += solution.get(2).distance; minDistance = Math.min(minDistance,solution.get(2).distance); // Use knowledge that solution[1] and solution[3] form a line. if( findNext(results.index,target.parallel,target.perpendicular,solution.get(1).direction,results) ) { solution.add(target.perpendicular.get(results.index)); sumDistance += solution.get(3).distance; minDistance = Math.min(minDistance,solution.get(3).distance); } } // Prefer closer valid sets of edges and larger sets. // the extra + minDistance was needed to bias it against smaller sets which would be more likely // to have a smaller average error. Division by the square of set/solution size biases it towards larger sets double error = (sumDistance+minDistance)/(solution.size()*solution.size()); // System.out.println(" first="+solution.get(0).dst.index+" size="+solution.size()+" error="+error); if( error < bestError ) { bestError = error; bestSolution.clear(); bestSolution.addAll(solution); } } }
java
void selectConnections( Vertex target ) { // There needs to be at least two corners if( target.perpendicular.size() <= 1 ) return; // if( target.index == 16 ) { // System.out.println("ASDSAD"); // } // System.out.println("======= Connecting "+target.index); double bestError = Double.MAX_VALUE; List<Edge> bestSolution = target.connections.edges; // Greedily select one vertex at a time to connect to. findNext() looks at all possible // vertexes it can connect too and minimizes an error function based on projectively invariant features for (int i = 0; i < target.perpendicular.size(); i++) { Edge e = target.perpendicular.get(i); solution.clear(); solution.add(e); double sumDistance = solution.get(0).distance; double minDistance = sumDistance; if( !findNext(i,target.parallel,target.perpendicular,Double.NaN,results) ) { continue; } solution.add(target.perpendicular.get(results.index)); sumDistance += solution.get(1).distance; minDistance = Math.min(minDistance,solution.get(1).distance); // Use knowledge that solution[0] and solution[2] form a line. // Lines are straight under projective distortion if( findNext(results.index,target.parallel,target.perpendicular,solution.get(0).direction,results) ) { solution.add(target.perpendicular.get(results.index)); sumDistance += solution.get(2).distance; minDistance = Math.min(minDistance,solution.get(2).distance); // Use knowledge that solution[1] and solution[3] form a line. if( findNext(results.index,target.parallel,target.perpendicular,solution.get(1).direction,results) ) { solution.add(target.perpendicular.get(results.index)); sumDistance += solution.get(3).distance; minDistance = Math.min(minDistance,solution.get(3).distance); } } // Prefer closer valid sets of edges and larger sets. // the extra + minDistance was needed to bias it against smaller sets which would be more likely // to have a smaller average error. Division by the square of set/solution size biases it towards larger sets double error = (sumDistance+minDistance)/(solution.size()*solution.size()); // System.out.println(" first="+solution.get(0).dst.index+" size="+solution.size()+" error="+error); if( error < bestError ) { bestError = error; bestSolution.clear(); bestSolution.addAll(solution); } } }
[ "void", "selectConnections", "(", "Vertex", "target", ")", "{", "// There needs to be at least two corners", "if", "(", "target", ".", "perpendicular", ".", "size", "(", ")", "<=", "1", ")", "return", ";", "//\t\tif( target.index == 16 ) {", "//\t\t\tSystem.out.println(...
Select the best 2,3, or 4 perpendicular vertexes to connect to. These are the output grid connections.
[ "Select", "the", "best", "2", "3", "or", "4", "perpendicular", "vertexes", "to", "connect", "to", ".", "These", "are", "the", "output", "grid", "connections", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L456-L515
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.findNext
boolean findNext( int firstIdx , EdgeSet splitterSet , EdgeSet candidateSet , double parallel, SearchResults results ) { Edge e0 = candidateSet.get(firstIdx); results.index = -1; results.error = Double.MAX_VALUE; boolean checkParallel = !Double.isNaN(parallel); for (int i = 0; i < candidateSet.size(); i++) { if( i == firstIdx ) continue; // stop considering edges when they are more than 180 degrees away Edge eI = candidateSet.get(i); double distanceCCW = UtilAngle.distanceCCW(e0.direction,eI.direction); if( distanceCCW >= Math.PI*0.9 ) // Multiplying by 0.9 helped remove a lot of bad matches continue; // It was pairing up opposite corners under heavy perspective distortion // It should be parallel to a previously found line if( checkParallel ) { double a = UtilAngle.boundHalf(eI.direction); double b = UtilAngle.boundHalf(parallel); double distanceParallel = UtilAngle.distHalf(a,b); if( distanceParallel > parallelTol ) { continue; } } // find the perpendicular corner which splits these two edges and also find the index of // the perpendicular sets which points towards the splitter. if( !findSplitter(e0.direction,eI.direction,splitterSet,e0.dst.perpendicular,eI.dst.perpendicular,tuple3) ) continue; double acute0 = UtilAngle.dist( candidateSet.get(firstIdx).direction, e0.dst.perpendicular.get(tuple3.b).direction); double error0 = UtilAngle.dist(acute0,Math.PI/2.0); if( error0 > Math.PI*0.3 ) continue; double acute1 = UtilAngle.dist( candidateSet.get(i).direction, eI.dst.perpendicular.get(tuple3.c).direction); double error1 = UtilAngle.dist(acute1,Math.PI/2.0); if( error1 > Math.PI*0.3 ) continue; // Find the edge from corner 0 to corner i. The direction of this vector and the corner's // orientation has a known relationship described by 'phaseOri' int e0_to_eI = e0.dst.parallel.find(eI.dst); if( e0_to_eI < 0 ) continue; // The quadrilateral with the smallest area is most often the best solution. Area is more expensive // so the perimeter is computed instead. one side is left off since all of them have that side double error = e0.dst.perpendicular.get(tuple3.b).distance; error += eI.dst.perpendicular.get(tuple3.c).distance; error += eI.distance; if( error < results.error ) { results.error = error; results.index = i; } } return results.index != -1; }
java
boolean findNext( int firstIdx , EdgeSet splitterSet , EdgeSet candidateSet , double parallel, SearchResults results ) { Edge e0 = candidateSet.get(firstIdx); results.index = -1; results.error = Double.MAX_VALUE; boolean checkParallel = !Double.isNaN(parallel); for (int i = 0; i < candidateSet.size(); i++) { if( i == firstIdx ) continue; // stop considering edges when they are more than 180 degrees away Edge eI = candidateSet.get(i); double distanceCCW = UtilAngle.distanceCCW(e0.direction,eI.direction); if( distanceCCW >= Math.PI*0.9 ) // Multiplying by 0.9 helped remove a lot of bad matches continue; // It was pairing up opposite corners under heavy perspective distortion // It should be parallel to a previously found line if( checkParallel ) { double a = UtilAngle.boundHalf(eI.direction); double b = UtilAngle.boundHalf(parallel); double distanceParallel = UtilAngle.distHalf(a,b); if( distanceParallel > parallelTol ) { continue; } } // find the perpendicular corner which splits these two edges and also find the index of // the perpendicular sets which points towards the splitter. if( !findSplitter(e0.direction,eI.direction,splitterSet,e0.dst.perpendicular,eI.dst.perpendicular,tuple3) ) continue; double acute0 = UtilAngle.dist( candidateSet.get(firstIdx).direction, e0.dst.perpendicular.get(tuple3.b).direction); double error0 = UtilAngle.dist(acute0,Math.PI/2.0); if( error0 > Math.PI*0.3 ) continue; double acute1 = UtilAngle.dist( candidateSet.get(i).direction, eI.dst.perpendicular.get(tuple3.c).direction); double error1 = UtilAngle.dist(acute1,Math.PI/2.0); if( error1 > Math.PI*0.3 ) continue; // Find the edge from corner 0 to corner i. The direction of this vector and the corner's // orientation has a known relationship described by 'phaseOri' int e0_to_eI = e0.dst.parallel.find(eI.dst); if( e0_to_eI < 0 ) continue; // The quadrilateral with the smallest area is most often the best solution. Area is more expensive // so the perimeter is computed instead. one side is left off since all of them have that side double error = e0.dst.perpendicular.get(tuple3.b).distance; error += eI.dst.perpendicular.get(tuple3.c).distance; error += eI.distance; if( error < results.error ) { results.error = error; results.index = i; } } return results.index != -1; }
[ "boolean", "findNext", "(", "int", "firstIdx", ",", "EdgeSet", "splitterSet", ",", "EdgeSet", "candidateSet", ",", "double", "parallel", ",", "SearchResults", "results", ")", "{", "Edge", "e0", "=", "candidateSet", ".", "get", "(", "firstIdx", ")", ";", "res...
Greedily select the next edge that will belong to the final graph. @param firstIdx Index of the edge CW of the one being considered @param splitterSet Set of edges that the splitter can belong to @param candidateSet Set of edges that the next edge can belong to @param parallel if NaN this is the angle the edge should be parallel to @param results Output. @return true if successful.
[ "Greedily", "select", "the", "next", "edge", "that", "will", "belong", "to", "the", "final", "graph", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L527-L598
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.findSplitter
boolean findSplitter(double ccw0 , double ccw1 , EdgeSet master , EdgeSet other1 , EdgeSet other2 , TupleI32 output ) { double bestDistance = Double.MAX_VALUE; for (int i = 0; i < master.size(); i++) { // select the splitter Edge me = master.get(i); // TODO decide if this is helpful or not // check that it lies between these two angles if( UtilAngle.distanceCCW(ccw0 , me.direction) > Math.PI*0.9 || UtilAngle.distanceCW(ccw1,me.direction) > Math.PI*0.9 ) continue; // Find indexes which point towards the splitter corner int idxB = other1.find(me.dst); if( idxB == -1 ) continue; double thetaB = UtilAngle.distanceCCW(ccw0 , other1.get(idxB).direction); if( thetaB < 0.05 ) continue; int idxC = other2.find(me.dst); if( idxC == -1 ) continue; double thetaC = UtilAngle.distanceCW(ccw1 , other2.get(idxC).direction); if( thetaC < 0.05 ) continue; // want it to be closer and without parallel lines double error = me.distance/(0.5+Math.min(thetaB,thetaC)); if( error < bestDistance ) { bestDistance = error; output.a = i; output.b = idxB; output.c = idxC; } } // Reject the best solution if it doesn't form a convex quadrilateral if( bestDistance < Double.MAX_VALUE ) { // 2 is CCW of 1, and since both of them are pointing towards the splitter we know // how to compute the angular distance double pointingB = other1.edges.get(output.b).direction; double pointingC = other2.edges.get(output.c).direction; return UtilAngle.distanceCW(pointingB, pointingC) < Math.PI; } else { return false; } }
java
boolean findSplitter(double ccw0 , double ccw1 , EdgeSet master , EdgeSet other1 , EdgeSet other2 , TupleI32 output ) { double bestDistance = Double.MAX_VALUE; for (int i = 0; i < master.size(); i++) { // select the splitter Edge me = master.get(i); // TODO decide if this is helpful or not // check that it lies between these two angles if( UtilAngle.distanceCCW(ccw0 , me.direction) > Math.PI*0.9 || UtilAngle.distanceCW(ccw1,me.direction) > Math.PI*0.9 ) continue; // Find indexes which point towards the splitter corner int idxB = other1.find(me.dst); if( idxB == -1 ) continue; double thetaB = UtilAngle.distanceCCW(ccw0 , other1.get(idxB).direction); if( thetaB < 0.05 ) continue; int idxC = other2.find(me.dst); if( idxC == -1 ) continue; double thetaC = UtilAngle.distanceCW(ccw1 , other2.get(idxC).direction); if( thetaC < 0.05 ) continue; // want it to be closer and without parallel lines double error = me.distance/(0.5+Math.min(thetaB,thetaC)); if( error < bestDistance ) { bestDistance = error; output.a = i; output.b = idxB; output.c = idxC; } } // Reject the best solution if it doesn't form a convex quadrilateral if( bestDistance < Double.MAX_VALUE ) { // 2 is CCW of 1, and since both of them are pointing towards the splitter we know // how to compute the angular distance double pointingB = other1.edges.get(output.b).direction; double pointingC = other2.edges.get(output.c).direction; return UtilAngle.distanceCW(pointingB, pointingC) < Math.PI; } else { return false; } }
[ "boolean", "findSplitter", "(", "double", "ccw0", ",", "double", "ccw1", ",", "EdgeSet", "master", ",", "EdgeSet", "other1", ",", "EdgeSet", "other2", ",", "TupleI32", "output", ")", "{", "double", "bestDistance", "=", "Double", ".", "MAX_VALUE", ";", "for",...
Splitter is a vertex that has an angle between two edges being considered. @param ccw0 angle of edge 0 @param ccw1 angle of edge 1 @param master Set of edges that contains all potential spitters @param other1 set of perpendicular edges to vertex ccw0 @param other2 set of perpendicular edges to vertex ccw1 @param output index of indexes for edges in master, other1, other2 @return true if successful
[ "Splitter", "is", "a", "vertex", "that", "has", "an", "angle", "between", "two", "edges", "being", "considered", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L611-L665
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.repairVertexes
private void repairVertexes() { // System.out.println("######## Repair"); for (int idxV = 0; idxV < dirtyVertexes.size(); idxV++) { final Vertex v = dirtyVertexes.get(idxV); // System.out.println(" dirty="+v.index); bestSolution.clear(); for (int idxE = 0; idxE < v.perpendicular.size(); idxE++) { // Assume this edge is in the solutions Edge e = v.perpendicular.get(idxE); // only can connect new modified vertexes or ones already connected too if( !(e.dst.marked || -1 != v.connections.find(e.dst)) ) { continue; } // System.out.println(" e[0].dst = "+e.dst.index); solution.clear(); solution.add(e); // search for connections until there's no more to be found for (int count = 0; count < 3; count++) { // Find the an edge which is about to 90 degrees CCW of the previous edge 'v' Vertex va=null; double dir90 = UtilAngle.bound(e.direction+Math.PI/2.0); for (int i = 0; i < e.dst.connections.size(); i++) { Edge ei = e.dst.connections.get(i); if( UtilAngle.dist(ei.direction,dir90) < Math.PI/3 ) { va = ei.dst; break; } } // Search for an edge in v which has a connection to 'va' and is ccw of 'e' boolean matched = false; for (int i = 0; i < v.perpendicular.size(); i++) { Edge ei = v.perpendicular.get(i); if( e == ei ) continue; // angle test double ccw = UtilAngle.distanceCCW(e.direction,ei.direction); if( ccw > Math.PI*0.9 ) continue; if( !(ei.dst.marked || -1 != v.connections.find(ei.dst)) ) { continue; } // connection test if( ei.dst.connections.find(va) != -1 ) { // System.out.println(" e[i].dst = "+ei.dst.index+" va="+va.index); e = ei; solution.add(ei); matched = true; break; } } if( !matched ) break; } if( solution.size() > bestSolution.size() ) { bestSolution.clear(); bestSolution.addAll(solution); } } if( bestSolution.size() > 1 ) { // See if any connection that was there before is now gone. If that's the case the destination // will need to be checked for mutual matches for (int i = 0; i < v.connections.edges.size(); i++) { if( !bestSolution.contains(v.connections.edges.get(i)) ){ v.connections.edges.get(i).dst.marked = true; break; } } // Save the new connections v.connections.edges.clear(); v.connections.edges.addAll(bestSolution); } } }
java
private void repairVertexes() { // System.out.println("######## Repair"); for (int idxV = 0; idxV < dirtyVertexes.size(); idxV++) { final Vertex v = dirtyVertexes.get(idxV); // System.out.println(" dirty="+v.index); bestSolution.clear(); for (int idxE = 0; idxE < v.perpendicular.size(); idxE++) { // Assume this edge is in the solutions Edge e = v.perpendicular.get(idxE); // only can connect new modified vertexes or ones already connected too if( !(e.dst.marked || -1 != v.connections.find(e.dst)) ) { continue; } // System.out.println(" e[0].dst = "+e.dst.index); solution.clear(); solution.add(e); // search for connections until there's no more to be found for (int count = 0; count < 3; count++) { // Find the an edge which is about to 90 degrees CCW of the previous edge 'v' Vertex va=null; double dir90 = UtilAngle.bound(e.direction+Math.PI/2.0); for (int i = 0; i < e.dst.connections.size(); i++) { Edge ei = e.dst.connections.get(i); if( UtilAngle.dist(ei.direction,dir90) < Math.PI/3 ) { va = ei.dst; break; } } // Search for an edge in v which has a connection to 'va' and is ccw of 'e' boolean matched = false; for (int i = 0; i < v.perpendicular.size(); i++) { Edge ei = v.perpendicular.get(i); if( e == ei ) continue; // angle test double ccw = UtilAngle.distanceCCW(e.direction,ei.direction); if( ccw > Math.PI*0.9 ) continue; if( !(ei.dst.marked || -1 != v.connections.find(ei.dst)) ) { continue; } // connection test if( ei.dst.connections.find(va) != -1 ) { // System.out.println(" e[i].dst = "+ei.dst.index+" va="+va.index); e = ei; solution.add(ei); matched = true; break; } } if( !matched ) break; } if( solution.size() > bestSolution.size() ) { bestSolution.clear(); bestSolution.addAll(solution); } } if( bestSolution.size() > 1 ) { // See if any connection that was there before is now gone. If that's the case the destination // will need to be checked for mutual matches for (int i = 0; i < v.connections.edges.size(); i++) { if( !bestSolution.contains(v.connections.edges.get(i)) ){ v.connections.edges.get(i).dst.marked = true; break; } } // Save the new connections v.connections.edges.clear(); v.connections.edges.addAll(bestSolution); } } }
[ "private", "void", "repairVertexes", "(", ")", "{", "//\t\tSystem.out.println(\"######## Repair\");", "for", "(", "int", "idxV", "=", "0", ";", "idxV", "<", "dirtyVertexes", ".", "size", "(", ")", ";", "idxV", "++", ")", "{", "final", "Vertex", "v", "=", "...
Given the current graph, attempt to replace edges from vertexes which lost them in an apparent bad decision. This is a very simple algorithm and gives up if the graph around the current node is less than perfect. 1) Can only connect to vertexes which lost edges 2) Can't modify an existing edge 3) Parallel lines must be parallel 4) If current graph can't predict direction no decision is made
[ "Given", "the", "current", "graph", "attempt", "to", "replace", "edges", "from", "vertexes", "which", "lost", "them", "in", "an", "apparent", "bad", "decision", ".", "This", "is", "a", "very", "simple", "algorithm", "and", "gives", "up", "if", "the", "grap...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L677-L765
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.convertToOutput
private void convertToOutput(List<ChessboardCorner> corners) { c2n.resize(corners.size()); n2c.resize(vertexes.size()); open.reset(); n2c.fill(-1); c2n.fill(-1); for (int seedIdx = 0; seedIdx < vertexes.size; seedIdx++) { Vertex seedN = vertexes.get(seedIdx); if( seedN.marked) continue; ChessboardCornerGraph graph = clusters.grow(); graph.reset(); // traverse the graph and add all the nodes in this cluster growCluster(corners, seedIdx, graph); // Connect the nodes together in the output graph for (int i = 0; i < graph.corners.size; i++) { ChessboardCornerGraph.Node gn = graph.corners.get(i); Vertex n = vertexes.get( n2c.get(i) ); for (int j = 0; j < n.connections.size(); j++) { int edgeCornerIdx = n.connections.get(j).dst.index; int outputIdx = c2n.get( edgeCornerIdx ); if( outputIdx == -1 ) { throw new IllegalArgumentException("Edge to node not in the graph. n.idx="+n.index+" conn.idx="+edgeCornerIdx); } gn.edges[j] = graph.corners.get(outputIdx); } } // ensure arrays are all -1 again for sanity checks for (int i = 0; i < graph.corners.size; i++) { ChessboardCornerGraph.Node gn = graph.corners.get(i); int indexCorner = n2c.get(gn.index); c2n.data[indexCorner] = -1; n2c.data[gn.index] = -1; } if( graph.corners.size <= 1 ) clusters.removeTail(); } }
java
private void convertToOutput(List<ChessboardCorner> corners) { c2n.resize(corners.size()); n2c.resize(vertexes.size()); open.reset(); n2c.fill(-1); c2n.fill(-1); for (int seedIdx = 0; seedIdx < vertexes.size; seedIdx++) { Vertex seedN = vertexes.get(seedIdx); if( seedN.marked) continue; ChessboardCornerGraph graph = clusters.grow(); graph.reset(); // traverse the graph and add all the nodes in this cluster growCluster(corners, seedIdx, graph); // Connect the nodes together in the output graph for (int i = 0; i < graph.corners.size; i++) { ChessboardCornerGraph.Node gn = graph.corners.get(i); Vertex n = vertexes.get( n2c.get(i) ); for (int j = 0; j < n.connections.size(); j++) { int edgeCornerIdx = n.connections.get(j).dst.index; int outputIdx = c2n.get( edgeCornerIdx ); if( outputIdx == -1 ) { throw new IllegalArgumentException("Edge to node not in the graph. n.idx="+n.index+" conn.idx="+edgeCornerIdx); } gn.edges[j] = graph.corners.get(outputIdx); } } // ensure arrays are all -1 again for sanity checks for (int i = 0; i < graph.corners.size; i++) { ChessboardCornerGraph.Node gn = graph.corners.get(i); int indexCorner = n2c.get(gn.index); c2n.data[indexCorner] = -1; n2c.data[gn.index] = -1; } if( graph.corners.size <= 1 ) clusters.removeTail(); } }
[ "private", "void", "convertToOutput", "(", "List", "<", "ChessboardCorner", ">", "corners", ")", "{", "c2n", ".", "resize", "(", "corners", ".", "size", "(", ")", ")", ";", "n2c", ".", "resize", "(", "vertexes", ".", "size", "(", ")", ")", ";", "open...
Converts the internal graphs into unordered chessboard grids.
[ "Converts", "the", "internal", "graphs", "into", "unordered", "chessboard", "grids", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L771-L815
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java
ChessboardCornerClusterFinder.growCluster
private void growCluster(List<ChessboardCorner> corners, int seedIdx, ChessboardCornerGraph graph) { // open contains corner list indexes open.add(seedIdx); while( open.size > 0 ) { int cornerIdx = open.pop(); Vertex v = vertexes.get(cornerIdx); // make sure it hasn't already been processed if( v.marked) continue; v.marked = true; // Create the node in the output cluster for this corner ChessboardCornerGraph.Node gn = graph.growCorner(); c2n.data[cornerIdx] = gn.index; n2c.data[gn.index] = cornerIdx; gn.set(corners.get(cornerIdx)); // Add to the open list all the edges which haven't been processed yet; for (int i = 0; i < v.connections.size(); i++) { Vertex dst = v.connections.get(i).dst; if( dst.marked) continue; open.add( dst.index ); } } }
java
private void growCluster(List<ChessboardCorner> corners, int seedIdx, ChessboardCornerGraph graph) { // open contains corner list indexes open.add(seedIdx); while( open.size > 0 ) { int cornerIdx = open.pop(); Vertex v = vertexes.get(cornerIdx); // make sure it hasn't already been processed if( v.marked) continue; v.marked = true; // Create the node in the output cluster for this corner ChessboardCornerGraph.Node gn = graph.growCorner(); c2n.data[cornerIdx] = gn.index; n2c.data[gn.index] = cornerIdx; gn.set(corners.get(cornerIdx)); // Add to the open list all the edges which haven't been processed yet; for (int i = 0; i < v.connections.size(); i++) { Vertex dst = v.connections.get(i).dst; if( dst.marked) continue; open.add( dst.index ); } } }
[ "private", "void", "growCluster", "(", "List", "<", "ChessboardCorner", ">", "corners", ",", "int", "seedIdx", ",", "ChessboardCornerGraph", "graph", ")", "{", "// open contains corner list indexes", "open", ".", "add", "(", "seedIdx", ")", ";", "while", "(", "o...
Given the initial seed, add all connected nodes to the output cluster while keeping track of how to convert one node index into another one, between the two graphs
[ "Given", "the", "initial", "seed", "add", "all", "connected", "nodes", "to", "the", "output", "cluster", "while", "keeping", "track", "of", "how", "to", "convert", "one", "node", "index", "into", "another", "one", "between", "the", "two", "graphs" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterFinder.java#L821-L847
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/edge/BaseIntegralEdge.java
BaseIntegralEdge.setTransform
public void setTransform( PixelTransform<Point2D_F32> undistToDist ) { if( undistToDist != null ) { InterpolatePixelS<T> interpolate = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); integralImage = new GImageGrayDistorted<>(undistToDist, interpolate); } else { integralImage = FactoryGImageGray.create(imageType); } }
java
public void setTransform( PixelTransform<Point2D_F32> undistToDist ) { if( undistToDist != null ) { InterpolatePixelS<T> interpolate = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); integralImage = new GImageGrayDistorted<>(undistToDist, interpolate); } else { integralImage = FactoryGImageGray.create(imageType); } }
[ "public", "void", "setTransform", "(", "PixelTransform", "<", "Point2D_F32", ">", "undistToDist", ")", "{", "if", "(", "undistToDist", "!=", "null", ")", "{", "InterpolatePixelS", "<", "T", ">", "interpolate", "=", "FactoryInterpolation", ".", "bilinearPixelS", ...
Used to specify a transform that is applied to pixel coordinates to bring them back into original input image coordinates. For example if the input image has lens distortion but the edge were found in undistorted coordinates this code needs to know how to go from undistorted back into distorted image coordinates in order to read the pixel's value. @param undistToDist Pixel transformation from undistorted pixels into the actual distorted input image..
[ "Used", "to", "specify", "a", "transform", "that", "is", "applied", "to", "pixel", "coordinates", "to", "bring", "them", "back", "into", "original", "input", "image", "coordinates", ".", "For", "example", "if", "the", "input", "image", "has", "lens", "distor...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/edge/BaseIntegralEdge.java#L58-L65
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/EnforceTrifocalGeometry.java
EnforceTrifocalGeometry.process
public void process( Point3D_F64 e2 , Point3D_F64 e3 , DMatrixRMaj A ) { // construct the linear system that the solution which solves the unknown square // matrices in the camera matrices constructE(e2, e3); // Computes U, which is used to map the 18 unknowns onto the 27 trifocal unknowns svdU.decompose(E); svdU.getU(U, false); // Copy the parts of U which correspond to the non singular parts if the SVD // since there are only really 18-nullity unknowns due to linear dependencies SingularOps_DDRM.descendingOrder(U,false,svdU.getSingularValues(),svdU.numberOfSingularValues(),null,false); int rank = SingularOps_DDRM.rank(svdU, 1e-13); Up.reshape(U.numRows,rank); CommonOps_DDRM.extract(U,0,U.numRows,0,Up.numCols,Up,0,0); // project the linear constraint matrix into this subspace AU.reshape(A.numRows,Up.numCols); CommonOps_DDRM.mult(A,Up,AU); // Extract the solution of ||A*U*x|| = 0 from the null space svdV.decompose(AU); xp.reshape(rank,1); SingularOps_DDRM.nullVector(svdV,true,xp); // Translate the solution from the subspace and into a valid trifocal tensor CommonOps_DDRM.mult(Up,xp,vectorT); // the sign of vectorT is arbitrary, but make it positive for consistency if( vectorT.data[0] > 0 ) CommonOps_DDRM.changeSign(vectorT); }
java
public void process( Point3D_F64 e2 , Point3D_F64 e3 , DMatrixRMaj A ) { // construct the linear system that the solution which solves the unknown square // matrices in the camera matrices constructE(e2, e3); // Computes U, which is used to map the 18 unknowns onto the 27 trifocal unknowns svdU.decompose(E); svdU.getU(U, false); // Copy the parts of U which correspond to the non singular parts if the SVD // since there are only really 18-nullity unknowns due to linear dependencies SingularOps_DDRM.descendingOrder(U,false,svdU.getSingularValues(),svdU.numberOfSingularValues(),null,false); int rank = SingularOps_DDRM.rank(svdU, 1e-13); Up.reshape(U.numRows,rank); CommonOps_DDRM.extract(U,0,U.numRows,0,Up.numCols,Up,0,0); // project the linear constraint matrix into this subspace AU.reshape(A.numRows,Up.numCols); CommonOps_DDRM.mult(A,Up,AU); // Extract the solution of ||A*U*x|| = 0 from the null space svdV.decompose(AU); xp.reshape(rank,1); SingularOps_DDRM.nullVector(svdV,true,xp); // Translate the solution from the subspace and into a valid trifocal tensor CommonOps_DDRM.mult(Up,xp,vectorT); // the sign of vectorT is arbitrary, but make it positive for consistency if( vectorT.data[0] > 0 ) CommonOps_DDRM.changeSign(vectorT); }
[ "public", "void", "process", "(", "Point3D_F64", "e2", ",", "Point3D_F64", "e3", ",", "DMatrixRMaj", "A", ")", "{", "// construct the linear system that the solution which solves the unknown square", "// matrices in the camera matrices", "constructE", "(", "e2", ",", "e3", ...
Computes a trifocal tensor which minimizes the algebraic error given the two epipoles and the linear constraint matrix. The epipoles are from a previously computed trifocal tensor. @param e2 Epipole of first image in the second image @param e3 Epipole of first image in the third image @param A Linear constraint matrix for trifocal tensor created from image observations.
[ "Computes", "a", "trifocal", "tensor", "which", "minimizes", "the", "algebraic", "error", "given", "the", "two", "epipoles", "and", "the", "linear", "constraint", "matrix", ".", "The", "epipoles", "are", "from", "a", "previously", "computed", "trifocal", "tensor...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/EnforceTrifocalGeometry.java#L85-L117
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/EnforceTrifocalGeometry.java
EnforceTrifocalGeometry.constructE
protected void constructE( Point3D_F64 e2 , Point3D_F64 e3 ) { E.zero(); for( int i = 0; i < 3; i++ ) { for( int j = 0; j < 3; j++ ) { for( int k = 0; k < 3; k++ ) { // which element in the trifocal tensor is being manipulated int row = 9*i + 3*j + k; // which unknowns are being multiplied by int col1 = j*3 + i; int col2 = k*3 + i + 9; E.data[row*18 + col1 ] = e3.getIdx(k); E.data[row*18 + col2 ] = -e2.getIdx(j); } } } }
java
protected void constructE( Point3D_F64 e2 , Point3D_F64 e3 ) { E.zero(); for( int i = 0; i < 3; i++ ) { for( int j = 0; j < 3; j++ ) { for( int k = 0; k < 3; k++ ) { // which element in the trifocal tensor is being manipulated int row = 9*i + 3*j + k; // which unknowns are being multiplied by int col1 = j*3 + i; int col2 = k*3 + i + 9; E.data[row*18 + col1 ] = e3.getIdx(k); E.data[row*18 + col2 ] = -e2.getIdx(j); } } } }
[ "protected", "void", "constructE", "(", "Point3D_F64", "e2", ",", "Point3D_F64", "e3", ")", "{", "E", ".", "zero", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "3", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0"...
The matrix E is a linear system for computing the trifocal tensor. The columns are the unknown square matrices from view 2 and 3. The right most column in both projection matrices are the provided epipoles, whose values are inserted into E
[ "The", "matrix", "E", "is", "a", "linear", "system", "for", "computing", "the", "trifocal", "tensor", ".", "The", "columns", "are", "the", "unknown", "square", "matrices", "from", "view", "2", "and", "3", ".", "The", "right", "most", "column", "in", "bot...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/EnforceTrifocalGeometry.java#L140-L157
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/struct/geo/TrifocalTensor.java
TrifocalTensor.copy
public TrifocalTensor copy() { TrifocalTensor ret = new TrifocalTensor(); ret.T1.set(T1); ret.T2.set(T2); ret.T3.set(T3); return ret; }
java
public TrifocalTensor copy() { TrifocalTensor ret = new TrifocalTensor(); ret.T1.set(T1); ret.T2.set(T2); ret.T3.set(T3); return ret; }
[ "public", "TrifocalTensor", "copy", "(", ")", "{", "TrifocalTensor", "ret", "=", "new", "TrifocalTensor", "(", ")", ";", "ret", ".", "T1", ".", "set", "(", "T1", ")", ";", "ret", ".", "T2", ".", "set", "(", "T2", ")", ";", "ret", ".", "T3", ".", ...
Returns a new copy of the TrifocalTensor @return Copy of the trifocal tensor
[ "Returns", "a", "new", "copy", "of", "the", "TrifocalTensor" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/struct/geo/TrifocalTensor.java#L101-L107
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/DisparitySparseScoreSadRect.java
DisparitySparseScoreSadRect.setImages
public void setImages( Input left , Input right ) { InputSanityCheck.checkSameShape(left, right); this.left = left; this.right = right; }
java
public void setImages( Input left , Input right ) { InputSanityCheck.checkSameShape(left, right); this.left = left; this.right = right; }
[ "public", "void", "setImages", "(", "Input", "left", ",", "Input", "right", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "left", ",", "right", ")", ";", "this", ".", "left", "=", "left", ";", "this", ".", "right", "=", "right", ";", "}" ]
Specify inputs for left and right camera images. @param left Rectified left camera image. @param right Rectified right camera image.
[ "Specify", "inputs", "for", "left", "and", "right", "camera", "images", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/DisparitySparseScoreSadRect.java#L72-L77
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.getImageType
protected <T extends ImageBase> ImageType<T> getImageType( int which ) { synchronized ( inputStreams ) { return inputStreams.get(which).imageType; } }
java
protected <T extends ImageBase> ImageType<T> getImageType( int which ) { synchronized ( inputStreams ) { return inputStreams.get(which).imageType; } }
[ "protected", "<", "T", "extends", "ImageBase", ">", "ImageType", "<", "T", ">", "getImageType", "(", "int", "which", ")", "{", "synchronized", "(", "inputStreams", ")", "{", "return", "inputStreams", ".", "get", "(", "which", ")", ".", "imageType", ";", ...
Get input input type for a stream safely
[ "Get", "input", "input", "type", "for", "a", "stream", "safely" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L150-L154
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.updateRecentItems
private void updateRecentItems() { if( menuRecent == null ) return; menuRecent.removeAll(); List<String> recentFiles = BoofSwingUtil.getListOfRecentFiles(this); for( String filePath : recentFiles ) { final File f = new File(filePath); JMenuItem recentItem = new JMenuItem(f.getName()); recentItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(f); } }); menuRecent.add(recentItem); } }
java
private void updateRecentItems() { if( menuRecent == null ) return; menuRecent.removeAll(); List<String> recentFiles = BoofSwingUtil.getListOfRecentFiles(this); for( String filePath : recentFiles ) { final File f = new File(filePath); JMenuItem recentItem = new JMenuItem(f.getName()); recentItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFile(f); } }); menuRecent.add(recentItem); } }
[ "private", "void", "updateRecentItems", "(", ")", "{", "if", "(", "menuRecent", "==", "null", ")", "return", ";", "menuRecent", ".", "removeAll", "(", ")", ";", "List", "<", "String", ">", "recentFiles", "=", "BoofSwingUtil", ".", "getListOfRecentFiles", "("...
Updates the list in recent menu
[ "Updates", "the", "list", "in", "recent", "menu" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L230-L246
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.openExample
public void openExample( Object o ) { if (o instanceof PathLabel) { PathLabel p = (PathLabel)o; if( p.path.length == 1 ) openFile(new File(p.path[0])); else { // openFile(new File(p.path[0])); openImageSet(p.path); } } else if (o instanceof String) { openFile(new File((String) o)); } else { throw new IllegalArgumentException("Unknown example object type. Please override openExample()"); } }
java
public void openExample( Object o ) { if (o instanceof PathLabel) { PathLabel p = (PathLabel)o; if( p.path.length == 1 ) openFile(new File(p.path[0])); else { // openFile(new File(p.path[0])); openImageSet(p.path); } } else if (o instanceof String) { openFile(new File((String) o)); } else { throw new IllegalArgumentException("Unknown example object type. Please override openExample()"); } }
[ "public", "void", "openExample", "(", "Object", "o", ")", "{", "if", "(", "o", "instanceof", "PathLabel", ")", "{", "PathLabel", "p", "=", "(", "PathLabel", ")", "o", ";", "if", "(", "p", ".", "path", ".", "length", "==", "1", ")", "openFile", "(",...
Function that is invoked when an example has been selected
[ "Function", "that", "is", "invoked", "when", "an", "example", "has", "been", "selected" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L251-L265
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.stopAllInputProcessing
public void stopAllInputProcessing() { ProcessThread threadProcess; synchronized (inputStreams) { threadProcess = this.threadProcess; if( threadProcess != null ) { if( threadProcess.running ) { threadProcess.requestStop = true; } else { threadProcess = this.threadProcess = null; } } } inputSizeKnown = false; if( threadProcess == null ) { return; } long timeout = System.currentTimeMillis()+5000; while( threadProcess.running && timeout >= System.currentTimeMillis() ) { synchronized (inputStreams) { if( threadProcess != this.threadProcess ) { throw new RuntimeException("BUG! the thread got modified by anotehr process"); } } BoofMiscOps.sleep(100); } if( timeout < System.currentTimeMillis() ) throw new RuntimeException("Took too long to stop input processing thread"); this.threadProcess = null; }
java
public void stopAllInputProcessing() { ProcessThread threadProcess; synchronized (inputStreams) { threadProcess = this.threadProcess; if( threadProcess != null ) { if( threadProcess.running ) { threadProcess.requestStop = true; } else { threadProcess = this.threadProcess = null; } } } inputSizeKnown = false; if( threadProcess == null ) { return; } long timeout = System.currentTimeMillis()+5000; while( threadProcess.running && timeout >= System.currentTimeMillis() ) { synchronized (inputStreams) { if( threadProcess != this.threadProcess ) { throw new RuntimeException("BUG! the thread got modified by anotehr process"); } } BoofMiscOps.sleep(100); } if( timeout < System.currentTimeMillis() ) throw new RuntimeException("Took too long to stop input processing thread"); this.threadProcess = null; }
[ "public", "void", "stopAllInputProcessing", "(", ")", "{", "ProcessThread", "threadProcess", ";", "synchronized", "(", "inputStreams", ")", "{", "threadProcess", "=", "this", ".", "threadProcess", ";", "if", "(", "threadProcess", "!=", "null", ")", "{", "if", ...
Blocks until it kills all input streams from running
[ "Blocks", "until", "it", "kills", "all", "input", "streams", "from", "running" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L270-L304
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.openFile
public void openFile(File file) { final String path = massageFilePath(file); if( path == null ) return; inputFilePath = path; // update recent items menu BoofSwingUtil.invokeNowOrLater(() -> { BoofSwingUtil.addToRecentFiles(DemonstrationBase.this,path); updateRecentItems(); }); BufferedImage buffered = inputFilePath.endsWith("mjpeg") ? null : UtilImageIO.loadImage(inputFilePath); if( buffered == null ) { if( allowVideos ) openVideo(false,inputFilePath); } else if( allowImages ){ openImage(false,file.getName(), buffered); } }
java
public void openFile(File file) { final String path = massageFilePath(file); if( path == null ) return; inputFilePath = path; // update recent items menu BoofSwingUtil.invokeNowOrLater(() -> { BoofSwingUtil.addToRecentFiles(DemonstrationBase.this,path); updateRecentItems(); }); BufferedImage buffered = inputFilePath.endsWith("mjpeg") ? null : UtilImageIO.loadImage(inputFilePath); if( buffered == null ) { if( allowVideos ) openVideo(false,inputFilePath); } else if( allowImages ){ openImage(false,file.getName(), buffered); } }
[ "public", "void", "openFile", "(", "File", "file", ")", "{", "final", "String", "path", "=", "massageFilePath", "(", "file", ")", ";", "if", "(", "path", "==", "null", ")", "return", ";", "inputFilePath", "=", "path", ";", "// update recent items menu", "B...
Opens a file. First it will attempt to open it as an image. If that fails it will try opening it as a video. If all else fails tell the user it has failed. If a streaming source was running before it will be stopped.
[ "Opens", "a", "file", ".", "First", "it", "will", "attempt", "to", "open", "it", "as", "an", "image", ".", "If", "that", "fails", "it", "will", "try", "opening", "it", "as", "a", "video", ".", "If", "all", "else", "fails", "tell", "the", "user", "i...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L346-L365
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.openImageSet
public void openImageSet(String ...files ) { synchronized (lockStartingProcess) { if( startingProcess ) { System.out.println("Ignoring open image set request. Detected spamming"); return; } startingProcess = true; } stopAllInputProcessing(); synchronized (inputStreams) { inputMethod = InputMethod.IMAGE_SET; inputFileSet = files; if( threadProcess != null ) throw new RuntimeException("There is still an active stream thread!"); threadProcess = new ProcessImageSetThread(files); imageSetSize = files.length; } threadPool.execute(threadProcess); }
java
public void openImageSet(String ...files ) { synchronized (lockStartingProcess) { if( startingProcess ) { System.out.println("Ignoring open image set request. Detected spamming"); return; } startingProcess = true; } stopAllInputProcessing(); synchronized (inputStreams) { inputMethod = InputMethod.IMAGE_SET; inputFileSet = files; if( threadProcess != null ) throw new RuntimeException("There is still an active stream thread!"); threadProcess = new ProcessImageSetThread(files); imageSetSize = files.length; } threadPool.execute(threadProcess); }
[ "public", "void", "openImageSet", "(", "String", "...", "files", ")", "{", "synchronized", "(", "lockStartingProcess", ")", "{", "if", "(", "startingProcess", ")", "{", "System", ".", "out", ".", "println", "(", "\"Ignoring open image set request. Detected spamming...
Opens a set of images @param files
[ "Opens", "a", "set", "of", "images" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L404-L424
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.openNextFile
public void openNextFile() { if( inputFilePath == null || inputMethod != InputMethod.IMAGE ) return; String path; try { // need to remove annoying %20 from the path is there is whitespace path = URLDecoder.decode(inputFilePath, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return; } File current = new File(UtilIO.ensureURL(path).getFile()); File parent = current.getParentFile(); if( parent == null ) return; File[] files = parent.listFiles(); if( files == null || files.length <= 1 ) return; File closest = null; for (int i = 0; i < files.length; i++) { File f = files[i]; String name = f.getName().toLowerCase(); // filter out common non image/video files if( name.endsWith(".txt") || name.endsWith(".yaml") || name.endsWith(".xml")) continue; if( current.compareTo(f) < 0 ) { if( closest == null || closest.compareTo(f) > 0 ) { closest = f; } } } if( closest != null && closest.isFile() ) { openFile(closest); } else { if( closest != null ) { System.err.println("Next file isn't a file. name="+closest.getName()); } else { System.err.println("No valid closest file found."); } } }
java
public void openNextFile() { if( inputFilePath == null || inputMethod != InputMethod.IMAGE ) return; String path; try { // need to remove annoying %20 from the path is there is whitespace path = URLDecoder.decode(inputFilePath, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return; } File current = new File(UtilIO.ensureURL(path).getFile()); File parent = current.getParentFile(); if( parent == null ) return; File[] files = parent.listFiles(); if( files == null || files.length <= 1 ) return; File closest = null; for (int i = 0; i < files.length; i++) { File f = files[i]; String name = f.getName().toLowerCase(); // filter out common non image/video files if( name.endsWith(".txt") || name.endsWith(".yaml") || name.endsWith(".xml")) continue; if( current.compareTo(f) < 0 ) { if( closest == null || closest.compareTo(f) > 0 ) { closest = f; } } } if( closest != null && closest.isFile() ) { openFile(closest); } else { if( closest != null ) { System.err.println("Next file isn't a file. name="+closest.getName()); } else { System.err.println("No valid closest file found."); } } }
[ "public", "void", "openNextFile", "(", ")", "{", "if", "(", "inputFilePath", "==", "null", "||", "inputMethod", "!=", "InputMethod", ".", "IMAGE", ")", "return", ";", "String", "path", ";", "try", "{", "// need to remove annoying %20 from the path is there is whites...
Opens the next file in the directory by lexicographical order.
[ "Opens", "the", "next", "file", "in", "the", "directory", "by", "lexicographical", "order", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L429-L474
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.openVideo
protected void openVideo(boolean reopen , String ...filePaths) { synchronized (lockStartingProcess) { if( startingProcess ) { System.out.println("Ignoring video request. Detected spamming"); return; } startingProcess = true; } synchronized (inputStreams) { if (inputStreams.size() != filePaths.length) throw new IllegalArgumentException("Input streams not equal to "+filePaths.length+". Override openVideo()"); } stopAllInputProcessing(); streamPaused = false; boolean failed = false; for( int which = 0; which < filePaths.length; which++ ) { CacheSequenceStream cache = inputStreams.get(which); SimpleImageSequence sequence = media.openVideo(filePaths[which], cache.getImageType()); if( sequence == null ) { failed = true; System.out.println("Can't find file. "+filePaths[which]); break; } configureVideo(which,sequence); synchronized (inputStreams) { cache.reset(); cache.setSequence(sequence); } } if (!failed) { setInputName(new File(filePaths[0]).getName()); synchronized (inputStreams) { inputMethod = InputMethod.VIDEO; streamPeriod = 33; // default to 33 FPS for a video if( threadProcess != null ) throw new RuntimeException("There was still an active stream thread!"); threadProcess = new SynchronizedStreamsThread(); } if( !reopen ) { for (int i = 0; i < inputStreams.size(); i++) { CacheSequenceStream stream = inputStreams.get(i); handleInputChange(i, inputMethod, stream.getWidth(), stream.getHeight()); } } threadPool.execute(threadProcess); } else { synchronized (inputStreams) { inputMethod = InputMethod.NONE; inputFilePath = null; } synchronized (lockStartingProcess) { startingProcess = false; } showRejectDiaglog("Can't open file"); } }
java
protected void openVideo(boolean reopen , String ...filePaths) { synchronized (lockStartingProcess) { if( startingProcess ) { System.out.println("Ignoring video request. Detected spamming"); return; } startingProcess = true; } synchronized (inputStreams) { if (inputStreams.size() != filePaths.length) throw new IllegalArgumentException("Input streams not equal to "+filePaths.length+". Override openVideo()"); } stopAllInputProcessing(); streamPaused = false; boolean failed = false; for( int which = 0; which < filePaths.length; which++ ) { CacheSequenceStream cache = inputStreams.get(which); SimpleImageSequence sequence = media.openVideo(filePaths[which], cache.getImageType()); if( sequence == null ) { failed = true; System.out.println("Can't find file. "+filePaths[which]); break; } configureVideo(which,sequence); synchronized (inputStreams) { cache.reset(); cache.setSequence(sequence); } } if (!failed) { setInputName(new File(filePaths[0]).getName()); synchronized (inputStreams) { inputMethod = InputMethod.VIDEO; streamPeriod = 33; // default to 33 FPS for a video if( threadProcess != null ) throw new RuntimeException("There was still an active stream thread!"); threadProcess = new SynchronizedStreamsThread(); } if( !reopen ) { for (int i = 0; i < inputStreams.size(); i++) { CacheSequenceStream stream = inputStreams.get(i); handleInputChange(i, inputMethod, stream.getWidth(), stream.getHeight()); } } threadPool.execute(threadProcess); } else { synchronized (inputStreams) { inputMethod = InputMethod.NONE; inputFilePath = null; } synchronized (lockStartingProcess) { startingProcess = false; } showRejectDiaglog("Can't open file"); } }
[ "protected", "void", "openVideo", "(", "boolean", "reopen", ",", "String", "...", "filePaths", ")", "{", "synchronized", "(", "lockStartingProcess", ")", "{", "if", "(", "startingProcess", ")", "{", "System", ".", "out", ".", "println", "(", "\"Ignoring video ...
Before invoking this function make sure waitingToOpenImage is false AND that the previous input has been stopped
[ "Before", "invoking", "this", "function", "make", "sure", "waitingToOpenImage", "is", "false", "AND", "that", "the", "previous", "input", "has", "been", "stopped" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L479-L541
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.display
public void display(String appName ) { waitUntilInputSizeIsKnown(); this.appName = appName; window = ShowImages.showWindow(this,appName,true); window.setJMenuBar(menuBar); }
java
public void display(String appName ) { waitUntilInputSizeIsKnown(); this.appName = appName; window = ShowImages.showWindow(this,appName,true); window.setJMenuBar(menuBar); }
[ "public", "void", "display", "(", "String", "appName", ")", "{", "waitUntilInputSizeIsKnown", "(", ")", ";", "this", ".", "appName", "=", "appName", ";", "window", "=", "ShowImages", ".", "showWindow", "(", "this", ",", "appName", ",", "true", ")", ";", ...
Opens a window with this application inside of it @param appName Name of the application
[ "Opens", "a", "window", "with", "this", "application", "inside", "of", "it" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L658-L663
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.openFileMenuBar
protected void openFileMenuBar() { List<BoofSwingUtil.FileTypes> types = new ArrayList<>(); if( allowImages ) types.add(BoofSwingUtil.FileTypes.IMAGES); if( allowVideos ) types.add(BoofSwingUtil.FileTypes.VIDEOS); BoofSwingUtil.FileTypes array[] = types.toArray(new BoofSwingUtil.FileTypes[0]); File file = BoofSwingUtil.openFileChooser(DemonstrationBase.this,array); if (file != null) { openFile(file); } }
java
protected void openFileMenuBar() { List<BoofSwingUtil.FileTypes> types = new ArrayList<>(); if( allowImages ) types.add(BoofSwingUtil.FileTypes.IMAGES); if( allowVideos ) types.add(BoofSwingUtil.FileTypes.VIDEOS); BoofSwingUtil.FileTypes array[] = types.toArray(new BoofSwingUtil.FileTypes[0]); File file = BoofSwingUtil.openFileChooser(DemonstrationBase.this,array); if (file != null) { openFile(file); } }
[ "protected", "void", "openFileMenuBar", "(", ")", "{", "List", "<", "BoofSwingUtil", ".", "FileTypes", ">", "types", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "allowImages", ")", "types", ".", "add", "(", "BoofSwingUtil", ".", "FileTypes", ...
Open file in the menu bar was invoked by the user
[ "Open", "file", "in", "the", "menu", "bar", "was", "invoked", "by", "the", "user" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L693-L705
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java
DemonstrationBase.reprocessInput
public void reprocessInput() { if ( inputMethod == InputMethod.VIDEO ) { openVideo(true,inputFilePath); } else if( inputMethod == InputMethod.IMAGE ) { BufferedImage buff = inputStreams.get(0).getBufferedImage(); openImage(true,new File(inputFilePath).getName(),buff);// TODO still does a pointless image conversion } else if( inputMethod == InputMethod.IMAGE_SET ) { openImageSet(inputFileSet); } }
java
public void reprocessInput() { if ( inputMethod == InputMethod.VIDEO ) { openVideo(true,inputFilePath); } else if( inputMethod == InputMethod.IMAGE ) { BufferedImage buff = inputStreams.get(0).getBufferedImage(); openImage(true,new File(inputFilePath).getName(),buff);// TODO still does a pointless image conversion } else if( inputMethod == InputMethod.IMAGE_SET ) { openImageSet(inputFileSet); } }
[ "public", "void", "reprocessInput", "(", ")", "{", "if", "(", "inputMethod", "==", "InputMethod", ".", "VIDEO", ")", "{", "openVideo", "(", "true", ",", "inputFilePath", ")", ";", "}", "else", "if", "(", "inputMethod", "==", "InputMethod", ".", "IMAGE", ...
If just a single image was processed it will process it again. If it's a stream there is no need to reprocess, the next image will be handled soon enough.
[ "If", "just", "a", "single", "image", "was", "processed", "it", "will", "process", "it", "again", ".", "If", "it", "s", "a", "stream", "there", "is", "no", "need", "to", "reprocess", "the", "next", "image", "will", "be", "handled", "soon", "enough", "....
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/gui/DemonstrationBase.java#L880-L889
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/GeneralFeatureDetector.java
GeneralFeatureDetector.process
public void process(I image, D derivX, D derivY, D derivXX, D derivYY, D derivXY) { intensity.process(image, derivX, derivY, derivXX, derivYY, derivXY); GrayF32 intensityImage = intensity.getIntensity(); int numSelectMin = -1; int numSelectMax = -1; if( maxFeatures > 0 ) { if( intensity.localMinimums() ) numSelectMin = excludeMinimum == null ? maxFeatures : maxFeatures - excludeMinimum.size; if( intensity.localMaximums() ) numSelectMax = excludeMaximum == null ? maxFeatures : maxFeatures - excludeMaximum.size; // return without processing if there is no room to detect any more features if( numSelectMin <= 0 && numSelectMax <= 0 ) return; } // mark pixels that should be excluded if( excludeMinimum != null ) { for( int i = 0; i < excludeMinimum.size; i++ ) { Point2D_I16 p = excludeMinimum.get(i); intensityImage.set(p.x,p.y,-Float.MAX_VALUE); } } if( excludeMaximum != null ) { for( int i = 0; i < excludeMaximum.size; i++ ) { Point2D_I16 p = excludeMaximum.get(i); intensityImage.set(p.x,p.y,Float.MAX_VALUE); } } foundMinimum.reset(); foundMaximum.reset(); if (intensity.hasCandidates()) { extractor.process(intensityImage, intensity.getCandidatesMin(), intensity.getCandidatesMax(),foundMinimum, foundMaximum); } else { extractor.process(intensityImage, null, null,foundMinimum, foundMaximum); } // optionally select the most intense features only selectBest(intensityImage, foundMinimum, numSelectMin, false); selectBest(intensityImage, foundMaximum, numSelectMax, true); }
java
public void process(I image, D derivX, D derivY, D derivXX, D derivYY, D derivXY) { intensity.process(image, derivX, derivY, derivXX, derivYY, derivXY); GrayF32 intensityImage = intensity.getIntensity(); int numSelectMin = -1; int numSelectMax = -1; if( maxFeatures > 0 ) { if( intensity.localMinimums() ) numSelectMin = excludeMinimum == null ? maxFeatures : maxFeatures - excludeMinimum.size; if( intensity.localMaximums() ) numSelectMax = excludeMaximum == null ? maxFeatures : maxFeatures - excludeMaximum.size; // return without processing if there is no room to detect any more features if( numSelectMin <= 0 && numSelectMax <= 0 ) return; } // mark pixels that should be excluded if( excludeMinimum != null ) { for( int i = 0; i < excludeMinimum.size; i++ ) { Point2D_I16 p = excludeMinimum.get(i); intensityImage.set(p.x,p.y,-Float.MAX_VALUE); } } if( excludeMaximum != null ) { for( int i = 0; i < excludeMaximum.size; i++ ) { Point2D_I16 p = excludeMaximum.get(i); intensityImage.set(p.x,p.y,Float.MAX_VALUE); } } foundMinimum.reset(); foundMaximum.reset(); if (intensity.hasCandidates()) { extractor.process(intensityImage, intensity.getCandidatesMin(), intensity.getCandidatesMax(),foundMinimum, foundMaximum); } else { extractor.process(intensityImage, null, null,foundMinimum, foundMaximum); } // optionally select the most intense features only selectBest(intensityImage, foundMinimum, numSelectMin, false); selectBest(intensityImage, foundMaximum, numSelectMax, true); }
[ "public", "void", "process", "(", "I", "image", ",", "D", "derivX", ",", "D", "derivY", ",", "D", "derivXX", ",", "D", "derivYY", ",", "D", "derivXY", ")", "{", "intensity", ".", "process", "(", "image", ",", "derivX", ",", "derivY", ",", "derivXX", ...
Computes point features from image gradients. @param image Original image. @param derivX image derivative in along the x-axis. Only needed if {@link #getRequiresGradient()} is true. @param derivY image derivative in along the y-axis. Only needed if {@link #getRequiresGradient()} is true. @param derivXX Second derivative. Only needed if {@link #getRequiresHessian()} ()} is true. @param derivXY Second derivative. Only needed if {@link #getRequiresHessian()} ()} is true. @param derivYY Second derivative. Only needed if {@link #getRequiresHessian()} ()} is true.
[ "Computes", "point", "features", "from", "image", "gradients", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/GeneralFeatureDetector.java#L107-L149
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribeRegionPoint.java
FactoryDescribeRegionPoint.surfColorStable
public static <T extends ImageBase<T>, II extends ImageGray<II>> DescribeRegionPoint<T,BrightFeature> surfColorStable(ConfigSurfDescribe.Stability config, ImageType<T> imageType) { Class bandType = imageType.getImageClass(); Class<II> integralType = GIntegralImageOps.getIntegralType(bandType); DescribePointSurf<II> alg = FactoryDescribePointAlgs.surfStability( config, integralType); if( imageType.getFamily() == ImageType.Family.PLANAR) { DescribePointSurfPlanar<II> color = FactoryDescribePointAlgs.surfColor( alg,imageType.getNumBands()); return new SurfPlanar_to_DescribeRegionPoint(color,bandType,integralType); } else { throw new IllegalArgumentException("Unknown image type"); } }
java
public static <T extends ImageBase<T>, II extends ImageGray<II>> DescribeRegionPoint<T,BrightFeature> surfColorStable(ConfigSurfDescribe.Stability config, ImageType<T> imageType) { Class bandType = imageType.getImageClass(); Class<II> integralType = GIntegralImageOps.getIntegralType(bandType); DescribePointSurf<II> alg = FactoryDescribePointAlgs.surfStability( config, integralType); if( imageType.getFamily() == ImageType.Family.PLANAR) { DescribePointSurfPlanar<II> color = FactoryDescribePointAlgs.surfColor( alg,imageType.getNumBands()); return new SurfPlanar_to_DescribeRegionPoint(color,bandType,integralType); } else { throw new IllegalArgumentException("Unknown image type"); } }
[ "public", "static", "<", "T", "extends", "ImageBase", "<", "T", ">", ",", "II", "extends", "ImageGray", "<", "II", ">", ">", "DescribeRegionPoint", "<", "T", ",", "BrightFeature", ">", "surfColorStable", "(", "ConfigSurfDescribe", ".", "Stability", "config", ...
Color variant of the SURF descriptor which has been designed for stability. @see DescribePointSurfPlanar @param config SURF configuration. Pass in null for default options. @param imageType Type of input image. @return SURF color description extractor
[ "Color", "variant", "of", "the", "SURF", "descriptor", "which", "has", "been", "designed", "for", "stability", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribeRegionPoint.java#L127-L142
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribeRegionPoint.java
FactoryDescribeRegionPoint.pixel
@SuppressWarnings({"unchecked"}) public static <T extends ImageGray<T>, D extends TupleDesc> DescribeRegionPoint<T,D> pixel( int regionWidth , int regionHeight , Class<T> imageType ) { return new WrapDescribePixelRegion( FactoryDescribePointAlgs.pixelRegion(regionWidth,regionHeight,imageType),imageType); }
java
@SuppressWarnings({"unchecked"}) public static <T extends ImageGray<T>, D extends TupleDesc> DescribeRegionPoint<T,D> pixel( int regionWidth , int regionHeight , Class<T> imageType ) { return new WrapDescribePixelRegion( FactoryDescribePointAlgs.pixelRegion(regionWidth,regionHeight,imageType),imageType); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", "}", ")", "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ",", "D", "extends", "TupleDesc", ">", "DescribeRegionPoint", "<", "T", ",", "D", ">", "pixel", "(", "int", "regionWidth", ...
Creates a region descriptor based on pixel intensity values alone. A classic and fast to compute descriptor, but much less stable than more modern ones. @see boofcv.alg.feature.describe.DescribePointPixelRegion @param regionWidth How wide the pixel region is. @param regionHeight How tall the pixel region is. @param imageType Type of image it will process. @return Pixel region descriptor
[ "Creates", "a", "region", "descriptor", "based", "on", "pixel", "intensity", "values", "alone", ".", "A", "classic", "and", "fast", "to", "compute", "descriptor", "but", "much", "less", "stable", "than", "more", "modern", "ones", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribeRegionPoint.java#L215-L220
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribeRegionPoint.java
FactoryDescribeRegionPoint.pixelNCC
@SuppressWarnings({"unchecked"}) public static <T extends ImageGray<T>> DescribeRegionPoint<T,NccFeature> pixelNCC( int regionWidth , int regionHeight , Class<T> imageType ) { return new WrapDescribePixelRegionNCC( FactoryDescribePointAlgs.pixelRegionNCC(regionWidth,regionHeight,imageType),imageType); }
java
@SuppressWarnings({"unchecked"}) public static <T extends ImageGray<T>> DescribeRegionPoint<T,NccFeature> pixelNCC( int regionWidth , int regionHeight , Class<T> imageType ) { return new WrapDescribePixelRegionNCC( FactoryDescribePointAlgs.pixelRegionNCC(regionWidth,regionHeight,imageType),imageType); }
[ "@", "SuppressWarnings", "(", "{", "\"unchecked\"", "}", ")", "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "DescribeRegionPoint", "<", "T", ",", "NccFeature", ">", "pixelNCC", "(", "int", "regionWidth", ",", "int", "regionHeight"...
Creates a region descriptor based on normalized pixel intensity values alone. This descriptor is designed to be light invariance, but is still less stable than more modern ones. @see boofcv.alg.feature.describe.DescribePointPixelRegionNCC @param regionWidth How wide the pixel region is. @param regionHeight How tall the pixel region is. @param imageType Type of image it will process. @return Pixel region descriptor
[ "Creates", "a", "region", "descriptor", "based", "on", "normalized", "pixel", "intensity", "values", "alone", ".", "This", "descriptor", "is", "designed", "to", "be", "light", "invariance", "but", "is", "still", "less", "stable", "than", "more", "modern", "one...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribeRegionPoint.java#L233-L238
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/calibration/CalibrationIO.java
CalibrationIO.save
public static <T extends CameraPinhole> void save(T parameters , Writer outputWriter ) { PrintWriter out = new PrintWriter(outputWriter); Yaml yaml = createYmlObject(); Map<String, Object> data = new HashMap<>(); if( parameters instanceof CameraPinholeBrown) { out.println("# Pinhole camera model with radial and tangential distortion"); out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape"); out.println("# radial = radial distortion, (t1,t2) = tangential distortion"); out.println(); putModelRadial((CameraPinholeBrown) parameters, data); } else if( parameters instanceof CameraUniversalOmni ) { out.println("# Omnidirectional camera model with radial and tangential distortion"); out.println("# C. Mei, and P. Rives. \"Single view point omnidirectional camera calibration" + " from planar grids.\" ICRA 2007"); out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape"); out.println("# mirror_offset = offset mirror along z-axis in unit circle"); out.println("# radial = radial distortion, (t1,t2) = tangential distortion"); out.println(); putModelUniversalOmni((CameraUniversalOmni) parameters, data); } else { out.println("# Pinhole camera model"); out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape"); out.println(); putModelPinhole(parameters,data); } yaml.dump(data,out); out.close(); }
java
public static <T extends CameraPinhole> void save(T parameters , Writer outputWriter ) { PrintWriter out = new PrintWriter(outputWriter); Yaml yaml = createYmlObject(); Map<String, Object> data = new HashMap<>(); if( parameters instanceof CameraPinholeBrown) { out.println("# Pinhole camera model with radial and tangential distortion"); out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape"); out.println("# radial = radial distortion, (t1,t2) = tangential distortion"); out.println(); putModelRadial((CameraPinholeBrown) parameters, data); } else if( parameters instanceof CameraUniversalOmni ) { out.println("# Omnidirectional camera model with radial and tangential distortion"); out.println("# C. Mei, and P. Rives. \"Single view point omnidirectional camera calibration" + " from planar grids.\" ICRA 2007"); out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape"); out.println("# mirror_offset = offset mirror along z-axis in unit circle"); out.println("# radial = radial distortion, (t1,t2) = tangential distortion"); out.println(); putModelUniversalOmni((CameraUniversalOmni) parameters, data); } else { out.println("# Pinhole camera model"); out.println("# (fx,fy) = focal length, (cx,cy) = principle point, (width,height) = image shape"); out.println(); putModelPinhole(parameters,data); } yaml.dump(data,out); out.close(); }
[ "public", "static", "<", "T", "extends", "CameraPinhole", ">", "void", "save", "(", "T", "parameters", ",", "Writer", "outputWriter", ")", "{", "PrintWriter", "out", "=", "new", "PrintWriter", "(", "outputWriter", ")", ";", "Yaml", "yaml", "=", "createYmlObj...
Saves intrinsic camera model to disk @param parameters Camera parameters @param outputWriter Path to where it should be saved
[ "Saves", "intrinsic", "camera", "model", "to", "disk" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/calibration/CalibrationIO.java#L56-L89
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/calibration/CalibrationIO.java
CalibrationIO.save
public static void save(StereoParameters parameters , Writer outputWriter ) { Map<String, Object> map = new HashMap<>(); map.put("model",MODEL_STEREO); map.put(VERSION,0); map.put("left",putModelRadial(parameters.left,null)); map.put("right",putModelRadial(parameters.right,null)); map.put("rightToLeft",putSe3(parameters.rightToLeft)); PrintWriter out = new PrintWriter(outputWriter); out.println("# Intrinsic and extrinsic parameters for a stereo camera pair"); Yaml yaml = createYmlObject(); yaml.dump(map,out); out.close(); }
java
public static void save(StereoParameters parameters , Writer outputWriter ) { Map<String, Object> map = new HashMap<>(); map.put("model",MODEL_STEREO); map.put(VERSION,0); map.put("left",putModelRadial(parameters.left,null)); map.put("right",putModelRadial(parameters.right,null)); map.put("rightToLeft",putSe3(parameters.rightToLeft)); PrintWriter out = new PrintWriter(outputWriter); out.println("# Intrinsic and extrinsic parameters for a stereo camera pair"); Yaml yaml = createYmlObject(); yaml.dump(map,out); out.close(); }
[ "public", "static", "void", "save", "(", "StereoParameters", "parameters", ",", "Writer", "outputWriter", ")", "{", "Map", "<", "String", ",", "Object", ">", "map", "=", "new", "HashMap", "<>", "(", ")", ";", "map", ".", "put", "(", "\"model\"", ",", "...
Saves stereo camera model to disk @param parameters Camera parameters @param outputWriter Stream to save the parameters to
[ "Saves", "stereo", "camera", "model", "to", "disk" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/calibration/CalibrationIO.java#L115-L129
train
lessthanoptimal/BoofCV
main/boofcv-io/src/main/java/boofcv/io/calibration/CalibrationIO.java
CalibrationIO.load
public static <T> T load(Reader reader ) { Yaml yaml = createYmlObject(); Map<String,Object> data = (Map<String, Object>) yaml.load(reader); try { reader.close(); } catch (IOException e) { throw new RuntimeException(e); } return load(data); }
java
public static <T> T load(Reader reader ) { Yaml yaml = createYmlObject(); Map<String,Object> data = (Map<String, Object>) yaml.load(reader); try { reader.close(); } catch (IOException e) { throw new RuntimeException(e); } return load(data); }
[ "public", "static", "<", "T", ">", "T", "load", "(", "Reader", "reader", ")", "{", "Yaml", "yaml", "=", "createYmlObject", "(", ")", ";", "Map", "<", "String", ",", "Object", ">", "data", "=", "(", "Map", "<", "String", ",", "Object", ">", ")", "...
Loads intrinsic parameters from disk @param reader Reader @return Camera model
[ "Loads", "intrinsic", "parameters", "from", "disk" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/calibration/CalibrationIO.java#L238-L250
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java
CalibrationPlanarGridZhang99.process
public boolean process( List<CalibrationObservation> observations ) { // compute initial parameter estimates using linear algebra if( !linearEstimate(observations) ) return false; status("Non-linear refinement"); // perform non-linear optimization to improve results if( !performBundleAdjustment()) return false; return true; }
java
public boolean process( List<CalibrationObservation> observations ) { // compute initial parameter estimates using linear algebra if( !linearEstimate(observations) ) return false; status("Non-linear refinement"); // perform non-linear optimization to improve results if( !performBundleAdjustment()) return false; return true; }
[ "public", "boolean", "process", "(", "List", "<", "CalibrationObservation", ">", "observations", ")", "{", "// compute initial parameter estimates using linear algebra", "if", "(", "!", "linearEstimate", "(", "observations", ")", ")", "return", "false", ";", "status", ...
Processes observed calibration point coordinates and computes camera intrinsic and extrinsic parameters. @param observations Set of observed grid locations in pixel coordinates. @return true if successful and false if it failed
[ "Processes", "observed", "calibration", "point", "coordinates", "and", "computes", "camera", "intrinsic", "and", "extrinsic", "parameters", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java#L122-L134
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java
CalibrationPlanarGridZhang99.linearEstimate
protected boolean linearEstimate(List<CalibrationObservation> observations ) { status("Estimating Homographies"); List<DMatrixRMaj> homographies = new ArrayList<>(); List<Se3_F64> motions = new ArrayList<>(); for( CalibrationObservation obs : observations ) { if( !computeHomography.computeHomography(obs) ) return false; DMatrixRMaj H = computeHomography.getHomography(); homographies.add(H); } status("Estimating Calibration Matrix"); computeK.process(homographies); DMatrixRMaj K = computeK.getCalibrationMatrix(); decomposeH.setCalibrationMatrix(K); for( DMatrixRMaj H : homographies ) { motions.add(decomposeH.decompose(H)); } status("Estimating Radial Distortion"); computeRadial.process(K, homographies, observations); double distort[] = computeRadial.getParameters(); convertIntoBundleStructure(motions, K,distort,observations); return true; }
java
protected boolean linearEstimate(List<CalibrationObservation> observations ) { status("Estimating Homographies"); List<DMatrixRMaj> homographies = new ArrayList<>(); List<Se3_F64> motions = new ArrayList<>(); for( CalibrationObservation obs : observations ) { if( !computeHomography.computeHomography(obs) ) return false; DMatrixRMaj H = computeHomography.getHomography(); homographies.add(H); } status("Estimating Calibration Matrix"); computeK.process(homographies); DMatrixRMaj K = computeK.getCalibrationMatrix(); decomposeH.setCalibrationMatrix(K); for( DMatrixRMaj H : homographies ) { motions.add(decomposeH.decompose(H)); } status("Estimating Radial Distortion"); computeRadial.process(K, homographies, observations); double distort[] = computeRadial.getParameters(); convertIntoBundleStructure(motions, K,distort,observations); return true; }
[ "protected", "boolean", "linearEstimate", "(", "List", "<", "CalibrationObservation", ">", "observations", ")", "{", "status", "(", "\"Estimating Homographies\"", ")", ";", "List", "<", "DMatrixRMaj", ">", "homographies", "=", "new", "ArrayList", "<>", "(", ")", ...
Find an initial estimate for calibration parameters using linear techniques.
[ "Find", "an", "initial", "estimate", "for", "calibration", "parameters", "using", "linear", "techniques", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java#L139-L171
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java
CalibrationPlanarGridZhang99.performBundleAdjustment
public boolean performBundleAdjustment() { // Configure the sparse Levenberg-Marquardt solver ConfigLevenbergMarquardt configLM = new ConfigLevenbergMarquardt(); configLM.hessianScaling = false; ConfigBundleAdjustment configSBA = new ConfigBundleAdjustment(); configSBA.configOptimizer = configLM; BundleAdjustment<SceneStructureMetric> bundleAdjustment; if( robust ) { configLM.mixture = 0; bundleAdjustment = FactoryMultiView.bundleDenseMetric(true,configSBA); } else { bundleAdjustment = FactoryMultiView.bundleSparseMetric(configSBA); } bundleAdjustment.setVerbose(verbose,0); // Specifies convergence criteria bundleAdjustment.configure(1e-20, 1e-20, 200); bundleAdjustment.setParameters(structure,observations); return bundleAdjustment.optimize(structure); }
java
public boolean performBundleAdjustment() { // Configure the sparse Levenberg-Marquardt solver ConfigLevenbergMarquardt configLM = new ConfigLevenbergMarquardt(); configLM.hessianScaling = false; ConfigBundleAdjustment configSBA = new ConfigBundleAdjustment(); configSBA.configOptimizer = configLM; BundleAdjustment<SceneStructureMetric> bundleAdjustment; if( robust ) { configLM.mixture = 0; bundleAdjustment = FactoryMultiView.bundleDenseMetric(true,configSBA); } else { bundleAdjustment = FactoryMultiView.bundleSparseMetric(configSBA); } bundleAdjustment.setVerbose(verbose,0); // Specifies convergence criteria bundleAdjustment.configure(1e-20, 1e-20, 200); bundleAdjustment.setParameters(structure,observations); return bundleAdjustment.optimize(structure); }
[ "public", "boolean", "performBundleAdjustment", "(", ")", "{", "// Configure the sparse Levenberg-Marquardt solver", "ConfigLevenbergMarquardt", "configLM", "=", "new", "ConfigLevenbergMarquardt", "(", ")", ";", "configLM", ".", "hessianScaling", "=", "false", ";", "ConfigB...
Use non-linear optimization to improve the parameter estimates
[ "Use", "non", "-", "linear", "optimization", "to", "improve", "the", "parameter", "estimates" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java#L183-L206
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java
CalibrationPlanarGridZhang99.applyDistortion
public static void applyDistortion(Point2D_F64 normPt, double[] radial, double t1 , double t2 ) { final double x = normPt.x; final double y = normPt.y; double a = 0; double r2 = x*x + y*y; double r2i = r2; for( int i = 0; i < radial.length; i++ ) { a += radial[i]*r2i; r2i *= r2; } normPt.x = x + x*a + 2*t1*x*y + t2*(r2 + 2*x*x); normPt.y = y + y*a + t1*(r2 + 2*y*y) + 2*t2*x*y; }
java
public static void applyDistortion(Point2D_F64 normPt, double[] radial, double t1 , double t2 ) { final double x = normPt.x; final double y = normPt.y; double a = 0; double r2 = x*x + y*y; double r2i = r2; for( int i = 0; i < radial.length; i++ ) { a += radial[i]*r2i; r2i *= r2; } normPt.x = x + x*a + 2*t1*x*y + t2*(r2 + 2*x*x); normPt.y = y + y*a + t1*(r2 + 2*y*y) + 2*t2*x*y; }
[ "public", "static", "void", "applyDistortion", "(", "Point2D_F64", "normPt", ",", "double", "[", "]", "radial", ",", "double", "t1", ",", "double", "t2", ")", "{", "final", "double", "x", "=", "normPt", ".", "x", ";", "final", "double", "y", "=", "norm...
Applies radial and tangential distortion to the normalized image coordinate. @param normPt point in normalized image coordinates @param radial radial distortion parameters @param t1 tangential parameter @param t2 tangential parameter
[ "Applies", "radial", "and", "tangential", "distortion", "to", "the", "normalized", "image", "coordinate", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/CalibrationPlanarGridZhang99.java#L303-L318
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/robust/DistanceSe3SymmetricSq.java
DistanceSe3SymmetricSq.computeDistance
@Override public double computeDistance(AssociatedPair obs) { // triangulate the point in 3D space triangulate.triangulate(obs.p1,obs.p2,keyToCurr,p); if( p.z < 0 ) return Double.MAX_VALUE; // compute observational error in each view double error = errorCam1.errorSq(obs.p1.x,obs.p1.y,p.x/p.z,p.y/p.z); SePointOps_F64.transform(keyToCurr,p,p); if( p.z < 0 ) return Double.MAX_VALUE; error += errorCam2.errorSq(obs.p2.x,obs.p2.y, p.x/p.z , p.y/p.z); return error; }
java
@Override public double computeDistance(AssociatedPair obs) { // triangulate the point in 3D space triangulate.triangulate(obs.p1,obs.p2,keyToCurr,p); if( p.z < 0 ) return Double.MAX_VALUE; // compute observational error in each view double error = errorCam1.errorSq(obs.p1.x,obs.p1.y,p.x/p.z,p.y/p.z); SePointOps_F64.transform(keyToCurr,p,p); if( p.z < 0 ) return Double.MAX_VALUE; error += errorCam2.errorSq(obs.p2.x,obs.p2.y, p.x/p.z , p.y/p.z); return error; }
[ "@", "Override", "public", "double", "computeDistance", "(", "AssociatedPair", "obs", ")", "{", "// triangulate the point in 3D space", "triangulate", ".", "triangulate", "(", "obs", ".", "p1", ",", "obs", ".", "p2", ",", "keyToCurr", ",", "p", ")", ";", "if",...
Computes the error given the motion model @param obs Observation in normalized pixel coordinates @return observation error
[ "Computes", "the", "error", "given", "the", "motion", "model" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/robust/DistanceSe3SymmetricSq.java#L93-L112
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java
GImageDerivativeOps.getDerivativeType
public static <I extends ImageGray<I>, D extends ImageGray<D>> Class<D> getDerivativeType( Class<I> imageType ) { if( imageType == GrayF32.class ) { return (Class<D>) GrayF32.class; } else if( imageType == GrayU8.class ) { return (Class<D>) GrayS16.class; } else if( imageType == GrayU16.class ) { return (Class<D>) GrayS32.class; } else { throw new IllegalArgumentException("Unknown input image type: "+imageType.getSimpleName()); } }
java
public static <I extends ImageGray<I>, D extends ImageGray<D>> Class<D> getDerivativeType( Class<I> imageType ) { if( imageType == GrayF32.class ) { return (Class<D>) GrayF32.class; } else if( imageType == GrayU8.class ) { return (Class<D>) GrayS16.class; } else if( imageType == GrayU16.class ) { return (Class<D>) GrayS32.class; } else { throw new IllegalArgumentException("Unknown input image type: "+imageType.getSimpleName()); } }
[ "public", "static", "<", "I", "extends", "ImageGray", "<", "I", ">", ",", "D", "extends", "ImageGray", "<", "D", ">", ">", "Class", "<", "D", ">", "getDerivativeType", "(", "Class", "<", "I", ">", "imageType", ")", "{", "if", "(", "imageType", "==", ...
Returns the type of image the derivative should be for the specified input type. @param imageType Input image type. @return Appropriate output image type.
[ "Returns", "the", "type", "of", "image", "the", "derivative", "should", "be", "for", "the", "specified", "input", "type", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java#L57-L68
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java
GImageDerivativeOps.hessian
public static <I extends ImageGray<I>, D extends ImageGray<D>> void hessian( DerivativeType type , I input , D derivXX , D derivYY , D derivXY , BorderType borderType ) { ImageBorder<I> border = BorderType.SKIP == borderType ? null : FactoryImageBorder.wrap(borderType, input); switch( type ) { case SOBEL: if( input instanceof GrayF32) { HessianSobel.process((GrayF32) input, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( input instanceof GrayU8) { HessianSobel.process((GrayU8) input, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+input.getClass().getSimpleName()); } break; case THREE: if( input instanceof GrayF32) { HessianThree.process((GrayF32) input, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( input instanceof GrayU8) { HessianThree.process((GrayU8) input, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+input.getClass().getSimpleName()); } break; default: throw new IllegalArgumentException("Unsupported derivative type "+type); } }
java
public static <I extends ImageGray<I>, D extends ImageGray<D>> void hessian( DerivativeType type , I input , D derivXX , D derivYY , D derivXY , BorderType borderType ) { ImageBorder<I> border = BorderType.SKIP == borderType ? null : FactoryImageBorder.wrap(borderType, input); switch( type ) { case SOBEL: if( input instanceof GrayF32) { HessianSobel.process((GrayF32) input, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( input instanceof GrayU8) { HessianSobel.process((GrayU8) input, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+input.getClass().getSimpleName()); } break; case THREE: if( input instanceof GrayF32) { HessianThree.process((GrayF32) input, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( input instanceof GrayU8) { HessianThree.process((GrayU8) input, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+input.getClass().getSimpleName()); } break; default: throw new IllegalArgumentException("Unsupported derivative type "+type); } }
[ "public", "static", "<", "I", "extends", "ImageGray", "<", "I", ">", ",", "D", "extends", "ImageGray", "<", "D", ">", ">", "void", "hessian", "(", "DerivativeType", "type", ",", "I", "input", ",", "D", "derivXX", ",", "D", "derivYY", ",", "D", "deriv...
Computes the hessian from the original input image. Only Sobel and Three supported. @param type Type of gradient to compute @param input Input image @param derivXX Output. Derivative XX @param derivYY Output. Derivative YY @param derivXY Output. Derivative XY @param borderType How it should handle borders. null == skip border @param <I> Input image type @param <D> Output image type
[ "Computes", "the", "hessian", "from", "the", "original", "input", "image", ".", "Only", "Sobel", "and", "Three", "supported", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java#L181-L209
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java
GImageDerivativeOps.hessian
public static <D extends ImageGray<D>> void hessian( DerivativeType type , D derivX , D derivY , D derivXX , D derivYY , D derivXY , BorderType borderType ) { ImageBorder<D> border = BorderType.SKIP == borderType ? null : FactoryImageBorder.wrap(borderType, derivX); switch( type ) { case PREWITT: if( derivX instanceof GrayF32) { HessianFromGradient.hessianPrewitt((GrayF32) derivX, (GrayF32) derivY, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( derivX instanceof GrayS16) { HessianFromGradient.hessianPrewitt((GrayS16) derivX, (GrayS16) derivY, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+derivX.getClass().getSimpleName()); } break; case SOBEL: if( derivX instanceof GrayF32) { HessianFromGradient.hessianSobel((GrayF32) derivX, (GrayF32) derivY, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( derivX instanceof GrayS16) { HessianFromGradient.hessianSobel((GrayS16) derivX, (GrayS16) derivY, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+derivX.getClass().getSimpleName()); } break; case THREE: if( derivX instanceof GrayF32) { HessianFromGradient.hessianThree((GrayF32) derivX, (GrayF32) derivY, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( derivX instanceof GrayS16) { HessianFromGradient.hessianThree((GrayS16) derivX, (GrayS16) derivY, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+derivX.getClass().getSimpleName()); } break; default: throw new IllegalArgumentException("Unsupported derivative type "+type); } }
java
public static <D extends ImageGray<D>> void hessian( DerivativeType type , D derivX , D derivY , D derivXX , D derivYY , D derivXY , BorderType borderType ) { ImageBorder<D> border = BorderType.SKIP == borderType ? null : FactoryImageBorder.wrap(borderType, derivX); switch( type ) { case PREWITT: if( derivX instanceof GrayF32) { HessianFromGradient.hessianPrewitt((GrayF32) derivX, (GrayF32) derivY, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( derivX instanceof GrayS16) { HessianFromGradient.hessianPrewitt((GrayS16) derivX, (GrayS16) derivY, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+derivX.getClass().getSimpleName()); } break; case SOBEL: if( derivX instanceof GrayF32) { HessianFromGradient.hessianSobel((GrayF32) derivX, (GrayF32) derivY, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( derivX instanceof GrayS16) { HessianFromGradient.hessianSobel((GrayS16) derivX, (GrayS16) derivY, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+derivX.getClass().getSimpleName()); } break; case THREE: if( derivX instanceof GrayF32) { HessianFromGradient.hessianThree((GrayF32) derivX, (GrayF32) derivY, (GrayF32) derivXX, (GrayF32) derivYY, (GrayF32) derivXY, (ImageBorder_F32) border); } else if( derivX instanceof GrayS16) { HessianFromGradient.hessianThree((GrayS16) derivX, (GrayS16) derivY, (GrayS16) derivXX, (GrayS16) derivYY, (GrayS16) derivXY, (ImageBorder_S32) border); } else { throw new IllegalArgumentException("Unknown input image type: "+derivX.getClass().getSimpleName()); } break; default: throw new IllegalArgumentException("Unsupported derivative type "+type); } }
[ "public", "static", "<", "D", "extends", "ImageGray", "<", "D", ">", ">", "void", "hessian", "(", "DerivativeType", "type", ",", "D", "derivX", ",", "D", "derivY", ",", "D", "derivXX", ",", "D", "derivYY", ",", "D", "derivXY", ",", "BorderType", "borde...
Computes the hessian from the gradient. Only Prewitt, Sobel and Three supported. @param type Type of gradient to compute @param derivX Input derivative X @param derivY Input derivative Y @param derivXX Output. Derivative XX @param derivYY Output. Derivative YY @param derivXY Output. Derivative XY @param borderType How it should handle borders. null == skip border
[ "Computes", "the", "hessian", "from", "the", "gradient", ".", "Only", "Prewitt", "Sobel", "and", "Three", "supported", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java#L222-L260
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java
GImageDerivativeOps.lookupKernelX
public static KernelBase lookupKernelX( DerivativeType type , boolean isInteger) { switch( type ) { case PREWITT: return GradientPrewitt.getKernelX(isInteger); case SOBEL: return GradientSobel.getKernelX(isInteger); case THREE: return GradientThree.getKernelX(isInteger); case TWO_0: return GradientTwo0.getKernelX(isInteger); case TWO_1: return GradientTwo1.getKernelX(isInteger); } throw new IllegalArgumentException("Unknown kernel type: "+type); }
java
public static KernelBase lookupKernelX( DerivativeType type , boolean isInteger) { switch( type ) { case PREWITT: return GradientPrewitt.getKernelX(isInteger); case SOBEL: return GradientSobel.getKernelX(isInteger); case THREE: return GradientThree.getKernelX(isInteger); case TWO_0: return GradientTwo0.getKernelX(isInteger); case TWO_1: return GradientTwo1.getKernelX(isInteger); } throw new IllegalArgumentException("Unknown kernel type: "+type); }
[ "public", "static", "KernelBase", "lookupKernelX", "(", "DerivativeType", "type", ",", "boolean", "isInteger", ")", "{", "switch", "(", "type", ")", "{", "case", "PREWITT", ":", "return", "GradientPrewitt", ".", "getKernelX", "(", "isInteger", ")", ";", "case"...
Returns the kernel for finding the X derivative. @param type Type of gradient @param isInteger integer or floating point kernels @return The kernel. Can be 1D or 2D
[ "Returns", "the", "kernel", "for", "finding", "the", "X", "derivative", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GImageDerivativeOps.java#L268-L287
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/KeyPointsCircleHexagonalGrid.java
KeyPointsCircleHexagonalGrid.computeEllipseCenters
boolean computeEllipseCenters() { keypoints.reset(); for (int tangentIdx = 0; tangentIdx < tangents.size(); tangentIdx++) { // System.out.println("tangent id "+tangentIdx); Tangents t = tangents.get(tangentIdx); Point2D_F64 center = keypoints.grow(); center.set(0,0); double totalWeight = 0; for (int i = 0; i < t.size(); i += 2) { UtilLine2D_F64.convert(t.get(i),t.get(i+1),lineA); for (int j = i+2; j < t.size(); j += 2) { UtilLine2D_F64.convert(t.get(j),t.get(j+1),lineB); // way each intersection based on the acute angle. lines which are nearly parallel will // be unstable estimates double w = UtilVector2D_F64.acute(lineA.A,lineA.B,lineB.A,lineB.B); if( w > Math.PI/2.0 ) w = Math.PI-w; // If there is perfect data and no noise there will be duplicated lines. With noise there will // be very similar lines if( w <= 0.02 ) continue; if( null == Intersection2D_F64.intersection(lineA,lineB, location) ) { return false; } // System.out.printf(" %4.2f loc %6.2f %6.2f\n",w,location.x,location.y); center.x += location.x*w; center.y += location.y*w; totalWeight += w; } } if( totalWeight == 0 ) return false; center.x /= totalWeight; center.y /= totalWeight; } return true; }
java
boolean computeEllipseCenters() { keypoints.reset(); for (int tangentIdx = 0; tangentIdx < tangents.size(); tangentIdx++) { // System.out.println("tangent id "+tangentIdx); Tangents t = tangents.get(tangentIdx); Point2D_F64 center = keypoints.grow(); center.set(0,0); double totalWeight = 0; for (int i = 0; i < t.size(); i += 2) { UtilLine2D_F64.convert(t.get(i),t.get(i+1),lineA); for (int j = i+2; j < t.size(); j += 2) { UtilLine2D_F64.convert(t.get(j),t.get(j+1),lineB); // way each intersection based on the acute angle. lines which are nearly parallel will // be unstable estimates double w = UtilVector2D_F64.acute(lineA.A,lineA.B,lineB.A,lineB.B); if( w > Math.PI/2.0 ) w = Math.PI-w; // If there is perfect data and no noise there will be duplicated lines. With noise there will // be very similar lines if( w <= 0.02 ) continue; if( null == Intersection2D_F64.intersection(lineA,lineB, location) ) { return false; } // System.out.printf(" %4.2f loc %6.2f %6.2f\n",w,location.x,location.y); center.x += location.x*w; center.y += location.y*w; totalWeight += w; } } if( totalWeight == 0 ) return false; center.x /= totalWeight; center.y /= totalWeight; } return true; }
[ "boolean", "computeEllipseCenters", "(", ")", "{", "keypoints", ".", "reset", "(", ")", ";", "for", "(", "int", "tangentIdx", "=", "0", ";", "tangentIdx", "<", "tangents", ".", "size", "(", ")", ";", "tangentIdx", "++", ")", "{", "//\t\t\tSystem.out.printl...
Finds the intersection of all the tangent lines with each other the computes the average of those points. That location is where the center is set to. Each intersection of lines is weighted by the acute angle. lines which are 90 degrees to each other are less sensitive to noise
[ "Finds", "the", "intersection", "of", "all", "the", "tangent", "lines", "with", "each", "other", "the", "computes", "the", "average", "of", "those", "points", ".", "That", "location", "is", "where", "the", "center", "is", "set", "to", ".", "Each", "interse...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/KeyPointsCircleHexagonalGrid.java#L190-L237
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java
Planar.getBand
public T getBand(int band) { if (band >= bands.length || band < 0) throw new IllegalArgumentException("The specified band is out of bounds: "+band); return bands[band]; }
java
public T getBand(int band) { if (band >= bands.length || band < 0) throw new IllegalArgumentException("The specified band is out of bounds: "+band); return bands[band]; }
[ "public", "T", "getBand", "(", "int", "band", ")", "{", "if", "(", "band", ">=", "bands", ".", "length", "||", "band", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"The specified band is out of bounds: \"", "+", "band", ")", ";", "return...
Returns a band in the multi-band image. @param band Which band should be returned. @return Image band
[ "Returns", "a", "band", "in", "the", "multi", "-", "band", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java#L132-L137
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java
Planar.setTo
@Override public void setTo( Planar<T> orig) { if (orig.width != width || orig.height != height) reshape(orig.width,orig.height); if( orig.getBandType() != getBandType() ) throw new IllegalArgumentException("The band type must be the same"); int N = orig.getNumBands(); if( N != getNumBands() ) { setNumberOfBands(orig.getNumBands()); } for( int i = 0; i < N; i++ ) { bands[i].setTo(orig.getBand(i)); } }
java
@Override public void setTo( Planar<T> orig) { if (orig.width != width || orig.height != height) reshape(orig.width,orig.height); if( orig.getBandType() != getBandType() ) throw new IllegalArgumentException("The band type must be the same"); int N = orig.getNumBands(); if( N != getNumBands() ) { setNumberOfBands(orig.getNumBands()); } for( int i = 0; i < N; i++ ) { bands[i].setTo(orig.getBand(i)); } }
[ "@", "Override", "public", "void", "setTo", "(", "Planar", "<", "T", ">", "orig", ")", "{", "if", "(", "orig", ".", "width", "!=", "width", "||", "orig", ".", "height", "!=", "height", ")", "reshape", "(", "orig", ".", "width", ",", "orig", ".", ...
Sets the values of each pixel equal to the pixels in the specified matrix. Automatically resized to match the input image. @param orig The original image whose value is to be copied into this one
[ "Sets", "the", "values", "of", "each", "pixel", "equal", "to", "the", "pixels", "in", "the", "specified", "matrix", ".", "Automatically", "resized", "to", "match", "the", "input", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java#L181-L196
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java
Planar.createNew
@Override public Planar<T> createNew(int imgWidth, int imgHeight) { return new Planar<>(type, imgWidth, imgHeight, bands.length); }
java
@Override public Planar<T> createNew(int imgWidth, int imgHeight) { return new Planar<>(type, imgWidth, imgHeight, bands.length); }
[ "@", "Override", "public", "Planar", "<", "T", ">", "createNew", "(", "int", "imgWidth", ",", "int", "imgHeight", ")", "{", "return", "new", "Planar", "<>", "(", "type", ",", "imgWidth", ",", "imgHeight", ",", "bands", ".", "length", ")", ";", "}" ]
Creates a new image of the same type and number of bands @param imgWidth image width @param imgHeight image height @return new image
[ "Creates", "a", "new", "image", "of", "the", "same", "type", "and", "number", "of", "bands" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java#L255-L258
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java
Planar.reorderBands
public void reorderBands( int ...order ) { T[] bands = (T[]) Array.newInstance(type, order.length); for (int i = 0; i < order.length; i++) { bands[i] = this.bands[order[i]]; } this.bands = bands; }
java
public void reorderBands( int ...order ) { T[] bands = (T[]) Array.newInstance(type, order.length); for (int i = 0; i < order.length; i++) { bands[i] = this.bands[order[i]]; } this.bands = bands; }
[ "public", "void", "reorderBands", "(", "int", "...", "order", ")", "{", "T", "[", "]", "bands", "=", "(", "T", "[", "]", ")", "Array", ".", "newInstance", "(", "type", ",", "order", ".", "length", ")", ";", "for", "(", "int", "i", "=", "0", ";"...
Changes the bands order @param order The new band order
[ "Changes", "the", "bands", "order" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java#L284-L291
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java
Planar.setNumberOfBands
@Override public void setNumberOfBands( int numberOfBands ) { if( numberOfBands == this.bands.length ) return; T[] bands = (T[]) Array.newInstance(type, numberOfBands); int N = Math.min(numberOfBands, this.bands.length ); for (int i = 0; i < N; i++) { bands[i] = this.bands[i]; } for (int i = N; i < bands.length; i++) { bands[i] = GeneralizedImageOps.createSingleBand(type, width, height); } this.bands = bands; }
java
@Override public void setNumberOfBands( int numberOfBands ) { if( numberOfBands == this.bands.length ) return; T[] bands = (T[]) Array.newInstance(type, numberOfBands); int N = Math.min(numberOfBands, this.bands.length ); for (int i = 0; i < N; i++) { bands[i] = this.bands[i]; } for (int i = N; i < bands.length; i++) { bands[i] = GeneralizedImageOps.createSingleBand(type, width, height); } this.bands = bands; }
[ "@", "Override", "public", "void", "setNumberOfBands", "(", "int", "numberOfBands", ")", "{", "if", "(", "numberOfBands", "==", "this", ".", "bands", ".", "length", ")", "return", ";", "T", "[", "]", "bands", "=", "(", "T", "[", "]", ")", "Array", "....
Changes the number of bands in the image. A new array is declared and individual bands are recycled if possible @param numberOfBands New number of bands in the image.
[ "Changes", "the", "number", "of", "bands", "in", "the", "image", ".", "A", "new", "array", "is", "declared", "and", "individual", "bands", "are", "recycled", "if", "possible" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/Planar.java#L298-L312
train
lessthanoptimal/BoofCV
main/boofcv-learning/src/main/java/boofcv/struct/learning/Confusion.java
Confusion.computeAccuracy
public double computeAccuracy() { double totalCorrect = 0; double totalIncorrect = 0; for (int i = 0; i < actualCounts.length; i++) { for (int j = 0; j < actualCounts.length; j++) { if( i == j ) { totalCorrect += matrix.get(i,j); } else { totalIncorrect += matrix.get(i,j); } } } return totalCorrect/(totalCorrect+totalIncorrect); }
java
public double computeAccuracy() { double totalCorrect = 0; double totalIncorrect = 0; for (int i = 0; i < actualCounts.length; i++) { for (int j = 0; j < actualCounts.length; j++) { if( i == j ) { totalCorrect += matrix.get(i,j); } else { totalIncorrect += matrix.get(i,j); } } } return totalCorrect/(totalCorrect+totalIncorrect); }
[ "public", "double", "computeAccuracy", "(", ")", "{", "double", "totalCorrect", "=", "0", ";", "double", "totalIncorrect", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "actualCounts", ".", "length", ";", "i", "++", ")", "{", "for",...
Computes accuracy from the confusion matrix. This is the sum of the fraction correct divide by total number of types. The number of each sample for each type is not taken in account. @return overall accuracy
[ "Computes", "accuracy", "from", "the", "confusion", "matrix", ".", "This", "is", "the", "sum", "of", "the", "fraction", "correct", "divide", "by", "total", "number", "of", "types", ".", "The", "number", "of", "each", "sample", "for", "each", "type", "is", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-learning/src/main/java/boofcv/struct/learning/Confusion.java#L48-L63
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/abst/geo/calibration/CalibrateMonoPlanar.java
CalibrateMonoPlanar.addImage
public void addImage( CalibrationObservation observation ) { if( imageWidth == 0 ) { this.imageWidth = observation.getWidth(); this.imageHeight = observation.getHeight(); } else if( observation.getWidth() != this.imageWidth || observation.getHeight() != this.imageHeight) { throw new IllegalArgumentException("Image shape miss match"); } observations.add( observation ); }
java
public void addImage( CalibrationObservation observation ) { if( imageWidth == 0 ) { this.imageWidth = observation.getWidth(); this.imageHeight = observation.getHeight(); } else if( observation.getWidth() != this.imageWidth || observation.getHeight() != this.imageHeight) { throw new IllegalArgumentException("Image shape miss match"); } observations.add( observation ); }
[ "public", "void", "addImage", "(", "CalibrationObservation", "observation", ")", "{", "if", "(", "imageWidth", "==", "0", ")", "{", "this", ".", "imageWidth", "=", "observation", ".", "getWidth", "(", ")", ";", "this", ".", "imageHeight", "=", "observation",...
Adds the observations from a calibration target detector @param observation Detected calibration points
[ "Adds", "the", "observations", "from", "a", "calibration", "target", "detector" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/abst/geo/calibration/CalibrateMonoPlanar.java#L139-L147
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/abst/geo/calibration/CalibrateMonoPlanar.java
CalibrateMonoPlanar.process
public <T extends CameraModel>T process() { if( zhang99 == null ) throw new IllegalArgumentException("Please call configure first."); zhang99.setVerbose(verbose,0); if( !zhang99.process(observations) ) { throw new RuntimeException("Zhang99 algorithm failed!"); } structure = zhang99.getStructure(); errors = zhang99.computeErrors(); foundIntrinsic = zhang99.getCameraModel(); foundIntrinsic.width = imageWidth; foundIntrinsic.height = imageHeight; return (T)foundIntrinsic; }
java
public <T extends CameraModel>T process() { if( zhang99 == null ) throw new IllegalArgumentException("Please call configure first."); zhang99.setVerbose(verbose,0); if( !zhang99.process(observations) ) { throw new RuntimeException("Zhang99 algorithm failed!"); } structure = zhang99.getStructure(); errors = zhang99.computeErrors(); foundIntrinsic = zhang99.getCameraModel(); foundIntrinsic.width = imageWidth; foundIntrinsic.height = imageHeight; return (T)foundIntrinsic; }
[ "public", "<", "T", "extends", "CameraModel", ">", "T", "process", "(", ")", "{", "if", "(", "zhang99", "==", "null", ")", "throw", "new", "IllegalArgumentException", "(", "\"Please call configure first.\"", ")", ";", "zhang99", ".", "setVerbose", "(", "verbos...
After calibration points have been found this invokes the Zhang99 algorithm to estimate calibration parameters. Error statistics are also computed.
[ "After", "calibration", "points", "have", "been", "found", "this", "invokes", "the", "Zhang99", "algorithm", "to", "estimate", "calibration", "parameters", ".", "Error", "statistics", "are", "also", "computed", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/abst/geo/calibration/CalibrateMonoPlanar.java#L160-L177
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/abst/geo/calibration/CalibrateMonoPlanar.java
CalibrateMonoPlanar.printErrors
public static void printErrors( List<ImageResults> results ) { double totalError = 0; for( int i = 0; i < results.size(); i++ ) { ImageResults r = results.get(i); totalError += r.meanError; System.out.printf("image %3d Euclidean ( mean = %7.1e max = %7.1e ) bias ( X = %8.1e Y %8.1e )\n",i,r.meanError,r.maxError,r.biasX,r.biasY); } System.out.println("Average Mean Error = "+(totalError/results.size())); }
java
public static void printErrors( List<ImageResults> results ) { double totalError = 0; for( int i = 0; i < results.size(); i++ ) { ImageResults r = results.get(i); totalError += r.meanError; System.out.printf("image %3d Euclidean ( mean = %7.1e max = %7.1e ) bias ( X = %8.1e Y %8.1e )\n",i,r.meanError,r.maxError,r.biasX,r.biasY); } System.out.println("Average Mean Error = "+(totalError/results.size())); }
[ "public", "static", "void", "printErrors", "(", "List", "<", "ImageResults", ">", "results", ")", "{", "double", "totalError", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "results", ".", "size", "(", ")", ";", "i", "++", ")", ...
Prints out error information to standard out
[ "Prints", "out", "error", "information", "to", "standard", "out" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/abst/geo/calibration/CalibrateMonoPlanar.java#L189-L198
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/learning/ConfusionMatrixPanel.java
ConfusionMatrixPanel.renderLabels
private void renderLabels(Graphics2D g2, double fontSize) { int numCategories = confusion.getNumRows(); int longestLabel = 0; if(renderLabels) { for (int i = 0; i < numCategories; i++) { longestLabel = Math.max(longestLabel,labels.get(i).length()); } } Font fontLabel = new Font("monospaced", Font.BOLD, (int)(0.055*longestLabel*fontSize + 0.5)); g2.setFont(fontLabel); FontMetrics metrics = g2.getFontMetrics(fontLabel); // clear the background g2.setColor(Color.WHITE); g2.fillRect(gridWidth,0,viewWidth-gridWidth,viewHeight); // draw the text g2.setColor(Color.BLACK); for (int i = 0; i < numCategories; i++) { String label = labels.get(i); int y0 = i * gridHeight / numCategories; int y1 = (i + 1) * gridHeight / numCategories; Rectangle2D r = metrics.getStringBounds(label,null); float adjX = (float)(r.getX()*2 + r.getWidth())/2.0f; float adjY = (float)(r.getY()*2 + r.getHeight())/2.0f; float x = ((viewWidth+gridWidth)/2f-adjX); float y = ((y1+y0)/2f-adjY); g2.drawString(label, x, y); } }
java
private void renderLabels(Graphics2D g2, double fontSize) { int numCategories = confusion.getNumRows(); int longestLabel = 0; if(renderLabels) { for (int i = 0; i < numCategories; i++) { longestLabel = Math.max(longestLabel,labels.get(i).length()); } } Font fontLabel = new Font("monospaced", Font.BOLD, (int)(0.055*longestLabel*fontSize + 0.5)); g2.setFont(fontLabel); FontMetrics metrics = g2.getFontMetrics(fontLabel); // clear the background g2.setColor(Color.WHITE); g2.fillRect(gridWidth,0,viewWidth-gridWidth,viewHeight); // draw the text g2.setColor(Color.BLACK); for (int i = 0; i < numCategories; i++) { String label = labels.get(i); int y0 = i * gridHeight / numCategories; int y1 = (i + 1) * gridHeight / numCategories; Rectangle2D r = metrics.getStringBounds(label,null); float adjX = (float)(r.getX()*2 + r.getWidth())/2.0f; float adjY = (float)(r.getY()*2 + r.getHeight())/2.0f; float x = ((viewWidth+gridWidth)/2f-adjX); float y = ((y1+y0)/2f-adjY); g2.drawString(label, x, y); } }
[ "private", "void", "renderLabels", "(", "Graphics2D", "g2", ",", "double", "fontSize", ")", "{", "int", "numCategories", "=", "confusion", ".", "getNumRows", "(", ")", ";", "int", "longestLabel", "=", "0", ";", "if", "(", "renderLabels", ")", "{", "for", ...
Renders the names on each category to the side of the confusion matrix
[ "Renders", "the", "names", "on", "each", "category", "to", "the", "side", "of", "the", "confusion", "matrix" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/learning/ConfusionMatrixPanel.java#L200-L236
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/learning/ConfusionMatrixPanel.java
ConfusionMatrixPanel.renderMatrix
private void renderMatrix(Graphics2D g2, double fontSize) { int numCategories = confusion.getNumRows(); Font fontNumber = new Font("Serif", Font.BOLD, (int)(0.6*fontSize + 0.5)); g2.setFont(fontNumber); FontMetrics metrics = g2.getFontMetrics(fontNumber); for (int i = 0; i < numCategories; i++) { int y0 = i*gridHeight/numCategories; int y1 = (i+1)*gridHeight/numCategories; for (int j = 0; j < numCategories; j++) { int x0 = j*gridWidth/numCategories; int x1 = (j+1)*gridWidth/numCategories; double value = confusion.unsafe_get(i,j); int red,green,blue; if( gray ) { red = green = blue = (int)(255*(1.0-value)); } else { green = 0; red = (int)(255*value); blue = (int)(255*(1.0-value)); } g2.setColor(new Color(red, green, blue)); g2.fillRect(x0,y0,x1-x0,y1-y0); // Render numbers inside the squares. Pick a color so that the number is visible no matter what // the color of the square is if( showNumbers && (showZeros || value != 0 )) { int a = (red+green+blue)/3; String text = ""+(int)(value*100.0+0.5); Rectangle2D r = metrics.getStringBounds(text,null); float adjX = (float)(r.getX()*2 + r.getWidth())/2.0f; float adjY = (float)(r.getY()*2 + r.getHeight())/2.0f; float x = ((x1+x0)/2f-adjX); float y = ((y1+y0)/2f-adjY); int gray = a > 127 ? 0 : 255; g2.setColor(new Color(gray,gray,gray)); g2.drawString(text,x,y); } } } }
java
private void renderMatrix(Graphics2D g2, double fontSize) { int numCategories = confusion.getNumRows(); Font fontNumber = new Font("Serif", Font.BOLD, (int)(0.6*fontSize + 0.5)); g2.setFont(fontNumber); FontMetrics metrics = g2.getFontMetrics(fontNumber); for (int i = 0; i < numCategories; i++) { int y0 = i*gridHeight/numCategories; int y1 = (i+1)*gridHeight/numCategories; for (int j = 0; j < numCategories; j++) { int x0 = j*gridWidth/numCategories; int x1 = (j+1)*gridWidth/numCategories; double value = confusion.unsafe_get(i,j); int red,green,blue; if( gray ) { red = green = blue = (int)(255*(1.0-value)); } else { green = 0; red = (int)(255*value); blue = (int)(255*(1.0-value)); } g2.setColor(new Color(red, green, blue)); g2.fillRect(x0,y0,x1-x0,y1-y0); // Render numbers inside the squares. Pick a color so that the number is visible no matter what // the color of the square is if( showNumbers && (showZeros || value != 0 )) { int a = (red+green+blue)/3; String text = ""+(int)(value*100.0+0.5); Rectangle2D r = metrics.getStringBounds(text,null); float adjX = (float)(r.getX()*2 + r.getWidth())/2.0f; float adjY = (float)(r.getY()*2 + r.getHeight())/2.0f; float x = ((x1+x0)/2f-adjX); float y = ((y1+y0)/2f-adjY); int gray = a > 127 ? 0 : 255; g2.setColor(new Color(gray,gray,gray)); g2.drawString(text,x,y); } } } }
[ "private", "void", "renderMatrix", "(", "Graphics2D", "g2", ",", "double", "fontSize", ")", "{", "int", "numCategories", "=", "confusion", ".", "getNumRows", "(", ")", ";", "Font", "fontNumber", "=", "new", "Font", "(", "\"Serif\"", ",", "Font", ".", "BOLD...
Renders the confusion matrix and visualizes the value in each cell with a color and optionally a color.
[ "Renders", "the", "confusion", "matrix", "and", "visualizes", "the", "value", "in", "each", "cell", "with", "a", "color", "and", "optionally", "a", "color", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/learning/ConfusionMatrixPanel.java#L241-L290
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/learning/ConfusionMatrixPanel.java
ConfusionMatrixPanel.whatIsAtPoint
public LocationInfo whatIsAtPoint( int pixelX , int pixelY , LocationInfo output ) { if( output == null ) output = new LocationInfo(); int numCategories = confusion.getNumRows(); synchronized ( this ) { if( pixelX >= gridWidth ) { output.insideMatrix = false; output.col = output.row = pixelY*numCategories/gridHeight; } else { output.insideMatrix = true; output.row = pixelY*numCategories/gridHeight; output.col = pixelX*numCategories/gridWidth; } } return output; }
java
public LocationInfo whatIsAtPoint( int pixelX , int pixelY , LocationInfo output ) { if( output == null ) output = new LocationInfo(); int numCategories = confusion.getNumRows(); synchronized ( this ) { if( pixelX >= gridWidth ) { output.insideMatrix = false; output.col = output.row = pixelY*numCategories/gridHeight; } else { output.insideMatrix = true; output.row = pixelY*numCategories/gridHeight; output.col = pixelX*numCategories/gridWidth; } } return output; }
[ "public", "LocationInfo", "whatIsAtPoint", "(", "int", "pixelX", ",", "int", "pixelY", ",", "LocationInfo", "output", ")", "{", "if", "(", "output", "==", "null", ")", "output", "=", "new", "LocationInfo", "(", ")", ";", "int", "numCategories", "=", "confu...
Use to sample the panel to see what is being displayed at the location clicked. All coordinates are in panel coordinates. @param pixelX x-axis in panel coordinates @param pixelY y-axis in panel coordinates @param output (Optional) storage for output. @return Information on what is at the specified location
[ "Use", "to", "sample", "the", "panel", "to", "see", "what", "is", "being", "displayed", "at", "the", "location", "clicked", ".", "All", "coordinates", "are", "in", "panel", "coordinates", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/learning/ConfusionMatrixPanel.java#L301-L319
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java
StitchingFromMotion2D.configure
public void configure( int widthStitch, int heightStitch , IT worldToInit ) { this.worldToInit = (IT)worldToCurr.createInstance(); if( worldToInit != null ) this.worldToInit.set(worldToInit); this.widthStitch = widthStitch; this.heightStitch = heightStitch; }
java
public void configure( int widthStitch, int heightStitch , IT worldToInit ) { this.worldToInit = (IT)worldToCurr.createInstance(); if( worldToInit != null ) this.worldToInit.set(worldToInit); this.widthStitch = widthStitch; this.heightStitch = heightStitch; }
[ "public", "void", "configure", "(", "int", "widthStitch", ",", "int", "heightStitch", ",", "IT", "worldToInit", ")", "{", "this", ".", "worldToInit", "=", "(", "IT", ")", "worldToCurr", ".", "createInstance", "(", ")", ";", "if", "(", "worldToInit", "!=", ...
Specifies size of stitch image and the location of the initial coordinate system. @param widthStitch Width of the image being stitched into @param heightStitch Height of the image being stitched into @param worldToInit (Option) Used to change the location of the initial frame in stitched image. null means no transform.
[ "Specifies", "size", "of", "stitch", "image", "and", "the", "location", "of", "the", "initial", "coordinate", "system", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java#L120-L126
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java
StitchingFromMotion2D.reset
public void reset() { if( stitchedImage != null ) GImageMiscOps.fill(stitchedImage, 0); motion.reset(); worldToCurr.reset(); first = true; }
java
public void reset() { if( stitchedImage != null ) GImageMiscOps.fill(stitchedImage, 0); motion.reset(); worldToCurr.reset(); first = true; }
[ "public", "void", "reset", "(", ")", "{", "if", "(", "stitchedImage", "!=", "null", ")", "GImageMiscOps", ".", "fill", "(", "stitchedImage", ",", "0", ")", ";", "motion", ".", "reset", "(", ")", ";", "worldToCurr", ".", "reset", "(", ")", ";", "first...
Throws away current results and starts over again
[ "Throws", "away", "current", "results", "and", "starts", "over", "again" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java#L155-L161
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java
StitchingFromMotion2D.checkLargeMotion
private boolean checkLargeMotion( int width , int height ) { if( first ) { getImageCorners(width,height,corners); previousArea = computeArea(corners); first = false; } else { getImageCorners(width,height,corners); double area = computeArea(corners); double change = Math.max(area/previousArea,previousArea/area)-1; if( change > maxJumpFraction ) { return true; } previousArea = area; } return false; }
java
private boolean checkLargeMotion( int width , int height ) { if( first ) { getImageCorners(width,height,corners); previousArea = computeArea(corners); first = false; } else { getImageCorners(width,height,corners); double area = computeArea(corners); double change = Math.max(area/previousArea,previousArea/area)-1; if( change > maxJumpFraction ) { return true; } previousArea = area; } return false; }
[ "private", "boolean", "checkLargeMotion", "(", "int", "width", ",", "int", "height", ")", "{", "if", "(", "first", ")", "{", "getImageCorners", "(", "width", ",", "height", ",", "corners", ")", ";", "previousArea", "=", "computeArea", "(", "corners", ")", ...
Looks for sudden large changes in corner location to detect motion estimation faults. @param width image width @param height image height @return true for fault
[ "Looks", "for", "sudden", "large", "changes", "in", "corner", "location", "to", "detect", "motion", "estimation", "faults", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java#L169-L188
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java
StitchingFromMotion2D.update
private void update(I image) { computeCurrToInit_PixelTran(); // only process a cropped portion to speed up processing RectangleLength2D_I32 box = DistortImageOps.boundBox(image.width, image.height, stitchedImage.width, stitchedImage.height,work, tranCurrToWorld); int x0 = box.x0; int y0 = box.y0; int x1 = box.x0 + box.width; int y1 = box.y0 + box.height; distorter.setModel(tranWorldToCurr); distorter.apply(image, stitchedImage,x0,y0,x1,y1); }
java
private void update(I image) { computeCurrToInit_PixelTran(); // only process a cropped portion to speed up processing RectangleLength2D_I32 box = DistortImageOps.boundBox(image.width, image.height, stitchedImage.width, stitchedImage.height,work, tranCurrToWorld); int x0 = box.x0; int y0 = box.y0; int x1 = box.x0 + box.width; int y1 = box.y0 + box.height; distorter.setModel(tranWorldToCurr); distorter.apply(image, stitchedImage,x0,y0,x1,y1); }
[ "private", "void", "update", "(", "I", "image", ")", "{", "computeCurrToInit_PixelTran", "(", ")", ";", "// only process a cropped portion to speed up processing", "RectangleLength2D_I32", "box", "=", "DistortImageOps", ".", "boundBox", "(", "image", ".", "width", ",", ...
Adds the latest image into the stitched image @param image
[ "Adds", "the", "latest", "image", "into", "the", "stitched", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java#L200-L214
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java
StitchingFromMotion2D.resizeStitchImage
public void resizeStitchImage( int widthStitch, int heightStitch , IT newToOldStitch ) { // copy the old image into the new one workImage.reshape(widthStitch,heightStitch); GImageMiscOps.fill(workImage, 0); if( newToOldStitch != null ) { PixelTransform<Point2D_F32> newToOld = converter.convertPixel(newToOldStitch,null); distorter.setModel(newToOld); distorter.apply(stitchedImage, workImage); // update the transforms IT tmp = (IT)worldToCurr.createInstance(); newToOldStitch.concat(worldToInit, tmp); worldToInit.set(tmp); computeCurrToInit_PixelTran(); } else { int overlapWidth = Math.min(widthStitch,stitchedImage.width); int overlapHeight = Math.min(heightStitch,stitchedImage.height); GImageMiscOps.copy(0,0,0,0,overlapWidth,overlapHeight,stitchedImage,workImage); } stitchedImage.reshape(widthStitch,heightStitch); I tmp = stitchedImage; stitchedImage = workImage; workImage = tmp; this.widthStitch = widthStitch; this.heightStitch = heightStitch; }
java
public void resizeStitchImage( int widthStitch, int heightStitch , IT newToOldStitch ) { // copy the old image into the new one workImage.reshape(widthStitch,heightStitch); GImageMiscOps.fill(workImage, 0); if( newToOldStitch != null ) { PixelTransform<Point2D_F32> newToOld = converter.convertPixel(newToOldStitch,null); distorter.setModel(newToOld); distorter.apply(stitchedImage, workImage); // update the transforms IT tmp = (IT)worldToCurr.createInstance(); newToOldStitch.concat(worldToInit, tmp); worldToInit.set(tmp); computeCurrToInit_PixelTran(); } else { int overlapWidth = Math.min(widthStitch,stitchedImage.width); int overlapHeight = Math.min(heightStitch,stitchedImage.height); GImageMiscOps.copy(0,0,0,0,overlapWidth,overlapHeight,stitchedImage,workImage); } stitchedImage.reshape(widthStitch,heightStitch); I tmp = stitchedImage; stitchedImage = workImage; workImage = tmp; this.widthStitch = widthStitch; this.heightStitch = heightStitch; }
[ "public", "void", "resizeStitchImage", "(", "int", "widthStitch", ",", "int", "heightStitch", ",", "IT", "newToOldStitch", ")", "{", "// copy the old image into the new one", "workImage", ".", "reshape", "(", "widthStitch", ",", "heightStitch", ")", ";", "GImageMiscOp...
Resizes the stitch image. If no transform is provided then the old stitch region is simply places on top of the new one and copied. Pixels which do not exist in the old image are filled with zero. @param widthStitch The new width of the stitch image. @param heightStitch The new height of the stitch image. @param newToOldStitch (Optional) Transform from new stitch image pixels to old stick pixels. Can be null.
[ "Resizes", "the", "stitch", "image", ".", "If", "no", "transform", "is", "provided", "then", "the", "old", "stitch", "region", "is", "simply", "places", "on", "top", "of", "the", "new", "one", "and", "copied", ".", "Pixels", "which", "do", "not", "exist"...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java#L264-L292
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java
StitchingFromMotion2D.getImageCorners
public Corners getImageCorners( int width , int height , Corners corners ) { if( corners == null ) corners = new Corners(); int w = width; int h = height; tranCurrToWorld.compute(0,0,work); corners.p0.set(work.x, work.y); tranCurrToWorld.compute(w,0,work); corners.p1.set(work.x, work.y); tranCurrToWorld.compute(w,h,work); corners.p2.set(work.x, work.y); tranCurrToWorld.compute(0,h,work); corners.p3.set(work.x, work.y); return corners; }
java
public Corners getImageCorners( int width , int height , Corners corners ) { if( corners == null ) corners = new Corners(); int w = width; int h = height; tranCurrToWorld.compute(0,0,work); corners.p0.set(work.x, work.y); tranCurrToWorld.compute(w,0,work); corners.p1.set(work.x, work.y); tranCurrToWorld.compute(w,h,work); corners.p2.set(work.x, work.y); tranCurrToWorld.compute(0,h,work); corners.p3.set(work.x, work.y); return corners; }
[ "public", "Corners", "getImageCorners", "(", "int", "width", ",", "int", "height", ",", "Corners", "corners", ")", "{", "if", "(", "corners", "==", "null", ")", "corners", "=", "new", "Corners", "(", ")", ";", "int", "w", "=", "width", ";", "int", "h...
Returns the location of the input image's corners inside the stitch image. @return image corners
[ "Returns", "the", "location", "of", "the", "input", "image", "s", "corners", "inside", "the", "stitch", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/StitchingFromMotion2D.java#L299-L313
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalAlgebraicPoint7.java
TrifocalAlgebraicPoint7.minimizeWithGeometricConstraints
private void minimizeWithGeometricConstraints() { extractEpipoles.setTensor(solutionN); extractEpipoles.extractEpipoles(e2,e3); // encode the parameters being optimized param[0] = e2.x; param[1] = e2.y; param[2] = e2.z; param[3] = e3.x; param[4] = e3.y; param[5] = e3.z; // adjust the error function for the current inputs errorFunction.init(); // set up the optimization algorithm optimizer.setFunction(errorFunction,null); optimizer.initialize(param,gtol,ftol); // optimize until convergence or the maximum number of iterations UtilOptimize.process(optimizer, maxIterations); // get the results and compute the trifocal tensor double found[] = optimizer.getParameters(); paramToEpipoles(found,e2,e3); enforce.process(e2,e3,A); enforce.extractSolution(solutionN); }
java
private void minimizeWithGeometricConstraints() { extractEpipoles.setTensor(solutionN); extractEpipoles.extractEpipoles(e2,e3); // encode the parameters being optimized param[0] = e2.x; param[1] = e2.y; param[2] = e2.z; param[3] = e3.x; param[4] = e3.y; param[5] = e3.z; // adjust the error function for the current inputs errorFunction.init(); // set up the optimization algorithm optimizer.setFunction(errorFunction,null); optimizer.initialize(param,gtol,ftol); // optimize until convergence or the maximum number of iterations UtilOptimize.process(optimizer, maxIterations); // get the results and compute the trifocal tensor double found[] = optimizer.getParameters(); paramToEpipoles(found,e2,e3); enforce.process(e2,e3,A); enforce.extractSolution(solutionN); }
[ "private", "void", "minimizeWithGeometricConstraints", "(", ")", "{", "extractEpipoles", ".", "setTensor", "(", "solutionN", ")", ";", "extractEpipoles", ".", "extractEpipoles", "(", "e2", ",", "e3", ")", ";", "// encode the parameters being optimized", "param", "[", ...
Minimize the algebraic error using LM. The two epipoles are the parameters being optimized.
[ "Minimize", "the", "algebraic", "error", "using", "LM", ".", "The", "two", "epipoles", "are", "the", "parameters", "being", "optimized", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalAlgebraicPoint7.java#L103-L127
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/PositiveDepthConstraintCheck.java
PositiveDepthConstraintCheck.checkConstraint
public boolean checkConstraint( Point2D_F64 viewA , Point2D_F64 viewB , Se3_F64 fromAtoB ) { triangulate.triangulate(viewA,viewB,fromAtoB,P); if( P.z > 0 ) { SePointOps_F64.transform(fromAtoB,P,P); return P.z > 0; } return false; }
java
public boolean checkConstraint( Point2D_F64 viewA , Point2D_F64 viewB , Se3_F64 fromAtoB ) { triangulate.triangulate(viewA,viewB,fromAtoB,P); if( P.z > 0 ) { SePointOps_F64.transform(fromAtoB,P,P); return P.z > 0; } return false; }
[ "public", "boolean", "checkConstraint", "(", "Point2D_F64", "viewA", ",", "Point2D_F64", "viewB", ",", "Se3_F64", "fromAtoB", ")", "{", "triangulate", ".", "triangulate", "(", "viewA", ",", "viewB", ",", "fromAtoB", ",", "P", ")", ";", "if", "(", "P", ".",...
Checks to see if a single point meets the constraint. @param viewA View of the 3D point from the first camera. Calibrated coordinates. @param viewB View of the 3D point from the second camera. Calibrated coordinates. @param fromAtoB Transform from the B to A camera frame. @return If the triangulated point appears in front of both cameras.
[ "Checks", "to", "see", "if", "a", "single", "point", "meets", "the", "constraint", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/PositiveDepthConstraintCheck.java#L67-L76
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryMotion2D.java
FactoryMotion2D.createMotion2D
public static <I extends ImageBase<I>, IT extends InvertibleTransform> ImageMotion2D<I,IT> createMotion2D( int ransacIterations , double inlierThreshold,int outlierPrune, int absoluteMinimumTracks, double respawnTrackFraction, double respawnCoverageFraction, boolean refineEstimate , PointTracker<I> tracker , IT motionModel ) { ModelManager<IT> manager; ModelGenerator<IT,AssociatedPair> fitter; DistanceFromModel<IT,AssociatedPair> distance; ModelFitter<IT,AssociatedPair> modelRefiner = null; if( motionModel instanceof Homography2D_F64) { GenerateHomographyLinear mf = new GenerateHomographyLinear(true); manager = (ModelManager)new ModelManagerHomography2D_F64(); fitter = (ModelGenerator)mf; if( refineEstimate ) modelRefiner = (ModelFitter)mf; distance = (DistanceFromModel)new DistanceHomographySq(); } else if( motionModel instanceof Affine2D_F64) { manager = (ModelManager)new ModelManagerAffine2D_F64(); GenerateAffine2D mf = new GenerateAffine2D(); fitter = (ModelGenerator)mf; if( refineEstimate ) modelRefiner = (ModelFitter)mf; distance = (DistanceFromModel)new DistanceAffine2DSq(); } else if( motionModel instanceof Se2_F64) { manager = (ModelManager)new ModelManagerSe2_F64(); MotionTransformPoint<Se2_F64, Point2D_F64> alg = new MotionSe2PointSVD_F64(); GenerateSe2_AssociatedPair mf = new GenerateSe2_AssociatedPair(alg); fitter = (ModelGenerator)mf; distance = (DistanceFromModel)new DistanceSe2Sq(); // no refine, already optimal } else { throw new RuntimeException("Unknown model type: "+motionModel.getClass().getSimpleName()); } ModelMatcher<IT,AssociatedPair> modelMatcher = new Ransac(123123,manager,fitter,distance,ransacIterations,inlierThreshold); ImageMotionPointTrackerKey<I,IT> lowlevel = new ImageMotionPointTrackerKey<>(tracker, modelMatcher, modelRefiner, motionModel, outlierPrune); ImageMotionPtkSmartRespawn<I,IT> smartRespawn = new ImageMotionPtkSmartRespawn<>(lowlevel, absoluteMinimumTracks, respawnTrackFraction, respawnCoverageFraction); return new WrapImageMotionPtkSmartRespawn<>(smartRespawn); }
java
public static <I extends ImageBase<I>, IT extends InvertibleTransform> ImageMotion2D<I,IT> createMotion2D( int ransacIterations , double inlierThreshold,int outlierPrune, int absoluteMinimumTracks, double respawnTrackFraction, double respawnCoverageFraction, boolean refineEstimate , PointTracker<I> tracker , IT motionModel ) { ModelManager<IT> manager; ModelGenerator<IT,AssociatedPair> fitter; DistanceFromModel<IT,AssociatedPair> distance; ModelFitter<IT,AssociatedPair> modelRefiner = null; if( motionModel instanceof Homography2D_F64) { GenerateHomographyLinear mf = new GenerateHomographyLinear(true); manager = (ModelManager)new ModelManagerHomography2D_F64(); fitter = (ModelGenerator)mf; if( refineEstimate ) modelRefiner = (ModelFitter)mf; distance = (DistanceFromModel)new DistanceHomographySq(); } else if( motionModel instanceof Affine2D_F64) { manager = (ModelManager)new ModelManagerAffine2D_F64(); GenerateAffine2D mf = new GenerateAffine2D(); fitter = (ModelGenerator)mf; if( refineEstimate ) modelRefiner = (ModelFitter)mf; distance = (DistanceFromModel)new DistanceAffine2DSq(); } else if( motionModel instanceof Se2_F64) { manager = (ModelManager)new ModelManagerSe2_F64(); MotionTransformPoint<Se2_F64, Point2D_F64> alg = new MotionSe2PointSVD_F64(); GenerateSe2_AssociatedPair mf = new GenerateSe2_AssociatedPair(alg); fitter = (ModelGenerator)mf; distance = (DistanceFromModel)new DistanceSe2Sq(); // no refine, already optimal } else { throw new RuntimeException("Unknown model type: "+motionModel.getClass().getSimpleName()); } ModelMatcher<IT,AssociatedPair> modelMatcher = new Ransac(123123,manager,fitter,distance,ransacIterations,inlierThreshold); ImageMotionPointTrackerKey<I,IT> lowlevel = new ImageMotionPointTrackerKey<>(tracker, modelMatcher, modelRefiner, motionModel, outlierPrune); ImageMotionPtkSmartRespawn<I,IT> smartRespawn = new ImageMotionPtkSmartRespawn<>(lowlevel, absoluteMinimumTracks, respawnTrackFraction, respawnCoverageFraction); return new WrapImageMotionPtkSmartRespawn<>(smartRespawn); }
[ "public", "static", "<", "I", "extends", "ImageBase", "<", "I", ">", ",", "IT", "extends", "InvertibleTransform", ">", "ImageMotion2D", "<", "I", ",", "IT", ">", "createMotion2D", "(", "int", "ransacIterations", ",", "double", "inlierThreshold", ",", "int", ...
Estimates the 2D motion of an image using different models. @param ransacIterations Number of RANSAC iterations @param inlierThreshold Threshold which defines an inlier. @param outlierPrune If a feature is an outlier for this many turns in a row it is dropped. Try 2 @param absoluteMinimumTracks New features will be respawned if the number of inliers drop below this number. @param respawnTrackFraction If the fraction of current inliers to the original number of inliers drops below this fraction then new features are spawned. Try 0.3 @param respawnCoverageFraction If the area covered drops by this fraction then spawn more features. Try 0.8 @param refineEstimate Should it refine the model estimate using all inliers. @param tracker Point feature tracker. @param motionModel Instance of the model model used. Affine2D_F64 or Homography2D_F64 @param <I> Image input type. @param <IT> Model model @return ImageMotion2D
[ "Estimates", "the", "2D", "motion", "of", "an", "image", "using", "different", "models", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryMotion2D.java#L73-L121
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryMotion2D.java
FactoryMotion2D.createVideoStitch
@SuppressWarnings("unchecked") public static <I extends ImageBase<I>, IT extends InvertibleTransform> StitchingFromMotion2D<I, IT> createVideoStitch( double maxJumpFraction , ImageMotion2D<I,IT> motion2D , ImageType<I> imageType ) { StitchingTransform<IT> transform; if( motion2D.getTransformType() == Affine2D_F64.class ) { transform = (StitchingTransform)FactoryStitchingTransform.createAffine_F64(); } else { transform = (StitchingTransform)FactoryStitchingTransform.createHomography_F64(); } InterpolatePixel<I> interp; if( imageType.getFamily() == ImageType.Family.GRAY || imageType.getFamily() == ImageType.Family.PLANAR ) { interp = FactoryInterpolation.createPixelS(0, 255, InterpolationType.BILINEAR, BorderType.EXTENDED, imageType.getImageClass()); } else { throw new IllegalArgumentException("Unsupported image type"); } ImageDistort<I,I> distorter = FactoryDistort.distort(false, interp, imageType); distorter.setRenderAll(false); return new StitchingFromMotion2D<>(motion2D, distorter, transform, maxJumpFraction); }
java
@SuppressWarnings("unchecked") public static <I extends ImageBase<I>, IT extends InvertibleTransform> StitchingFromMotion2D<I, IT> createVideoStitch( double maxJumpFraction , ImageMotion2D<I,IT> motion2D , ImageType<I> imageType ) { StitchingTransform<IT> transform; if( motion2D.getTransformType() == Affine2D_F64.class ) { transform = (StitchingTransform)FactoryStitchingTransform.createAffine_F64(); } else { transform = (StitchingTransform)FactoryStitchingTransform.createHomography_F64(); } InterpolatePixel<I> interp; if( imageType.getFamily() == ImageType.Family.GRAY || imageType.getFamily() == ImageType.Family.PLANAR ) { interp = FactoryInterpolation.createPixelS(0, 255, InterpolationType.BILINEAR, BorderType.EXTENDED, imageType.getImageClass()); } else { throw new IllegalArgumentException("Unsupported image type"); } ImageDistort<I,I> distorter = FactoryDistort.distort(false, interp, imageType); distorter.setRenderAll(false); return new StitchingFromMotion2D<>(motion2D, distorter, transform, maxJumpFraction); }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "I", "extends", "ImageBase", "<", "I", ">", ",", "IT", "extends", "InvertibleTransform", ">", "StitchingFromMotion2D", "<", "I", ",", "IT", ">", "createVideoStitch", "(", "double", "m...
Estimates the image motion then combines images together. Typically used for mosaics and stabilization. @param maxJumpFraction If the area changes by this much between two consecuative frames then the transform is reset. @param motion2D Estimates the image motion. @param imageType Type of image processed @param <I> Image input type. @param <IT> Model model @return StitchingFromMotion2D
[ "Estimates", "the", "image", "motion", "then", "combines", "images", "together", ".", "Typically", "used", "for", "mosaics", "and", "stabilization", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/factory/sfm/FactoryMotion2D.java#L134-L159
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageStatistics.java
ImageStatistics.min
public static int min( GrayS32 input ) { if( BoofConcurrency.USE_CONCURRENT ) { return ImplImageStatistics_MT.min(input.data, input.startIndex, input.height, input.width , input.stride); } else { return ImplImageStatistics.min(input.data, input.startIndex, input.height, input.width , input.stride); } }
java
public static int min( GrayS32 input ) { if( BoofConcurrency.USE_CONCURRENT ) { return ImplImageStatistics_MT.min(input.data, input.startIndex, input.height, input.width , input.stride); } else { return ImplImageStatistics.min(input.data, input.startIndex, input.height, input.width , input.stride); } }
[ "public", "static", "int", "min", "(", "GrayS32", "input", ")", "{", "if", "(", "BoofConcurrency", ".", "USE_CONCURRENT", ")", "{", "return", "ImplImageStatistics_MT", ".", "min", "(", "input", ".", "data", ",", "input", ".", "startIndex", ",", "input", "....
Returns the minimum element value. @param input Input image. Not modified. @return Minimum pixel value.
[ "Returns", "the", "minimum", "element", "value", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageStatistics.java#L971-L977
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageStatistics.java
ImageStatistics.maxAbs
public static float maxAbs( InterleavedF32 input ) { if( BoofConcurrency.USE_CONCURRENT ) { return ImplImageStatistics_MT.maxAbs(input.data, input.startIndex, input.height, input.width*input.numBands , input.stride); } else { return ImplImageStatistics.maxAbs(input.data, input.startIndex, input.height, input.width*input.numBands , input.stride); } }
java
public static float maxAbs( InterleavedF32 input ) { if( BoofConcurrency.USE_CONCURRENT ) { return ImplImageStatistics_MT.maxAbs(input.data, input.startIndex, input.height, input.width*input.numBands , input.stride); } else { return ImplImageStatistics.maxAbs(input.data, input.startIndex, input.height, input.width*input.numBands , input.stride); } }
[ "public", "static", "float", "maxAbs", "(", "InterleavedF32", "input", ")", "{", "if", "(", "BoofConcurrency", ".", "USE_CONCURRENT", ")", "{", "return", "ImplImageStatistics_MT", ".", "maxAbs", "(", "input", ".", "data", ",", "input", ".", "startIndex", ",", ...
Returns the maximum element value. @param input Input image. Not modified. @return Maximum pixel value.
[ "Returns", "the", "maximum", "element", "value", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/ImageStatistics.java#L1503-L1509
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java
ConnectLinesGrid.connectToNeighbors
private void connectToNeighbors(int x, int y ) { List<LineSegment2D_F32> lines = grid.get(x,y); Iterator<LineSegment2D_F32> iter = lines.iterator(); while( iter.hasNext() ) { LineSegment2D_F32 l = iter.next(); boolean connected = false; if( connectTry(l,x+1,y) ) connected = true; if( !connected && connectTry(l,x+1,y+1) ) connected = true; if( !connected && connectTry(l,x,y+1) ) connected = true; if( !connected && connectTry(l,x-1,y+1) ) connected = true; // the line was added to the connecting grid // remove it to avoid double counting the line if( connected ) iter.remove(); } }
java
private void connectToNeighbors(int x, int y ) { List<LineSegment2D_F32> lines = grid.get(x,y); Iterator<LineSegment2D_F32> iter = lines.iterator(); while( iter.hasNext() ) { LineSegment2D_F32 l = iter.next(); boolean connected = false; if( connectTry(l,x+1,y) ) connected = true; if( !connected && connectTry(l,x+1,y+1) ) connected = true; if( !connected && connectTry(l,x,y+1) ) connected = true; if( !connected && connectTry(l,x-1,y+1) ) connected = true; // the line was added to the connecting grid // remove it to avoid double counting the line if( connected ) iter.remove(); } }
[ "private", "void", "connectToNeighbors", "(", "int", "x", ",", "int", "y", ")", "{", "List", "<", "LineSegment2D_F32", ">", "lines", "=", "grid", ".", "get", "(", "x", ",", "y", ")", ";", "Iterator", "<", "LineSegment2D_F32", ">", "iter", "=", "lines",...
Connect lines in the target region to lines in neighboring regions. Regions are selected such that no two regions are compared against each other more than once. @param x target region grid x-coordinate @param y target region grid y-coordinate
[ "Connect", "lines", "in", "the", "target", "region", "to", "lines", "in", "neighboring", "regions", ".", "Regions", "are", "selected", "such", "that", "no", "two", "regions", "are", "compared", "against", "each", "other", "more", "than", "once", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java#L113-L136
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java
ConnectLinesGrid.connectTry
private boolean connectTry( LineSegment2D_F32 target , int x , int y ) { if( !grid.isInBounds(x,y) ) return false; List<LineSegment2D_F32> lines = grid.get(x,y); int index = findBestCompatible(target,lines,0); if( index == -1 ) return false; LineSegment2D_F32 b = lines.remove(index); // join the two lines by connecting the farthest points from each other Point2D_F32 pt0 = farthestIndex < 2 ? target.a : target.b; Point2D_F32 pt1 = (farthestIndex %2) == 0 ? b.a : b.b; target.a.set(pt0); target.b.set(pt1); // adding the merged one back in allows it to be merged with other lines down // the line. It will be compared against others in 'target's grid though lines.add(target); return true; }
java
private boolean connectTry( LineSegment2D_F32 target , int x , int y ) { if( !grid.isInBounds(x,y) ) return false; List<LineSegment2D_F32> lines = grid.get(x,y); int index = findBestCompatible(target,lines,0); if( index == -1 ) return false; LineSegment2D_F32 b = lines.remove(index); // join the two lines by connecting the farthest points from each other Point2D_F32 pt0 = farthestIndex < 2 ? target.a : target.b; Point2D_F32 pt1 = (farthestIndex %2) == 0 ? b.a : b.b; target.a.set(pt0); target.b.set(pt1); // adding the merged one back in allows it to be merged with other lines down // the line. It will be compared against others in 'target's grid though lines.add(target); return true; }
[ "private", "boolean", "connectTry", "(", "LineSegment2D_F32", "target", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "!", "grid", ".", "isInBounds", "(", "x", ",", "y", ")", ")", "return", "false", ";", "List", "<", "LineSegment2D_F32", ">", ...
See if there is a line that matches in this adjacent region. @param target Line being connected. @param x x-coordinate of adjacent region. @param y y-coordinate of adjacent region. @return true if a connection was made.
[ "See", "if", "there", "is", "a", "line", "that", "matches", "in", "this", "adjacent", "region", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java#L146-L171
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java
ConnectLinesGrid.connectInSameElement
private void connectInSameElement(List<LineSegment2D_F32> lines ) { for( int i = 0; i < lines.size(); i++ ) { LineSegment2D_F32 a = lines.get(i); int index = findBestCompatible(a,lines,i+1); if( index == -1 ) continue; // remove the line from the index which it is being connected to LineSegment2D_F32 b = lines.remove(index); // join the two lines by connecting the farthest points from each other Point2D_F32 pt0 = farthestIndex < 2 ? a.a : a.b; Point2D_F32 pt1 = (farthestIndex %2) == 0 ? b.a : b.b; a.a.set(pt0); a.b.set(pt1); } }
java
private void connectInSameElement(List<LineSegment2D_F32> lines ) { for( int i = 0; i < lines.size(); i++ ) { LineSegment2D_F32 a = lines.get(i); int index = findBestCompatible(a,lines,i+1); if( index == -1 ) continue; // remove the line from the index which it is being connected to LineSegment2D_F32 b = lines.remove(index); // join the two lines by connecting the farthest points from each other Point2D_F32 pt0 = farthestIndex < 2 ? a.a : a.b; Point2D_F32 pt1 = (farthestIndex %2) == 0 ? b.a : b.b; a.a.set(pt0); a.b.set(pt1); } }
[ "private", "void", "connectInSameElement", "(", "List", "<", "LineSegment2D_F32", ">", "lines", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "lines", ".", "size", "(", ")", ";", "i", "++", ")", "{", "LineSegment2D_F32", "a", "=", "lines...
Search for lines in the same region for it to be connected to. @param lines All the lines in the region.
[ "Search", "for", "lines", "in", "the", "same", "region", "for", "it", "to", "be", "connected", "to", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java#L178-L196
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java
ConnectLinesGrid.findBestCompatible
private int findBestCompatible( LineSegment2D_F32 target , List<LineSegment2D_F32> candidates , int start ) { int bestIndex = -1; double bestDistance = Double.MAX_VALUE; int bestFarthest = 0; float targetAngle = UtilAngle.atanSafe(target.slopeY(),target.slopeX()); float cos = (float)Math.cos(targetAngle); float sin = (float)Math.sin(targetAngle); for( int i = start; i < candidates.size(); i++ ) { LineSegment2D_F32 c = candidates.get(i); float angle = UtilAngle.atanSafe(c.slopeY(),c.slopeX()); // see if the two lines have the same slope if( UtilAngle.distHalf(targetAngle,angle) > lineSlopeAngleTol ) continue; // see the distance the two lines are apart and if it could be the best line closestFarthestPoints(target, c); // two closest end points Point2D_F32 pt0 = closestIndex < 2 ? target.a : target.b; Point2D_F32 pt1 = (closestIndex %2) == 0 ? c.a : c.b; float xx = pt1.x-pt0.x; float yy = pt1.y-pt0.y; float distX = Math.abs(cos*xx - sin*yy); float distY = Math.abs(cos*yy + sin*xx); if( distX >= bestDistance || distX > parallelTol || distY > tangentTol ) continue; // check the angle of the combined line pt0 = farthestIndex < 2 ? target.a : target.b; pt1 = (farthestIndex %2) == 0 ? c.a : c.b; float angleCombined = UtilAngle.atanSafe(pt1.y-pt0.y,pt1.x-pt0.x); if( UtilAngle.distHalf(targetAngle,angleCombined) <= lineSlopeAngleTol ) { bestDistance = distX; bestIndex = i; bestFarthest = farthestIndex; } } if( bestDistance < parallelTol) { farthestIndex = bestFarthest; return bestIndex; } return -1; }
java
private int findBestCompatible( LineSegment2D_F32 target , List<LineSegment2D_F32> candidates , int start ) { int bestIndex = -1; double bestDistance = Double.MAX_VALUE; int bestFarthest = 0; float targetAngle = UtilAngle.atanSafe(target.slopeY(),target.slopeX()); float cos = (float)Math.cos(targetAngle); float sin = (float)Math.sin(targetAngle); for( int i = start; i < candidates.size(); i++ ) { LineSegment2D_F32 c = candidates.get(i); float angle = UtilAngle.atanSafe(c.slopeY(),c.slopeX()); // see if the two lines have the same slope if( UtilAngle.distHalf(targetAngle,angle) > lineSlopeAngleTol ) continue; // see the distance the two lines are apart and if it could be the best line closestFarthestPoints(target, c); // two closest end points Point2D_F32 pt0 = closestIndex < 2 ? target.a : target.b; Point2D_F32 pt1 = (closestIndex %2) == 0 ? c.a : c.b; float xx = pt1.x-pt0.x; float yy = pt1.y-pt0.y; float distX = Math.abs(cos*xx - sin*yy); float distY = Math.abs(cos*yy + sin*xx); if( distX >= bestDistance || distX > parallelTol || distY > tangentTol ) continue; // check the angle of the combined line pt0 = farthestIndex < 2 ? target.a : target.b; pt1 = (farthestIndex %2) == 0 ? c.a : c.b; float angleCombined = UtilAngle.atanSafe(pt1.y-pt0.y,pt1.x-pt0.x); if( UtilAngle.distHalf(targetAngle,angleCombined) <= lineSlopeAngleTol ) { bestDistance = distX; bestIndex = i; bestFarthest = farthestIndex; } } if( bestDistance < parallelTol) { farthestIndex = bestFarthest; return bestIndex; } return -1; }
[ "private", "int", "findBestCompatible", "(", "LineSegment2D_F32", "target", ",", "List", "<", "LineSegment2D_F32", ">", "candidates", ",", "int", "start", ")", "{", "int", "bestIndex", "=", "-", "1", ";", "double", "bestDistance", "=", "Double", ".", "MAX_VALU...
Searches for a line in the list which the target is compatible with and can be connected to. @param target Line being connected to. @param candidates List of candidate lines. @param start First index in the candidate list it should start searching at. @return Index of the candidate it can connect to. -1 if there is no match.
[ "Searches", "for", "a", "line", "in", "the", "list", "which", "the", "target", "is", "compatible", "with", "and", "can", "be", "connected", "to", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java#L207-L263
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java
ConnectLinesGrid.closestFarthestPoints
private void closestFarthestPoints(LineSegment2D_F32 a, LineSegment2D_F32 b) { dist[0] = a.a.distance2(b.a); dist[1] = a.a.distance2(b.b); dist[2] = a.b.distance2(b.a); dist[3] = a.b.distance2(b.b); // find the two points which are closest together and save which ones those are // for future reference farthestIndex = 0; float closest = dist[0]; float farthest = dist[0]; for( int i = 1; i < 4; i++ ) { float d = dist[i]; if( d < closest ) { closest = d; closestIndex = i; } if( d > farthest ) { farthest = d; farthestIndex = i; } } }
java
private void closestFarthestPoints(LineSegment2D_F32 a, LineSegment2D_F32 b) { dist[0] = a.a.distance2(b.a); dist[1] = a.a.distance2(b.b); dist[2] = a.b.distance2(b.a); dist[3] = a.b.distance2(b.b); // find the two points which are closest together and save which ones those are // for future reference farthestIndex = 0; float closest = dist[0]; float farthest = dist[0]; for( int i = 1; i < 4; i++ ) { float d = dist[i]; if( d < closest ) { closest = d; closestIndex = i; } if( d > farthest ) { farthest = d; farthestIndex = i; } } }
[ "private", "void", "closestFarthestPoints", "(", "LineSegment2D_F32", "a", ",", "LineSegment2D_F32", "b", ")", "{", "dist", "[", "0", "]", "=", "a", ".", "a", ".", "distance2", "(", "b", ".", "a", ")", ";", "dist", "[", "1", "]", "=", "a", ".", "a"...
Finds the points on each line which are closest and farthest away from each other.
[ "Finds", "the", "points", "on", "each", "line", "which", "are", "closest", "and", "farthest", "away", "from", "each", "other", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/ConnectLinesGrid.java#L268-L291
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/CalibrationFiducialDetector.java
CalibrationFiducialDetector.selectBoundaryCorners
protected void selectBoundaryCorners() { List<Point2D_F64> layout = detector.getLayout(); Polygon2D_F64 hull = new Polygon2D_F64(); UtilPolygons2D_F64.convexHull(layout,hull); UtilPolygons2D_F64.removeAlmostParallel(hull,0.02); boundaryIndexes = new int[hull.size()]; for (int i = 0; i < hull.size(); i++) { Point2D_F64 h = hull.get(i); boolean matched = false; for (int j = 0; j < layout.size(); j++) { if( h.isIdentical(layout.get(j),1e-6)) { matched = true; boundaryIndexes[i] = j; break; } } if( !matched ) throw new RuntimeException("Bug!"); } }
java
protected void selectBoundaryCorners() { List<Point2D_F64> layout = detector.getLayout(); Polygon2D_F64 hull = new Polygon2D_F64(); UtilPolygons2D_F64.convexHull(layout,hull); UtilPolygons2D_F64.removeAlmostParallel(hull,0.02); boundaryIndexes = new int[hull.size()]; for (int i = 0; i < hull.size(); i++) { Point2D_F64 h = hull.get(i); boolean matched = false; for (int j = 0; j < layout.size(); j++) { if( h.isIdentical(layout.get(j),1e-6)) { matched = true; boundaryIndexes[i] = j; break; } } if( !matched ) throw new RuntimeException("Bug!"); } }
[ "protected", "void", "selectBoundaryCorners", "(", ")", "{", "List", "<", "Point2D_F64", ">", "layout", "=", "detector", ".", "getLayout", "(", ")", ";", "Polygon2D_F64", "hull", "=", "new", "Polygon2D_F64", "(", ")", ";", "UtilPolygons2D_F64", ".", "convexHul...
Selects points which will be the corners in the boundary. Finds the convex hull.
[ "Selects", "points", "which", "will", "be", "the", "corners", "in", "the", "boundary", ".", "Finds", "the", "convex", "hull", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/CalibrationFiducialDetector.java#L203-L225
train