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-ip/src/main/java/boofcv/factory/filter/kernel/FactoryKernelGaussian.java
FactoryKernelGaussian.gaussianWidth
public static Kernel2D_F64 gaussianWidth( double sigma , int width ) { if( sigma <= 0 ) sigma = sigmaForRadius(width/2,0); else if( width <= 0 ) throw new IllegalArgumentException("Must specify the width since it doesn't know if it should be even or odd"); if( width % 2 == 0 ) { int r = width/2-1; Kernel2D_F64 ret = new Kernel2D_F64(width); double sum = 0; for( int y = 0; y < width; y++ ) { double dy = y <= r ? Math.abs(y-r)+0.5 : Math.abs(y-r-1)+0.5; for( int x = 0; x < width; x++ ) { double dx = x <= r ? Math.abs(x-r)+0.5 : Math.abs(x-r-1)+0.5; double d = Math.sqrt(dx*dx + dy*dy); double val = UtilGaussian.computePDF(0,sigma,d); ret.set(x,y,val); sum += val; } } for( int i = 0; i < ret.data.length; i++ ) { ret.data[i] /= sum; } return ret; } else { return gaussian2D_F64(sigma,width/2, true, true); } }
java
public static Kernel2D_F64 gaussianWidth( double sigma , int width ) { if( sigma <= 0 ) sigma = sigmaForRadius(width/2,0); else if( width <= 0 ) throw new IllegalArgumentException("Must specify the width since it doesn't know if it should be even or odd"); if( width % 2 == 0 ) { int r = width/2-1; Kernel2D_F64 ret = new Kernel2D_F64(width); double sum = 0; for( int y = 0; y < width; y++ ) { double dy = y <= r ? Math.abs(y-r)+0.5 : Math.abs(y-r-1)+0.5; for( int x = 0; x < width; x++ ) { double dx = x <= r ? Math.abs(x-r)+0.5 : Math.abs(x-r-1)+0.5; double d = Math.sqrt(dx*dx + dy*dy); double val = UtilGaussian.computePDF(0,sigma,d); ret.set(x,y,val); sum += val; } } for( int i = 0; i < ret.data.length; i++ ) { ret.data[i] /= sum; } return ret; } else { return gaussian2D_F64(sigma,width/2, true, true); } }
[ "public", "static", "Kernel2D_F64", "gaussianWidth", "(", "double", "sigma", ",", "int", "width", ")", "{", "if", "(", "sigma", "<=", "0", ")", "sigma", "=", "sigmaForRadius", "(", "width", "/", "2", ",", "0", ")", ";", "else", "if", "(", "width", "<...
Create a gaussian kernel based on its width. Supports kernels of even or odd widths . @param sigma Sigma of the Gaussian distribution. If &le; 0 then the width will be used. @param width How wide the kernel is. Can be even or odd. @return Gaussian convolution kernel.
[ "Create", "a", "gaussian", "kernel", "based", "on", "its", "width", ".", "Supports", "kernels", "of", "even", "or", "odd", "widths", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/kernel/FactoryKernelGaussian.java#L386-L416
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java
ThreeViewEstimateMetricScene.process
public boolean process(List<AssociatedTriple> associated , int width , int height ) { init(width, height); // Fit a trifocal tensor to the input observations if (!robustFitTrifocal(associated) ) return false; // estimate the scene's structure if( !estimateProjectiveScene()) return false; if( !projectiveToMetric() ) return false; // Run bundle adjustment while make sure a valid solution is found setupMetricBundleAdjustment(inliers); bundleAdjustment = FactoryMultiView.bundleSparseMetric(configSBA); findBestValidSolution(bundleAdjustment); // Prune outliers and run bundle adjustment one last time pruneOutliers(bundleAdjustment); return true; }
java
public boolean process(List<AssociatedTriple> associated , int width , int height ) { init(width, height); // Fit a trifocal tensor to the input observations if (!robustFitTrifocal(associated) ) return false; // estimate the scene's structure if( !estimateProjectiveScene()) return false; if( !projectiveToMetric() ) return false; // Run bundle adjustment while make sure a valid solution is found setupMetricBundleAdjustment(inliers); bundleAdjustment = FactoryMultiView.bundleSparseMetric(configSBA); findBestValidSolution(bundleAdjustment); // Prune outliers and run bundle adjustment one last time pruneOutliers(bundleAdjustment); return true; }
[ "public", "boolean", "process", "(", "List", "<", "AssociatedTriple", ">", "associated", ",", "int", "width", ",", "int", "height", ")", "{", "init", "(", "width", ",", "height", ")", ";", "// Fit a trifocal tensor to the input observations", "if", "(", "!", "...
Determines the metric scene. The principle point is assumed to be zero in the passed in pixel coordinates. Typically this is done by subtracting the image center from each pixel coordinate for each view. @param associated List of associated features from 3 views. pixels @param width width of all images @param height height of all images @return true if successful or false if it failed
[ "Determines", "the", "metric", "scene", ".", "The", "principle", "point", "is", "assumed", "to", "be", "zero", "in", "the", "passed", "in", "pixel", "coordinates", ".", "Typically", "this", "is", "done", "by", "subtracting", "the", "image", "center", "from",...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java#L157-L181
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java
ThreeViewEstimateMetricScene.robustFitTrifocal
private boolean robustFitTrifocal(List<AssociatedTriple> associated) { // Fit a trifocal tensor to the observations robustly ransac.process(associated); inliers = ransac.getMatchSet(); TrifocalTensor model = ransac.getModelParameters(); if( verbose != null ) verbose.println("Remaining after RANSAC "+inliers.size()+" / "+associated.size()); // estimate using all the inliers // No need to re-scale the input because the estimator automatically adjusts the input on its own if( !trifocalEstimator.process(inliers,model) ) { if( verbose != null ) { verbose.println("Trifocal estimator failed"); } return false; } return true; }
java
private boolean robustFitTrifocal(List<AssociatedTriple> associated) { // Fit a trifocal tensor to the observations robustly ransac.process(associated); inliers = ransac.getMatchSet(); TrifocalTensor model = ransac.getModelParameters(); if( verbose != null ) verbose.println("Remaining after RANSAC "+inliers.size()+" / "+associated.size()); // estimate using all the inliers // No need to re-scale the input because the estimator automatically adjusts the input on its own if( !trifocalEstimator.process(inliers,model) ) { if( verbose != null ) { verbose.println("Trifocal estimator failed"); } return false; } return true; }
[ "private", "boolean", "robustFitTrifocal", "(", "List", "<", "AssociatedTriple", ">", "associated", ")", "{", "// Fit a trifocal tensor to the observations robustly", "ransac", ".", "process", "(", "associated", ")", ";", "inliers", "=", "ransac", ".", "getMatchSet", ...
Fits a trifocal tensor to the list of matches features using a robust method
[ "Fits", "a", "trifocal", "tensor", "to", "the", "list", "of", "matches", "features", "using", "a", "robust", "method" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java#L195-L213
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java
ThreeViewEstimateMetricScene.pruneOutliers
private void pruneOutliers(BundleAdjustment<SceneStructureMetric> bundleAdjustment) { // see if it's configured to not prune if( pruneFraction == 1.0 ) return; PruneStructureFromSceneMetric pruner = new PruneStructureFromSceneMetric(structure,observations); pruner.pruneObservationsByErrorRank(pruneFraction); pruner.pruneViews(10); pruner.prunePoints(1); bundleAdjustment.setParameters(structure,observations); bundleAdjustment.optimize(structure); if( verbose != null ) { verbose.println("\nCamera"); for (int i = 0; i < structure.cameras.length; i++) { verbose.println(structure.cameras[i].getModel().toString()); } verbose.println("\n\nworldToView"); for (int i = 0; i < structure.views.length; i++) { verbose.println(structure.views[i].worldToView.toString()); } verbose.println("Fit Score: " + bundleAdjustment.getFitScore()); } }
java
private void pruneOutliers(BundleAdjustment<SceneStructureMetric> bundleAdjustment) { // see if it's configured to not prune if( pruneFraction == 1.0 ) return; PruneStructureFromSceneMetric pruner = new PruneStructureFromSceneMetric(structure,observations); pruner.pruneObservationsByErrorRank(pruneFraction); pruner.pruneViews(10); pruner.prunePoints(1); bundleAdjustment.setParameters(structure,observations); bundleAdjustment.optimize(structure); if( verbose != null ) { verbose.println("\nCamera"); for (int i = 0; i < structure.cameras.length; i++) { verbose.println(structure.cameras[i].getModel().toString()); } verbose.println("\n\nworldToView"); for (int i = 0; i < structure.views.length; i++) { verbose.println(structure.views[i].worldToView.toString()); } verbose.println("Fit Score: " + bundleAdjustment.getFitScore()); } }
[ "private", "void", "pruneOutliers", "(", "BundleAdjustment", "<", "SceneStructureMetric", ">", "bundleAdjustment", ")", "{", "// see if it's configured to not prune", "if", "(", "pruneFraction", "==", "1.0", ")", "return", ";", "PruneStructureFromSceneMetric", "pruner", "...
Prunes the features with the largest reprojection error
[ "Prunes", "the", "features", "with", "the", "largest", "reprojection", "error" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java#L218-L240
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java
ThreeViewEstimateMetricScene.estimateProjectiveScene
private boolean estimateProjectiveScene() { List<AssociatedTriple> inliers = ransac.getMatchSet(); TrifocalTensor model = ransac.getModelParameters(); MultiViewOps.extractCameraMatrices(model,P2,P3); // Most of the time this makes little difference, but in some edges cases this enables it to // converge correctly RefineThreeViewProjective refineP23 = FactoryMultiView.threeViewRefine(null); if( !refineP23.process(inliers,P2,P3,P2,P3) ) { if( verbose != null ) { verbose.println("Can't refine P2 and P3!"); } return false; } return true; }
java
private boolean estimateProjectiveScene() { List<AssociatedTriple> inliers = ransac.getMatchSet(); TrifocalTensor model = ransac.getModelParameters(); MultiViewOps.extractCameraMatrices(model,P2,P3); // Most of the time this makes little difference, but in some edges cases this enables it to // converge correctly RefineThreeViewProjective refineP23 = FactoryMultiView.threeViewRefine(null); if( !refineP23.process(inliers,P2,P3,P2,P3) ) { if( verbose != null ) { verbose.println("Can't refine P2 and P3!"); } return false; } return true; }
[ "private", "boolean", "estimateProjectiveScene", "(", ")", "{", "List", "<", "AssociatedTriple", ">", "inliers", "=", "ransac", ".", "getMatchSet", "(", ")", ";", "TrifocalTensor", "model", "=", "ransac", ".", "getModelParameters", "(", ")", ";", "MultiViewOps",...
Estimate the projective scene from the trifocal tensor
[ "Estimate", "the", "projective", "scene", "from", "the", "trifocal", "tensor" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java#L318-L334
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java
ThreeViewEstimateMetricScene.setupMetricBundleAdjustment
private void setupMetricBundleAdjustment(List<AssociatedTriple> inliers) { // Construct bundle adjustment data structure structure = new SceneStructureMetric(false); observations = new SceneObservations(3); structure.initialize(3,3,inliers.size()); for (int i = 0; i < listPinhole.size(); i++) { CameraPinhole cp = listPinhole.get(i); BundlePinholeSimplified bp = new BundlePinholeSimplified(); bp.f = cp.fx; structure.setCamera(i,false,bp); structure.setView(i,i==0,worldToView.get(i)); structure.connectViewToCamera(i,i); } for (int i = 0; i < inliers.size(); i++) { AssociatedTriple t = inliers.get(i); observations.getView(0).add(i,(float)t.p1.x,(float)t.p1.y); observations.getView(1).add(i,(float)t.p2.x,(float)t.p2.y); observations.getView(2).add(i,(float)t.p3.x,(float)t.p3.y); structure.connectPointToView(i,0); structure.connectPointToView(i,1); structure.connectPointToView(i,2); } // Initial estimate for point 3D locations triangulatePoints(structure,observations); }
java
private void setupMetricBundleAdjustment(List<AssociatedTriple> inliers) { // Construct bundle adjustment data structure structure = new SceneStructureMetric(false); observations = new SceneObservations(3); structure.initialize(3,3,inliers.size()); for (int i = 0; i < listPinhole.size(); i++) { CameraPinhole cp = listPinhole.get(i); BundlePinholeSimplified bp = new BundlePinholeSimplified(); bp.f = cp.fx; structure.setCamera(i,false,bp); structure.setView(i,i==0,worldToView.get(i)); structure.connectViewToCamera(i,i); } for (int i = 0; i < inliers.size(); i++) { AssociatedTriple t = inliers.get(i); observations.getView(0).add(i,(float)t.p1.x,(float)t.p1.y); observations.getView(1).add(i,(float)t.p2.x,(float)t.p2.y); observations.getView(2).add(i,(float)t.p3.x,(float)t.p3.y); structure.connectPointToView(i,0); structure.connectPointToView(i,1); structure.connectPointToView(i,2); } // Initial estimate for point 3D locations triangulatePoints(structure,observations); }
[ "private", "void", "setupMetricBundleAdjustment", "(", "List", "<", "AssociatedTriple", ">", "inliers", ")", "{", "// Construct bundle adjustment data structure", "structure", "=", "new", "SceneStructureMetric", "(", "false", ")", ";", "observations", "=", "new", "Scene...
Using the initial metric reconstruction, provide the initial configurations for bundle adjustment
[ "Using", "the", "initial", "metric", "reconstruction", "provide", "the", "initial", "configurations", "for", "bundle", "adjustment" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java#L339-L368
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java
ThreeViewEstimateMetricScene.checkBehindCamera
private boolean checkBehindCamera(SceneStructureMetric structure ) { int totalBehind = 0; Point3D_F64 X = new Point3D_F64(); for (int i = 0; i < structure.points.length; i++) { structure.points[i].get(X); if( X.z < 0 ) totalBehind++; } if( verbose != null ) { verbose.println("points behind "+totalBehind+" / "+structure.points.length); } return totalBehind > structure.points.length/2; }
java
private boolean checkBehindCamera(SceneStructureMetric structure ) { int totalBehind = 0; Point3D_F64 X = new Point3D_F64(); for (int i = 0; i < structure.points.length; i++) { structure.points[i].get(X); if( X.z < 0 ) totalBehind++; } if( verbose != null ) { verbose.println("points behind "+totalBehind+" / "+structure.points.length); } return totalBehind > structure.points.length/2; }
[ "private", "boolean", "checkBehindCamera", "(", "SceneStructureMetric", "structure", ")", "{", "int", "totalBehind", "=", "0", ";", "Point3D_F64", "X", "=", "new", "Point3D_F64", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "structure", ...
Checks to see if a solution was converged to where the points are behind the camera. This is pysically impossible
[ "Checks", "to", "see", "if", "a", "solution", "was", "converged", "to", "where", "the", "points", "are", "behind", "the", "camera", ".", "This", "is", "pysically", "impossible" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java#L462-L477
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java
ThreeViewEstimateMetricScene.flipAround
private static void flipAround(SceneStructureMetric structure, SceneObservations observations) { // The first view will be identity for (int i = 1; i < structure.views.length; i++) { Se3_F64 w2v = structure.views[i].worldToView; w2v.set(w2v.invert(null)); } triangulatePoints(structure,observations); }
java
private static void flipAround(SceneStructureMetric structure, SceneObservations observations) { // The first view will be identity for (int i = 1; i < structure.views.length; i++) { Se3_F64 w2v = structure.views[i].worldToView; w2v.set(w2v.invert(null)); } triangulatePoints(structure,observations); }
[ "private", "static", "void", "flipAround", "(", "SceneStructureMetric", "structure", ",", "SceneObservations", "observations", ")", "{", "// The first view will be identity", "for", "(", "int", "i", "=", "1", ";", "i", "<", "structure", ".", "views", ".", "length"...
Flip the camera pose around. This seems to help it converge to a valid solution if it got it backwards even if it's not technically something which can be inverted this way
[ "Flip", "the", "camera", "pose", "around", ".", "This", "seems", "to", "help", "it", "converge", "to", "a", "valid", "solution", "if", "it", "got", "it", "backwards", "even", "if", "it", "s", "not", "technically", "something", "which", "can", "be", "inve...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/ThreeViewEstimateMetricScene.java#L483-L490
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointSurfPlanar.java
DescribePointSurfPlanar.setImage
public void setImage( II grayII , Planar<II> colorII ) { InputSanityCheck.checkSameShape(grayII,colorII); if( colorII.getNumBands() != numBands ) throw new IllegalArgumentException("Expected planar images to have " +numBands+" not "+colorII.getNumBands()); this.grayII = grayII; this.colorII = colorII; }
java
public void setImage( II grayII , Planar<II> colorII ) { InputSanityCheck.checkSameShape(grayII,colorII); if( colorII.getNumBands() != numBands ) throw new IllegalArgumentException("Expected planar images to have " +numBands+" not "+colorII.getNumBands()); this.grayII = grayII; this.colorII = colorII; }
[ "public", "void", "setImage", "(", "II", "grayII", ",", "Planar", "<", "II", ">", "colorII", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "grayII", ",", "colorII", ")", ";", "if", "(", "colorII", ".", "getNumBands", "(", ")", "!=", "numBands...
Specifies input image shapes. @param grayII integral image of gray scale image @param colorII integral image of color image
[ "Specifies", "input", "image", "shapes", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointSurfPlanar.java#L87-L95
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/color/ColorHsv.java
ColorHsv.hsvToRgb
public static void hsvToRgb( double h , double s , double v , double []rgb ) { if( s == 0 ) { rgb[0] = v; rgb[1] = v; rgb[2] = v; return; } h /= d60_F64; int h_int = (int)h; double remainder = h - h_int; double p = v * ( 1 - s ); double q = v * ( 1 - s * remainder ); double t = v * ( 1 - s * ( 1 - remainder ) ); if( h_int < 1 ) { rgb[0] = v; rgb[1] = t; rgb[2] = p; } else if( h_int < 2 ) { rgb[0] = q; rgb[1] = v; rgb[2] = p; } else if( h_int < 3 ) { rgb[0] = p; rgb[1] = v; rgb[2] = t; } else if( h_int < 4 ) { rgb[0] = p; rgb[1] = q; rgb[2] = v; } else if( h_int < 5 ) { rgb[0] = t; rgb[1] = p; rgb[2] = v; } else { rgb[0] = v; rgb[1] = p; rgb[2] = q; } }
java
public static void hsvToRgb( double h , double s , double v , double []rgb ) { if( s == 0 ) { rgb[0] = v; rgb[1] = v; rgb[2] = v; return; } h /= d60_F64; int h_int = (int)h; double remainder = h - h_int; double p = v * ( 1 - s ); double q = v * ( 1 - s * remainder ); double t = v * ( 1 - s * ( 1 - remainder ) ); if( h_int < 1 ) { rgb[0] = v; rgb[1] = t; rgb[2] = p; } else if( h_int < 2 ) { rgb[0] = q; rgb[1] = v; rgb[2] = p; } else if( h_int < 3 ) { rgb[0] = p; rgb[1] = v; rgb[2] = t; } else if( h_int < 4 ) { rgb[0] = p; rgb[1] = q; rgb[2] = v; } else if( h_int < 5 ) { rgb[0] = t; rgb[1] = p; rgb[2] = v; } else { rgb[0] = v; rgb[1] = p; rgb[2] = q; } }
[ "public", "static", "void", "hsvToRgb", "(", "double", "h", ",", "double", "s", ",", "double", "v", ",", "double", "[", "]", "rgb", ")", "{", "if", "(", "s", "==", "0", ")", "{", "rgb", "[", "0", "]", "=", "v", ";", "rgb", "[", "1", "]", "=...
Convert HSV color into RGB color @param h Hue [0,2*PI] @param s Saturation [0,1] @param v Value @param rgb (Output) RGB value
[ "Convert", "HSV", "color", "into", "RGB", "color" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/color/ColorHsv.java#L109-L148
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CreateSyntheticOverheadView.java
CreateSyntheticOverheadView.configure
public void configure( CameraPinholeBrown intrinsic , Se3_F64 planeToCamera , double centerX, double centerY, double cellSize , int overheadWidth , int overheadHeight ) { this.overheadWidth = overheadWidth; this.overheadHeight = overheadHeight; Point2Transform2_F64 normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); // Declare storage for precomputed pixel locations int overheadPixels = overheadHeight*overheadWidth; if( mapPixels == null || mapPixels.length < overheadPixels) { mapPixels = new Point2D_F32[overheadPixels]; } points.reset(); // -------- storage for intermediate results Point2D_F64 pixel = new Point2D_F64(); // coordinate on the plane Point3D_F64 pt_plane = new Point3D_F64(); // coordinate in camera reference frame Point3D_F64 pt_cam = new Point3D_F64(); int indexOut = 0; for( int i = 0; i < overheadHeight; i++ ) { pt_plane.x = -(i*cellSize - centerY); for( int j = 0; j < overheadWidth; j++ , indexOut++ ) { pt_plane.z = j*cellSize - centerX; // plane to camera reference frame SePointOps_F64.transform(planeToCamera, pt_plane, pt_cam); // can't see behind the camera if( pt_cam.z > 0 ) { // compute normalized then convert to pixels normToPixel.compute(pt_cam.x/pt_cam.z,pt_cam.y/pt_cam.z,pixel); float x = (float)pixel.x; float y = (float)pixel.y; // make sure it's in the image if(BoofMiscOps.checkInside(intrinsic.width,intrinsic.height,x,y) ){ Point2D_F32 p = points.grow(); p.set(x,y); mapPixels[ indexOut ]= p; } else { mapPixels[ indexOut ]= null; } } } } }
java
public void configure( CameraPinholeBrown intrinsic , Se3_F64 planeToCamera , double centerX, double centerY, double cellSize , int overheadWidth , int overheadHeight ) { this.overheadWidth = overheadWidth; this.overheadHeight = overheadHeight; Point2Transform2_F64 normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); // Declare storage for precomputed pixel locations int overheadPixels = overheadHeight*overheadWidth; if( mapPixels == null || mapPixels.length < overheadPixels) { mapPixels = new Point2D_F32[overheadPixels]; } points.reset(); // -------- storage for intermediate results Point2D_F64 pixel = new Point2D_F64(); // coordinate on the plane Point3D_F64 pt_plane = new Point3D_F64(); // coordinate in camera reference frame Point3D_F64 pt_cam = new Point3D_F64(); int indexOut = 0; for( int i = 0; i < overheadHeight; i++ ) { pt_plane.x = -(i*cellSize - centerY); for( int j = 0; j < overheadWidth; j++ , indexOut++ ) { pt_plane.z = j*cellSize - centerX; // plane to camera reference frame SePointOps_F64.transform(planeToCamera, pt_plane, pt_cam); // can't see behind the camera if( pt_cam.z > 0 ) { // compute normalized then convert to pixels normToPixel.compute(pt_cam.x/pt_cam.z,pt_cam.y/pt_cam.z,pixel); float x = (float)pixel.x; float y = (float)pixel.y; // make sure it's in the image if(BoofMiscOps.checkInside(intrinsic.width,intrinsic.height,x,y) ){ Point2D_F32 p = points.grow(); p.set(x,y); mapPixels[ indexOut ]= p; } else { mapPixels[ indexOut ]= null; } } } } }
[ "public", "void", "configure", "(", "CameraPinholeBrown", "intrinsic", ",", "Se3_F64", "planeToCamera", ",", "double", "centerX", ",", "double", "centerY", ",", "double", "cellSize", ",", "int", "overheadWidth", ",", "int", "overheadHeight", ")", "{", "this", "....
Specifies camera configurations. @param intrinsic Intrinsic camera parameters @param planeToCamera Transform from the plane to the camera. This is the extrinsic parameters. @param centerX X-coordinate of camera center in the overhead image in world units. @param centerY Y-coordinate of camera center in the overhead image in world units. @param cellSize Size of each cell in the overhead image in world units. @param overheadWidth Number of columns in overhead image @param overheadHeight Number of rows in overhead image
[ "Specifies", "camera", "configurations", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CreateSyntheticOverheadView.java#L81-L133
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/DetectFiducialSquareGrid.java
DetectFiducialSquareGrid.detect
public boolean detect( T input ) { detections.reset(); detector.process(input); FastQueue<FoundFiducial> found = detector.getFound(); for (int i = 0; i < found.size(); i++) { FoundFiducial fid = found.get(i); int gridIndex = isExpected(fid.id); if( gridIndex >= 0 ) { Detection d = lookupDetection(fid.id,gridIndex); d.location.set(fid.distortedPixels); d.numDetected++; } } for (int i = detections.size-1; i >= 0; i--) { if( detections.get(i).numDetected != 1 ) { detections.remove(i); } } return detections.size > 0; }
java
public boolean detect( T input ) { detections.reset(); detector.process(input); FastQueue<FoundFiducial> found = detector.getFound(); for (int i = 0; i < found.size(); i++) { FoundFiducial fid = found.get(i); int gridIndex = isExpected(fid.id); if( gridIndex >= 0 ) { Detection d = lookupDetection(fid.id,gridIndex); d.location.set(fid.distortedPixels); d.numDetected++; } } for (int i = detections.size-1; i >= 0; i--) { if( detections.get(i).numDetected != 1 ) { detections.remove(i); } } return detections.size > 0; }
[ "public", "boolean", "detect", "(", "T", "input", ")", "{", "detections", ".", "reset", "(", ")", ";", "detector", ".", "process", "(", "input", ")", ";", "FastQueue", "<", "FoundFiducial", ">", "found", "=", "detector", ".", "getFound", "(", ")", ";",...
Searches for the fiducial inside the image. If at least a partial match is found true is returned. @param input Input image @return true if at least one of the component fiducials is detected. False otherwise
[ "Searches", "for", "the", "fiducial", "inside", "the", "image", ".", "If", "at", "least", "a", "partial", "match", "is", "found", "true", "is", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/DetectFiducialSquareGrid.java#L87-L113
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/DetectFiducialSquareGrid.java
DetectFiducialSquareGrid.isExpected
private int isExpected( long found ) { int bestHamming = 2; int bestNumber = -1; for (int i = 0; i < numbers.length; i++) { int hamming = DescriptorDistance.hamming((int)found^(int)numbers[i]); if( hamming < bestHamming ) { bestHamming = hamming; bestNumber = i; } } return bestNumber; }
java
private int isExpected( long found ) { int bestHamming = 2; int bestNumber = -1; for (int i = 0; i < numbers.length; i++) { int hamming = DescriptorDistance.hamming((int)found^(int)numbers[i]); if( hamming < bestHamming ) { bestHamming = hamming; bestNumber = i; } } return bestNumber; }
[ "private", "int", "isExpected", "(", "long", "found", ")", "{", "int", "bestHamming", "=", "2", ";", "int", "bestNumber", "=", "-", "1", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numbers", ".", "length", ";", "i", "++", ")", "{", "...
Checks to see if the provided ID number is expected or not @param found Fiducial ID number @return true if it's looking for this ID number
[ "Checks", "to", "see", "if", "the", "provided", "ID", "number", "is", "expected", "or", "not" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/DetectFiducialSquareGrid.java#L121-L135
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/DetectFiducialSquareGrid.java
DetectFiducialSquareGrid.lookupDetection
private Detection lookupDetection( long found , int gridIndex) { for (int i = 0; i < detections.size(); i++) { Detection d = detections.get(i); if( d.id == found ) { return d; } } Detection d = detections.grow(); d.reset(); d.id = found; d.gridIndex = gridIndex; return d; }
java
private Detection lookupDetection( long found , int gridIndex) { for (int i = 0; i < detections.size(); i++) { Detection d = detections.get(i); if( d.id == found ) { return d; } } Detection d = detections.grow(); d.reset(); d.id = found; d.gridIndex = gridIndex; return d; }
[ "private", "Detection", "lookupDetection", "(", "long", "found", ",", "int", "gridIndex", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "detections", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Detection", "d", "=", "detections", ...
Looks up a detection given the fiducial ID number. If not seen before the gridIndex is saved and a new instance returned.
[ "Looks", "up", "a", "detection", "given", "the", "fiducial", "ID", "number", ".", "If", "not", "seen", "before", "the", "gridIndex", "is", "saved", "and", "a", "new", "instance", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/DetectFiducialSquareGrid.java#L141-L155
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearContourLabelChang2004.java
LinearContourLabelChang2004.process
public void process(GrayU8 binary , GrayS32 labeled ) { // initialize data structures labeled.reshape(binary.width,binary.height); // ensure that the image border pixels are filled with zero by enlarging the image if( border.width != binary.width+2 || border.height != binary.height+2) { border.reshape(binary.width + 2, binary.height + 2); ImageMiscOps.fillBorder(border, 0, 1); } border.subimage(1,1,border.width-1,border.height-1, null).setTo(binary); // labeled image must initially be filled with zeros ImageMiscOps.fill(labeled,0); binary = border; packedPoints.reset(); contours.reset(); tracer.setInputs(binary,labeled, packedPoints); // Outside border is all zeros so it can be ignored int endY = binary.height-1, enxX = binary.width-1; for( y = 1; y < endY; y++ ) { indexIn = binary.startIndex + y*binary.stride+1; indexOut = labeled.startIndex + (y-1)*labeled.stride; x = 1; int delta = scanForOne(binary.data,indexIn,indexIn+enxX-x)-indexIn; x += delta; indexIn += delta; indexOut += delta; while( x < enxX ) { int label = labeled.data[indexOut]; boolean handled = false; if( label == 0 && binary.data[indexIn - binary.stride ] != 1 ) { handleStep1(); handled = true; label = contours.size; } // could be an external and internal contour if( binary.data[indexIn + binary.stride ] == 0 ) { handleStep2(labeled, label); handled = true; } if( !handled ) { // Step 3: Must not be part of the contour but an inner pixel and the pixel to the left must be // labeled if( labeled.data[indexOut] == 0 ) labeled.data[indexOut] = labeled.data[indexOut-1]; } delta = scanForOne(binary.data,indexIn+1,indexIn+enxX-x)-indexIn; x += delta; indexIn += delta; indexOut += delta; } } }
java
public void process(GrayU8 binary , GrayS32 labeled ) { // initialize data structures labeled.reshape(binary.width,binary.height); // ensure that the image border pixels are filled with zero by enlarging the image if( border.width != binary.width+2 || border.height != binary.height+2) { border.reshape(binary.width + 2, binary.height + 2); ImageMiscOps.fillBorder(border, 0, 1); } border.subimage(1,1,border.width-1,border.height-1, null).setTo(binary); // labeled image must initially be filled with zeros ImageMiscOps.fill(labeled,0); binary = border; packedPoints.reset(); contours.reset(); tracer.setInputs(binary,labeled, packedPoints); // Outside border is all zeros so it can be ignored int endY = binary.height-1, enxX = binary.width-1; for( y = 1; y < endY; y++ ) { indexIn = binary.startIndex + y*binary.stride+1; indexOut = labeled.startIndex + (y-1)*labeled.stride; x = 1; int delta = scanForOne(binary.data,indexIn,indexIn+enxX-x)-indexIn; x += delta; indexIn += delta; indexOut += delta; while( x < enxX ) { int label = labeled.data[indexOut]; boolean handled = false; if( label == 0 && binary.data[indexIn - binary.stride ] != 1 ) { handleStep1(); handled = true; label = contours.size; } // could be an external and internal contour if( binary.data[indexIn + binary.stride ] == 0 ) { handleStep2(labeled, label); handled = true; } if( !handled ) { // Step 3: Must not be part of the contour but an inner pixel and the pixel to the left must be // labeled if( labeled.data[indexOut] == 0 ) labeled.data[indexOut] = labeled.data[indexOut-1]; } delta = scanForOne(binary.data,indexIn+1,indexIn+enxX-x)-indexIn; x += delta; indexIn += delta; indexOut += delta; } } }
[ "public", "void", "process", "(", "GrayU8", "binary", ",", "GrayS32", "labeled", ")", "{", "// initialize data structures", "labeled", ".", "reshape", "(", "binary", ".", "width", ",", "binary", ".", "height", ")", ";", "// ensure that the image border pixels are fi...
Processes the binary image to find the contour of and label blobs. @param binary Input binary image. Not modified. @param labeled Output. Labeled image. Modified.
[ "Processes", "the", "binary", "image", "to", "find", "the", "contour", "of", "and", "label", "blobs", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearContourLabelChang2004.java#L96-L152
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearContourLabelChang2004.java
LinearContourLabelChang2004.scanForOne
private int scanForOne(byte[] data , int index , int end ) { while (index < end && data[index] != 1) { index++; } return index; }
java
private int scanForOne(byte[] data , int index , int end ) { while (index < end && data[index] != 1) { index++; } return index; }
[ "private", "int", "scanForOne", "(", "byte", "[", "]", "data", ",", "int", "index", ",", "int", "end", ")", "{", "while", "(", "index", "<", "end", "&&", "data", "[", "index", "]", "!=", "1", ")", "{", "index", "++", ";", "}", "return", "index", ...
Faster when there's a specialized function which searches for one pixels
[ "Faster", "when", "there", "s", "a", "specialized", "function", "which", "searches", "for", "one", "pixels" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearContourLabelChang2004.java#L157-L162
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/factory/fiducial/FactoryFiducial.java
FactoryFiducial.qrcode
public static <T extends ImageGray<T>> QrCodePreciseDetector<T> qrcode(ConfigQrCode config, Class<T> imageType) { if( config == null ) config = new ConfigQrCode(); config.checkValidity(); InputToBinary<T> inputToBinary = FactoryThresholdBinary.threshold(config.threshold,imageType); DetectPolygonBinaryGrayRefine<T> squareDetector = FactoryShapeDetector.polygon(config.polygon, imageType); QrCodePositionPatternDetector<T> detectPositionPatterns = new QrCodePositionPatternDetector<>(squareDetector,config.versionMaximum); return new QrCodePreciseDetector<>(inputToBinary,detectPositionPatterns, config.forceEncoding,false, imageType); }
java
public static <T extends ImageGray<T>> QrCodePreciseDetector<T> qrcode(ConfigQrCode config, Class<T> imageType) { if( config == null ) config = new ConfigQrCode(); config.checkValidity(); InputToBinary<T> inputToBinary = FactoryThresholdBinary.threshold(config.threshold,imageType); DetectPolygonBinaryGrayRefine<T> squareDetector = FactoryShapeDetector.polygon(config.polygon, imageType); QrCodePositionPatternDetector<T> detectPositionPatterns = new QrCodePositionPatternDetector<>(squareDetector,config.versionMaximum); return new QrCodePreciseDetector<>(inputToBinary,detectPositionPatterns, config.forceEncoding,false, imageType); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "QrCodePreciseDetector", "<", "T", ">", "qrcode", "(", "ConfigQrCode", "config", ",", "Class", "<", "T", ">", "imageType", ")", "{", "if", "(", "config", "==", "null", ")", "conf...
Returns a QR Code detector @param config Configuration @param imageType type of input image @return the detector
[ "Returns", "a", "QR", "Code", "detector" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/factory/fiducial/FactoryFiducial.java#L174-L188
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java
TldTracker.initialize
public void initialize( T image , int x0 , int y0 , int x1 , int y1 ) { if( imagePyramid == null || imagePyramid.getInputWidth() != image.width || imagePyramid.getInputHeight() != image.height ) { int minSize = (config.trackerFeatureRadius*2+1)*5; int scales[] = selectPyramidScale(image.width,image.height,minSize); imagePyramid = FactoryPyramid.discreteGaussian(scales,-1,1,true,image.getImageType()); } imagePyramid.process(image); reacquiring = false; targetRegion.set(x0, y0, x1, y1); createCascadeRegion(image.width,image.height); template.reset(); fern.reset(); tracking.initialize(imagePyramid); variance.setImage(image); template.setImage(image); fern.setImage(image); adjustRegion.init(image.width,image.height); learning.initialLearning(targetRegion, cascadeRegions); strongMatch = true; previousTrackArea = targetRegion.area(); }
java
public void initialize( T image , int x0 , int y0 , int x1 , int y1 ) { if( imagePyramid == null || imagePyramid.getInputWidth() != image.width || imagePyramid.getInputHeight() != image.height ) { int minSize = (config.trackerFeatureRadius*2+1)*5; int scales[] = selectPyramidScale(image.width,image.height,minSize); imagePyramid = FactoryPyramid.discreteGaussian(scales,-1,1,true,image.getImageType()); } imagePyramid.process(image); reacquiring = false; targetRegion.set(x0, y0, x1, y1); createCascadeRegion(image.width,image.height); template.reset(); fern.reset(); tracking.initialize(imagePyramid); variance.setImage(image); template.setImage(image); fern.setImage(image); adjustRegion.init(image.width,image.height); learning.initialLearning(targetRegion, cascadeRegions); strongMatch = true; previousTrackArea = targetRegion.area(); }
[ "public", "void", "initialize", "(", "T", "image", ",", "int", "x0", ",", "int", "y0", ",", "int", "x1", ",", "int", "y1", ")", "{", "if", "(", "imagePyramid", "==", "null", "||", "imagePyramid", ".", "getInputWidth", "(", ")", "!=", "image", ".", ...
Starts tracking the rectangular region. @param image First image in the sequence. @param x0 Top-left corner of rectangle. x-axis @param y0 Top-left corner of rectangle. y-axis @param x1 Bottom-right corner of rectangle. x-axis @param y1 Bottom-right corner of rectangle. y-axis
[ "Starts", "tracking", "the", "rectangular", "region", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java#L148-L175
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java
TldTracker.createCascadeRegion
private void createCascadeRegion( int imageWidth , int imageHeight ) { cascadeRegions.reset(); int rectWidth = (int)(targetRegion.getWidth()+0.5); int rectHeight = (int)(targetRegion.getHeight()+0.5); for( int scaleInt = -config.scaleSpread; scaleInt <= config.scaleSpread; scaleInt++ ) { // try several scales as specified in the paper double scale = Math.pow(1.2,scaleInt); // the actual rectangular region being tested at this scale int actualWidth = (int)(rectWidth*scale); int actualHeight = (int)(rectHeight*scale); // see if the region is too small or too large if( actualWidth < config.detectMinimumSide || actualHeight < config.detectMinimumSide ) continue; if( actualWidth >= imageWidth || actualHeight >= imageHeight ) continue; // step size at this scale int stepWidth = (int)(rectWidth*scale*0.1); int stepHeight = (int)(rectHeight*scale*0.1); if( stepWidth < 1 ) stepWidth = 1; if( stepHeight < 1 ) stepHeight = 1; // maximum allowed values int maxX = imageWidth-actualWidth; int maxY = imageHeight-actualHeight; // start at (1,1). Otherwise a more complex algorithm needs to be used for integral images for( int y0 = 1; y0 < maxY; y0 += stepHeight ) { for( int x0 = 1; x0 < maxX; x0 += stepWidth) { ImageRectangle r = cascadeRegions.grow(); r.x0 = x0; r.y0 = y0; r.x1 = x0 + actualWidth; r.y1 = y0 + actualHeight; } } } }
java
private void createCascadeRegion( int imageWidth , int imageHeight ) { cascadeRegions.reset(); int rectWidth = (int)(targetRegion.getWidth()+0.5); int rectHeight = (int)(targetRegion.getHeight()+0.5); for( int scaleInt = -config.scaleSpread; scaleInt <= config.scaleSpread; scaleInt++ ) { // try several scales as specified in the paper double scale = Math.pow(1.2,scaleInt); // the actual rectangular region being tested at this scale int actualWidth = (int)(rectWidth*scale); int actualHeight = (int)(rectHeight*scale); // see if the region is too small or too large if( actualWidth < config.detectMinimumSide || actualHeight < config.detectMinimumSide ) continue; if( actualWidth >= imageWidth || actualHeight >= imageHeight ) continue; // step size at this scale int stepWidth = (int)(rectWidth*scale*0.1); int stepHeight = (int)(rectHeight*scale*0.1); if( stepWidth < 1 ) stepWidth = 1; if( stepHeight < 1 ) stepHeight = 1; // maximum allowed values int maxX = imageWidth-actualWidth; int maxY = imageHeight-actualHeight; // start at (1,1). Otherwise a more complex algorithm needs to be used for integral images for( int y0 = 1; y0 < maxY; y0 += stepHeight ) { for( int x0 = 1; x0 < maxX; x0 += stepWidth) { ImageRectangle r = cascadeRegions.grow(); r.x0 = x0; r.y0 = y0; r.x1 = x0 + actualWidth; r.y1 = y0 + actualHeight; } } } }
[ "private", "void", "createCascadeRegion", "(", "int", "imageWidth", ",", "int", "imageHeight", ")", "{", "cascadeRegions", ".", "reset", "(", ")", ";", "int", "rectWidth", "=", "(", "int", ")", "(", "targetRegion", ".", "getWidth", "(", ")", "+", "0.5", ...
Creates a list containing all the regions which need to be tested
[ "Creates", "a", "list", "containing", "all", "the", "regions", "which", "need", "to", "be", "tested" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java#L205-L250
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java
TldTracker.track
public boolean track( T image ) { boolean success = true; valid = false; imagePyramid.process(image); template.setImage(image); variance.setImage(image); fern.setImage(image); if( reacquiring ) { // It can reinitialize if there is a single detection detection.detectionCascade(cascadeRegions); if( detection.isSuccess() && !detection.isAmbiguous() ) { TldRegion region = detection.getBest(); reacquiring = false; valid = false; // set it to the detected region ImageRectangle r = region.rect; targetRegion.set(r.x0, r.y0, r.x1, r.y1); // get tracking running again tracking.initialize(imagePyramid); checkNewTrackStrong(region.confidence); } else { success = false; } } else { detection.detectionCascade(cascadeRegions); // update the previous track region using the tracker trackerRegion.set(targetRegion); boolean trackingWorked = tracking.process(imagePyramid, trackerRegion); trackingWorked &= adjustRegion.process(tracking.getPairs(), trackerRegion); TldHelperFunctions.convertRegion(trackerRegion, trackerRegion_I32); if( hypothesisFusion( trackingWorked , detection.isSuccess() ) ) { // if it found a hypothesis and it is valid for learning, then learn if( valid && performLearning ) { learning.updateLearning(targetRegion); } } else { reacquiring = true; success = false; } } if( strongMatch ) { previousTrackArea = targetRegion.area(); } return success; }
java
public boolean track( T image ) { boolean success = true; valid = false; imagePyramid.process(image); template.setImage(image); variance.setImage(image); fern.setImage(image); if( reacquiring ) { // It can reinitialize if there is a single detection detection.detectionCascade(cascadeRegions); if( detection.isSuccess() && !detection.isAmbiguous() ) { TldRegion region = detection.getBest(); reacquiring = false; valid = false; // set it to the detected region ImageRectangle r = region.rect; targetRegion.set(r.x0, r.y0, r.x1, r.y1); // get tracking running again tracking.initialize(imagePyramid); checkNewTrackStrong(region.confidence); } else { success = false; } } else { detection.detectionCascade(cascadeRegions); // update the previous track region using the tracker trackerRegion.set(targetRegion); boolean trackingWorked = tracking.process(imagePyramid, trackerRegion); trackingWorked &= adjustRegion.process(tracking.getPairs(), trackerRegion); TldHelperFunctions.convertRegion(trackerRegion, trackerRegion_I32); if( hypothesisFusion( trackingWorked , detection.isSuccess() ) ) { // if it found a hypothesis and it is valid for learning, then learn if( valid && performLearning ) { learning.updateLearning(targetRegion); } } else { reacquiring = true; success = false; } } if( strongMatch ) { previousTrackArea = targetRegion.area(); } return success; }
[ "public", "boolean", "track", "(", "T", "image", ")", "{", "boolean", "success", "=", "true", ";", "valid", "=", "false", ";", "imagePyramid", ".", "process", "(", "image", ")", ";", "template", ".", "setImage", "(", "image", ")", ";", "variance", ".",...
Updates track region. @param image Next image in the sequence. @return true if the object could be found and false if not
[ "Updates", "track", "region", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java#L258-L314
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java
TldTracker.hypothesisFusion
protected boolean hypothesisFusion( boolean trackingWorked , boolean detectionWorked ) { valid = false; boolean uniqueDetection = detectionWorked && !detection.isAmbiguous(); TldRegion detectedRegion = detection.getBest(); double confidenceTarget; if( trackingWorked ) { // get the scores from tracking and detection double scoreTrack = template.computeConfidence(trackerRegion_I32); double scoreDetected = 0; if( uniqueDetection ) { scoreDetected = detectedRegion.confidence; } double adjustment = strongMatch ? 0.07 : 0.02; if( uniqueDetection && scoreDetected > scoreTrack + adjustment ) { // if there is a unique detection and it has higher confidence than the // track region, use the detected region TldHelperFunctions.convertRegion(detectedRegion.rect, targetRegion); confidenceTarget = detectedRegion.confidence; // if it's far away from the current track, re-evaluate if it's a strongMatch checkNewTrackStrong(scoreDetected); } else { // Otherwise use the tracker region targetRegion.set(trackerRegion); confidenceTarget = scoreTrack; strongMatch |= confidenceTarget > config.confidenceThresholdStrong; // see if the most likely detected region overlaps the track region if( strongMatch && confidenceTarget >= config.confidenceThresholdLower ) { valid = true; } } } else if( uniqueDetection ) { // just go with the best detected region detectedRegion = detection.getBest(); TldHelperFunctions.convertRegion(detectedRegion.rect, targetRegion); confidenceTarget = detectedRegion.confidence; strongMatch = confidenceTarget > config.confidenceThresholdStrong; } else { return false; } return confidenceTarget >= config.confidenceAccept; }
java
protected boolean hypothesisFusion( boolean trackingWorked , boolean detectionWorked ) { valid = false; boolean uniqueDetection = detectionWorked && !detection.isAmbiguous(); TldRegion detectedRegion = detection.getBest(); double confidenceTarget; if( trackingWorked ) { // get the scores from tracking and detection double scoreTrack = template.computeConfidence(trackerRegion_I32); double scoreDetected = 0; if( uniqueDetection ) { scoreDetected = detectedRegion.confidence; } double adjustment = strongMatch ? 0.07 : 0.02; if( uniqueDetection && scoreDetected > scoreTrack + adjustment ) { // if there is a unique detection and it has higher confidence than the // track region, use the detected region TldHelperFunctions.convertRegion(detectedRegion.rect, targetRegion); confidenceTarget = detectedRegion.confidence; // if it's far away from the current track, re-evaluate if it's a strongMatch checkNewTrackStrong(scoreDetected); } else { // Otherwise use the tracker region targetRegion.set(trackerRegion); confidenceTarget = scoreTrack; strongMatch |= confidenceTarget > config.confidenceThresholdStrong; // see if the most likely detected region overlaps the track region if( strongMatch && confidenceTarget >= config.confidenceThresholdLower ) { valid = true; } } } else if( uniqueDetection ) { // just go with the best detected region detectedRegion = detection.getBest(); TldHelperFunctions.convertRegion(detectedRegion.rect, targetRegion); confidenceTarget = detectedRegion.confidence; strongMatch = confidenceTarget > config.confidenceThresholdStrong; } else { return false; } return confidenceTarget >= config.confidenceAccept; }
[ "protected", "boolean", "hypothesisFusion", "(", "boolean", "trackingWorked", ",", "boolean", "detectionWorked", ")", "{", "valid", "=", "false", ";", "boolean", "uniqueDetection", "=", "detectionWorked", "&&", "!", "detection", ".", "isAmbiguous", "(", ")", ";", ...
Combines hypotheses from tracking and detection. @param trackingWorked If the sequential tracker updated the track region successfully or not @return true a hypothesis was found, false if it failed to find a hypothesis
[ "Combines", "hypotheses", "from", "tracking", "and", "detection", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java#L332-L385
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java
TldTracker.selectPyramidScale
public static int[] selectPyramidScale( int imageWidth , int imageHeight, int minSize ) { int w = Math.max(imageWidth,imageHeight); int maxScale = w/minSize; int n = 1; int scale = 1; while( scale*2 < maxScale ) { n++; scale *= 2; } int ret[] = new int[n]; scale = 1; for( int i = 0; i < n; i++ ) { ret[i] = scale; scale *= 2; } return ret; }
java
public static int[] selectPyramidScale( int imageWidth , int imageHeight, int minSize ) { int w = Math.max(imageWidth,imageHeight); int maxScale = w/minSize; int n = 1; int scale = 1; while( scale*2 < maxScale ) { n++; scale *= 2; } int ret[] = new int[n]; scale = 1; for( int i = 0; i < n; i++ ) { ret[i] = scale; scale *= 2; } return ret; }
[ "public", "static", "int", "[", "]", "selectPyramidScale", "(", "int", "imageWidth", ",", "int", "imageHeight", ",", "int", "minSize", ")", "{", "int", "w", "=", "Math", ".", "max", "(", "imageWidth", ",", "imageHeight", ")", ";", "int", "maxScale", "=",...
Selects the scale for the image pyramid based on image size and feature size @return scales for image pyramid
[ "Selects", "the", "scale", "for", "the", "image", "pyramid", "based", "on", "image", "size", "and", "feature", "size" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldTracker.java#L391-L410
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeBinaryGridReader.java
QrCodeBinaryGridReader.imageToGrid
public void imageToGrid( Point2D_F64 pixel , Point2D_F64 grid ) { transformGrid.imageToGrid(pixel.x, pixel.y, grid); }
java
public void imageToGrid( Point2D_F64 pixel , Point2D_F64 grid ) { transformGrid.imageToGrid(pixel.x, pixel.y, grid); }
[ "public", "void", "imageToGrid", "(", "Point2D_F64", "pixel", ",", "Point2D_F64", "grid", ")", "{", "transformGrid", ".", "imageToGrid", "(", "pixel", ".", "x", ",", "pixel", ".", "y", ",", "grid", ")", ";", "}" ]
Converts a pixel coordinate into a grid coordinate.
[ "Converts", "a", "pixel", "coordinate", "into", "a", "grid", "coordinate", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeBinaryGridReader.java#L105-L107
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeBinaryGridReader.java
QrCodeBinaryGridReader.readBit
public int readBit( int row , int col ) { // todo use adjustments from near by alignment patterns float center = 0.5f; // if( pixel.x < -0.5 || pixel.y < -0.5 || pixel.x > imageWidth || pixel.y > imageHeight ) // return -1; transformGrid.gridToImage(row+center-0.2f, col+center, pixel); float pixel01 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center+0.2f, col+center, pixel); float pixel21 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center, col+center-0.2f, pixel); float pixel10 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center, col+center+0.2f, pixel); float pixel12 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center, col+center, pixel); float pixel00 = interpolate.get(pixel.x,pixel.y); // float threshold = this.threshold*1.25f; int total = 0; if( pixel01 < threshold ) total++; if( pixel21 < threshold ) total++; if( pixel10 < threshold ) total++; if( pixel12 < threshold ) total++; if( pixel00 < threshold ) total++; if( total >= 3 ) return 1; else return 0; // float value = (pixel01+pixel21+pixel10+pixel12)*0.25f; // value = value*0.5f + pixel00*0.5f; // in at least one situation this was found to improve the reading // float threshold; // if( qr != null ) { // int N = qr.getNumberOfModules(); // if( row > N/2 ) { // if( col < N/2 ) // threshold = (float)qr.threshDown; // else { // threshold = (float)(qr.threshDown+qr.threshRight)/2f; // } // } else if( col < N/2 ) { // threshold = (float)qr.threshCorner; // } else { // threshold = (float)qr.threshRight; // } // } else { // threshold = this.threshold; // } // if( pixel00 < threshold ) // return 1; // else // return 0; }
java
public int readBit( int row , int col ) { // todo use adjustments from near by alignment patterns float center = 0.5f; // if( pixel.x < -0.5 || pixel.y < -0.5 || pixel.x > imageWidth || pixel.y > imageHeight ) // return -1; transformGrid.gridToImage(row+center-0.2f, col+center, pixel); float pixel01 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center+0.2f, col+center, pixel); float pixel21 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center, col+center-0.2f, pixel); float pixel10 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center, col+center+0.2f, pixel); float pixel12 = interpolate.get(pixel.x,pixel.y); transformGrid.gridToImage(row+center, col+center, pixel); float pixel00 = interpolate.get(pixel.x,pixel.y); // float threshold = this.threshold*1.25f; int total = 0; if( pixel01 < threshold ) total++; if( pixel21 < threshold ) total++; if( pixel10 < threshold ) total++; if( pixel12 < threshold ) total++; if( pixel00 < threshold ) total++; if( total >= 3 ) return 1; else return 0; // float value = (pixel01+pixel21+pixel10+pixel12)*0.25f; // value = value*0.5f + pixel00*0.5f; // in at least one situation this was found to improve the reading // float threshold; // if( qr != null ) { // int N = qr.getNumberOfModules(); // if( row > N/2 ) { // if( col < N/2 ) // threshold = (float)qr.threshDown; // else { // threshold = (float)(qr.threshDown+qr.threshRight)/2f; // } // } else if( col < N/2 ) { // threshold = (float)qr.threshCorner; // } else { // threshold = (float)qr.threshRight; // } // } else { // threshold = this.threshold; // } // if( pixel00 < threshold ) // return 1; // else // return 0; }
[ "public", "int", "readBit", "(", "int", "row", ",", "int", "col", ")", "{", "// todo use adjustments from near by alignment patterns", "float", "center", "=", "0.5f", ";", "//\t\tif( pixel.x < -0.5 || pixel.y < -0.5 || pixel.x > imageWidth || pixel.y > imageHeight )", "//\t\t\tre...
Reads a bit from the qr code's data matrix while adjusting for location distortions using known feature locations. @param row grid row @param col grid column @return
[ "Reads", "a", "bit", "from", "the", "qr", "code", "s", "data", "matrix", "while", "adjusting", "for", "location", "distortions", "using", "known", "feature", "locations", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeBinaryGridReader.java#L132-L191
train
lessthanoptimal/BoofCV
integration/boofcv-WebcamCapture/src/main/java/boofcv/io/webcamcapture/UtilWebcamCapture.java
UtilWebcamCapture.openDefault
public static Webcam openDefault( int desiredWidth , int desiredHeight) { Webcam webcam = Webcam.getDefault(); // Webcam doesn't list all available resolutions. Just pass in a custom // resolution and hope it works adjustResolution(webcam,desiredWidth,desiredHeight); webcam.open(); return webcam; }
java
public static Webcam openDefault( int desiredWidth , int desiredHeight) { Webcam webcam = Webcam.getDefault(); // Webcam doesn't list all available resolutions. Just pass in a custom // resolution and hope it works adjustResolution(webcam,desiredWidth,desiredHeight); webcam.open(); return webcam; }
[ "public", "static", "Webcam", "openDefault", "(", "int", "desiredWidth", ",", "int", "desiredHeight", ")", "{", "Webcam", "webcam", "=", "Webcam", ".", "getDefault", "(", ")", ";", "// Webcam doesn't list all available resolutions. Just pass in a custom", "// resolution a...
Opens the default camera while adjusting its resolution
[ "Opens", "the", "default", "camera", "while", "adjusting", "its", "resolution" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-WebcamCapture/src/main/java/boofcv/io/webcamcapture/UtilWebcamCapture.java#L37-L46
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java
EllipsesIntoClusters.process
public void process(List<EllipseInfo> ellipses , List<List<Node>> output ) { init(ellipses); connect(ellipses); output.clear(); for (int i = 0; i < clusters.size(); i++) { List<Node> c = clusters.get(i); // remove noise removeSingleConnections(c); if( c.size() >= minimumClusterSize) { output.add(c); } } }
java
public void process(List<EllipseInfo> ellipses , List<List<Node>> output ) { init(ellipses); connect(ellipses); output.clear(); for (int i = 0; i < clusters.size(); i++) { List<Node> c = clusters.get(i); // remove noise removeSingleConnections(c); if( c.size() >= minimumClusterSize) { output.add(c); } } }
[ "public", "void", "process", "(", "List", "<", "EllipseInfo", ">", "ellipses", ",", "List", "<", "List", "<", "Node", ">", ">", "output", ")", "{", "init", "(", "ellipses", ")", ";", "connect", "(", "ellipses", ")", ";", "output", ".", "clear", "(", ...
Processes the ellipses and creates clusters. @param ellipses Set of unordered ellipses @param output Resulting found clusters. Cleared automatically. Returned lists are recycled on next call.
[ "Processes", "the", "ellipses", "and", "creates", "clusters", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java#L95-L112
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java
EllipsesIntoClusters.removeSingleConnections
static void removeSingleConnections( List<Node> cluster ) { List<Node> open = new ArrayList<>(); List<Node> future = new ArrayList<>(); open.addAll(cluster); while( !open.isEmpty() ) { for (int i = open.size()-1; i >= 0; i--) { Node n = open.get(i); if( n.connections.size == 1 ) { // clear it's connections and remove it from the cluster int index = findNode(n.which,cluster); cluster.remove(index); // Remove the reference to this node from its one connection int parent = findNode(n.connections.get(0),cluster); n.connections.reset(); if( parent == -1 ) throw new RuntimeException("BUG!"); Node p = cluster.get(parent); int edge = p.connections.indexOf(n.which); if( edge == -1 ) throw new RuntimeException("BUG!"); p.connections.remove(edge); // if the parent now only has one connection if( p.connections.size == 1) { future.add(p); } } } open.clear(); List<Node> tmp = open; open = future; future = tmp; } }
java
static void removeSingleConnections( List<Node> cluster ) { List<Node> open = new ArrayList<>(); List<Node> future = new ArrayList<>(); open.addAll(cluster); while( !open.isEmpty() ) { for (int i = open.size()-1; i >= 0; i--) { Node n = open.get(i); if( n.connections.size == 1 ) { // clear it's connections and remove it from the cluster int index = findNode(n.which,cluster); cluster.remove(index); // Remove the reference to this node from its one connection int parent = findNode(n.connections.get(0),cluster); n.connections.reset(); if( parent == -1 ) throw new RuntimeException("BUG!"); Node p = cluster.get(parent); int edge = p.connections.indexOf(n.which); if( edge == -1 ) throw new RuntimeException("BUG!"); p.connections.remove(edge); // if the parent now only has one connection if( p.connections.size == 1) { future.add(p); } } } open.clear(); List<Node> tmp = open; open = future; future = tmp; } }
[ "static", "void", "removeSingleConnections", "(", "List", "<", "Node", ">", "cluster", ")", "{", "List", "<", "Node", ">", "open", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "Node", ">", "future", "=", "new", "ArrayList", "<>", "(", "...
Removes stray connections that are highly likely to be noise. If a node has one connection it then removed. Then it's only connection is considered for removal.
[ "Removes", "stray", "connections", "that", "are", "highly", "likely", "to", "be", "noise", ".", "If", "a", "node", "has", "one", "connection", "it", "then", "removed", ".", "Then", "it", "s", "only", "connection", "is", "considered", "for", "removal", "." ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java#L221-L256
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java
EllipsesIntoClusters.init
void init(List<EllipseInfo> ellipses) { nodes.resize(ellipses.size()); clusters.reset(); for (int i = 0; i < ellipses.size(); i++) { Node n = nodes.get(i); n.connections.reset(); n.which = i; n.cluster = -1; } nn.setPoints(ellipses,true); }
java
void init(List<EllipseInfo> ellipses) { nodes.resize(ellipses.size()); clusters.reset(); for (int i = 0; i < ellipses.size(); i++) { Node n = nodes.get(i); n.connections.reset(); n.which = i; n.cluster = -1; } nn.setPoints(ellipses,true); }
[ "void", "init", "(", "List", "<", "EllipseInfo", ">", "ellipses", ")", "{", "nodes", ".", "resize", "(", "ellipses", ".", "size", "(", ")", ")", ";", "clusters", ".", "reset", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "ell...
Recycles and initializes all internal data structures
[ "Recycles", "and", "initializes", "all", "internal", "data", "structures" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java#L290-L302
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java
EllipsesIntoClusters.joinClusters
void joinClusters( int mouth , int food ) { List<Node> listMouth = clusters.get(mouth); List<Node> listFood = clusters.get(food); // put all members of food into mouth for (int i = 0; i < listFood.size(); i++) { listMouth.add( listFood.get(i) ); listFood.get(i).cluster = mouth; } // zero food members listFood.clear(); }
java
void joinClusters( int mouth , int food ) { List<Node> listMouth = clusters.get(mouth); List<Node> listFood = clusters.get(food); // put all members of food into mouth for (int i = 0; i < listFood.size(); i++) { listMouth.add( listFood.get(i) ); listFood.get(i).cluster = mouth; } // zero food members listFood.clear(); }
[ "void", "joinClusters", "(", "int", "mouth", ",", "int", "food", ")", "{", "List", "<", "Node", ">", "listMouth", "=", "clusters", ".", "get", "(", "mouth", ")", ";", "List", "<", "Node", ">", "listFood", "=", "clusters", ".", "get", "(", "food", "...
Moves all the members of 'food' into 'mouth' @param mouth The group which will not be changed. @param food All members of this group are put into mouth
[ "Moves", "all", "the", "members", "of", "food", "into", "mouth" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipsesIntoClusters.java#L309-L322
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/GrayI8.java
GrayI8.set
@Override public void set(int x, int y, int value) { if (!isInBounds(x, y)) throw new ImageAccessException("Requested pixel is out of bounds: "+x+" "+y); data[getIndex(x, y)] = (byte) value; }
java
@Override public void set(int x, int y, int value) { if (!isInBounds(x, y)) throw new ImageAccessException("Requested pixel is out of bounds: "+x+" "+y); data[getIndex(x, y)] = (byte) value; }
[ "@", "Override", "public", "void", "set", "(", "int", "x", ",", "int", "y", ",", "int", "value", ")", "{", "if", "(", "!", "isInBounds", "(", "x", ",", "y", ")", ")", "throw", "new", "ImageAccessException", "(", "\"Requested pixel is out of bounds: \"", ...
Sets the value of the specified pixel. @param x pixel coordinate. @param y pixel coordinate. @param value The pixel's new value.
[ "Sets", "the", "value", "of", "the", "specified", "pixel", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/GrayI8.java#L72-L78
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientSobel_Outer.java
GradientSobel_Outer.process
public static void process(GrayU8 orig, GrayS16 derivX, GrayS16 derivY) { final byte[] data = orig.data; final short[] imgX = derivX.data; final short[] imgY = derivY.data; final int width = orig.getWidth(); final int height = orig.getHeight() - 1; //CONCURRENT_BELOW BoofConcurrency.loopFor(1,height,y->{ for (int y = 1; y < height; y++) { int endX = width * y + width - 1; for (int index = width * y + 1; index < endX; index++) { int v = (data[index + width + 1] & 0xFF) - (data[index - width - 1] & 0xFF); int w = (data[index + width - 1] & 0xFF) - (data[index - width + 1] & 0xFF); imgY[index] = (short) (((data[index + width] & 0xFF) - (data[index - width] & 0xFF)) * 2 + v + w); imgX[index] = (short) (((data[index + 1] & 0xFF) - (data[index - 1] & 0xFF)) * 2 + v - w); } } //CONCURRENT_ABOVE }); }
java
public static void process(GrayU8 orig, GrayS16 derivX, GrayS16 derivY) { final byte[] data = orig.data; final short[] imgX = derivX.data; final short[] imgY = derivY.data; final int width = orig.getWidth(); final int height = orig.getHeight() - 1; //CONCURRENT_BELOW BoofConcurrency.loopFor(1,height,y->{ for (int y = 1; y < height; y++) { int endX = width * y + width - 1; for (int index = width * y + 1; index < endX; index++) { int v = (data[index + width + 1] & 0xFF) - (data[index - width - 1] & 0xFF); int w = (data[index + width - 1] & 0xFF) - (data[index - width + 1] & 0xFF); imgY[index] = (short) (((data[index + width] & 0xFF) - (data[index - width] & 0xFF)) * 2 + v + w); imgX[index] = (short) (((data[index + 1] & 0xFF) - (data[index - 1] & 0xFF)) * 2 + v - w); } } //CONCURRENT_ABOVE }); }
[ "public", "static", "void", "process", "(", "GrayU8", "orig", ",", "GrayS16", "derivX", ",", "GrayS16", "derivY", ")", "{", "final", "byte", "[", "]", "data", "=", "orig", ".", "data", ";", "final", "short", "[", "]", "imgX", "=", "derivX", ".", "dat...
Computes derivative of GrayU8. None of the images can be sub-images.
[ "Computes", "derivative", "of", "GrayU8", ".", "None", "of", "the", "images", "can", "be", "sub", "-", "images", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientSobel_Outer.java#L47-L71
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientSobel_Outer.java
GradientSobel_Outer.process_sub
public static void process_sub(GrayU8 orig, GrayS16 derivX, GrayS16 derivY) { final byte[] data = orig.data; final short[] imgX = derivX.data; final short[] imgY = derivY.data; final int width = orig.getWidth(); final int height = orig.getHeight() - 1; final int strideSrc = orig.getStride(); //CONCURRENT_BELOW BoofConcurrency.loopFor(1,height,y->{ for (int y = 1; y < height; y++) { int indexSrc = orig.startIndex + orig.stride * y + 1; final int endX = indexSrc + width - 2; int indexX = derivX.startIndex + derivX.stride * y + 1; int indexY = derivY.startIndex + derivY.stride * y + 1; for (; indexSrc < endX; indexSrc++) { int v = (data[indexSrc + strideSrc + 1] & 0xFF) - (data[indexSrc - strideSrc - 1] & 0xFF); int w = (data[indexSrc + strideSrc - 1] & 0xFF) - (data[indexSrc - strideSrc + 1] & 0xFF); imgY[indexY++] = (short) (((data[indexSrc + strideSrc] & 0xFF) - (data[indexSrc - strideSrc] & 0xFF)) * 2 + v + w); imgX[indexX++] = (short) (((data[indexSrc + 1] & 0xFF) - (data[indexSrc - 1] & 0xFF)) * 2 + v - w); } } //CONCURRENT_ABOVE }); }
java
public static void process_sub(GrayU8 orig, GrayS16 derivX, GrayS16 derivY) { final byte[] data = orig.data; final short[] imgX = derivX.data; final short[] imgY = derivY.data; final int width = orig.getWidth(); final int height = orig.getHeight() - 1; final int strideSrc = orig.getStride(); //CONCURRENT_BELOW BoofConcurrency.loopFor(1,height,y->{ for (int y = 1; y < height; y++) { int indexSrc = orig.startIndex + orig.stride * y + 1; final int endX = indexSrc + width - 2; int indexX = derivX.startIndex + derivX.stride * y + 1; int indexY = derivY.startIndex + derivY.stride * y + 1; for (; indexSrc < endX; indexSrc++) { int v = (data[indexSrc + strideSrc + 1] & 0xFF) - (data[indexSrc - strideSrc - 1] & 0xFF); int w = (data[indexSrc + strideSrc - 1] & 0xFF) - (data[indexSrc - strideSrc + 1] & 0xFF); imgY[indexY++] = (short) (((data[indexSrc + strideSrc] & 0xFF) - (data[indexSrc - strideSrc] & 0xFF)) * 2 + v + w); imgX[indexX++] = (short) (((data[indexSrc + 1] & 0xFF) - (data[indexSrc - 1] & 0xFF)) * 2 + v - w); } } //CONCURRENT_ABOVE }); }
[ "public", "static", "void", "process_sub", "(", "GrayU8", "orig", ",", "GrayS16", "derivX", ",", "GrayS16", "derivY", ")", "{", "final", "byte", "[", "]", "data", "=", "orig", ".", "data", ";", "final", "short", "[", "]", "imgX", "=", "derivX", ".", ...
Computes derivative of GrayU8. Inputs can be sub-images.
[ "Computes", "derivative", "of", "GrayU8", ".", "Inputs", "can", "be", "sub", "-", "images", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientSobel_Outer.java#L76-L105
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/pyramid/PyramidFloat.java
PyramidFloat.setScaleFactors
public void setScaleFactors( double ...scaleFactors ) { // see if the scale factors have not changed if( scale != null && scale.length == scaleFactors.length ) { boolean theSame = true; for( int i = 0; i < scale.length; i++ ) { if( scale[i] != scaleFactors[i] ) { theSame = false; break; } } // no changes needed if( theSame ) return; } // set width/height to zero to force the image to be redeclared bottomWidth = bottomHeight = 0; this.scale = scaleFactors.clone(); checkScales(); }
java
public void setScaleFactors( double ...scaleFactors ) { // see if the scale factors have not changed if( scale != null && scale.length == scaleFactors.length ) { boolean theSame = true; for( int i = 0; i < scale.length; i++ ) { if( scale[i] != scaleFactors[i] ) { theSame = false; break; } } // no changes needed if( theSame ) return; } // set width/height to zero to force the image to be redeclared bottomWidth = bottomHeight = 0; this.scale = scaleFactors.clone(); checkScales(); }
[ "public", "void", "setScaleFactors", "(", "double", "...", "scaleFactors", ")", "{", "// see if the scale factors have not changed", "if", "(", "scale", "!=", "null", "&&", "scale", ".", "length", "==", "scaleFactors", ".", "length", ")", "{", "boolean", "theSame"...
Specifies the pyramid's structure. @param scaleFactors Change in scale factor for each layer in the pyramid.
[ "Specifies", "the", "pyramid", "s", "structure", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/pyramid/PyramidFloat.java#L62-L81
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/misc/HistogramStatistics.java
HistogramStatistics.variance
public static double variance(int[] histogram, double mean , int N ) { return variance(histogram, mean, count(histogram,N), N); }
java
public static double variance(int[] histogram, double mean , int N ) { return variance(histogram, mean, count(histogram,N), N); }
[ "public", "static", "double", "variance", "(", "int", "[", "]", "histogram", ",", "double", "mean", ",", "int", "N", ")", "{", "return", "variance", "(", "histogram", ",", "mean", ",", "count", "(", "histogram", ",", "N", ")", ",", "N", ")", ";", "...
Computes the variance of pixel intensity values for a GrayU8 image represented by the given histogram. @param histogram Histogram with N bins @param mean Mean of the image. @param N number of bins in the histogram. @return variance
[ "Computes", "the", "variance", "of", "pixel", "intensity", "values", "for", "a", "GrayU8", "image", "represented", "by", "the", "given", "histogram", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/HistogramStatistics.java#L36-L38
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/misc/HistogramStatistics.java
HistogramStatistics.variance
public static double variance(int[] histogram, double mean, int counts , int N) { double sum = 0.0; for(int i=0;i<N;i++) { double d = i - mean; sum += (d*d) * histogram[i]; } return sum / counts; }
java
public static double variance(int[] histogram, double mean, int counts , int N) { double sum = 0.0; for(int i=0;i<N;i++) { double d = i - mean; sum += (d*d) * histogram[i]; } return sum / counts; }
[ "public", "static", "double", "variance", "(", "int", "[", "]", "histogram", ",", "double", "mean", ",", "int", "counts", ",", "int", "N", ")", "{", "double", "sum", "=", "0.0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i...
Computes the variance of elements in the histogram @param histogram Histogram with N bins @param mean Histogram's mean. @param counts Sum of all bins in the histogram. @param N number of bins in the histogram. @return variance of values inside the histogram
[ "Computes", "the", "variance", "of", "elements", "in", "the", "histogram" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/HistogramStatistics.java#L49-L57
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/misc/HistogramStatistics.java
HistogramStatistics.count
public static int count(int[] histogram, int N) { int counts = 0; for(int i=0;i<N;i++) { counts += histogram[i]; } return counts; }
java
public static int count(int[] histogram, int N) { int counts = 0; for(int i=0;i<N;i++) { counts += histogram[i]; } return counts; }
[ "public", "static", "int", "count", "(", "int", "[", "]", "histogram", ",", "int", "N", ")", "{", "int", "counts", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "N", ";", "i", "++", ")", "{", "counts", "+=", "histogram", "["...
Counts sum of all the bins inside the histogram @param histogram Histogram with N bins @param N number of bins in the histogram. @return Sum of all values in the histogram array.
[ "Counts", "sum", "of", "all", "the", "bins", "inside", "the", "histogram" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/HistogramStatistics.java#L66-L72
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GradientReduceToSingle.java
GradientReduceToSingle.maxf
public static void maxf(Planar<GrayF32> inX , Planar<GrayF32> inY , GrayF32 outX , GrayF32 outY ) { // input and output should be the same shape InputSanityCheck.checkSameShape(inX,inY); InputSanityCheck.reshapeOneIn(inX,outX,outY); // make sure that the pixel index is the same InputSanityCheck.checkIndexing(inX,inY); InputSanityCheck.checkIndexing(outX,outY); for (int y = 0; y < inX.height; y++) { int indexIn = inX.startIndex + inX.stride*y; int indexOut = outX.startIndex + outX.stride*y; for (int x = 0; x < inX.width; x++, indexIn++, indexOut++ ) { float maxValueX = inX.bands[0].data[indexIn]; float maxValueY = inY.bands[0].data[indexIn]; float maxNorm = maxValueX*maxValueX + maxValueY*maxValueY; for (int band = 1; band < inX.bands.length; band++) { float valueX = inX.bands[band].data[indexIn]; float valueY = inY.bands[band].data[indexIn]; float n = valueX*valueX + valueY*valueY; if( n > maxNorm ) { maxNorm = n; maxValueX = valueX; maxValueY = valueY; } } outX.data[indexOut] = maxValueX; outY.data[indexOut] = maxValueY; } } }
java
public static void maxf(Planar<GrayF32> inX , Planar<GrayF32> inY , GrayF32 outX , GrayF32 outY ) { // input and output should be the same shape InputSanityCheck.checkSameShape(inX,inY); InputSanityCheck.reshapeOneIn(inX,outX,outY); // make sure that the pixel index is the same InputSanityCheck.checkIndexing(inX,inY); InputSanityCheck.checkIndexing(outX,outY); for (int y = 0; y < inX.height; y++) { int indexIn = inX.startIndex + inX.stride*y; int indexOut = outX.startIndex + outX.stride*y; for (int x = 0; x < inX.width; x++, indexIn++, indexOut++ ) { float maxValueX = inX.bands[0].data[indexIn]; float maxValueY = inY.bands[0].data[indexIn]; float maxNorm = maxValueX*maxValueX + maxValueY*maxValueY; for (int band = 1; band < inX.bands.length; band++) { float valueX = inX.bands[band].data[indexIn]; float valueY = inY.bands[band].data[indexIn]; float n = valueX*valueX + valueY*valueY; if( n > maxNorm ) { maxNorm = n; maxValueX = valueX; maxValueY = valueY; } } outX.data[indexOut] = maxValueX; outY.data[indexOut] = maxValueY; } } }
[ "public", "static", "void", "maxf", "(", "Planar", "<", "GrayF32", ">", "inX", ",", "Planar", "<", "GrayF32", ">", "inY", ",", "GrayF32", "outX", ",", "GrayF32", "outY", ")", "{", "// input and output should be the same shape", "InputSanityCheck", ".", "checkSam...
Reduces the number of bands by selecting the band with the largest Frobenius norm and using its gradient to be the output gradient on a pixel-by-pixel basis @param inX Input gradient X @param inY Input gradient Y @param outX Output gradient X @param outY Output gradient Y
[ "Reduces", "the", "number", "of", "bands", "by", "selecting", "the", "band", "with", "the", "largest", "Frobenius", "norm", "and", "using", "its", "gradient", "to", "be", "the", "output", "gradient", "on", "a", "pixel", "-", "by", "-", "pixel", "basis" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/GradientReduceToSingle.java#L42-L77
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/enhance/ExampleImageEnhancement.java
ExampleImageEnhancement.histogram
public static void histogram() { BufferedImage buffered = UtilImageIO.loadImage(UtilIO.pathExample(imagePath)); GrayU8 gray = ConvertBufferedImage.convertFrom(buffered,(GrayU8)null); GrayU8 adjusted = gray.createSameShape(); int histogram[] = new int[256]; int transform[] = new int[256]; ListDisplayPanel panel = new ListDisplayPanel(); ImageStatistics.histogram(gray,0, histogram); EnhanceImageOps.equalize(histogram, transform); EnhanceImageOps.applyTransform(gray, transform, adjusted); panel.addImage(ConvertBufferedImage.convertTo(adjusted, null), "Global"); EnhanceImageOps.equalizeLocal(gray, 50, adjusted, 256, null); panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Local"); panel.addImage(ConvertBufferedImage.convertTo(gray, null), "Original"); panel.setPreferredSize(new Dimension(gray.width, gray.height)); mainPanel.addItem(panel, "Histogram"); }
java
public static void histogram() { BufferedImage buffered = UtilImageIO.loadImage(UtilIO.pathExample(imagePath)); GrayU8 gray = ConvertBufferedImage.convertFrom(buffered,(GrayU8)null); GrayU8 adjusted = gray.createSameShape(); int histogram[] = new int[256]; int transform[] = new int[256]; ListDisplayPanel panel = new ListDisplayPanel(); ImageStatistics.histogram(gray,0, histogram); EnhanceImageOps.equalize(histogram, transform); EnhanceImageOps.applyTransform(gray, transform, adjusted); panel.addImage(ConvertBufferedImage.convertTo(adjusted, null), "Global"); EnhanceImageOps.equalizeLocal(gray, 50, adjusted, 256, null); panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Local"); panel.addImage(ConvertBufferedImage.convertTo(gray, null), "Original"); panel.setPreferredSize(new Dimension(gray.width, gray.height)); mainPanel.addItem(panel, "Histogram"); }
[ "public", "static", "void", "histogram", "(", ")", "{", "BufferedImage", "buffered", "=", "UtilImageIO", ".", "loadImage", "(", "UtilIO", ".", "pathExample", "(", "imagePath", ")", ")", ";", "GrayU8", "gray", "=", "ConvertBufferedImage", ".", "convertFrom", "(...
Histogram adjustment algorithms aim to spread out pixel intensity values uniformly across the allowed range. This if an image is dark, it will have greater contrast and be brighter.
[ "Histogram", "adjustment", "algorithms", "aim", "to", "spread", "out", "pixel", "intensity", "values", "uniformly", "across", "the", "allowed", "range", ".", "This", "if", "an", "image", "is", "dark", "it", "will", "have", "greater", "contrast", "and", "be", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/enhance/ExampleImageEnhancement.java#L50-L72
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/enhance/ExampleImageEnhancement.java
ExampleImageEnhancement.sharpen
public static void sharpen() { BufferedImage buffered = UtilImageIO.loadImage(UtilIO.pathExample(imagePath)); GrayU8 gray = ConvertBufferedImage.convertFrom(buffered,(GrayU8)null); GrayU8 adjusted = gray.createSameShape(); ListDisplayPanel panel = new ListDisplayPanel(); EnhanceImageOps.sharpen4(gray, adjusted); panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-4"); EnhanceImageOps.sharpen8(gray, adjusted); panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-8"); panel.addImage(ConvertBufferedImage.convertTo(gray,null),"Original"); panel.setPreferredSize(new Dimension(gray.width,gray.height)); mainPanel.addItem(panel, "Sharpen"); }
java
public static void sharpen() { BufferedImage buffered = UtilImageIO.loadImage(UtilIO.pathExample(imagePath)); GrayU8 gray = ConvertBufferedImage.convertFrom(buffered,(GrayU8)null); GrayU8 adjusted = gray.createSameShape(); ListDisplayPanel panel = new ListDisplayPanel(); EnhanceImageOps.sharpen4(gray, adjusted); panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-4"); EnhanceImageOps.sharpen8(gray, adjusted); panel.addImage(ConvertBufferedImage.convertTo(adjusted,null),"Sharpen-8"); panel.addImage(ConvertBufferedImage.convertTo(gray,null),"Original"); panel.setPreferredSize(new Dimension(gray.width,gray.height)); mainPanel.addItem(panel, "Sharpen"); }
[ "public", "static", "void", "sharpen", "(", ")", "{", "BufferedImage", "buffered", "=", "UtilImageIO", ".", "loadImage", "(", "UtilIO", ".", "pathExample", "(", "imagePath", ")", ")", ";", "GrayU8", "gray", "=", "ConvertBufferedImage", ".", "convertFrom", "(",...
When an image is sharpened the intensity of edges are made more extreme while flat regions remain unchanged.
[ "When", "an", "image", "is", "sharpened", "the", "intensity", "of", "edges", "are", "made", "more", "extreme", "while", "flat", "regions", "remain", "unchanged", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/enhance/ExampleImageEnhancement.java#L77-L95
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/VisOdomPixelDepthPnP.java
VisOdomPixelDepthPnP.process
public boolean process( T image ) { tracker.process(image); tick++; inlierTracks.clear(); if( first ) { addNewTracks(); first = false; } else { if( !estimateMotion() ) { return false; } dropUnusedTracks(); int N = motionEstimator.getMatchSet().size(); if( thresholdAdd <= 0 || N < thresholdAdd ) { changePoseToReference(); addNewTracks(); } // System.out.println(" num inliers = "+N+" num dropped "+numDropped+" total active "+tracker.getActivePairs().size()); } return true; }
java
public boolean process( T image ) { tracker.process(image); tick++; inlierTracks.clear(); if( first ) { addNewTracks(); first = false; } else { if( !estimateMotion() ) { return false; } dropUnusedTracks(); int N = motionEstimator.getMatchSet().size(); if( thresholdAdd <= 0 || N < thresholdAdd ) { changePoseToReference(); addNewTracks(); } // System.out.println(" num inliers = "+N+" num dropped "+numDropped+" total active "+tracker.getActivePairs().size()); } return true; }
[ "public", "boolean", "process", "(", "T", "image", ")", "{", "tracker", ".", "process", "(", "image", ")", ";", "tick", "++", ";", "inlierTracks", ".", "clear", "(", ")", ";", "if", "(", "first", ")", "{", "addNewTracks", "(", ")", ";", "first", "=...
Estimates the motion given the left camera image. The latest information required by ImagePixelTo3D should be passed to the class before invoking this function. @param image Camera image. @return true if successful or false if it failed
[ "Estimates", "the", "motion", "given", "the", "left", "camera", "image", ".", "The", "latest", "information", "required", "by", "ImagePixelTo3D", "should", "be", "passed", "to", "the", "class", "before", "invoking", "this", "function", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/VisOdomPixelDepthPnP.java#L154-L180
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/VisOdomPixelDepthPnP.java
VisOdomPixelDepthPnP.addNewTracks
private void addNewTracks() { // System.out.println("----------- Adding new tracks ---------------"); tracker.spawnTracks(); List<PointTrack> spawned = tracker.getNewTracks(null); // estimate 3D coordinate using stereo vision for( PointTrack t : spawned ) { Point2D3DTrack p = t.getCookie(); if( p == null) { t.cookie = p = new Point2D3DTrack(); } // discard point if it can't localized if( !pixelTo3D.process(t.x,t.y) || pixelTo3D.getW() == 0 ) { tracker.dropTrack(t); } else { Point3D_F64 X = p.getLocation(); double w = pixelTo3D.getW(); X.set(pixelTo3D.getX() / w, pixelTo3D.getY() / w, pixelTo3D.getZ() / w); // translate the point into the key frame // SePointOps_F64.transform(currToKey,X,X); // not needed since the current frame was just set to be the key frame p.lastInlier = tick; pixelToNorm.compute(t.x, t.y, p.observation); } } }
java
private void addNewTracks() { // System.out.println("----------- Adding new tracks ---------------"); tracker.spawnTracks(); List<PointTrack> spawned = tracker.getNewTracks(null); // estimate 3D coordinate using stereo vision for( PointTrack t : spawned ) { Point2D3DTrack p = t.getCookie(); if( p == null) { t.cookie = p = new Point2D3DTrack(); } // discard point if it can't localized if( !pixelTo3D.process(t.x,t.y) || pixelTo3D.getW() == 0 ) { tracker.dropTrack(t); } else { Point3D_F64 X = p.getLocation(); double w = pixelTo3D.getW(); X.set(pixelTo3D.getX() / w, pixelTo3D.getY() / w, pixelTo3D.getZ() / w); // translate the point into the key frame // SePointOps_F64.transform(currToKey,X,X); // not needed since the current frame was just set to be the key frame p.lastInlier = tick; pixelToNorm.compute(t.x, t.y, p.observation); } } }
[ "private", "void", "addNewTracks", "(", ")", "{", "//\t\tSystem.out.println(\"----------- Adding new tracks ---------------\");", "tracker", ".", "spawnTracks", "(", ")", ";", "List", "<", "PointTrack", ">", "spawned", "=", "tracker", ".", "getNewTracks", "(", "null", ...
Detects new features and computes their 3D coordinates
[ "Detects", "new", "features", "and", "computes", "their", "3D", "coordinates" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/VisOdomPixelDepthPnP.java#L224-L254
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/VisOdomPixelDepthPnP.java
VisOdomPixelDepthPnP.estimateMotion
private boolean estimateMotion() { List<PointTrack> active = tracker.getActiveTracks(null); List<Point2D3D> obs = new ArrayList<>(); for( PointTrack t : active ) { Point2D3D p = t.getCookie(); pixelToNorm.compute( t.x , t.y , p.observation ); obs.add( p ); } // estimate the motion up to a scale factor in translation if( !motionEstimator.process( obs ) ) return false; if( doublePass ) { if (!performSecondPass(active, obs)) return false; } tracker.finishTracking(); Se3_F64 keyToCurr; if( refine != null ) { keyToCurr = new Se3_F64(); refine.fitModel(motionEstimator.getMatchSet(), motionEstimator.getModelParameters(), keyToCurr); } else { keyToCurr = motionEstimator.getModelParameters(); } keyToCurr.invert(currToKey); // mark tracks as being inliers and add to inlier list int N = motionEstimator.getMatchSet().size(); for( int i = 0; i < N; i++ ) { int index = motionEstimator.getInputIndex(i); Point2D3DTrack t = active.get(index).getCookie(); t.lastInlier = tick; inlierTracks.add( t ); } return true; }
java
private boolean estimateMotion() { List<PointTrack> active = tracker.getActiveTracks(null); List<Point2D3D> obs = new ArrayList<>(); for( PointTrack t : active ) { Point2D3D p = t.getCookie(); pixelToNorm.compute( t.x , t.y , p.observation ); obs.add( p ); } // estimate the motion up to a scale factor in translation if( !motionEstimator.process( obs ) ) return false; if( doublePass ) { if (!performSecondPass(active, obs)) return false; } tracker.finishTracking(); Se3_F64 keyToCurr; if( refine != null ) { keyToCurr = new Se3_F64(); refine.fitModel(motionEstimator.getMatchSet(), motionEstimator.getModelParameters(), keyToCurr); } else { keyToCurr = motionEstimator.getModelParameters(); } keyToCurr.invert(currToKey); // mark tracks as being inliers and add to inlier list int N = motionEstimator.getMatchSet().size(); for( int i = 0; i < N; i++ ) { int index = motionEstimator.getInputIndex(i); Point2D3DTrack t = active.get(index).getCookie(); t.lastInlier = tick; inlierTracks.add( t ); } return true; }
[ "private", "boolean", "estimateMotion", "(", ")", "{", "List", "<", "PointTrack", ">", "active", "=", "tracker", ".", "getActiveTracks", "(", "null", ")", ";", "List", "<", "Point2D3D", ">", "obs", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "...
Estimates motion from the set of tracks and their 3D location @return true if successful.
[ "Estimates", "motion", "from", "the", "set", "of", "tracks", "and", "their", "3D", "location" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/VisOdomPixelDepthPnP.java#L261-L302
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/EstimateSceneUncalibrated.java
EstimateSceneUncalibrated.scoreForTriangulation
double scoreForTriangulation( Motion motion ) { DMatrixRMaj H = new DMatrixRMaj(3,3); View viewA = motion.viewSrc; View viewB = motion.viewDst; // Compute initial estimate for H pairs.reset(); for (int i = 0; i < motion.associated.size(); i++) { AssociatedIndex ai = motion.associated.get(i); pairs.grow().set( viewA.observationPixels.get(ai.src), viewB.observationPixels.get(ai.dst)); } if(!computeH.process(pairs.toList(),H)) return -1; // remove bias from linear model if( !refineH.fitModel(pairs.toList(),H,H) ) return -1; // Compute 50% errors to avoid bias from outliers MultiViewOps.errorsHomographySymm(pairs.toList(),H,null,errors); errors.sort(); return errors.getFraction(0.5)*Math.max(5,pairs.size-20); }
java
double scoreForTriangulation( Motion motion ) { DMatrixRMaj H = new DMatrixRMaj(3,3); View viewA = motion.viewSrc; View viewB = motion.viewDst; // Compute initial estimate for H pairs.reset(); for (int i = 0; i < motion.associated.size(); i++) { AssociatedIndex ai = motion.associated.get(i); pairs.grow().set( viewA.observationPixels.get(ai.src), viewB.observationPixels.get(ai.dst)); } if(!computeH.process(pairs.toList(),H)) return -1; // remove bias from linear model if( !refineH.fitModel(pairs.toList(),H,H) ) return -1; // Compute 50% errors to avoid bias from outliers MultiViewOps.errorsHomographySymm(pairs.toList(),H,null,errors); errors.sort(); return errors.getFraction(0.5)*Math.max(5,pairs.size-20); }
[ "double", "scoreForTriangulation", "(", "Motion", "motion", ")", "{", "DMatrixRMaj", "H", "=", "new", "DMatrixRMaj", "(", "3", ",", "3", ")", ";", "View", "viewA", "=", "motion", ".", "viewSrc", ";", "View", "viewB", "=", "motion", ".", "viewDst", ";", ...
Compute score to decide which motion to initialize structure from. A homography is fit to the observations and the error compute. The homography should be a poor fit if the scene had 3D structure. The 50% homography error is then scaled by the number of pairs to bias the score good matches @param motion input @return fit score. Larger is better.
[ "Compute", "score", "to", "decide", "which", "motion", "to", "initialize", "structure", "from", ".", "A", "homography", "is", "fit", "to", "the", "observations", "and", "the", "error", "compute", ".", "The", "homography", "should", "be", "a", "poor", "fit", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/EstimateSceneUncalibrated.java#L217-L245
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/WorldToCameraToPixel.java
WorldToCameraToPixel.configure
public void configure(LensDistortionNarrowFOV distortion , Se3_F64 worldToCamera ) { this.worldToCamera = worldToCamera; normToPixel = distortion.distort_F64(false,true); }
java
public void configure(LensDistortionNarrowFOV distortion , Se3_F64 worldToCamera ) { this.worldToCamera = worldToCamera; normToPixel = distortion.distort_F64(false,true); }
[ "public", "void", "configure", "(", "LensDistortionNarrowFOV", "distortion", ",", "Se3_F64", "worldToCamera", ")", "{", "this", ".", "worldToCamera", "=", "worldToCamera", ";", "normToPixel", "=", "distortion", ".", "distort_F64", "(", "false", ",", "true", ")", ...
Specifies intrinsic camera parameters and the transform from world to camera. @param distortion camera parameters @param worldToCamera transform from world to camera
[ "Specifies", "intrinsic", "camera", "parameters", "and", "the", "transform", "from", "world", "to", "camera", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/WorldToCameraToPixel.java#L67-L71
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/WorldToCameraToPixel.java
WorldToCameraToPixel.transform
public boolean transform( Point3D_F64 worldPt , Point2D_F64 pixelPt ) { SePointOps_F64.transform(worldToCamera,worldPt,cameraPt); // can't see the point if( cameraPt.z <= 0 ) return false; normToPixel.compute(cameraPt.x/cameraPt.z, cameraPt.y/cameraPt.z, pixelPt); return true; }
java
public boolean transform( Point3D_F64 worldPt , Point2D_F64 pixelPt ) { SePointOps_F64.transform(worldToCamera,worldPt,cameraPt); // can't see the point if( cameraPt.z <= 0 ) return false; normToPixel.compute(cameraPt.x/cameraPt.z, cameraPt.y/cameraPt.z, pixelPt); return true; }
[ "public", "boolean", "transform", "(", "Point3D_F64", "worldPt", ",", "Point2D_F64", "pixelPt", ")", "{", "SePointOps_F64", ".", "transform", "(", "worldToCamera", ",", "worldPt", ",", "cameraPt", ")", ";", "// can't see the point", "if", "(", "cameraPt", ".", "...
Computes the observed location of the specified point in world coordinates in the camera pixel. If the object can't be viewed because it is behind the camera then false is returned. @param worldPt Location of point in world frame @param pixelPt Pixel observation of point. @return True if visible (+z) or false if not visible (-z)
[ "Computes", "the", "observed", "location", "of", "the", "specified", "point", "in", "world", "coordinates", "in", "the", "camera", "pixel", ".", "If", "the", "object", "can", "t", "be", "viewed", "because", "it", "is", "behind", "the", "camera", "then", "f...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/WorldToCameraToPixel.java#L80-L89
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/WorldToCameraToPixel.java
WorldToCameraToPixel.transform
public Point2D_F64 transform( Point3D_F64 worldPt ) { Point2D_F64 out = new Point2D_F64(); if( transform(worldPt,out)) return out; else return null; }
java
public Point2D_F64 transform( Point3D_F64 worldPt ) { Point2D_F64 out = new Point2D_F64(); if( transform(worldPt,out)) return out; else return null; }
[ "public", "Point2D_F64", "transform", "(", "Point3D_F64", "worldPt", ")", "{", "Point2D_F64", "out", "=", "new", "Point2D_F64", "(", ")", ";", "if", "(", "transform", "(", "worldPt", ",", "out", ")", ")", "return", "out", ";", "else", "return", "null", "...
Computes location of 3D point in world as observed in the camera. Point is returned if visible or null if not visible. @param worldPt Location of point on world reference frame @return Pixel coordinate of point or null if not visible
[ "Computes", "location", "of", "3D", "point", "in", "world", "as", "observed", "in", "the", "camera", ".", "Point", "is", "returned", "if", "visible", "or", "null", "if", "not", "visible", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/WorldToCameraToPixel.java#L112-L118
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java
SplitMergeLineFitLoop.splitPixels
protected void splitPixels(int indexStart, int length) { // too short to split if( length < minimumSideLengthPixel) return; // end points of the line int indexEnd = (indexStart+length)%N; int splitOffset = selectSplitOffset(indexStart,length); if( splitOffset >= 0 ) { // System.out.println(" splitting "); splitPixels(indexStart, splitOffset); int indexSplit = (indexStart+splitOffset)%N; splits.add(indexSplit); splitPixels(indexSplit, circularDistance(indexSplit, indexEnd)); } }
java
protected void splitPixels(int indexStart, int length) { // too short to split if( length < minimumSideLengthPixel) return; // end points of the line int indexEnd = (indexStart+length)%N; int splitOffset = selectSplitOffset(indexStart,length); if( splitOffset >= 0 ) { // System.out.println(" splitting "); splitPixels(indexStart, splitOffset); int indexSplit = (indexStart+splitOffset)%N; splits.add(indexSplit); splitPixels(indexSplit, circularDistance(indexSplit, indexEnd)); } }
[ "protected", "void", "splitPixels", "(", "int", "indexStart", ",", "int", "length", ")", "{", "// too short to split", "if", "(", "length", "<", "minimumSideLengthPixel", ")", "return", ";", "// end points of the line", "int", "indexEnd", "=", "(", "indexStart", "...
Recursively splits pixels between indexStart to indexStart+length. A split happens if there is a pixel more than the desired distance away from the two end points. Results are placed into 'splits'
[ "Recursively", "splits", "pixels", "between", "indexStart", "to", "indexStart", "+", "length", ".", "A", "split", "happens", "if", "there", "is", "a", "pixel", "more", "than", "the", "desired", "distance", "away", "from", "the", "two", "end", "points", ".", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java#L98-L115
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java
SplitMergeLineFitLoop.mergeSegments
protected boolean mergeSegments() { // See if merging will cause a degenerate case if( splits.size() <= 3 ) return false; boolean change = false; work.reset(); for( int i = 0; i < splits.size; i++ ) { int start = splits.data[i]; int end = splits.data[(i+2)%splits.size]; if( selectSplitOffset(start,circularDistance(start,end)) < 0 ) { // merge the two lines by not adding it change = true; } else { work.add(splits.data[(i + 1)%splits.size]); } } // swap the two lists GrowQueue_I32 tmp = work; work = splits; splits = tmp; return change; }
java
protected boolean mergeSegments() { // See if merging will cause a degenerate case if( splits.size() <= 3 ) return false; boolean change = false; work.reset(); for( int i = 0; i < splits.size; i++ ) { int start = splits.data[i]; int end = splits.data[(i+2)%splits.size]; if( selectSplitOffset(start,circularDistance(start,end)) < 0 ) { // merge the two lines by not adding it change = true; } else { work.add(splits.data[(i + 1)%splits.size]); } } // swap the two lists GrowQueue_I32 tmp = work; work = splits; splits = tmp; return change; }
[ "protected", "boolean", "mergeSegments", "(", ")", "{", "// See if merging will cause a degenerate case", "if", "(", "splits", ".", "size", "(", ")", "<=", "3", ")", "return", "false", ";", "boolean", "change", "=", "false", ";", "work", ".", "reset", "(", "...
Merges lines together if the common corner is close to a common line @return true the list being changed
[ "Merges", "lines", "together", "if", "the", "common", "corner", "is", "close", "to", "a", "common", "line" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java#L153-L181
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java
SplitMergeLineFitLoop.splitSegments
protected boolean splitSegments() { boolean change = false; work.reset(); for( int i = 0; i < splits.size-1; i++ ) { change |= checkSplit(change, i,i+1); } change |= checkSplit(change, splits.size - 1, 0); // swap the two lists GrowQueue_I32 tmp = work; work = splits; splits = tmp; return change; }
java
protected boolean splitSegments() { boolean change = false; work.reset(); for( int i = 0; i < splits.size-1; i++ ) { change |= checkSplit(change, i,i+1); } change |= checkSplit(change, splits.size - 1, 0); // swap the two lists GrowQueue_I32 tmp = work; work = splits; splits = tmp; return change; }
[ "protected", "boolean", "splitSegments", "(", ")", "{", "boolean", "change", "=", "false", ";", "work", ".", "reset", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "splits", ".", "size", "-", "1", ";", "i", "++", ")", "{", "ch...
Splits a line in two if there is a point that is too far away @return true for change
[ "Splits", "a", "line", "in", "two", "if", "there", "is", "a", "point", "that", "is", "too", "far", "away" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java#L187-L203
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java
SplitMergeLineFitLoop.circularDistance
protected int circularDistance( int start , int end ) { if( end >= start ) return end-start; else return N-start+end; }
java
protected int circularDistance( int start , int end ) { if( end >= start ) return end-start; else return N-start+end; }
[ "protected", "int", "circularDistance", "(", "int", "start", ",", "int", "end", ")", "{", "if", "(", "end", ">=", "start", ")", "return", "end", "-", "start", ";", "else", "return", "N", "-", "start", "+", "end", ";", "}" ]
Distance the two points are apart in clockwise direction
[ "Distance", "the", "two", "points", "are", "apart", "in", "clockwise", "direction" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFitLoop.java#L260-L265
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/misc/ImplAverageDownSample.java
ImplAverageDownSample.horizontal
public static void horizontal( GrayF32 src , GrayF32 dst ) { if( src.width < dst.width ) throw new IllegalArgumentException("src width must be >= dst width"); if( src.height != dst.height ) throw new IllegalArgumentException("src height must equal dst height"); float scale = src.width/(float)dst.width; //CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.height, y -> { for (int y = 0; y < dst.height; y++) { int indexDst = dst.startIndex + y*dst.stride; for (int x = 0; x < dst.width-1; x++, indexDst++ ) { float srcX0 = x*scale; float srcX1 = (x+1)*scale; int isrcX0 = (int)srcX0; int isrcX1 = (int)srcX1; int index = src.getIndex(isrcX0,y); // compute value of overlapped region float startWeight = (1.0f-(srcX0-isrcX0)); float start = src.data[index++]; float middle = 0; for( int i = isrcX0+1; i < isrcX1; i++ ) { middle += src.data[index++]; } float endWeight = (srcX1%1); float end = src.data[index]; dst.data[indexDst] = (start*startWeight + middle + end*endWeight)/scale; } // handle the last area as a special case int x = dst.width-1; float srcX0 = x*scale; int isrcX0 = (int)srcX0; int isrcX1 = src.width-1; int index = src.getIndex(isrcX0,y); // compute value of overlapped region float startWeight = (1.0f-(srcX0-isrcX0)); float start = src.data[index++]; float middle = 0; for( int i = isrcX0+1; i < isrcX1; i++ ) { middle += src.data[index++]; } float end = isrcX1 != isrcX0 ? src.data[index] : 0; dst.data[indexDst] = (start*startWeight + middle + end)/scale; } //CONCURRENT_ABOVE }); }
java
public static void horizontal( GrayF32 src , GrayF32 dst ) { if( src.width < dst.width ) throw new IllegalArgumentException("src width must be >= dst width"); if( src.height != dst.height ) throw new IllegalArgumentException("src height must equal dst height"); float scale = src.width/(float)dst.width; //CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.height, y -> { for (int y = 0; y < dst.height; y++) { int indexDst = dst.startIndex + y*dst.stride; for (int x = 0; x < dst.width-1; x++, indexDst++ ) { float srcX0 = x*scale; float srcX1 = (x+1)*scale; int isrcX0 = (int)srcX0; int isrcX1 = (int)srcX1; int index = src.getIndex(isrcX0,y); // compute value of overlapped region float startWeight = (1.0f-(srcX0-isrcX0)); float start = src.data[index++]; float middle = 0; for( int i = isrcX0+1; i < isrcX1; i++ ) { middle += src.data[index++]; } float endWeight = (srcX1%1); float end = src.data[index]; dst.data[indexDst] = (start*startWeight + middle + end*endWeight)/scale; } // handle the last area as a special case int x = dst.width-1; float srcX0 = x*scale; int isrcX0 = (int)srcX0; int isrcX1 = src.width-1; int index = src.getIndex(isrcX0,y); // compute value of overlapped region float startWeight = (1.0f-(srcX0-isrcX0)); float start = src.data[index++]; float middle = 0; for( int i = isrcX0+1; i < isrcX1; i++ ) { middle += src.data[index++]; } float end = isrcX1 != isrcX0 ? src.data[index] : 0; dst.data[indexDst] = (start*startWeight + middle + end)/scale; } //CONCURRENT_ABOVE }); }
[ "public", "static", "void", "horizontal", "(", "GrayF32", "src", ",", "GrayF32", "dst", ")", "{", "if", "(", "src", ".", "width", "<", "dst", ".", "width", ")", "throw", "new", "IllegalArgumentException", "(", "\"src width must be >= dst width\"", ")", ";", ...
Down samples the image along the x-axis only. Image height's must be the same. @param src Input image. Not modified. @param dst Output image. Modified.
[ "Down", "samples", "the", "image", "along", "the", "x", "-", "axis", "only", ".", "Image", "height", "s", "must", "be", "the", "same", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/misc/ImplAverageDownSample.java#L314-L371
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/misc/ImplAverageDownSample.java
ImplAverageDownSample.vertical
public static void vertical( GrayF32 src , GrayF32 dst ) { if( src.height < dst.height ) throw new IllegalArgumentException("src height must be >= dst height"); if( src.width != dst.width ) throw new IllegalArgumentException("src width must equal dst width"); float scale = src.height/(float)dst.height; //CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.width, x -> { for (int x = 0; x < dst.width; x++) { int indexDst = dst.startIndex + x; for (int y = 0; y < dst.height-1; y++) { float srcY0 = y*scale; float srcY1 = (y+1)*scale; int isrcY0 = (int)srcY0; int isrcY1 = (int)srcY1; int index = src.getIndex(x,isrcY0); // compute value of overlapped region float startWeight = (1.0f-(srcY0-isrcY0)); float start = src.data[index]; index += src.stride; float middle = 0; for( int i = isrcY0+1; i < isrcY1; i++ ) { middle += src.data[index]; index += src.stride; } float endWeight = (srcY1%1); float end = src.data[index]; dst.data[indexDst] = (float)((start*startWeight + middle + end*endWeight)/scale ); indexDst += dst.stride; } // handle the last area as a special case int y = dst.height-1; float srcY0 = y*scale; int isrcY0 = (int)srcY0; int isrcY1 = src.height-1; int index = src.getIndex(x,isrcY0); // compute value of overlapped region float startWeight = (1.0f-(srcY0-isrcY0)); float start = src.data[index]; index += src.stride; float middle = 0; for( int i = isrcY0+1; i < isrcY1; i++ ) { middle += src.data[index]; index += src.stride; } float end = isrcY1 != isrcY0 ? src.data[index]: 0; dst.data[indexDst] = (float)((start*startWeight + middle + end)/scale ); } //CONCURRENT_ABOVE }); }
java
public static void vertical( GrayF32 src , GrayF32 dst ) { if( src.height < dst.height ) throw new IllegalArgumentException("src height must be >= dst height"); if( src.width != dst.width ) throw new IllegalArgumentException("src width must equal dst width"); float scale = src.height/(float)dst.height; //CONCURRENT_BELOW BoofConcurrency.loopFor(0, dst.width, x -> { for (int x = 0; x < dst.width; x++) { int indexDst = dst.startIndex + x; for (int y = 0; y < dst.height-1; y++) { float srcY0 = y*scale; float srcY1 = (y+1)*scale; int isrcY0 = (int)srcY0; int isrcY1 = (int)srcY1; int index = src.getIndex(x,isrcY0); // compute value of overlapped region float startWeight = (1.0f-(srcY0-isrcY0)); float start = src.data[index]; index += src.stride; float middle = 0; for( int i = isrcY0+1; i < isrcY1; i++ ) { middle += src.data[index]; index += src.stride; } float endWeight = (srcY1%1); float end = src.data[index]; dst.data[indexDst] = (float)((start*startWeight + middle + end*endWeight)/scale ); indexDst += dst.stride; } // handle the last area as a special case int y = dst.height-1; float srcY0 = y*scale; int isrcY0 = (int)srcY0; int isrcY1 = src.height-1; int index = src.getIndex(x,isrcY0); // compute value of overlapped region float startWeight = (1.0f-(srcY0-isrcY0)); float start = src.data[index]; index += src.stride; float middle = 0; for( int i = isrcY0+1; i < isrcY1; i++ ) { middle += src.data[index]; index += src.stride; } float end = isrcY1 != isrcY0 ? src.data[index]: 0; dst.data[indexDst] = (float)((start*startWeight + middle + end)/scale ); } //CONCURRENT_ABOVE }); }
[ "public", "static", "void", "vertical", "(", "GrayF32", "src", ",", "GrayF32", "dst", ")", "{", "if", "(", "src", ".", "height", "<", "dst", ".", "height", ")", "throw", "new", "IllegalArgumentException", "(", "\"src height must be >= dst height\"", ")", ";", ...
Down samples the image along the y-axis only. Image width's must be the same. @param src Input image. Not modified. @param dst Output image. Modified.
[ "Down", "samples", "the", "image", "along", "the", "y", "-", "axis", "only", ".", "Image", "width", "s", "must", "be", "the", "same", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/misc/ImplAverageDownSample.java#L378-L441
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/sfm/d2/Motion2DPanel.java
Motion2DPanel.drawFeatures
protected void drawFeatures( float scale , int offsetX , int offsetY , FastQueue<Point2D_F64> all, FastQueue<Point2D_F64> inliers, Homography2D_F64 currToGlobal, Graphics2D g2 ) { Point2D_F64 distPt = new Point2D_F64(); for( int i = 0; i < all.size; i++ ) { HomographyPointOps_F64.transform(currToGlobal, all.get(i), distPt); distPt.x = offsetX + distPt.x*scale; distPt.y = offsetY + distPt.y*scale; VisualizeFeatures.drawPoint(g2, (int) distPt.x, (int) distPt.y, Color.RED); } for( int i = 0; i < inliers.size; i++ ) { HomographyPointOps_F64.transform(currToGlobal,inliers.get(i),distPt); distPt.x = offsetX + distPt.x*scale; distPt.y = offsetY + distPt.y*scale; VisualizeFeatures.drawPoint(g2, (int) distPt.x, (int) distPt.y, Color.BLUE); } }
java
protected void drawFeatures( float scale , int offsetX , int offsetY , FastQueue<Point2D_F64> all, FastQueue<Point2D_F64> inliers, Homography2D_F64 currToGlobal, Graphics2D g2 ) { Point2D_F64 distPt = new Point2D_F64(); for( int i = 0; i < all.size; i++ ) { HomographyPointOps_F64.transform(currToGlobal, all.get(i), distPt); distPt.x = offsetX + distPt.x*scale; distPt.y = offsetY + distPt.y*scale; VisualizeFeatures.drawPoint(g2, (int) distPt.x, (int) distPt.y, Color.RED); } for( int i = 0; i < inliers.size; i++ ) { HomographyPointOps_F64.transform(currToGlobal,inliers.get(i),distPt); distPt.x = offsetX + distPt.x*scale; distPt.y = offsetY + distPt.y*scale; VisualizeFeatures.drawPoint(g2, (int) distPt.x, (int) distPt.y, Color.BLUE); } }
[ "protected", "void", "drawFeatures", "(", "float", "scale", ",", "int", "offsetX", ",", "int", "offsetY", ",", "FastQueue", "<", "Point2D_F64", ">", "all", ",", "FastQueue", "<", "Point2D_F64", ">", "inliers", ",", "Homography2D_F64", "currToGlobal", ",", "Gra...
Draw features after applying a homography transformation.
[ "Draw", "features", "after", "applying", "a", "homography", "transformation", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/sfm/d2/Motion2DPanel.java#L119-L143
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/ImageHistogramPanel.java
ImageHistogramPanel.update
public void update( ImageGray image ) { if( approximateHistogram ) { for (int i = 0; i < bins.length; i++) bins[i] = 0; if (image instanceof GrayF32) update((GrayF32) image); else if (GrayI.class.isAssignableFrom(image.getClass())) update((GrayI) image); else throw new IllegalArgumentException("Image type not yet supported"); } else { GImageStatistics.histogram(image,0,bins); } }
java
public void update( ImageGray image ) { if( approximateHistogram ) { for (int i = 0; i < bins.length; i++) bins[i] = 0; if (image instanceof GrayF32) update((GrayF32) image); else if (GrayI.class.isAssignableFrom(image.getClass())) update((GrayI) image); else throw new IllegalArgumentException("Image type not yet supported"); } else { GImageStatistics.histogram(image,0,bins); } }
[ "public", "void", "update", "(", "ImageGray", "image", ")", "{", "if", "(", "approximateHistogram", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "bins", ".", "length", ";", "i", "++", ")", "bins", "[", "i", "]", "=", "0", ";", "if...
Update's the histogram. Must only be called in UI thread
[ "Update", "s", "the", "histogram", ".", "Must", "only", "be", "called", "in", "UI", "thread" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/ImageHistogramPanel.java#L60-L74
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/ListDisplayPanel.java
ListDisplayPanel.addImage
public void addImage( BufferedImage image , String name) { addImage(image, name, ScaleOptions.DOWN); }
java
public void addImage( BufferedImage image , String name) { addImage(image, name, ScaleOptions.DOWN); }
[ "public", "void", "addImage", "(", "BufferedImage", "image", ",", "String", "name", ")", "{", "addImage", "(", "image", ",", "name", ",", "ScaleOptions", ".", "DOWN", ")", ";", "}" ]
Displays a new image in the list. @param image The image being displayed @param name Name of the image. Shown in the list.
[ "Displays", "a", "new", "image", "in", "the", "list", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/ListDisplayPanel.java#L101-L103
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/ListDisplayPanel.java
ListDisplayPanel.addItem
public synchronized void addItem( final JComponent panel , final String name ) { Dimension panelD = panel.getPreferredSize(); final boolean sizeChanged = bodyWidth != panelD.width || bodyHeight != panelD.height; // make the preferred size large enough to hold all the images bodyWidth = (int)Math.max(bodyWidth, panelD.getWidth()); bodyHeight = (int)Math.max(bodyHeight,panelD.getHeight()); panels.add(panel); SwingUtilities.invokeLater(new Runnable() { public void run() { listModel.addElement(name); if (listModel.size() == 1) { listPanel.setSelectedIndex(0); } // update the list's size Dimension d = listPanel.getMinimumSize(); listPanel.setPreferredSize(new Dimension(d.width + scroll.getVerticalScrollBar().getWidth(), d.height)); // make sure it's preferred size is up to date if( sizeChanged ) { Component old = ((BorderLayout) bodyPanel.getLayout()).getLayoutComponent(BorderLayout.CENTER); if (old != null) { old.setPreferredSize(new Dimension(bodyWidth, bodyHeight)); } } validate(); } }); }
java
public synchronized void addItem( final JComponent panel , final String name ) { Dimension panelD = panel.getPreferredSize(); final boolean sizeChanged = bodyWidth != panelD.width || bodyHeight != panelD.height; // make the preferred size large enough to hold all the images bodyWidth = (int)Math.max(bodyWidth, panelD.getWidth()); bodyHeight = (int)Math.max(bodyHeight,panelD.getHeight()); panels.add(panel); SwingUtilities.invokeLater(new Runnable() { public void run() { listModel.addElement(name); if (listModel.size() == 1) { listPanel.setSelectedIndex(0); } // update the list's size Dimension d = listPanel.getMinimumSize(); listPanel.setPreferredSize(new Dimension(d.width + scroll.getVerticalScrollBar().getWidth(), d.height)); // make sure it's preferred size is up to date if( sizeChanged ) { Component old = ((BorderLayout) bodyPanel.getLayout()).getLayoutComponent(BorderLayout.CENTER); if (old != null) { old.setPreferredSize(new Dimension(bodyWidth, bodyHeight)); } } validate(); } }); }
[ "public", "synchronized", "void", "addItem", "(", "final", "JComponent", "panel", ",", "final", "String", "name", ")", "{", "Dimension", "panelD", "=", "panel", ".", "getPreferredSize", "(", ")", ";", "final", "boolean", "sizeChanged", "=", "bodyWidth", "!=", ...
Displays a new JPanel in the list. @param panel The panel being displayed @param name Name of the image. Shown in the list.
[ "Displays", "a", "new", "JPanel", "in", "the", "list", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/ListDisplayPanel.java#L115-L146
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/LensDistortionOps_F64.java
LensDistortionOps_F64.centerBoxInside
public static RectangleLength2D_F64 centerBoxInside(int srcWidth, int srcHeight, PixelTransform<Point2D_F64> transform , Point2D_F64 work ) { List<Point2D_F64> points = computeBoundingPoints(srcWidth, srcHeight, transform, work); Point2D_F64 center = new Point2D_F64(); UtilPoint2D_F64.mean(points,center); double x0,x1,y0,y1; double bx0,bx1,by0,by1; x0=x1=y0=y1=0; bx0=bx1=by0=by1=Double.MAX_VALUE; for (int i = 0; i < points.size(); i++) { Point2D_F64 p = points.get(i); double dx = p.x-center.x; double dy = p.y-center.y; double adx = Math.abs(dx); double ady = Math.abs(dy); if( adx < ady ) { if( dy < 0 ) { if( adx < by0 ) { by0 = adx; y0 = dy; } } else { if( adx < by1 ) { by1 = adx; y1 = dy; } } } else { if( dx < 0 ) { if( ady < bx0 ) { bx0 = ady; x0 = dx; } } else { if( ady < bx1 ) { bx1 = ady; x1 = dx; } } } } return new RectangleLength2D_F64(x0+center.x,y0+center.y,x1-x0,y1-y0); }
java
public static RectangleLength2D_F64 centerBoxInside(int srcWidth, int srcHeight, PixelTransform<Point2D_F64> transform , Point2D_F64 work ) { List<Point2D_F64> points = computeBoundingPoints(srcWidth, srcHeight, transform, work); Point2D_F64 center = new Point2D_F64(); UtilPoint2D_F64.mean(points,center); double x0,x1,y0,y1; double bx0,bx1,by0,by1; x0=x1=y0=y1=0; bx0=bx1=by0=by1=Double.MAX_VALUE; for (int i = 0; i < points.size(); i++) { Point2D_F64 p = points.get(i); double dx = p.x-center.x; double dy = p.y-center.y; double adx = Math.abs(dx); double ady = Math.abs(dy); if( adx < ady ) { if( dy < 0 ) { if( adx < by0 ) { by0 = adx; y0 = dy; } } else { if( adx < by1 ) { by1 = adx; y1 = dy; } } } else { if( dx < 0 ) { if( ady < bx0 ) { bx0 = ady; x0 = dx; } } else { if( ady < bx1 ) { bx1 = ady; x1 = dx; } } } } return new RectangleLength2D_F64(x0+center.x,y0+center.y,x1-x0,y1-y0); }
[ "public", "static", "RectangleLength2D_F64", "centerBoxInside", "(", "int", "srcWidth", ",", "int", "srcHeight", ",", "PixelTransform", "<", "Point2D_F64", ">", "transform", ",", "Point2D_F64", "work", ")", "{", "List", "<", "Point2D_F64", ">", "points", "=", "c...
Attempts to center the box inside. It will be approximately fitted too. @param srcWidth Width of the source image @param srcHeight Height of the source image @param transform Transform being applied to the image @return Bounding box
[ "Attempts", "to", "center", "the", "box", "inside", ".", "It", "will", "be", "approximately", "fitted", "too", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/LensDistortionOps_F64.java#L211-L261
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/LensDistortionOps_F64.java
LensDistortionOps_F64.roundInside
public static void roundInside( RectangleLength2D_F64 bound ) { double x0 = Math.ceil(bound.x0); double y0 = Math.ceil(bound.y0); double x1 = Math.floor(bound.x0+bound.width); double y1 = Math.floor(bound.y0+bound.height); bound.x0 = x0; bound.y0 = y0; bound.width = x1-x0; bound.height = y1-y0; }
java
public static void roundInside( RectangleLength2D_F64 bound ) { double x0 = Math.ceil(bound.x0); double y0 = Math.ceil(bound.y0); double x1 = Math.floor(bound.x0+bound.width); double y1 = Math.floor(bound.y0+bound.height); bound.x0 = x0; bound.y0 = y0; bound.width = x1-x0; bound.height = y1-y0; }
[ "public", "static", "void", "roundInside", "(", "RectangleLength2D_F64", "bound", ")", "{", "double", "x0", "=", "Math", ".", "ceil", "(", "bound", ".", "x0", ")", ";", "double", "y0", "=", "Math", ".", "ceil", "(", "bound", ".", "y0", ")", ";", "dou...
Adjust bound to ensure the entire image is contained inside, otherwise there might be single pixel wide black regions
[ "Adjust", "bound", "to", "ensure", "the", "entire", "image", "is", "contained", "inside", "otherwise", "there", "might", "be", "single", "pixel", "wide", "black", "regions" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/LensDistortionOps_F64.java#L288-L298
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointPixelRegionNCC.java
DescribePointPixelRegionNCC.isInBounds
public boolean isInBounds( int c_x , int c_y ) { return BoofMiscOps.checkInside(image, c_x, c_y, radiusWidth, radiusHeight); }
java
public boolean isInBounds( int c_x , int c_y ) { return BoofMiscOps.checkInside(image, c_x, c_y, radiusWidth, radiusHeight); }
[ "public", "boolean", "isInBounds", "(", "int", "c_x", ",", "int", "c_y", ")", "{", "return", "BoofMiscOps", ".", "checkInside", "(", "image", ",", "c_x", ",", "c_y", ",", "radiusWidth", ",", "radiusHeight", ")", ";", "}" ]
The entire region must be inside the image because any outside pixels will change the statistics
[ "The", "entire", "region", "must", "be", "inside", "the", "image", "because", "any", "outside", "pixels", "will", "change", "the", "statistics" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/DescribePointPixelRegionNCC.java#L45-L47
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/DoStuffFromPairwiseGraph.java
DoStuffFromPairwiseGraph.findCommonTracks
private GrowQueue_I32 findCommonTracks( SeedInfo target ) { // if true then it is visible in all tracks boolean visibleAll[] = new boolean[target.seed.totalFeatures]; Arrays.fill(visibleAll,true); // used to keep track of which features are visible in the current motion boolean visibleMotion[] = new boolean[target.seed.totalFeatures]; // Only look at features in the motions that were used to compute the score for (int idxMotion = 0; idxMotion < target.motions.size; idxMotion++) { PairwiseImageGraph2.Motion m = target.seed.connections.get(target.motions.get(idxMotion)); boolean seedIsSrc = m.src==target.seed; Arrays.fill(visibleMotion,false); for (int i = 0; i < m.inliers.size; i++) { AssociatedIndex a = m.inliers.get(i); visibleMotion[seedIsSrc?a.src:a.dst] = true; } for (int i = 0; i < target.seed.totalFeatures; i++) { visibleAll[i] &= visibleMotion[i]; } } GrowQueue_I32 common = new GrowQueue_I32(target.seed.totalFeatures/10+1); for (int i = 0; i < target.seed.totalFeatures; i++) { if( visibleAll[i] ) { common.add(i); } } return common; }
java
private GrowQueue_I32 findCommonTracks( SeedInfo target ) { // if true then it is visible in all tracks boolean visibleAll[] = new boolean[target.seed.totalFeatures]; Arrays.fill(visibleAll,true); // used to keep track of which features are visible in the current motion boolean visibleMotion[] = new boolean[target.seed.totalFeatures]; // Only look at features in the motions that were used to compute the score for (int idxMotion = 0; idxMotion < target.motions.size; idxMotion++) { PairwiseImageGraph2.Motion m = target.seed.connections.get(target.motions.get(idxMotion)); boolean seedIsSrc = m.src==target.seed; Arrays.fill(visibleMotion,false); for (int i = 0; i < m.inliers.size; i++) { AssociatedIndex a = m.inliers.get(i); visibleMotion[seedIsSrc?a.src:a.dst] = true; } for (int i = 0; i < target.seed.totalFeatures; i++) { visibleAll[i] &= visibleMotion[i]; } } GrowQueue_I32 common = new GrowQueue_I32(target.seed.totalFeatures/10+1); for (int i = 0; i < target.seed.totalFeatures; i++) { if( visibleAll[i] ) { common.add(i); } } return common; }
[ "private", "GrowQueue_I32", "findCommonTracks", "(", "SeedInfo", "target", ")", "{", "// if true then it is visible in all tracks", "boolean", "visibleAll", "[", "]", "=", "new", "boolean", "[", "target", ".", "seed", ".", "totalFeatures", "]", ";", "Arrays", ".", ...
Finds the indexes of tracks which are common to all views @param target The seed view @return indexes of common tracks
[ "Finds", "the", "indexes", "of", "tracks", "which", "are", "common", "to", "all", "views" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/DoStuffFromPairwiseGraph.java#L75-L102
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/DoStuffFromPairwiseGraph.java
DoStuffFromPairwiseGraph.score
private SeedInfo score( View target ) { SeedInfo output = new SeedInfo(); output.seed = target; scoresMotions.reset(); // score all edges for (int i = 0; i < target.connections.size; i++) { PairwiseImageGraph2.Motion m = target.connections.get(i); if( !m.is3D ) continue; scoresMotions.grow().set(score(m),i); } // only score the 3 best. This is to avoid biasing it for Collections.sort(scoresMotions.toList()); for (int i = Math.min(2, scoresMotions.size); i >= 0; i--) { output.motions.add(scoresMotions.get(i).index); output.score += scoresMotions.get(i).score; } return output; }
java
private SeedInfo score( View target ) { SeedInfo output = new SeedInfo(); output.seed = target; scoresMotions.reset(); // score all edges for (int i = 0; i < target.connections.size; i++) { PairwiseImageGraph2.Motion m = target.connections.get(i); if( !m.is3D ) continue; scoresMotions.grow().set(score(m),i); } // only score the 3 best. This is to avoid biasing it for Collections.sort(scoresMotions.toList()); for (int i = Math.min(2, scoresMotions.size); i >= 0; i--) { output.motions.add(scoresMotions.get(i).index); output.score += scoresMotions.get(i).score; } return output; }
[ "private", "SeedInfo", "score", "(", "View", "target", ")", "{", "SeedInfo", "output", "=", "new", "SeedInfo", "(", ")", ";", "output", ".", "seed", "=", "target", ";", "scoresMotions", ".", "reset", "(", ")", ";", "// score all edges", "for", "(", "int"...
Score a view for how well it could be a seed based on the the 3 best 3D motions associated with it
[ "Score", "a", "view", "for", "how", "well", "it", "could", "be", "a", "seed", "based", "on", "the", "the", "3", "best", "3D", "motions", "associated", "with", "it" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/DoStuffFromPairwiseGraph.java#L145-L168
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/DoStuffFromPairwiseGraph.java
DoStuffFromPairwiseGraph.score
public static double score( PairwiseImageGraph2.Motion m ) { // countF and countF will be <= totalFeatures // Prefer a scene more features from a fundamental matrix than a homography. // This can be sign that the scene has a rich 3D structure and is poorly represented by // a plane or rotational motion double score = Math.min(5,m.countF/(double)(m.countH+1)); // Also prefer more features from the original image to be matched score *= m.countF; return score; }
java
public static double score( PairwiseImageGraph2.Motion m ) { // countF and countF will be <= totalFeatures // Prefer a scene more features from a fundamental matrix than a homography. // This can be sign that the scene has a rich 3D structure and is poorly represented by // a plane or rotational motion double score = Math.min(5,m.countF/(double)(m.countH+1)); // Also prefer more features from the original image to be matched score *= m.countF; return score; }
[ "public", "static", "double", "score", "(", "PairwiseImageGraph2", ".", "Motion", "m", ")", "{", "// countF and countF will be <= totalFeatures", "// Prefer a scene more features from a fundamental matrix than a homography.", "// This can be sign that the scene has a rich 3D structure and ...
Scores the motion for its ability to capture 3D structure
[ "Scores", "the", "motion", "for", "its", "ability", "to", "capture", "3D", "structure" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/DoStuffFromPairwiseGraph.java#L173-L184
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/GridRansacLineDetector.java
GridRansacLineDetector.process
public void process( D derivX , D derivY , GrayU8 binaryEdges ) { InputSanityCheck.checkSameShape(derivX,derivY,binaryEdges); int w = derivX.width-regionSize+1; int h = derivY.height-regionSize+1; foundLines.reshape(derivX.width / regionSize, derivX.height / regionSize); foundLines.reset(); // avoid partial regions/other image edge conditions by being at least the region's radius away for( int y = 0; y < h; y += regionSize) { int gridY = y/regionSize; // index of the top left pixel in the region being considered // possible over optimization int index = binaryEdges.startIndex + y*binaryEdges.stride; for( int x = 0; x < w; x+= regionSize , index += regionSize) { int gridX = x/regionSize; // detects edgels inside the region detectEdgels(index,x,y,derivX,derivY,binaryEdges); // find lines inside the region using RANSAC findLinesInRegion(foundLines.get(gridX,gridY)); } } }
java
public void process( D derivX , D derivY , GrayU8 binaryEdges ) { InputSanityCheck.checkSameShape(derivX,derivY,binaryEdges); int w = derivX.width-regionSize+1; int h = derivY.height-regionSize+1; foundLines.reshape(derivX.width / regionSize, derivX.height / regionSize); foundLines.reset(); // avoid partial regions/other image edge conditions by being at least the region's radius away for( int y = 0; y < h; y += regionSize) { int gridY = y/regionSize; // index of the top left pixel in the region being considered // possible over optimization int index = binaryEdges.startIndex + y*binaryEdges.stride; for( int x = 0; x < w; x+= regionSize , index += regionSize) { int gridX = x/regionSize; // detects edgels inside the region detectEdgels(index,x,y,derivX,derivY,binaryEdges); // find lines inside the region using RANSAC findLinesInRegion(foundLines.get(gridX,gridY)); } } }
[ "public", "void", "process", "(", "D", "derivX", ",", "D", "derivY", ",", "GrayU8", "binaryEdges", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "derivX", ",", "derivY", ",", "binaryEdges", ")", ";", "int", "w", "=", "derivX", ".", "width", "...
Detects line segments through the image inside of grids. @param derivX Image derivative along x-axis. Not modified. @param derivY Image derivative along x-axis. Not modified. @param binaryEdges True values indicate that a pixel is an edge pixel. Not modified.
[ "Detects", "line", "segments", "through", "the", "image", "inside", "of", "grids", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/GridRansacLineDetector.java#L104-L129
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/GridRansacLineDetector.java
GridRansacLineDetector.findLinesInRegion
private void findLinesInRegion( List<LineSegment2D_F32> gridLines ) { List<Edgel> list = edgels.copyIntoList(null); int iterations = 0; // exit if not enough points or max iterations exceeded while( iterations++ < maxDetectLines) { if( !robustMatcher.process(list) ) break; // remove the found edges from the main list List<Edgel> matchSet = robustMatcher.getMatchSet(); // make sure the match set is large enough if( matchSet.size() < minInlierSize ) break; for( Edgel e : matchSet ) { list.remove(e); } gridLines.add(convertToLineSegment(matchSet, robustMatcher.getModelParameters())); } }
java
private void findLinesInRegion( List<LineSegment2D_F32> gridLines ) { List<Edgel> list = edgels.copyIntoList(null); int iterations = 0; // exit if not enough points or max iterations exceeded while( iterations++ < maxDetectLines) { if( !robustMatcher.process(list) ) break; // remove the found edges from the main list List<Edgel> matchSet = robustMatcher.getMatchSet(); // make sure the match set is large enough if( matchSet.size() < minInlierSize ) break; for( Edgel e : matchSet ) { list.remove(e); } gridLines.add(convertToLineSegment(matchSet, robustMatcher.getModelParameters())); } }
[ "private", "void", "findLinesInRegion", "(", "List", "<", "LineSegment2D_F32", ">", "gridLines", ")", "{", "List", "<", "Edgel", ">", "list", "=", "edgels", ".", "copyIntoList", "(", "null", ")", ";", "int", "iterations", "=", "0", ";", "// exit if not enoug...
Searches for lines inside inside the region.. @param gridLines Where the found lines are stored.
[ "Searches", "for", "lines", "inside", "inside", "the", "region", ".." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/GridRansacLineDetector.java#L156-L180
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/GridRansacLineDetector.java
GridRansacLineDetector.convertToLineSegment
private LineSegment2D_F32 convertToLineSegment(List<Edgel> matchSet, LinePolar2D_F32 model) { float minT = Float.MAX_VALUE; float maxT = -Float.MAX_VALUE; LineParametric2D_F32 line = UtilLine2D_F32.convert(model,(LineParametric2D_F32)null); Point2D_F32 p = new Point2D_F32(); for( Edgel e : matchSet ) { p.set(e.x,e.y); float t = ClosestPoint2D_F32.closestPointT(line,e); if( minT > t ) minT = t; if( maxT < t ) maxT = t; } LineSegment2D_F32 segment = new LineSegment2D_F32(); segment.a.x = line.p.x + line.slope.x * minT; segment.a.y = line.p.y + line.slope.y * minT; segment.b.x = line.p.x + line.slope.x * maxT; segment.b.y = line.p.y + line.slope.y * maxT; return segment; }
java
private LineSegment2D_F32 convertToLineSegment(List<Edgel> matchSet, LinePolar2D_F32 model) { float minT = Float.MAX_VALUE; float maxT = -Float.MAX_VALUE; LineParametric2D_F32 line = UtilLine2D_F32.convert(model,(LineParametric2D_F32)null); Point2D_F32 p = new Point2D_F32(); for( Edgel e : matchSet ) { p.set(e.x,e.y); float t = ClosestPoint2D_F32.closestPointT(line,e); if( minT > t ) minT = t; if( maxT < t ) maxT = t; } LineSegment2D_F32 segment = new LineSegment2D_F32(); segment.a.x = line.p.x + line.slope.x * minT; segment.a.y = line.p.y + line.slope.y * minT; segment.b.x = line.p.x + line.slope.x * maxT; segment.b.y = line.p.y + line.slope.y * maxT; return segment; }
[ "private", "LineSegment2D_F32", "convertToLineSegment", "(", "List", "<", "Edgel", ">", "matchSet", ",", "LinePolar2D_F32", "model", ")", "{", "float", "minT", "=", "Float", ".", "MAX_VALUE", ";", "float", "maxT", "=", "-", "Float", ".", "MAX_VALUE", ";", "L...
Lines are found in polar form and this coverts them into line segments by finding the extreme points of points on the line. @param matchSet Set of points belonging to the line. @param model Detected line. @return Line segement.
[ "Lines", "are", "found", "in", "polar", "form", "and", "this", "coverts", "them", "into", "line", "segments", "by", "finding", "the", "extreme", "points", "of", "points", "on", "the", "line", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/GridRansacLineDetector.java#L190-L214
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernManager.java
TldFernManager.lookupFern
public TldFernFeature lookupFern( int value ) { TldFernFeature found = table[value]; if( found == null ) { found = createFern(); found.init(value); table[value] = found; } return found; }
java
public TldFernFeature lookupFern( int value ) { TldFernFeature found = table[value]; if( found == null ) { found = createFern(); found.init(value); table[value] = found; } return found; }
[ "public", "TldFernFeature", "lookupFern", "(", "int", "value", ")", "{", "TldFernFeature", "found", "=", "table", "[", "value", "]", ";", "if", "(", "found", "==", "null", ")", "{", "found", "=", "createFern", "(", ")", ";", "found", ".", "init", "(", ...
Looks up the fern with the specified value. If non exist a new one is created and returned. @param value The fern's value @return The fern associated with that value
[ "Looks", "up", "the", "fern", "with", "the", "specified", "value", ".", "If", "non", "exist", "a", "new", "one", "is", "created", "and", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernManager.java#L53-L61
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernManager.java
TldFernManager.lookupPosterior
public double lookupPosterior( int value ) { TldFernFeature found = table[value]; if( found == null ) { return 0; } return found.posterior; }
java
public double lookupPosterior( int value ) { TldFernFeature found = table[value]; if( found == null ) { return 0; } return found.posterior; }
[ "public", "double", "lookupPosterior", "(", "int", "value", ")", "{", "TldFernFeature", "found", "=", "table", "[", "value", "]", ";", "if", "(", "found", "==", "null", ")", "{", "return", "0", ";", "}", "return", "found", ".", "posterior", ";", "}" ]
Looks up the posterior probability of the specified fern. If a fern is found its posterior is returned otherwise -1 is returned. NOTE: How unknown values are handled is a deviation from the paper. @param value The fern's value @return Fern's posterior probability. If the value is known then return -1
[ "Looks", "up", "the", "posterior", "probability", "of", "the", "specified", "fern", ".", "If", "a", "fern", "is", "found", "its", "posterior", "is", "returned", "otherwise", "-", "1", "is", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldFernManager.java#L72-L78
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/dialogs/OpenImageSetDialog.java
OpenImageSetDialog.handleAdd
void handleAdd() { BoofSwingUtil.checkGuiThread(); java.util.List<File> paths = browser.getSelectedFiles(); for (int i = 0; i < paths.size(); i++) { File f = paths.get(i); // if it's a directory add all the files in the directory if( f.isDirectory() ) { java.util.List<String> files = UtilIO.listAll(f.getPath()); Collections.sort(files); for (int j = 0; j < files.size(); j++) { File p = new File(files.get(j)); // Note: Can't use mimetype to determine if it's an image or not since it isn't 100% reliable if( p.isFile() ) { selected.addPath(p); } } } else { selected.addPath(f); } } }
java
void handleAdd() { BoofSwingUtil.checkGuiThread(); java.util.List<File> paths = browser.getSelectedFiles(); for (int i = 0; i < paths.size(); i++) { File f = paths.get(i); // if it's a directory add all the files in the directory if( f.isDirectory() ) { java.util.List<String> files = UtilIO.listAll(f.getPath()); Collections.sort(files); for (int j = 0; j < files.size(); j++) { File p = new File(files.get(j)); // Note: Can't use mimetype to determine if it's an image or not since it isn't 100% reliable if( p.isFile() ) { selected.addPath(p); } } } else { selected.addPath(f); } } }
[ "void", "handleAdd", "(", ")", "{", "BoofSwingUtil", ".", "checkGuiThread", "(", ")", ";", "java", ".", "util", ".", "List", "<", "File", ">", "paths", "=", "browser", ".", "getSelectedFiles", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "...
Add all selected files
[ "Add", "all", "selected", "files" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/dialogs/OpenImageSetDialog.java#L110-L132
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/dialogs/OpenImageSetDialog.java
OpenImageSetDialog.handleOK
void handleOK() { String[] selected = this.selected.paths.toArray(new String[0]); listener.selectedImages(selected); }
java
void handleOK() { String[] selected = this.selected.paths.toArray(new String[0]); listener.selectedImages(selected); }
[ "void", "handleOK", "(", ")", "{", "String", "[", "]", "selected", "=", "this", ".", "selected", ".", "paths", ".", "toArray", "(", "new", "String", "[", "0", "]", ")", ";", "listener", ".", "selectedImages", "(", "selected", ")", ";", "}" ]
OK button pressed
[ "OK", "button", "pressed" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/dialogs/OpenImageSetDialog.java#L137-L140
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/dialogs/OpenImageSetDialog.java
OpenImageSetDialog.showPreview
void showPreview( String path ) { synchronized (lockPreview) { if( path == null ) { pendingPreview = null; } else if( previewThread == null ) { pendingPreview = path; previewThread = new PreviewThread(); previewThread.start(); } else { pendingPreview = path; } } }
java
void showPreview( String path ) { synchronized (lockPreview) { if( path == null ) { pendingPreview = null; } else if( previewThread == null ) { pendingPreview = path; previewThread = new PreviewThread(); previewThread.start(); } else { pendingPreview = path; } } }
[ "void", "showPreview", "(", "String", "path", ")", "{", "synchronized", "(", "lockPreview", ")", "{", "if", "(", "path", "==", "null", ")", "{", "pendingPreview", "=", "null", ";", "}", "else", "if", "(", "previewThread", "==", "null", ")", "{", "pendi...
Start a new preview thread if one isn't already running. Carefully manipulate variables due to threading
[ "Start", "a", "new", "preview", "thread", "if", "one", "isn", "t", "already", "running", ".", "Carefully", "manipulate", "variables", "due", "to", "threading" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/dialogs/OpenImageSetDialog.java#L264-L276
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/calib/CalibrationDetectorSquareGrid.java
CalibrationDetectorSquareGrid.createLayout
public static List<Point2D_F64> createLayout(int numRows, int numCols, double squareWidth, double spaceWidth) { List<Point2D_F64> all = new ArrayList<>(); double width = (numCols*squareWidth + (numCols-1)*spaceWidth); double height = (numRows*squareWidth + (numRows-1)*spaceWidth); double startX = -width/2; double startY = -height/2; for( int i = numRows-1; i >= 0; i-- ) { // this will be on the top of the black in the row double y = startY + i*(squareWidth+spaceWidth)+squareWidth; List<Point2D_F64> top = new ArrayList<>(); List<Point2D_F64> bottom = new ArrayList<>(); for( int j = 0; j < numCols; j++ ) { double x = startX + j*(squareWidth+spaceWidth); top.add( new Point2D_F64(x,y)); top.add( new Point2D_F64(x+squareWidth,y)); bottom.add( new Point2D_F64(x,y-squareWidth)); bottom.add( new Point2D_F64(x + squareWidth, y - squareWidth)); } all.addAll(top); all.addAll(bottom); } return all; }
java
public static List<Point2D_F64> createLayout(int numRows, int numCols, double squareWidth, double spaceWidth) { List<Point2D_F64> all = new ArrayList<>(); double width = (numCols*squareWidth + (numCols-1)*spaceWidth); double height = (numRows*squareWidth + (numRows-1)*spaceWidth); double startX = -width/2; double startY = -height/2; for( int i = numRows-1; i >= 0; i-- ) { // this will be on the top of the black in the row double y = startY + i*(squareWidth+spaceWidth)+squareWidth; List<Point2D_F64> top = new ArrayList<>(); List<Point2D_F64> bottom = new ArrayList<>(); for( int j = 0; j < numCols; j++ ) { double x = startX + j*(squareWidth+spaceWidth); top.add( new Point2D_F64(x,y)); top.add( new Point2D_F64(x+squareWidth,y)); bottom.add( new Point2D_F64(x,y-squareWidth)); bottom.add( new Point2D_F64(x + squareWidth, y - squareWidth)); } all.addAll(top); all.addAll(bottom); } return all; }
[ "public", "static", "List", "<", "Point2D_F64", ">", "createLayout", "(", "int", "numRows", ",", "int", "numCols", ",", "double", "squareWidth", ",", "double", "spaceWidth", ")", "{", "List", "<", "Point2D_F64", ">", "all", "=", "new", "ArrayList", "<>", "...
Creates a target that is composed of squares. The squares are spaced out and each corner provides a calibration point. @param numRows Number of rows in calibration target. Must be odd. @param numCols Number of column in each calibration target. Must be odd. @param squareWidth How wide each square is. Units are target dependent. @param spaceWidth Distance between the sides on each square. Units are target dependent. @return Target description
[ "Creates", "a", "target", "that", "is", "composed", "of", "squares", ".", "The", "squares", "are", "spaced", "out", "and", "each", "corner", "provides", "a", "calibration", "point", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/calib/CalibrationDetectorSquareGrid.java#L92-L123
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.process
public void process(FastQueue<PositionPatternNode> pps , T gray ) { gridReader.setImage(gray); storageQR.reset(); successes.clear(); failures.clear(); for (int i = 0; i < pps.size; i++) { PositionPatternNode ppn = pps.get(i); for (int j = 3,k=0; k < 4; j=k,k++) { if( ppn.edges[j] != null && ppn.edges[k] != null ) { QrCode qr = storageQR.grow(); qr.reset(); setPositionPatterns(ppn, j, k, qr); computeBoundingBox(qr); // Decode the entire marker now if( decode(gray,qr)) { successes.add(qr); } else { failures.add(qr); } } } } }
java
public void process(FastQueue<PositionPatternNode> pps , T gray ) { gridReader.setImage(gray); storageQR.reset(); successes.clear(); failures.clear(); for (int i = 0; i < pps.size; i++) { PositionPatternNode ppn = pps.get(i); for (int j = 3,k=0; k < 4; j=k,k++) { if( ppn.edges[j] != null && ppn.edges[k] != null ) { QrCode qr = storageQR.grow(); qr.reset(); setPositionPatterns(ppn, j, k, qr); computeBoundingBox(qr); // Decode the entire marker now if( decode(gray,qr)) { successes.add(qr); } else { failures.add(qr); } } } } }
[ "public", "void", "process", "(", "FastQueue", "<", "PositionPatternNode", ">", "pps", ",", "T", "gray", ")", "{", "gridReader", ".", "setImage", "(", "gray", ")", ";", "storageQR", ".", "reset", "(", ")", ";", "successes", ".", "clear", "(", ")", ";",...
Detects QR Codes inside image using position pattern graph @param pps position pattern graph @param gray Gray input image
[ "Detects", "QR", "Codes", "inside", "image", "using", "position", "pattern", "graph" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L75-L102
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.computeBoundingBox
static void computeBoundingBox(QrCode qr ) { qr.bounds.get(0).set(qr.ppCorner.get(0)); qr.bounds.get(1).set(qr.ppRight.get(1)); Intersection2D_F64.intersection( qr.ppRight.get(1),qr.ppRight.get(2), qr.ppDown.get(3),qr.ppDown.get(2),qr.bounds.get(2)); qr.bounds.get(3).set(qr.ppDown.get(3)); }
java
static void computeBoundingBox(QrCode qr ) { qr.bounds.get(0).set(qr.ppCorner.get(0)); qr.bounds.get(1).set(qr.ppRight.get(1)); Intersection2D_F64.intersection( qr.ppRight.get(1),qr.ppRight.get(2), qr.ppDown.get(3),qr.ppDown.get(2),qr.bounds.get(2)); qr.bounds.get(3).set(qr.ppDown.get(3)); }
[ "static", "void", "computeBoundingBox", "(", "QrCode", "qr", ")", "{", "qr", ".", "bounds", ".", "get", "(", "0", ")", ".", "set", "(", "qr", ".", "ppCorner", ".", "get", "(", "0", ")", ")", ";", "qr", ".", "bounds", ".", "get", "(", "1", ")", ...
3 or the 4 corners are from the position patterns. The 4th is extrapolated using the position pattern sides. @param qr
[ "3", "or", "the", "4", "corners", "are", "from", "the", "position", "patterns", ".", "The", "4th", "is", "extrapolated", "using", "the", "position", "pattern", "sides", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L154-L161
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.extractFormatInfo
private boolean extractFormatInfo(QrCode qr) { for (int i = 0; i < 2; i++) { // probably a better way to do this would be to go with the region that has the smallest // hamming distance if (i == 0) readFormatRegion0(qr); else readFormatRegion1(qr); int bitField = this.bits.read(0,15,false); bitField ^= QrCodePolynomialMath.FORMAT_MASK; int message; if (QrCodePolynomialMath.checkFormatBits(bitField)) { message = bitField >> 10; } else { message = QrCodePolynomialMath.correctFormatBits(bitField); } if (message >= 0) { QrCodePolynomialMath.decodeFormatMessage(message, qr); return true; } } return false; }
java
private boolean extractFormatInfo(QrCode qr) { for (int i = 0; i < 2; i++) { // probably a better way to do this would be to go with the region that has the smallest // hamming distance if (i == 0) readFormatRegion0(qr); else readFormatRegion1(qr); int bitField = this.bits.read(0,15,false); bitField ^= QrCodePolynomialMath.FORMAT_MASK; int message; if (QrCodePolynomialMath.checkFormatBits(bitField)) { message = bitField >> 10; } else { message = QrCodePolynomialMath.correctFormatBits(bitField); } if (message >= 0) { QrCodePolynomialMath.decodeFormatMessage(message, qr); return true; } } return false; }
[ "private", "boolean", "extractFormatInfo", "(", "QrCode", "qr", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "2", ";", "i", "++", ")", "{", "// probably a better way to do this would be to go with the region that has the smallest", "// hamming distance",...
Reads format info bits from the image and saves the results in qr @return true if successful or false if it failed
[ "Reads", "format", "info", "bits", "from", "the", "image", "and", "saves", "the", "results", "in", "qr" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L228-L251
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.readFormatRegion0
private boolean readFormatRegion0(QrCode qr) { // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppCorner,(float)qr.threshCorner); bits.resize(15); bits.zero(); for (int i = 0; i < 6; i++) { read(i,i,8); } read(6,7,8); read(7,8,8); read(8,8,7); for (int i = 0; i < 6; i++) { read(9+i,8,5-i); } return true; }
java
private boolean readFormatRegion0(QrCode qr) { // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppCorner,(float)qr.threshCorner); bits.resize(15); bits.zero(); for (int i = 0; i < 6; i++) { read(i,i,8); } read(6,7,8); read(7,8,8); read(8,8,7); for (int i = 0; i < 6; i++) { read(9+i,8,5-i); } return true; }
[ "private", "boolean", "readFormatRegion0", "(", "QrCode", "qr", ")", "{", "// set the coordinate system to the closest pp to reduce position errors", "gridReader", ".", "setSquare", "(", "qr", ".", "ppCorner", ",", "(", "float", ")", "qr", ".", "threshCorner", ")", ";...
Reads the format bits near the corner position pattern
[ "Reads", "the", "format", "bits", "near", "the", "corner", "position", "pattern" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L256-L275
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.readFormatRegion1
private boolean readFormatRegion1(QrCode qr) { // if( qr.ppRight.get(0).distance(988.8,268.3) < 30 ) // System.out.println("tjere"); // System.out.println(qr.ppRight.get(0)); // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppRight,(float)qr.threshRight); bits.resize(15); bits.zero(); for (int i = 0; i < 8; i++) { read(i,8,6-i); } gridReader.setSquare(qr.ppDown,(float)qr.threshDown); for (int i = 0; i < 6; i++) { read(i+8,i,8); } return true; }
java
private boolean readFormatRegion1(QrCode qr) { // if( qr.ppRight.get(0).distance(988.8,268.3) < 30 ) // System.out.println("tjere"); // System.out.println(qr.ppRight.get(0)); // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppRight,(float)qr.threshRight); bits.resize(15); bits.zero(); for (int i = 0; i < 8; i++) { read(i,8,6-i); } gridReader.setSquare(qr.ppDown,(float)qr.threshDown); for (int i = 0; i < 6; i++) { read(i+8,i,8); } return true; }
[ "private", "boolean", "readFormatRegion1", "(", "QrCode", "qr", ")", "{", "//\t\tif( qr.ppRight.get(0).distance(988.8,268.3) < 30 )", "//\t\t\tSystem.out.println(\"tjere\");", "//\t\tSystem.out.println(qr.ppRight.get(0));", "// set the coordinate system to the closest pp to reduce position err...
Read the format bits on the right and bottom patterns
[ "Read", "the", "format", "bits", "on", "the", "right", "and", "bottom", "patterns" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L280-L301
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.readRawData
private boolean readRawData( QrCode qr) { QrCode.VersionInfo info = QrCode.VERSION_INFO[qr.version]; qr.rawbits = new byte[info.codewords]; // predeclare memory bits.resize(info.codewords*8); // read bits from memory List<Point2D_I32> locationBits = QrCode.LOCATION_BITS[qr.version]; // end at bits.size instead of locationBits.size because location might point to useless bits for (int i = 0; i < bits.size; i++ ) { Point2D_I32 b = locationBits.get(i); readDataMatrix(i,b.y,b.x, qr.mask); } // System.out.println("Version "+qr.version); // System.out.println("bits8.size "+bits8.size+" locationBits "+locationBits.size()); // bits8.print(); // copy over the results System.arraycopy(bits.data,0,qr.rawbits,0,qr.rawbits.length); return true; }
java
private boolean readRawData( QrCode qr) { QrCode.VersionInfo info = QrCode.VERSION_INFO[qr.version]; qr.rawbits = new byte[info.codewords]; // predeclare memory bits.resize(info.codewords*8); // read bits from memory List<Point2D_I32> locationBits = QrCode.LOCATION_BITS[qr.version]; // end at bits.size instead of locationBits.size because location might point to useless bits for (int i = 0; i < bits.size; i++ ) { Point2D_I32 b = locationBits.get(i); readDataMatrix(i,b.y,b.x, qr.mask); } // System.out.println("Version "+qr.version); // System.out.println("bits8.size "+bits8.size+" locationBits "+locationBits.size()); // bits8.print(); // copy over the results System.arraycopy(bits.data,0,qr.rawbits,0,qr.rawbits.length); return true; }
[ "private", "boolean", "readRawData", "(", "QrCode", "qr", ")", "{", "QrCode", ".", "VersionInfo", "info", "=", "QrCode", ".", "VERSION_INFO", "[", "qr", ".", "version", "]", ";", "qr", ".", "rawbits", "=", "new", "byte", "[", "info", ".", "codewords", ...
Read the raw data from input memory
[ "Read", "the", "raw", "data", "from", "input", "memory" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L306-L330
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.read
private void read(int bit , int row , int col ) { int value = gridReader.readBit(row,col); if( value == -1 ) { // The requested region is outside the image. A partial QR code can be read so let's just // assign it a value of zero and let error correction handle this value = 0; } bits.set(bit,value); }
java
private void read(int bit , int row , int col ) { int value = gridReader.readBit(row,col); if( value == -1 ) { // The requested region is outside the image. A partial QR code can be read so let's just // assign it a value of zero and let error correction handle this value = 0; } bits.set(bit,value); }
[ "private", "void", "read", "(", "int", "bit", ",", "int", "row", ",", "int", "col", ")", "{", "int", "value", "=", "gridReader", ".", "readBit", "(", "row", ",", "col", ")", ";", "if", "(", "value", "==", "-", "1", ")", "{", "// The requested regio...
Reads a bit from the image. @param bit Index the bit will be written to @param row row in qr code grid @param col column in qr code grid
[ "Reads", "a", "bit", "from", "the", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L338-L346
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.extractVersionInfo
boolean extractVersionInfo(QrCode qr) { int version = estimateVersionBySize(qr); // For version 7 and beyond use the version which has been encoded into the qr code if( version >= QrCode.VERSION_ENCODED_AT) { readVersionRegion0(qr); int version0 = decodeVersion(); readVersionRegion1(qr); int version1 = decodeVersion(); if (version0 < 1 && version1 < 1) { // both decodings failed version = -1; } else if (version0 < 1) { // one failed so use the good one version = version1; } else if (version1 < 1) { version = version0; } else if( version0 != version1 ){ version = -1; } else { version = version0; } } else if( version <= 0 ) { version = -1; } qr.version = version; return version >= 1 && version <= QrCode.MAX_VERSION; }
java
boolean extractVersionInfo(QrCode qr) { int version = estimateVersionBySize(qr); // For version 7 and beyond use the version which has been encoded into the qr code if( version >= QrCode.VERSION_ENCODED_AT) { readVersionRegion0(qr); int version0 = decodeVersion(); readVersionRegion1(qr); int version1 = decodeVersion(); if (version0 < 1 && version1 < 1) { // both decodings failed version = -1; } else if (version0 < 1) { // one failed so use the good one version = version1; } else if (version1 < 1) { version = version0; } else if( version0 != version1 ){ version = -1; } else { version = version0; } } else if( version <= 0 ) { version = -1; } qr.version = version; return version >= 1 && version <= QrCode.MAX_VERSION; }
[ "boolean", "extractVersionInfo", "(", "QrCode", "qr", ")", "{", "int", "version", "=", "estimateVersionBySize", "(", "qr", ")", ";", "// For version 7 and beyond use the version which has been encoded into the qr code", "if", "(", "version", ">=", "QrCode", ".", "VERSION_...
Determine the QR code's version. For QR codes version < 7 it can be determined using the marker's size alone. Otherwise the version is read from the image itself @return true if version was successfully extracted or false if it failed
[ "Determine", "the", "QR", "code", "s", "version", ".", "For", "QR", "codes", "version", "<", "7", "it", "can", "be", "determined", "using", "the", "marker", "s", "size", "alone", ".", "Otherwise", "the", "version", "is", "read", "from", "the", "image", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L363-L390
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.decodeVersion
int decodeVersion() { int bitField = this.bits.read(0,18,false); int message; // see if there's any errors if (QrCodePolynomialMath.checkVersionBits(bitField)) { message = bitField >> 12; } else { message = QrCodePolynomialMath.correctVersionBits(bitField); } // sanity check results if( message > QrCode.MAX_VERSION || message < QrCode.VERSION_ENCODED_AT) return -1; return message; }
java
int decodeVersion() { int bitField = this.bits.read(0,18,false); int message; // see if there's any errors if (QrCodePolynomialMath.checkVersionBits(bitField)) { message = bitField >> 12; } else { message = QrCodePolynomialMath.correctVersionBits(bitField); } // sanity check results if( message > QrCode.MAX_VERSION || message < QrCode.VERSION_ENCODED_AT) return -1; return message; }
[ "int", "decodeVersion", "(", ")", "{", "int", "bitField", "=", "this", ".", "bits", ".", "read", "(", "0", ",", "18", ",", "false", ")", ";", "int", "message", ";", "// see if there's any errors", "if", "(", "QrCodePolynomialMath", ".", "checkVersionBits", ...
Decode version information from read in bits @return The found version or -1 if it failed
[ "Decode", "version", "information", "from", "read", "in", "bits" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L396-L410
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.estimateVersionBySize
int estimateVersionBySize( QrCode qr ) { // Just need the homography for this corner square square gridReader.setMarkerUnknownVersion(qr,0); // Compute location of position patterns relative to corner PP gridReader.imageToGrid(qr.ppRight.get(0),grid); // see if pp is miss aligned. Probably not a flat surface // or they don't belong to the same qr code if( Math.abs(grid.y/grid.x) >= 0.3 ) return -1; double versionX = ((grid.x+7)-17)/4; gridReader.imageToGrid(qr.ppDown.get(0),grid); if( Math.abs(grid.x/grid.y) >= 0.3 ) return -1; double versionY = ((grid.y+7)-17)/4; // see if they are in agreement if( Math.abs(versionX-versionY)/Math.max(versionX,versionY) > 0.4 ) return -1; return (int)((versionX+versionY)/2.0 + 0.5); }
java
int estimateVersionBySize( QrCode qr ) { // Just need the homography for this corner square square gridReader.setMarkerUnknownVersion(qr,0); // Compute location of position patterns relative to corner PP gridReader.imageToGrid(qr.ppRight.get(0),grid); // see if pp is miss aligned. Probably not a flat surface // or they don't belong to the same qr code if( Math.abs(grid.y/grid.x) >= 0.3 ) return -1; double versionX = ((grid.x+7)-17)/4; gridReader.imageToGrid(qr.ppDown.get(0),grid); if( Math.abs(grid.x/grid.y) >= 0.3 ) return -1; double versionY = ((grid.y+7)-17)/4; // see if they are in agreement if( Math.abs(versionX-versionY)/Math.max(versionX,versionY) > 0.4 ) return -1; return (int)((versionX+versionY)/2.0 + 0.5); }
[ "int", "estimateVersionBySize", "(", "QrCode", "qr", ")", "{", "// Just need the homography for this corner square square", "gridReader", ".", "setMarkerUnknownVersion", "(", "qr", ",", "0", ")", ";", "// Compute location of position patterns relative to corner PP", "gridReader",...
Attempts to estimate the qr-code's version based on distance between position patterns. If it can't estimate it based on distance return -1
[ "Attempts", "to", "estimate", "the", "qr", "-", "code", "s", "version", "based", "on", "distance", "between", "position", "patterns", ".", "If", "it", "can", "t", "estimate", "it", "based", "on", "distance", "return", "-", "1" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L416-L442
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.readVersionRegion0
private boolean readVersionRegion0(QrCode qr) { // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppRight, (float) qr.threshRight); bits.resize(18); bits.zero(); for (int i = 0; i < 18; i++) { int row = i/3; int col = i%3; read(i,row,col-4); } // System.out.println(" decoder version region 0 = "+Integer.toBinaryString(bits.data[0])); return true; }
java
private boolean readVersionRegion0(QrCode qr) { // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppRight, (float) qr.threshRight); bits.resize(18); bits.zero(); for (int i = 0; i < 18; i++) { int row = i/3; int col = i%3; read(i,row,col-4); } // System.out.println(" decoder version region 0 = "+Integer.toBinaryString(bits.data[0])); return true; }
[ "private", "boolean", "readVersionRegion0", "(", "QrCode", "qr", ")", "{", "// set the coordinate system to the closest pp to reduce position errors", "gridReader", ".", "setSquare", "(", "qr", ".", "ppRight", ",", "(", "float", ")", "qr", ".", "threshRight", ")", ";"...
Reads the version bits near the right position pattern
[ "Reads", "the", "version", "bits", "near", "the", "right", "position", "pattern" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L447-L462
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java
QrCodeDecoderImage.readVersionRegion1
private boolean readVersionRegion1(QrCode qr) { // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppDown, (float) qr.threshDown); bits.resize(18); bits.zero(); for (int i = 0; i < 18; i++) { int row = i%3; int col = i/3; read(i,row-4,col); } // System.out.println(" decoder version region 1 = "+Integer.toBinaryString(bits.data[0])); return true; }
java
private boolean readVersionRegion1(QrCode qr) { // set the coordinate system to the closest pp to reduce position errors gridReader.setSquare(qr.ppDown, (float) qr.threshDown); bits.resize(18); bits.zero(); for (int i = 0; i < 18; i++) { int row = i%3; int col = i/3; read(i,row-4,col); } // System.out.println(" decoder version region 1 = "+Integer.toBinaryString(bits.data[0])); return true; }
[ "private", "boolean", "readVersionRegion1", "(", "QrCode", "qr", ")", "{", "// set the coordinate system to the closest pp to reduce position errors", "gridReader", ".", "setSquare", "(", "qr", ".", "ppDown", ",", "(", "float", ")", "qr", ".", "threshDown", ")", ";", ...
Reads the version bits near the bottom position pattern
[ "Reads", "the", "version", "bits", "near", "the", "bottom", "position", "pattern" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeDecoderImage.java#L467-L482
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/impl/ImplIntegralImageFeatureIntensity_MT.java
ImplIntegralImageFeatureIntensity_MT.hessianBorder
public static void hessianBorder(GrayF32 integral, int skip , int size , GrayF32 intensity) { final int w = intensity.width; final int h = intensity.height; // get convolution kernels for the second order derivatives IntegralKernel kerXX = DerivativeIntegralImage.kernelDerivXX(size,null); IntegralKernel kerYY = DerivativeIntegralImage.kernelDerivYY(size,null); IntegralKernel kerXY = DerivativeIntegralImage.kernelDerivXY(size,null); int radiusFeature = size/2; final int borderOrig = radiusFeature+ 1 + (skip-(radiusFeature+1)%skip); final int border = borderOrig/skip; float norm = 1.0f/(size*size); BoofConcurrency.loopFor(0, h, y -> { int yy = y * skip; for (int x = 0; x < border; x++) { int xx = x * skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } for (int x = w - border; x < w; x++) { int xx = x * skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } }); BoofConcurrency.loopFor(border, w-border, x -> { int xx = x*skip; for( int y = 0; y < border; y++ ) { int yy = y*skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } for( int y = h-border; y < h; y++ ) { int yy = y*skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } }); }
java
public static void hessianBorder(GrayF32 integral, int skip , int size , GrayF32 intensity) { final int w = intensity.width; final int h = intensity.height; // get convolution kernels for the second order derivatives IntegralKernel kerXX = DerivativeIntegralImage.kernelDerivXX(size,null); IntegralKernel kerYY = DerivativeIntegralImage.kernelDerivYY(size,null); IntegralKernel kerXY = DerivativeIntegralImage.kernelDerivXY(size,null); int radiusFeature = size/2; final int borderOrig = radiusFeature+ 1 + (skip-(radiusFeature+1)%skip); final int border = borderOrig/skip; float norm = 1.0f/(size*size); BoofConcurrency.loopFor(0, h, y -> { int yy = y * skip; for (int x = 0; x < border; x++) { int xx = x * skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } for (int x = w - border; x < w; x++) { int xx = x * skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } }); BoofConcurrency.loopFor(border, w-border, x -> { int xx = x*skip; for( int y = 0; y < border; y++ ) { int yy = y*skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } for( int y = h-border; y < h; y++ ) { int yy = y*skip; computeHessian(integral, intensity, kerXX, kerYY, kerXY, norm, y, yy, x, xx); } }); }
[ "public", "static", "void", "hessianBorder", "(", "GrayF32", "integral", ",", "int", "skip", ",", "int", "size", ",", "GrayF32", "intensity", ")", "{", "final", "int", "w", "=", "intensity", ".", "width", ";", "final", "int", "h", "=", "intensity", ".", ...
Only computes the fast hessian along the border using a brute force approach
[ "Only", "computes", "the", "fast", "hessian", "along", "the", "border", "using", "a", "brute", "force", "approach" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/impl/ImplIntegralImageFeatureIntensity_MT.java#L43-L84
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.logicAnd
public static GrayU8 logicAnd(GrayU8 inputA , GrayU8 inputB , GrayU8 output ) { InputSanityCheck.checkSameShape(inputA,inputB); output = InputSanityCheck.checkDeclare(inputA, output); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.logicAnd(inputA, inputB, output); } else { ImplBinaryImageOps.logicAnd(inputA, inputB, output); } return output; }
java
public static GrayU8 logicAnd(GrayU8 inputA , GrayU8 inputB , GrayU8 output ) { InputSanityCheck.checkSameShape(inputA,inputB); output = InputSanityCheck.checkDeclare(inputA, output); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.logicAnd(inputA, inputB, output); } else { ImplBinaryImageOps.logicAnd(inputA, inputB, output); } return output; }
[ "public", "static", "GrayU8", "logicAnd", "(", "GrayU8", "inputA", ",", "GrayU8", "inputB", ",", "GrayU8", "output", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "inputA", ",", "inputB", ")", ";", "output", "=", "InputSanityCheck", ".", "checkDecl...
For each pixel it applies the logical 'and' operator between two images. @param inputA First input image. Not modified. @param inputB Second input image. Not modified. @param output Output image. Can be same as either input. If null a new instance will be declared, Modified. @return Output of logical operation.
[ "For", "each", "pixel", "it", "applies", "the", "logical", "and", "operator", "between", "two", "images", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L69-L81
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.invert
public static GrayU8 invert(GrayU8 input , GrayU8 output) { output = InputSanityCheck.checkDeclare(input, output); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.invert(input, output); } else { ImplBinaryImageOps.invert(input, output); } return output; }
java
public static GrayU8 invert(GrayU8 input , GrayU8 output) { output = InputSanityCheck.checkDeclare(input, output); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.invert(input, output); } else { ImplBinaryImageOps.invert(input, output); } return output; }
[ "public", "static", "GrayU8", "invert", "(", "GrayU8", "input", ",", "GrayU8", "output", ")", "{", "output", "=", "InputSanityCheck", ".", "checkDeclare", "(", "input", ",", "output", ")", ";", "if", "(", "BoofConcurrency", ".", "USE_CONCURRENT", ")", "{", ...
Inverts each pixel from true to false and vis-versa. @param input Input image. Not modified. @param output Output image. Can be same as input. If null a new instance will be declared, Modified. @return Output of logical operation.
[ "Inverts", "each", "pixel", "from", "true", "to", "false", "and", "vis", "-", "versa", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L134-L145
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.thin
public static GrayU8 thin(GrayU8 input , int maxIterations, GrayU8 output ) { output = InputSanityCheck.checkDeclare(input, output); output.setTo(input); BinaryThinning thinning = new BinaryThinning(); thinning.apply(output,maxIterations); return output; }
java
public static GrayU8 thin(GrayU8 input , int maxIterations, GrayU8 output ) { output = InputSanityCheck.checkDeclare(input, output); output.setTo(input); BinaryThinning thinning = new BinaryThinning(); thinning.apply(output,maxIterations); return output; }
[ "public", "static", "GrayU8", "thin", "(", "GrayU8", "input", ",", "int", "maxIterations", ",", "GrayU8", "output", ")", "{", "output", "=", "InputSanityCheck", ".", "checkDeclare", "(", "input", ",", "output", ")", ";", "output", ".", "setTo", "(", "input...
Applies a morphological thinning operation to the image. Also known as skeletonization. @see BinaryThinning @param input Input image. Not modified. @param maxIterations Maximum number of cycles it will thin for. -1 for the maximum required @param output If not null, the output image. If null a new image is declared and returned. Modified. @return Output image.
[ "Applies", "a", "morphological", "thinning", "operation", "to", "the", "image", ".", "Also", "known", "as", "skeletonization", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L423-L433
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.contourExternal
public static List<Contour> contourExternal(GrayU8 input, ConnectRule rule ) { BinaryContourFinder alg = FactoryBinaryContourFinder.linearExternal(); alg.setConnectRule(rule); alg.process(input); return convertContours(alg); }
java
public static List<Contour> contourExternal(GrayU8 input, ConnectRule rule ) { BinaryContourFinder alg = FactoryBinaryContourFinder.linearExternal(); alg.setConnectRule(rule); alg.process(input); return convertContours(alg); }
[ "public", "static", "List", "<", "Contour", ">", "contourExternal", "(", "GrayU8", "input", ",", "ConnectRule", "rule", ")", "{", "BinaryContourFinder", "alg", "=", "FactoryBinaryContourFinder", ".", "linearExternal", "(", ")", ";", "alg", ".", "setConnectRule", ...
Finds the external contours only in the image @param input Input binary image. Not modified. @param rule Connectivity rule. Can be 4 or 8. 8 is more commonly used. @return List of found contours for each blob.
[ "Finds", "the", "external", "contours", "only", "in", "the", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L477-L483
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.relabel
public static void relabel(GrayS32 input , int labels[] ) { if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.relabel(input, labels); } else { ImplBinaryImageOps.relabel(input, labels); } }
java
public static void relabel(GrayS32 input , int labels[] ) { if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.relabel(input, labels); } else { ImplBinaryImageOps.relabel(input, labels); } }
[ "public", "static", "void", "relabel", "(", "GrayS32", "input", ",", "int", "labels", "[", "]", ")", "{", "if", "(", "BoofConcurrency", ".", "USE_CONCURRENT", ")", "{", "ImplBinaryImageOps_MT", ".", "relabel", "(", "input", ",", "labels", ")", ";", "}", ...
Used to change the labels in a labeled binary image. @param input Labeled binary image. @param labels Look up table where the indexes are the current label and the value are its new value.
[ "Used", "to", "change", "the", "labels", "in", "a", "labeled", "binary", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L509-L515
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.labelToBinary
public static GrayU8 labelToBinary(GrayS32 labelImage , GrayU8 binaryImage ) { binaryImage = InputSanityCheck.checkDeclare(labelImage, binaryImage, GrayU8.class); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.labelToBinary(labelImage, binaryImage); } else { ImplBinaryImageOps.labelToBinary(labelImage, binaryImage); } return binaryImage; }
java
public static GrayU8 labelToBinary(GrayS32 labelImage , GrayU8 binaryImage ) { binaryImage = InputSanityCheck.checkDeclare(labelImage, binaryImage, GrayU8.class); if( BoofConcurrency.USE_CONCURRENT ) { ImplBinaryImageOps_MT.labelToBinary(labelImage, binaryImage); } else { ImplBinaryImageOps.labelToBinary(labelImage, binaryImage); } return binaryImage; }
[ "public", "static", "GrayU8", "labelToBinary", "(", "GrayS32", "labelImage", ",", "GrayU8", "binaryImage", ")", "{", "binaryImage", "=", "InputSanityCheck", ".", "checkDeclare", "(", "labelImage", ",", "binaryImage", ",", "GrayU8", ".", "class", ")", ";", "if", ...
Converts a labeled image into a binary image by setting any non-zero value to one. @param labelImage Input image. Not modified. @param binaryImage Output image. Modified. @return The binary image.
[ "Converts", "a", "labeled", "image", "into", "a", "binary", "image", "by", "setting", "any", "non", "-", "zero", "value", "to", "one", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L524-L534
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.labelToClusters
public static List<List<Point2D_I32>> labelToClusters( GrayS32 labelImage , int numLabels , FastQueue<Point2D_I32> queue ) { List<List<Point2D_I32>> ret = new ArrayList<>(); for( int i = 0; i < numLabels+1; i++ ) { ret.add( new ArrayList<Point2D_I32>() ); } if( queue == null ) { queue = new FastQueue<>(numLabels, Point2D_I32.class, true); } else queue.reset(); for( int y = 0; y < labelImage.height; y++ ) { int start = labelImage.startIndex + y*labelImage.stride; int end = start + labelImage.width; for( int index = start; index < end; index++ ) { int v = labelImage.data[index]; if( v > 0 ) { Point2D_I32 p = queue.grow(); p.set(index-start,y); ret.get(v).add(p); } } } // first list is a place holder and should be empty if( ret.get(0).size() != 0 ) throw new RuntimeException("BUG!"); ret.remove(0); return ret; }
java
public static List<List<Point2D_I32>> labelToClusters( GrayS32 labelImage , int numLabels , FastQueue<Point2D_I32> queue ) { List<List<Point2D_I32>> ret = new ArrayList<>(); for( int i = 0; i < numLabels+1; i++ ) { ret.add( new ArrayList<Point2D_I32>() ); } if( queue == null ) { queue = new FastQueue<>(numLabels, Point2D_I32.class, true); } else queue.reset(); for( int y = 0; y < labelImage.height; y++ ) { int start = labelImage.startIndex + y*labelImage.stride; int end = start + labelImage.width; for( int index = start; index < end; index++ ) { int v = labelImage.data[index]; if( v > 0 ) { Point2D_I32 p = queue.grow(); p.set(index-start,y); ret.get(v).add(p); } } } // first list is a place holder and should be empty if( ret.get(0).size() != 0 ) throw new RuntimeException("BUG!"); ret.remove(0); return ret; }
[ "public", "static", "List", "<", "List", "<", "Point2D_I32", ">", ">", "labelToClusters", "(", "GrayS32", "labelImage", ",", "int", "numLabels", ",", "FastQueue", "<", "Point2D_I32", ">", "queue", ")", "{", "List", "<", "List", "<", "Point2D_I32", ">>", "r...
Scans through the labeled image and adds the coordinate of each pixel that has been labeled to a list specific to its label. @param labelImage The labeled image. @param numLabels Number of labeled objects inside the image. @param queue (Optional) Storage for pixel coordinates. Improves runtime performance. Can be null. @return List of pixels in each cluster.
[ "Scans", "through", "the", "labeled", "image", "and", "adds", "the", "coordinate", "of", "each", "pixel", "that", "has", "been", "labeled", "to", "a", "list", "specific", "to", "its", "label", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L589-L620
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.clusterToBinary
public static void clusterToBinary( List<List<Point2D_I32>> clusters , GrayU8 binary ) { ImageMiscOps.fill(binary, 0); for( List<Point2D_I32> l : clusters ) { for( Point2D_I32 p : l ) { binary.set(p.x,p.y,1); } } }
java
public static void clusterToBinary( List<List<Point2D_I32>> clusters , GrayU8 binary ) { ImageMiscOps.fill(binary, 0); for( List<Point2D_I32> l : clusters ) { for( Point2D_I32 p : l ) { binary.set(p.x,p.y,1); } } }
[ "public", "static", "void", "clusterToBinary", "(", "List", "<", "List", "<", "Point2D_I32", ">", ">", "clusters", ",", "GrayU8", "binary", ")", "{", "ImageMiscOps", ".", "fill", "(", "binary", ",", "0", ")", ";", "for", "(", "List", "<", "Point2D_I32", ...
Sets each pixel in the list of clusters to one in the binary image. @param clusters List of all the clusters. @param binary Output
[ "Sets", "each", "pixel", "in", "the", "list", "of", "clusters", "to", "one", "in", "the", "binary", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L628-L638
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java
BinaryImageOps.selectRandomColors
public static int[] selectRandomColors( int numBlobs , Random rand ) { int colors[] = new int[ numBlobs+1 ]; colors[0] = 0; // black int B = 100; for( int i = 1; i < colors.length; i++ ) { int c; while( true ) { c = rand.nextInt(0xFFFFFF); // make sure its not too dark and can't be distriquished from the background if( (c & 0xFF) > B || ((c >> 8) & 0xFF) > B || ((c >> 8 ) & 0xFF) > B ) { break; } } colors[i] = c; } return colors; }
java
public static int[] selectRandomColors( int numBlobs , Random rand ) { int colors[] = new int[ numBlobs+1 ]; colors[0] = 0; // black int B = 100; for( int i = 1; i < colors.length; i++ ) { int c; while( true ) { c = rand.nextInt(0xFFFFFF); // make sure its not too dark and can't be distriquished from the background if( (c & 0xFF) > B || ((c >> 8) & 0xFF) > B || ((c >> 8 ) & 0xFF) > B ) { break; } } colors[i] = c; } return colors; }
[ "public", "static", "int", "[", "]", "selectRandomColors", "(", "int", "numBlobs", ",", "Random", "rand", ")", "{", "int", "colors", "[", "]", "=", "new", "int", "[", "numBlobs", "+", "1", "]", ";", "colors", "[", "0", "]", "=", "0", ";", "// black...
Several blob rending functions take in an array of colors so that the random blobs can be drawn with the same color each time. This function selects a random color for each blob and returns it in an array. @param numBlobs Number of blobs found. @param rand Random number generator @return array of RGB colors for each blob + the background blob
[ "Several", "blob", "rending", "functions", "take", "in", "an", "array", "of", "colors", "so", "that", "the", "random", "blobs", "can", "be", "drawn", "with", "the", "same", "color", "each", "time", ".", "This", "function", "selects", "a", "random", "color"...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/BinaryImageOps.java#L648-L666
train
lessthanoptimal/BoofCV
integration/boofcv-openkinect/src/main/java/boofcv/openkinect/UtilOpenKinect.java
UtilOpenKinect.bufferDepthToU16
public static void bufferDepthToU16( ByteBuffer input , GrayU16 output ) { int indexIn = 0; for( int y = 0; y < output.height; y++ ) { int indexOut = output.startIndex + y*output.stride; for( int x = 0; x < output.width; x++ , indexOut++ ) { output.data[indexOut] = (short)((input.get(indexIn++) & 0xFF) | ((input.get(indexIn++) & 0xFF) << 8 )); } } }
java
public static void bufferDepthToU16( ByteBuffer input , GrayU16 output ) { int indexIn = 0; for( int y = 0; y < output.height; y++ ) { int indexOut = output.startIndex + y*output.stride; for( int x = 0; x < output.width; x++ , indexOut++ ) { output.data[indexOut] = (short)((input.get(indexIn++) & 0xFF) | ((input.get(indexIn++) & 0xFF) << 8 )); } } }
[ "public", "static", "void", "bufferDepthToU16", "(", "ByteBuffer", "input", ",", "GrayU16", "output", ")", "{", "int", "indexIn", "=", "0", ";", "for", "(", "int", "y", "=", "0", ";", "y", "<", "output", ".", "height", ";", "y", "++", ")", "{", "in...
Converts data in a ByteBuffer into a 16bit depth image @param input Input buffer @param output Output depth image
[ "Converts", "data", "in", "a", "ByteBuffer", "into", "a", "16bit", "depth", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-openkinect/src/main/java/boofcv/openkinect/UtilOpenKinect.java#L65-L73
train
lessthanoptimal/BoofCV
integration/boofcv-openkinect/src/main/java/boofcv/openkinect/UtilOpenKinect.java
UtilOpenKinect.bufferRgbToMsU8
public static void bufferRgbToMsU8( byte []input , Planar<GrayU8> output ) { GrayU8 band0 = output.getBand(0); GrayU8 band1 = output.getBand(1); GrayU8 band2 = output.getBand(2); int indexIn = 0; for( int y = 0; y < output.height; y++ ) { int indexOut = output.startIndex + y*output.stride; for( int x = 0; x < output.width; x++ , indexOut++ ) { band0.data[indexOut] = input[indexIn++]; band1.data[indexOut] = input[indexIn++]; band2.data[indexOut] = input[indexIn++]; } } }
java
public static void bufferRgbToMsU8( byte []input , Planar<GrayU8> output ) { GrayU8 band0 = output.getBand(0); GrayU8 band1 = output.getBand(1); GrayU8 band2 = output.getBand(2); int indexIn = 0; for( int y = 0; y < output.height; y++ ) { int indexOut = output.startIndex + y*output.stride; for( int x = 0; x < output.width; x++ , indexOut++ ) { band0.data[indexOut] = input[indexIn++]; band1.data[indexOut] = input[indexIn++]; band2.data[indexOut] = input[indexIn++]; } } }
[ "public", "static", "void", "bufferRgbToMsU8", "(", "byte", "[", "]", "input", ",", "Planar", "<", "GrayU8", ">", "output", ")", "{", "GrayU8", "band0", "=", "output", ".", "getBand", "(", "0", ")", ";", "GrayU8", "band1", "=", "output", ".", "getBand"...
Converts byte array that contains RGB data into a 3-channel Planar image @param input Input array @param output Output depth image
[ "Converts", "byte", "array", "that", "contains", "RGB", "data", "into", "a", "3", "-", "channel", "Planar", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-openkinect/src/main/java/boofcv/openkinect/UtilOpenKinect.java#L116-L130
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java
ReidSolomonCodes.computeECC
public void computeECC( GrowQueue_I8 input , GrowQueue_I8 output ) { int N = generator.size-1; input.extend(input.size+N); Arrays.fill(input.data,input.size-N,input.size,(byte)0); math.polyDivide(input,generator,tmp0,output); input.size -= N; }
java
public void computeECC( GrowQueue_I8 input , GrowQueue_I8 output ) { int N = generator.size-1; input.extend(input.size+N); Arrays.fill(input.data,input.size-N,input.size,(byte)0); math.polyDivide(input,generator,tmp0,output); input.size -= N; }
[ "public", "void", "computeECC", "(", "GrowQueue_I8", "input", ",", "GrowQueue_I8", "output", ")", "{", "int", "N", "=", "generator", ".", "size", "-", "1", ";", "input", ".", "extend", "(", "input", ".", "size", "+", "N", ")", ";", "Arrays", ".", "fi...
Given the input message compute the error correction code for it @param input Input message. Modified internally then returned to its initial state @param output error correction code
[ "Given", "the", "input", "message", "compute", "the", "error", "correction", "code", "for", "it" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java#L62-L71
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java
ReidSolomonCodes.correct
public boolean correct(GrowQueue_I8 input , GrowQueue_I8 ecc ) { computeSyndromes(input,ecc,syndromes); findErrorLocatorPolynomialBM(syndromes,errorLocatorPoly); if( !findErrorLocations_BruteForce(errorLocatorPoly,input.size+ecc.size,errorLocations)) return false; correctErrors(input,input.size+ecc.size,syndromes,errorLocatorPoly,errorLocations); return true; }
java
public boolean correct(GrowQueue_I8 input , GrowQueue_I8 ecc ) { computeSyndromes(input,ecc,syndromes); findErrorLocatorPolynomialBM(syndromes,errorLocatorPoly); if( !findErrorLocations_BruteForce(errorLocatorPoly,input.size+ecc.size,errorLocations)) return false; correctErrors(input,input.size+ecc.size,syndromes,errorLocatorPoly,errorLocations); return true; }
[ "public", "boolean", "correct", "(", "GrowQueue_I8", "input", ",", "GrowQueue_I8", "ecc", ")", "{", "computeSyndromes", "(", "input", ",", "ecc", ",", "syndromes", ")", ";", "findErrorLocatorPolynomialBM", "(", "syndromes", ",", "errorLocatorPoly", ")", ";", "if...
Decodes the message and performs any necessary error correction @param input (Input) Corrupted Message (Output) corrected message @param ecc (Input) error correction code for the message @return true if it was successful or false if it failed
[ "Decodes", "the", "message", "and", "performs", "any", "necessary", "error", "correction" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java#L79-L88
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java
ReidSolomonCodes.findErrorLocatorPolynomial
void findErrorLocatorPolynomial( int messageLength , GrowQueue_I32 errorLocations , GrowQueue_I8 errorLocator ) { tmp1.resize(2); tmp1.data[1] = 1; errorLocator.resize(1); errorLocator.data[0] = 1; for (int i = 0; i < errorLocations.size; i++) { // Convert from positions in the message to coefficient degrees int where = messageLength - errorLocations.get(i) - 1; // tmp1 = [2**w,1] tmp1.data[0] = (byte)math.power(2,where); // tmp1.data[1] = 1; tmp0.setTo(errorLocator); math.polyMult(tmp0,tmp1,errorLocator); } }
java
void findErrorLocatorPolynomial( int messageLength , GrowQueue_I32 errorLocations , GrowQueue_I8 errorLocator ) { tmp1.resize(2); tmp1.data[1] = 1; errorLocator.resize(1); errorLocator.data[0] = 1; for (int i = 0; i < errorLocations.size; i++) { // Convert from positions in the message to coefficient degrees int where = messageLength - errorLocations.get(i) - 1; // tmp1 = [2**w,1] tmp1.data[0] = (byte)math.power(2,where); // tmp1.data[1] = 1; tmp0.setTo(errorLocator); math.polyMult(tmp0,tmp1,errorLocator); } }
[ "void", "findErrorLocatorPolynomial", "(", "int", "messageLength", ",", "GrowQueue_I32", "errorLocations", ",", "GrowQueue_I8", "errorLocator", ")", "{", "tmp1", ".", "resize", "(", "2", ")", ";", "tmp1", ".", "data", "[", "1", "]", "=", "1", ";", "errorLoca...
Compute the error locator polynomial when given the error locations in the message. @param messageLength (Input) Length of the message @param errorLocations (Input) List of error locations in the byte @param errorLocator (Output) Error locator polynomial. Coefficients are large to small.
[ "Compute", "the", "error", "locator", "polynomial", "when", "given", "the", "error", "locations", "in", "the", "message", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java#L186-L202
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java
ReidSolomonCodes.findErrorLocations_BruteForce
public boolean findErrorLocations_BruteForce(GrowQueue_I8 errorLocator , int messageLength , GrowQueue_I32 locations ) { locations.resize(0); for (int i = 0; i < messageLength; i++) { if( math.polyEval_S(errorLocator,math.power(2,i)) == 0 ) { locations.add(messageLength-i-1); } } // see if the expected number of errors were found return locations.size == errorLocator.size - 1; }
java
public boolean findErrorLocations_BruteForce(GrowQueue_I8 errorLocator , int messageLength , GrowQueue_I32 locations ) { locations.resize(0); for (int i = 0; i < messageLength; i++) { if( math.polyEval_S(errorLocator,math.power(2,i)) == 0 ) { locations.add(messageLength-i-1); } } // see if the expected number of errors were found return locations.size == errorLocator.size - 1; }
[ "public", "boolean", "findErrorLocations_BruteForce", "(", "GrowQueue_I8", "errorLocator", ",", "int", "messageLength", ",", "GrowQueue_I32", "locations", ")", "{", "locations", ".", "resize", "(", "0", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "...
Creates a list of bytes that have errors in them @param errorLocator (Input) Error locator polynomial. Coefficients from small to large. @param messageLength (Input) Length of the message + ecc. @param locations (Output) locations of bytes in message with errors.
[ "Creates", "a", "list", "of", "bytes", "that", "have", "errors", "in", "them" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java#L211-L224
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java
ReidSolomonCodes.correctErrors
void correctErrors( GrowQueue_I8 message , int length_msg_ecc, GrowQueue_I8 syndromes, GrowQueue_I8 errorLocator , GrowQueue_I32 errorLocations) { GrowQueue_I8 err_eval = new GrowQueue_I8(); // TODO avoid new findErrorEvaluator(syndromes,errorLocator,err_eval); // Compute error positions GrowQueue_I8 X = GrowQueue_I8.zeros(errorLocations.size); // TODO avoid new for (int i = 0; i < errorLocations.size; i++) { int coef_pos = (length_msg_ecc-errorLocations.data[i]-1); X.data[i] = (byte)math.power(2,coef_pos); // The commented out code below replicates exactly how the reference code works. This code above // seems to work just as well and passes all the unit tests // int coef_pos = math.max_value-(length_msg_ecc-errorLocations.data[i]-1); // X.data[i] = (byte)math.power_n(2,-coef_pos); } GrowQueue_I8 err_loc_prime_tmp = new GrowQueue_I8(X.size); // storage for error magnitude polynomial for (int i = 0; i < X.size; i++) { int Xi = X.data[i]&0xFF; int Xi_inv = math.inverse(Xi); // Compute the polynomial derivative err_loc_prime_tmp.size = 0; for (int j = 0; j < X.size; j++) { if( i == j ) continue; err_loc_prime_tmp.data[err_loc_prime_tmp.size++] = (byte)GaliosFieldOps.subtract(1,math.multiply(Xi_inv,X.data[j]&0xFF)); } // compute the product, which is the denominator of Forney algorithm (errata locator derivative) int err_loc_prime = 1; for (int j = 0; j < err_loc_prime_tmp.size; j++) { err_loc_prime = math.multiply(err_loc_prime,err_loc_prime_tmp.data[j]&0xFF); } int y = math.polyEval_S(err_eval,Xi_inv); y = math.multiply(math.power(Xi,1),y); // Compute the magnitude int magnitude = math.divide(y,err_loc_prime); // only apply a correction if it's part of the message and not the ECC int loc = errorLocations.get(i); if( loc < message.size ) message.data[loc] = (byte)((message.data[loc]&0xFF) ^ magnitude); } }
java
void correctErrors( GrowQueue_I8 message , int length_msg_ecc, GrowQueue_I8 syndromes, GrowQueue_I8 errorLocator , GrowQueue_I32 errorLocations) { GrowQueue_I8 err_eval = new GrowQueue_I8(); // TODO avoid new findErrorEvaluator(syndromes,errorLocator,err_eval); // Compute error positions GrowQueue_I8 X = GrowQueue_I8.zeros(errorLocations.size); // TODO avoid new for (int i = 0; i < errorLocations.size; i++) { int coef_pos = (length_msg_ecc-errorLocations.data[i]-1); X.data[i] = (byte)math.power(2,coef_pos); // The commented out code below replicates exactly how the reference code works. This code above // seems to work just as well and passes all the unit tests // int coef_pos = math.max_value-(length_msg_ecc-errorLocations.data[i]-1); // X.data[i] = (byte)math.power_n(2,-coef_pos); } GrowQueue_I8 err_loc_prime_tmp = new GrowQueue_I8(X.size); // storage for error magnitude polynomial for (int i = 0; i < X.size; i++) { int Xi = X.data[i]&0xFF; int Xi_inv = math.inverse(Xi); // Compute the polynomial derivative err_loc_prime_tmp.size = 0; for (int j = 0; j < X.size; j++) { if( i == j ) continue; err_loc_prime_tmp.data[err_loc_prime_tmp.size++] = (byte)GaliosFieldOps.subtract(1,math.multiply(Xi_inv,X.data[j]&0xFF)); } // compute the product, which is the denominator of Forney algorithm (errata locator derivative) int err_loc_prime = 1; for (int j = 0; j < err_loc_prime_tmp.size; j++) { err_loc_prime = math.multiply(err_loc_prime,err_loc_prime_tmp.data[j]&0xFF); } int y = math.polyEval_S(err_eval,Xi_inv); y = math.multiply(math.power(Xi,1),y); // Compute the magnitude int magnitude = math.divide(y,err_loc_prime); // only apply a correction if it's part of the message and not the ECC int loc = errorLocations.get(i); if( loc < message.size ) message.data[loc] = (byte)((message.data[loc]&0xFF) ^ magnitude); } }
[ "void", "correctErrors", "(", "GrowQueue_I8", "message", ",", "int", "length_msg_ecc", ",", "GrowQueue_I8", "syndromes", ",", "GrowQueue_I8", "errorLocator", ",", "GrowQueue_I32", "errorLocations", ")", "{", "GrowQueue_I8", "err_eval", "=", "new", "GrowQueue_I8", "(",...
Use Forney algorithm to compute correction values. @param message (Input/Output) The message which is to be corrected. Just the message. ECC not required. @param length_msg_ecc (Input) length of message and ecc code @param errorLocations (Input) locations of bytes in message with errors.
[ "Use", "Forney", "algorithm", "to", "compute", "correction", "values", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/ReidSolomonCodes.java#L233-L285
train