repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java
KltTracker.setAllowedBounds
protected void setAllowedBounds(KltFeature feature) { // compute the feature's width and temporary storage related to it widthFeature = feature.radius * 2 + 1; lengthFeature = widthFeature * widthFeature; allowedLeft = feature.radius; allowedTop = feature.radius; allowedRight = image.width - feature.radius-1; allowedBottom = image.height - feature.radius-1; outsideLeft = -feature.radius; outsideTop = -feature.radius; outsideRight = image.width + feature.radius-1; outsideBottom = image.height + feature.radius-1; }
java
protected void setAllowedBounds(KltFeature feature) { // compute the feature's width and temporary storage related to it widthFeature = feature.radius * 2 + 1; lengthFeature = widthFeature * widthFeature; allowedLeft = feature.radius; allowedTop = feature.radius; allowedRight = image.width - feature.radius-1; allowedBottom = image.height - feature.radius-1; outsideLeft = -feature.radius; outsideTop = -feature.radius; outsideRight = image.width + feature.radius-1; outsideBottom = image.height + feature.radius-1; }
[ "protected", "void", "setAllowedBounds", "(", "KltFeature", "feature", ")", "{", "// compute the feature's width and temporary storage related to it", "widthFeature", "=", "feature", ".", "radius", "*", "2", "+", "1", ";", "lengthFeature", "=", "widthFeature", "*", "wid...
Precompute image bounds that the feature is allowed inside of
[ "Precompute", "image", "bounds", "that", "the", "feature", "is", "allowed", "inside", "of" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java#L330-L344
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java
KltTracker.computeGandE_border
protected int computeGandE_border(KltFeature feature, float cx, float cy) { computeSubImageBounds(feature, cx, cy); ImageMiscOps.fill(currDesc, Float.NaN); currDesc.subimage(dstX0, dstY0, dstX1, dstY1, subimage); interpInput.setImage(image); interpInput.region(srcX0, srcY0, subimage); int total = 0; Gxx = 0; Gyy = 0; Gxy = 0; Ex = 0; Ey = 0; for( int i = 0; i < lengthFeature; i++ ) { float template = feature.desc.data[i]; float current = currDesc.data[i]; // if the description was outside of the image here skip it if( Float.isNaN(template) || Float.isNaN(current)) continue; // count total number of points inbounds total++; float dX = feature.derivX.data[i]; float dY = feature.derivY.data[i]; // compute the difference between the previous and the current image float d = template - current; Ex += d * dX; Ey += d * dY; Gxx += dX * dX; Gyy += dY * dY; Gxy += dX * dY; } return total; }
java
protected int computeGandE_border(KltFeature feature, float cx, float cy) { computeSubImageBounds(feature, cx, cy); ImageMiscOps.fill(currDesc, Float.NaN); currDesc.subimage(dstX0, dstY0, dstX1, dstY1, subimage); interpInput.setImage(image); interpInput.region(srcX0, srcY0, subimage); int total = 0; Gxx = 0; Gyy = 0; Gxy = 0; Ex = 0; Ey = 0; for( int i = 0; i < lengthFeature; i++ ) { float template = feature.desc.data[i]; float current = currDesc.data[i]; // if the description was outside of the image here skip it if( Float.isNaN(template) || Float.isNaN(current)) continue; // count total number of points inbounds total++; float dX = feature.derivX.data[i]; float dY = feature.derivY.data[i]; // compute the difference between the previous and the current image float d = template - current; Ex += d * dX; Ey += d * dY; Gxx += dX * dX; Gyy += dY * dY; Gxy += dX * dY; } return total; }
[ "protected", "int", "computeGandE_border", "(", "KltFeature", "feature", ",", "float", "cx", ",", "float", "cy", ")", "{", "computeSubImageBounds", "(", "feature", ",", "cx", ",", "cy", ")", ";", "ImageMiscOps", ".", "fill", "(", "currDesc", ",", "Float", ...
When part of the region is outside the image G and E need to be recomputed
[ "When", "part", "of", "the", "region", "is", "outside", "the", "image", "G", "and", "E", "need", "to", "be", "recomputed" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java#L379-L419
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java
KltTracker.isDescriptionComplete
public boolean isDescriptionComplete( KltFeature feature ) { for( int i = 0; i < lengthFeature; i++ ) { if( Float.isNaN(feature.desc.data[i]) ) return false; } return true; }
java
public boolean isDescriptionComplete( KltFeature feature ) { for( int i = 0; i < lengthFeature; i++ ) { if( Float.isNaN(feature.desc.data[i]) ) return false; } return true; }
[ "public", "boolean", "isDescriptionComplete", "(", "KltFeature", "feature", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "lengthFeature", ";", "i", "++", ")", "{", "if", "(", "Float", ".", "isNaN", "(", "feature", ".", "desc", ".", "dat...
Checks to see if the feature description is complete or if it was created by a feature partially outside the image
[ "Checks", "to", "see", "if", "the", "feature", "description", "is", "complete", "or", "if", "it", "was", "created", "by", "a", "feature", "partially", "outside", "the", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java#L463-L469
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java
KltTracker.isFullyInside
public boolean isFullyInside(float x, float y) { if (x < allowedLeft || x > allowedRight) return false; if (y < allowedTop || y > allowedBottom) return false; return true; }
java
public boolean isFullyInside(float x, float y) { if (x < allowedLeft || x > allowedRight) return false; if (y < allowedTop || y > allowedBottom) return false; return true; }
[ "public", "boolean", "isFullyInside", "(", "float", "x", ",", "float", "y", ")", "{", "if", "(", "x", "<", "allowedLeft", "||", "x", ">", "allowedRight", ")", "return", "false", ";", "if", "(", "y", "<", "allowedTop", "||", "y", ">", "allowedBottom", ...
Returns true if the features is entirely enclosed inside of the image.
[ "Returns", "true", "if", "the", "features", "is", "entirely", "enclosed", "inside", "of", "the", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java#L474-L481
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java
KltTracker.isFullyOutside
public boolean isFullyOutside(float x, float y) { if (x < outsideLeft || x > outsideRight) return true; if (y < outsideTop || y > outsideBottom) return true; return false; }
java
public boolean isFullyOutside(float x, float y) { if (x < outsideLeft || x > outsideRight) return true; if (y < outsideTop || y > outsideBottom) return true; return false; }
[ "public", "boolean", "isFullyOutside", "(", "float", "x", ",", "float", "y", ")", "{", "if", "(", "x", "<", "outsideLeft", "||", "x", ">", "outsideRight", ")", "return", "true", ";", "if", "(", "y", "<", "outsideTop", "||", "y", ">", "outsideBottom", ...
Returns true if the features is entirely outside of the image. A region is entirely outside if not an entire pixel is contained inside the image. So if only 0.999 of a pixel is inside then the whole region is considered to be outside. Can't interpolate nothing...
[ "Returns", "true", "if", "the", "features", "is", "entirely", "outside", "of", "the", "image", ".", "A", "region", "is", "entirely", "outside", "if", "not", "an", "entire", "pixel", "is", "contained", "inside", "the", "image", ".", "So", "if", "only", "0...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/KltTracker.java#L488-L495
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/FeatureLaplacePyramid.java
FeatureLaplacePyramid.checkMax
private boolean checkMax(T image, double adj, double bestScore, int c_x, int c_y) { sparseLaplace.setImage(image); boolean isMax = true; beginLoop: for (int i = c_y - 1; i <= c_y + 1; i++) { for (int j = c_x - 1; j <= c_x + 1; j++) { double value = adj*sparseLaplace.compute(j, i); if (value >= bestScore) { isMax = false; break beginLoop; } } } return isMax; }
java
private boolean checkMax(T image, double adj, double bestScore, int c_x, int c_y) { sparseLaplace.setImage(image); boolean isMax = true; beginLoop: for (int i = c_y - 1; i <= c_y + 1; i++) { for (int j = c_x - 1; j <= c_x + 1; j++) { double value = adj*sparseLaplace.compute(j, i); if (value >= bestScore) { isMax = false; break beginLoop; } } } return isMax; }
[ "private", "boolean", "checkMax", "(", "T", "image", ",", "double", "adj", ",", "double", "bestScore", ",", "int", "c_x", ",", "int", "c_y", ")", "{", "sparseLaplace", ".", "setImage", "(", "image", ")", ";", "boolean", "isMax", "=", "true", ";", "begi...
See if the best score is better than the local adjusted scores at this scale
[ "See", "if", "the", "best", "score", "is", "better", "than", "the", "local", "adjusted", "scores", "at", "this", "scale" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/FeatureLaplacePyramid.java#L244-L258
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardPatterns.java
DetectChessboardPatterns.findPatterns
public void findPatterns(GrayF32 input) { found.reset(); detector.process(input); clusterFinder.process(detector.getCorners().toList()); FastQueue<ChessboardCornerGraph> clusters = clusterFinder.getOutputClusters(); for (int clusterIdx = 0; clusterIdx < clusters.size; clusterIdx++) { ChessboardCornerGraph c = clusters.get(clusterIdx); if (!clusterToGrid.convert(c, found.grow())) { found.removeTail(); } } }
java
public void findPatterns(GrayF32 input) { found.reset(); detector.process(input); clusterFinder.process(detector.getCorners().toList()); FastQueue<ChessboardCornerGraph> clusters = clusterFinder.getOutputClusters(); for (int clusterIdx = 0; clusterIdx < clusters.size; clusterIdx++) { ChessboardCornerGraph c = clusters.get(clusterIdx); if (!clusterToGrid.convert(c, found.grow())) { found.removeTail(); } } }
[ "public", "void", "findPatterns", "(", "GrayF32", "input", ")", "{", "found", ".", "reset", "(", ")", ";", "detector", ".", "process", "(", "input", ")", ";", "clusterFinder", ".", "process", "(", "detector", ".", "getCorners", "(", ")", ".", "toList", ...
Processes the image and searches for all chessboard patterns.
[ "Processes", "the", "image", "and", "searches", "for", "all", "chessboard", "patterns", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardPatterns.java#L74-L87
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.configure
public void configure( int width , int height , int gridRows , int gridCols ) { // need to maintain the same ratio of pixels in the grid as in the regular image for similarity and rigid // to work correctly int s = Math.max(width,height); scaleX = s/(float)(gridCols-1); scaleY = s/(float)(gridRows-1); if( gridRows > gridCols ) { scaleY /= (gridCols-1)/ (float) (gridRows-1); } else { scaleX /= (gridRows-1)/ (float) (gridCols-1); } this.gridRows = gridRows; this.gridCols = gridCols; grid.resize(gridCols*gridRows); reset(); }
java
public void configure( int width , int height , int gridRows , int gridCols ) { // need to maintain the same ratio of pixels in the grid as in the regular image for similarity and rigid // to work correctly int s = Math.max(width,height); scaleX = s/(float)(gridCols-1); scaleY = s/(float)(gridRows-1); if( gridRows > gridCols ) { scaleY /= (gridCols-1)/ (float) (gridRows-1); } else { scaleX /= (gridRows-1)/ (float) (gridCols-1); } this.gridRows = gridRows; this.gridCols = gridCols; grid.resize(gridCols*gridRows); reset(); }
[ "public", "void", "configure", "(", "int", "width", ",", "int", "height", ",", "int", "gridRows", ",", "int", "gridCols", ")", "{", "// need to maintain the same ratio of pixels in the grid as in the regular image for similarity and rigid", "// to work correctly", "int", "s",...
Specifies the input image size and the size of the grid it will use to approximate the idea solution. All control points are discarded @param width Image width @param height Image height @param gridRows grid rows @param gridCols grid columns
[ "Specifies", "the", "input", "image", "size", "and", "the", "size", "of", "the", "grid", "it", "will", "use", "to", "approximate", "the", "idea", "solution", ".", "All", "control", "points", "are", "discarded" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L109-L127
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.addControl
public int addControl( float x , float y ) { Control c = controls.grow(); c.q.set(x,y); setUndistorted(controls.size()-1,x,y); return controls.size()-1; }
java
public int addControl( float x , float y ) { Control c = controls.grow(); c.q.set(x,y); setUndistorted(controls.size()-1,x,y); return controls.size()-1; }
[ "public", "int", "addControl", "(", "float", "x", ",", "float", "y", ")", "{", "Control", "c", "=", "controls", ".", "grow", "(", ")", ";", "c", ".", "q", ".", "set", "(", "x", ",", "y", ")", ";", "setUndistorted", "(", "controls", ".", "size", ...
Adds a new control point at the specified location. Initially the distorted and undistorted location will be set to the same @param x coordinate x-axis in image pixels @param y coordinate y-axis in image pixels @return Index of control point
[ "Adds", "a", "new", "control", "point", "at", "the", "specified", "location", ".", "Initially", "the", "distorted", "and", "undistorted", "location", "will", "be", "set", "to", "the", "same" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L137-L142
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.setUndistorted
public void setUndistorted(int which, float x, float y) { if( scaleX <= 0 || scaleY <= 0 ) throw new IllegalArgumentException("Must call configure first"); controls.get(which).p.set(x/scaleX,y/scaleY); }
java
public void setUndistorted(int which, float x, float y) { if( scaleX <= 0 || scaleY <= 0 ) throw new IllegalArgumentException("Must call configure first"); controls.get(which).p.set(x/scaleX,y/scaleY); }
[ "public", "void", "setUndistorted", "(", "int", "which", ",", "float", "x", ",", "float", "y", ")", "{", "if", "(", "scaleX", "<=", "0", "||", "scaleY", "<=", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"Must call configure first\"", ")", ...
Sets the location of a control point. @param x coordinate x-axis in image pixels @param y coordinate y-axis in image pixels
[ "Sets", "the", "location", "of", "a", "control", "point", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L149-L154
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.add
public int add( float srcX , float srcY , float dstX , float dstY ) { int which = addControl(srcX,srcY); setUndistorted(which,dstX,dstY); return which; }
java
public int add( float srcX , float srcY , float dstX , float dstY ) { int which = addControl(srcX,srcY); setUndistorted(which,dstX,dstY); return which; }
[ "public", "int", "add", "(", "float", "srcX", ",", "float", "srcY", ",", "float", "dstX", ",", "float", "dstY", ")", "{", "int", "which", "=", "addControl", "(", "srcX", ",", "srcY", ")", ";", "setUndistorted", "(", "which", ",", "dstX", ",", "dstY",...
Function that let's you set control and undistorted points at the same time @param srcX distorted coordinate @param srcY distorted coordinate @param dstX undistorted coordinate @param dstY undistorted coordinate @return Index of control point
[ "Function", "that", "let", "s", "you", "set", "control", "and", "undistorted", "points", "at", "the", "same", "time" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L164-L169
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.setDistorted
public void setDistorted( int which , float x , float y ) { controls.get(which).q.set(x,y); }
java
public void setDistorted( int which , float x , float y ) { controls.get(which).q.set(x,y); }
[ "public", "void", "setDistorted", "(", "int", "which", ",", "float", "x", ",", "float", "y", ")", "{", "controls", ".", "get", "(", "which", ")", ".", "q", ".", "set", "(", "x", ",", "y", ")", ";", "}" ]
Sets the distorted location of a specific control point @param which Which control point @param x distorted coordinate x-axis in image pixels @param y distorted coordinate y-axis in image pixels
[ "Sets", "the", "distorted", "location", "of", "a", "specific", "control", "point" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L177-L179
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.fixateUndistorted
public void fixateUndistorted() { if( controls.size() < 2 ) throw new RuntimeException("Not enough control points specified. Found "+controls.size()); for (int row = 0; row < gridRows; row++) { for (int col = 0; col < gridCols; col++) { Cache cache = getGrid(row,col); cache.weights.resize(controls.size); cache.A.resize(controls.size); cache.A_s.resize(controls.size()); float v_x = col; float v_y = row; computeWeights(cache, v_x, v_y); computeAverageP(cache); model.computeCache(cache, v_x, v_y); } } }
java
public void fixateUndistorted() { if( controls.size() < 2 ) throw new RuntimeException("Not enough control points specified. Found "+controls.size()); for (int row = 0; row < gridRows; row++) { for (int col = 0; col < gridCols; col++) { Cache cache = getGrid(row,col); cache.weights.resize(controls.size); cache.A.resize(controls.size); cache.A_s.resize(controls.size()); float v_x = col; float v_y = row; computeWeights(cache, v_x, v_y); computeAverageP(cache); model.computeCache(cache, v_x, v_y); } } }
[ "public", "void", "fixateUndistorted", "(", ")", "{", "if", "(", "controls", ".", "size", "(", ")", "<", "2", ")", "throw", "new", "RuntimeException", "(", "\"Not enough control points specified. Found \"", "+", "controls", ".", "size", "(", ")", ")", ";", ...
Precompute the portion of the equation which only concerns the undistorted location of each point on the grid even the current undistorted location of each control point.
[ "Precompute", "the", "portion", "of", "the", "equation", "which", "only", "concerns", "the", "undistorted", "location", "of", "each", "point", "on", "the", "grid", "even", "the", "current", "undistorted", "location", "of", "each", "control", "point", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L185-L203
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.computeAverageP
void computeAverageP(Cache cache) { float[] weights = cache.weights.data; cache.aveP.set(0,0); for (int i = 0; i < controls.size(); i++) { Control c = controls.get(i); float w = weights[i]; cache.aveP.x += c.p.x * w; cache.aveP.y += c.p.y * w; } cache.aveP.x /= cache.totalWeight; cache.aveP.y /= cache.totalWeight; }
java
void computeAverageP(Cache cache) { float[] weights = cache.weights.data; cache.aveP.set(0,0); for (int i = 0; i < controls.size(); i++) { Control c = controls.get(i); float w = weights[i]; cache.aveP.x += c.p.x * w; cache.aveP.y += c.p.y * w; } cache.aveP.x /= cache.totalWeight; cache.aveP.y /= cache.totalWeight; }
[ "void", "computeAverageP", "(", "Cache", "cache", ")", "{", "float", "[", "]", "weights", "=", "cache", ".", "weights", ".", "data", ";", "cache", ".", "aveP", ".", "set", "(", "0", ",", "0", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i"...
Computes the average P given the weights at this cached point
[ "Computes", "the", "average", "P", "given", "the", "weights", "at", "this", "cached", "point" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L222-L234
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.computeAverageQ
void computeAverageQ(Cache cache) { float[] weights = cache.weights.data; cache.aveQ.set(0,0); for (int i = 0; i < controls.size(); i++) { Control c = controls.get(i); float w = weights[i]; cache.aveQ.x += c.q.x * w; cache.aveQ.y += c.q.y * w; } cache.aveQ.x /= cache.totalWeight; cache.aveQ.y /= cache.totalWeight; }
java
void computeAverageQ(Cache cache) { float[] weights = cache.weights.data; cache.aveQ.set(0,0); for (int i = 0; i < controls.size(); i++) { Control c = controls.get(i); float w = weights[i]; cache.aveQ.x += c.q.x * w; cache.aveQ.y += c.q.y * w; } cache.aveQ.x /= cache.totalWeight; cache.aveQ.y /= cache.totalWeight; }
[ "void", "computeAverageQ", "(", "Cache", "cache", ")", "{", "float", "[", "]", "weights", "=", "cache", ".", "weights", ".", "data", ";", "cache", ".", "aveQ", ".", "set", "(", "0", ",", "0", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i"...
Computes the average Q given the weights at this cached point
[ "Computes", "the", "average", "Q", "given", "the", "weights", "at", "this", "cached", "point" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L239-L251
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java
ImageDeformPointMLS_F32.interpolateDeformedPoint
void interpolateDeformedPoint(float v_x , float v_y , Point2D_F32 deformed ) { // sample the closest point and x+1,y+1 int x0 = (int)v_x; int y0 = (int)v_y; int x1 = x0+1; int y1 = y0+1; // make sure the 4 sample points are in bounds if( x1 >= gridCols ) x1 = gridCols-1; if( y1 >= gridRows ) y1 = gridRows-1; // weight along each axis float ax = v_x - x0; float ay = v_y - y0; // bilinear weight for each sample point float w00 = (1.0f - ax) * (1.0f - ay); float w01 = ax * (1.0f - ay); float w11 = ax * ay; float w10 = (1.0f - ax) * ay; // apply weights to each sample point Point2D_F32 d00 = getGrid(y0,x0).deformed; Point2D_F32 d01 = getGrid(y0,x1).deformed; Point2D_F32 d10 = getGrid(y1,x0).deformed; Point2D_F32 d11 = getGrid(y1,x1).deformed; deformed.set(0,0); deformed.x += w00 * d00.x; deformed.x += w01 * d01.x; deformed.x += w11 * d11.x; deformed.x += w10 * d10.x; deformed.y += w00 * d00.y; deformed.y += w01 * d01.y; deformed.y += w11 * d11.y; deformed.y += w10 * d10.y; }
java
void interpolateDeformedPoint(float v_x , float v_y , Point2D_F32 deformed ) { // sample the closest point and x+1,y+1 int x0 = (int)v_x; int y0 = (int)v_y; int x1 = x0+1; int y1 = y0+1; // make sure the 4 sample points are in bounds if( x1 >= gridCols ) x1 = gridCols-1; if( y1 >= gridRows ) y1 = gridRows-1; // weight along each axis float ax = v_x - x0; float ay = v_y - y0; // bilinear weight for each sample point float w00 = (1.0f - ax) * (1.0f - ay); float w01 = ax * (1.0f - ay); float w11 = ax * ay; float w10 = (1.0f - ax) * ay; // apply weights to each sample point Point2D_F32 d00 = getGrid(y0,x0).deformed; Point2D_F32 d01 = getGrid(y0,x1).deformed; Point2D_F32 d10 = getGrid(y1,x0).deformed; Point2D_F32 d11 = getGrid(y1,x1).deformed; deformed.set(0,0); deformed.x += w00 * d00.x; deformed.x += w01 * d01.x; deformed.x += w11 * d11.x; deformed.x += w10 * d10.x; deformed.y += w00 * d00.y; deformed.y += w01 * d01.y; deformed.y += w11 * d11.y; deformed.y += w10 * d10.y; }
[ "void", "interpolateDeformedPoint", "(", "float", "v_x", ",", "float", "v_y", ",", "Point2D_F32", "deformed", ")", "{", "// sample the closest point and x+1,y+1", "int", "x0", "=", "(", "int", ")", "v_x", ";", "int", "y0", "=", "(", "int", ")", "v_y", ";", ...
Samples the 4 grid points around v and performs bilinear interpolation @param v_x Grid coordinate x-axis, undistorted @param v_y Grid coordinate y-axis, undistorted @param deformed Distorted grid coordinate in image pixels
[ "Samples", "the", "4", "grid", "points", "around", "v", "and", "performs", "bilinear", "interpolation" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/distort/mls/ImageDeformPointMLS_F32.java#L298-L338
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/RadialDistortionEstimateLinear.java
RadialDistortionEstimateLinear.process
public void process( DMatrixRMaj cameraCalibration , List<DMatrixRMaj> homographies , List<CalibrationObservation> observations ) { init( observations ); setupA_and_B(cameraCalibration,homographies,observations); if( !solver.setA(A) ) throw new RuntimeException("Solver had problems"); solver.solve(B,X); }
java
public void process( DMatrixRMaj cameraCalibration , List<DMatrixRMaj> homographies , List<CalibrationObservation> observations ) { init( observations ); setupA_and_B(cameraCalibration,homographies,observations); if( !solver.setA(A) ) throw new RuntimeException("Solver had problems"); solver.solve(B,X); }
[ "public", "void", "process", "(", "DMatrixRMaj", "cameraCalibration", ",", "List", "<", "DMatrixRMaj", ">", "homographies", ",", "List", "<", "CalibrationObservation", ">", "observations", ")", "{", "init", "(", "observations", ")", ";", "setupA_and_B", "(", "ca...
Computes radial distortion using a linear method. @param cameraCalibration Camera calibration matrix. Not modified. @param observations Observations of calibration grid. Not modified.
[ "Computes", "radial", "distortion", "using", "a", "linear", "method", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/RadialDistortionEstimateLinear.java#L93-L105
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/RadialDistortionEstimateLinear.java
RadialDistortionEstimateLinear.init
private void init( List<CalibrationObservation> observations ) { int totalPoints = 0; for (int i = 0; i < observations.size(); i++) { totalPoints += observations.get(i).size(); } A.reshape(2*totalPoints,X.numRows,false); B.reshape(A.numRows,1,false); }
java
private void init( List<CalibrationObservation> observations ) { int totalPoints = 0; for (int i = 0; i < observations.size(); i++) { totalPoints += observations.get(i).size(); } A.reshape(2*totalPoints,X.numRows,false); B.reshape(A.numRows,1,false); }
[ "private", "void", "init", "(", "List", "<", "CalibrationObservation", ">", "observations", ")", "{", "int", "totalPoints", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "observations", ".", "size", "(", ")", ";", "i", "++", ")", ...
Declares and sets up data structures
[ "Declares", "and", "sets", "up", "data", "structures" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/calibration/RadialDistortionEstimateLinear.java#L110-L119
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/StereoSparse3D.java
StereoSparse3D.process
@Override public boolean process(double x, double y) { leftPixelToRect.compute(x,y,pixelRect); // round to the nearest pixel if( !disparity.process((int)(pixelRect.x+0.5),(int)(pixelRect.y+0.5)) ) return false; // Compute coordinate in camera frame this.w = disparity.getDisparity(); computeHomo3D(pixelRect.x, pixelRect.y, pointLeft); return true; }
java
@Override public boolean process(double x, double y) { leftPixelToRect.compute(x,y,pixelRect); // round to the nearest pixel if( !disparity.process((int)(pixelRect.x+0.5),(int)(pixelRect.y+0.5)) ) return false; // Compute coordinate in camera frame this.w = disparity.getDisparity(); computeHomo3D(pixelRect.x, pixelRect.y, pointLeft); return true; }
[ "@", "Override", "public", "boolean", "process", "(", "double", "x", ",", "double", "y", ")", "{", "leftPixelToRect", ".", "compute", "(", "x", ",", "y", ",", "pixelRect", ")", ";", "// round to the nearest pixel", "if", "(", "!", "disparity", ".", "proces...
Takes in pixel coordinates from the left camera in the original image coordinate system @param x x-coordinate of the pixel @param y y-coordinate of the pixel @return true if successful
[ "Takes", "in", "pixel", "coordinates", "from", "the", "left", "camera", "in", "the", "original", "image", "coordinate", "system" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/StereoSparse3D.java#L81-L95
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java
SquareGraph.detachEdge
public void detachEdge(SquareEdge edge) { edge.a.edges[edge.sideA] = null; edge.b.edges[edge.sideB] = null; edge.distance = 0; edgeManager.recycleInstance(edge); }
java
public void detachEdge(SquareEdge edge) { edge.a.edges[edge.sideA] = null; edge.b.edges[edge.sideB] = null; edge.distance = 0; edgeManager.recycleInstance(edge); }
[ "public", "void", "detachEdge", "(", "SquareEdge", "edge", ")", "{", "edge", ".", "a", ".", "edges", "[", "edge", ".", "sideA", "]", "=", "null", ";", "edge", ".", "b", ".", "edges", "[", "edge", ".", "sideB", "]", "=", "null", ";", "edge", ".", ...
Removes the edge from the two nodes and recycles the data structure
[ "Removes", "the", "edge", "from", "the", "two", "nodes", "and", "recycles", "the", "data", "structure" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java#L66-L73
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java
SquareGraph.findSideIntersect
public int findSideIntersect(SquareNode n , LineSegment2D_F64 line , Point2D_F64 intersection, LineSegment2D_F64 storage ) { for (int j = 0,i=3; j < 4; i=j,j++) { storage.a = n.square.get(i); storage.b = n.square.get(j); if( Intersection2D_F64.intersection(line,storage,intersection) != null ) { return i; } } // bug but I won't throw an exception to stop it from blowing up a bunch return -1; }
java
public int findSideIntersect(SquareNode n , LineSegment2D_F64 line , Point2D_F64 intersection, LineSegment2D_F64 storage ) { for (int j = 0,i=3; j < 4; i=j,j++) { storage.a = n.square.get(i); storage.b = n.square.get(j); if( Intersection2D_F64.intersection(line,storage,intersection) != null ) { return i; } } // bug but I won't throw an exception to stop it from blowing up a bunch return -1; }
[ "public", "int", "findSideIntersect", "(", "SquareNode", "n", ",", "LineSegment2D_F64", "line", ",", "Point2D_F64", "intersection", ",", "LineSegment2D_F64", "storage", ")", "{", "for", "(", "int", "j", "=", "0", ",", "i", "=", "3", ";", "j", "<", "4", "...
Finds the side which intersects the line on the shape. The line is assumed to pass through the shape so if there is no intersection it is considered a bug
[ "Finds", "the", "side", "which", "intersects", "the", "line", "on", "the", "shape", ".", "The", "line", "is", "assumed", "to", "pass", "through", "the", "shape", "so", "if", "there", "is", "no", "intersection", "it", "is", "considered", "a", "bug" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java#L79-L91
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java
SquareGraph.checkConnect
public void checkConnect( SquareNode a , int indexA , SquareNode b , int indexB , double distance ) { if( a.edges[indexA] != null && a.edges[indexA].distance > distance ) { detachEdge(a.edges[indexA]); } if( b.edges[indexB] != null && b.edges[indexB].distance > distance ) { detachEdge(b.edges[indexB]); } if( a.edges[indexA] == null && b.edges[indexB] == null) { connect(a,indexA,b,indexB,distance); } }
java
public void checkConnect( SquareNode a , int indexA , SquareNode b , int indexB , double distance ) { if( a.edges[indexA] != null && a.edges[indexA].distance > distance ) { detachEdge(a.edges[indexA]); } if( b.edges[indexB] != null && b.edges[indexB].distance > distance ) { detachEdge(b.edges[indexB]); } if( a.edges[indexA] == null && b.edges[indexB] == null) { connect(a,indexA,b,indexB,distance); } }
[ "public", "void", "checkConnect", "(", "SquareNode", "a", ",", "int", "indexA", ",", "SquareNode", "b", ",", "int", "indexB", ",", "double", "distance", ")", "{", "if", "(", "a", ".", "edges", "[", "indexA", "]", "!=", "null", "&&", "a", ".", "edges"...
Checks to see if the two nodes can be connected. If one of the nodes is already connected to another it then checks to see if the proposed connection is more desirable. If it is the old connection is removed and a new one created. Otherwise nothing happens.
[ "Checks", "to", "see", "if", "the", "two", "nodes", "can", "be", "connected", ".", "If", "one", "of", "the", "nodes", "is", "already", "connected", "to", "another", "it", "then", "checks", "to", "see", "if", "the", "proposed", "connection", "is", "more",...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java#L98-L110
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java
SquareGraph.connect
void connect( SquareNode a , int indexA , SquareNode b , int indexB , double distance ) { SquareEdge edge = edgeManager.requestInstance(); edge.reset(); edge.a = a; edge.sideA = indexA; edge.b = b; edge.sideB = indexB; edge.distance = distance; a.edges[indexA] = edge; b.edges[indexB] = edge; }
java
void connect( SquareNode a , int indexA , SquareNode b , int indexB , double distance ) { SquareEdge edge = edgeManager.requestInstance(); edge.reset(); edge.a = a; edge.sideA = indexA; edge.b = b; edge.sideB = indexB; edge.distance = distance; a.edges[indexA] = edge; b.edges[indexB] = edge; }
[ "void", "connect", "(", "SquareNode", "a", ",", "int", "indexA", ",", "SquareNode", "b", ",", "int", "indexB", ",", "double", "distance", ")", "{", "SquareEdge", "edge", "=", "edgeManager", ".", "requestInstance", "(", ")", ";", "edge", ".", "reset", "("...
Creates a new edge which will connect the two nodes. The side on each node which is connected is specified by the indexes. @param a First node @param indexA side on node 'a' @param b Second node @param indexB side on node 'b' @param distance distance apart the center of the two nodes
[ "Creates", "a", "new", "edge", "which", "will", "connect", "the", "two", "nodes", ".", "The", "side", "on", "each", "node", "which", "is", "connected", "is", "specified", "by", "the", "indexes", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java#L121-L133
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java
SquareGraph.almostParallel
public boolean almostParallel(SquareNode a , int sideA , SquareNode b , int sideB ) { double selected = acuteAngle(a,sideA,b,sideB); if( selected > parallelThreshold ) return false; // see if the two sides are about parallel too // double left = acuteAngle(a,add(sideA,-1),b,add(sideB,1)); // double right = acuteAngle(a,add(sideA,1),b,add(sideB,-1)); // // if( left > selected+parallelThreshold || right > selected+parallelThreshold ) // return false; // if( selected > acuteAngle(a,sideA,b,add(sideB,1)) || selected > acuteAngle(a,sideA,b,add(sideB,-1)) ) // return false; // // if( selected > acuteAngle(a,add(sideA,1),b,sideB) || selected > acuteAngle(a,add(sideA,-1),b,sideB) ) // return false; return true; }
java
public boolean almostParallel(SquareNode a , int sideA , SquareNode b , int sideB ) { double selected = acuteAngle(a,sideA,b,sideB); if( selected > parallelThreshold ) return false; // see if the two sides are about parallel too // double left = acuteAngle(a,add(sideA,-1),b,add(sideB,1)); // double right = acuteAngle(a,add(sideA,1),b,add(sideB,-1)); // // if( left > selected+parallelThreshold || right > selected+parallelThreshold ) // return false; // if( selected > acuteAngle(a,sideA,b,add(sideB,1)) || selected > acuteAngle(a,sideA,b,add(sideB,-1)) ) // return false; // // if( selected > acuteAngle(a,add(sideA,1),b,sideB) || selected > acuteAngle(a,add(sideA,-1),b,sideB) ) // return false; return true; }
[ "public", "boolean", "almostParallel", "(", "SquareNode", "a", ",", "int", "sideA", ",", "SquareNode", "b", ",", "int", "sideB", ")", "{", "double", "selected", "=", "acuteAngle", "(", "a", ",", "sideA", ",", "b", ",", "sideB", ")", ";", "if", "(", "...
Checks to see if the two sides are almost parallel to each other by looking at their acute angle.
[ "Checks", "to", "see", "if", "the", "two", "sides", "are", "almost", "parallel", "to", "each", "other", "by", "looking", "at", "their", "acute", "angle", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGraph.java#L139-L160
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java
OrientationHistogramSift.setImageGradient
public void setImageGradient(Deriv derivX, Deriv derivY ) { this.derivX.wrap(derivX); this.derivY.wrap(derivY); }
java
public void setImageGradient(Deriv derivX, Deriv derivY ) { this.derivX.wrap(derivX); this.derivY.wrap(derivY); }
[ "public", "void", "setImageGradient", "(", "Deriv", "derivX", ",", "Deriv", "derivY", ")", "{", "this", ".", "derivX", ".", "wrap", "(", "derivX", ")", ";", "this", ".", "derivY", ".", "wrap", "(", "derivY", ")", ";", "}" ]
Specify the input image
[ "Specify", "the", "input", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java#L123-L126
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java
OrientationHistogramSift.computeHistogram
void computeHistogram(int c_x, int c_y, double sigma) { int r = (int)Math.ceil(sigma * sigmaEnlarge); // specify the area being sampled bound.x0 = c_x - r; bound.y0 = c_y - r; bound.x1 = c_x + r + 1; bound.y1 = c_y + r + 1; ImageGray rawDX = derivX.getImage(); ImageGray rawDY = derivY.getImage(); // make sure it is contained in the image bounds BoofMiscOps.boundRectangleInside(rawDX,bound); // clear the histogram Arrays.fill(histogramMag,0); Arrays.fill(histogramX,0); Arrays.fill(histogramY,0); // construct the histogram for( int y = bound.y0; y < bound.y1; y++ ) { // iterate through the raw array for speed int indexDX = rawDX.startIndex + y*rawDX.stride + bound.x0; int indexDY = rawDY.startIndex + y*rawDY.stride + bound.x0; for( int x = bound.x0; x < bound.x1; x++ ) { float dx = derivX.getF(indexDX++); float dy = derivY.getF(indexDY++); // edge intensity and angle double magnitude = Math.sqrt(dx*dx + dy*dy); double theta = UtilAngle.domain2PI(Math.atan2(dy,dx)); // weight from gaussian double weight = computeWeight( x-c_x, y-c_y , sigma ); // histogram index int h = (int)(theta / histAngleBin) % histogramMag.length; // update the histogram histogramMag[h] += magnitude*weight; histogramX[h] += dx*weight; histogramY[h] += dy*weight; } } }
java
void computeHistogram(int c_x, int c_y, double sigma) { int r = (int)Math.ceil(sigma * sigmaEnlarge); // specify the area being sampled bound.x0 = c_x - r; bound.y0 = c_y - r; bound.x1 = c_x + r + 1; bound.y1 = c_y + r + 1; ImageGray rawDX = derivX.getImage(); ImageGray rawDY = derivY.getImage(); // make sure it is contained in the image bounds BoofMiscOps.boundRectangleInside(rawDX,bound); // clear the histogram Arrays.fill(histogramMag,0); Arrays.fill(histogramX,0); Arrays.fill(histogramY,0); // construct the histogram for( int y = bound.y0; y < bound.y1; y++ ) { // iterate through the raw array for speed int indexDX = rawDX.startIndex + y*rawDX.stride + bound.x0; int indexDY = rawDY.startIndex + y*rawDY.stride + bound.x0; for( int x = bound.x0; x < bound.x1; x++ ) { float dx = derivX.getF(indexDX++); float dy = derivY.getF(indexDY++); // edge intensity and angle double magnitude = Math.sqrt(dx*dx + dy*dy); double theta = UtilAngle.domain2PI(Math.atan2(dy,dx)); // weight from gaussian double weight = computeWeight( x-c_x, y-c_y , sigma ); // histogram index int h = (int)(theta / histAngleBin) % histogramMag.length; // update the histogram histogramMag[h] += magnitude*weight; histogramX[h] += dx*weight; histogramY[h] += dy*weight; } } }
[ "void", "computeHistogram", "(", "int", "c_x", ",", "int", "c_y", ",", "double", "sigma", ")", "{", "int", "r", "=", "(", "int", ")", "Math", ".", "ceil", "(", "sigma", "*", "sigmaEnlarge", ")", ";", "// specify the area being sampled", "bound", ".", "x0...
Constructs the histogram around the specified point. @param c_x Center x-axis @param c_y Center y-axis @param sigma Scale of feature, adjusted for local octave
[ "Constructs", "the", "histogram", "around", "the", "specified", "point", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java#L155-L201
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java
OrientationHistogramSift.findHistogramPeaks
void findHistogramPeaks() { // reset data structures peaks.reset(); angles.reset(); peakAngle = 0; // identify peaks and find the highest peak double largest = 0; int largestIndex = -1; double before = histogramMag[ histogramMag.length-2 ]; double current = histogramMag[ histogramMag.length-1 ]; for(int i = 0; i < histogramMag.length; i++ ) { double after = histogramMag[ i ]; if( current > before && current > after ) { int currentIndex = CircularIndex.addOffset(i,-1,histogramMag.length); peaks.push(currentIndex); if( current > largest ) { largest = current; largestIndex = currentIndex; } } before = current; current = after; } if( largestIndex < 0 ) return; // see if any of the other peaks are within 80% of the max peak double threshold = largest*0.8; for( int i = 0; i < peaks.size; i++ ) { int index = peaks.data[i]; current = histogramMag[index]; if( current >= threshold) { double angle = computeAngle(index); angles.push( angle ); if( index == largestIndex ) peakAngle = angle; } } }
java
void findHistogramPeaks() { // reset data structures peaks.reset(); angles.reset(); peakAngle = 0; // identify peaks and find the highest peak double largest = 0; int largestIndex = -1; double before = histogramMag[ histogramMag.length-2 ]; double current = histogramMag[ histogramMag.length-1 ]; for(int i = 0; i < histogramMag.length; i++ ) { double after = histogramMag[ i ]; if( current > before && current > after ) { int currentIndex = CircularIndex.addOffset(i,-1,histogramMag.length); peaks.push(currentIndex); if( current > largest ) { largest = current; largestIndex = currentIndex; } } before = current; current = after; } if( largestIndex < 0 ) return; // see if any of the other peaks are within 80% of the max peak double threshold = largest*0.8; for( int i = 0; i < peaks.size; i++ ) { int index = peaks.data[i]; current = histogramMag[index]; if( current >= threshold) { double angle = computeAngle(index); angles.push( angle ); if( index == largestIndex ) peakAngle = angle; } } }
[ "void", "findHistogramPeaks", "(", ")", "{", "// reset data structures", "peaks", ".", "reset", "(", ")", ";", "angles", ".", "reset", "(", ")", ";", "peakAngle", "=", "0", ";", "// identify peaks and find the highest peak", "double", "largest", "=", "0", ";", ...
Finds local peaks in histogram and selects orientations. Location of peaks is interpolated.
[ "Finds", "local", "peaks", "in", "histogram", "and", "selects", "orientations", ".", "Location", "of", "peaks", "is", "interpolated", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java#L206-L249
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java
OrientationHistogramSift.computeAngle
double computeAngle( int index1 ) { int index0 = CircularIndex.addOffset(index1,-1, histogramMag.length); int index2 = CircularIndex.addOffset(index1, 1, histogramMag.length); // compute the peak location using a second order polygon double v0 = histogramMag[index0]; double v1 = histogramMag[index1]; double v2 = histogramMag[index2]; double offset = FastHessianFeatureDetector.polyPeak(v0,v1,v2); // interpolate using the index offset and angle of its neighbor return interpolateAngle(index0, index1, index2, offset); }
java
double computeAngle( int index1 ) { int index0 = CircularIndex.addOffset(index1,-1, histogramMag.length); int index2 = CircularIndex.addOffset(index1, 1, histogramMag.length); // compute the peak location using a second order polygon double v0 = histogramMag[index0]; double v1 = histogramMag[index1]; double v2 = histogramMag[index2]; double offset = FastHessianFeatureDetector.polyPeak(v0,v1,v2); // interpolate using the index offset and angle of its neighbor return interpolateAngle(index0, index1, index2, offset); }
[ "double", "computeAngle", "(", "int", "index1", ")", "{", "int", "index0", "=", "CircularIndex", ".", "addOffset", "(", "index1", ",", "-", "1", ",", "histogramMag", ".", "length", ")", ";", "int", "index2", "=", "CircularIndex", ".", "addOffset", "(", "...
Compute the angle. The angle for each neighbor bin is found using the weighted sum of the derivative. Then the peak index is found by 2nd order polygon interpolation. These two bits of information are combined and used to return the final angle output. @param index1 Histogram index of the peak @return angle of the peak. -pi to pi
[ "Compute", "the", "angle", ".", "The", "angle", "for", "each", "neighbor", "bin", "is", "found", "using", "the", "weighted", "sum", "of", "the", "derivative", ".", "Then", "the", "peak", "index", "is", "found", "by", "2nd", "order", "polygon", "interpolati...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java#L259-L273
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java
OrientationHistogramSift.interpolateAngle
double interpolateAngle(int index0, int index1, int index2, double offset) { double angle1 = Math.atan2(histogramY[index1],histogramX[index1]); double deltaAngle; if( offset < 0 ) { double angle0 = Math.atan2(histogramY[index0],histogramX[index0]); deltaAngle = UtilAngle.dist(angle0,angle1); } else { double angle2 = Math.atan2(histogramY[index2], histogramX[index2]); deltaAngle = UtilAngle.dist(angle2,angle1); } return UtilAngle.bound(angle1 + deltaAngle*offset); }
java
double interpolateAngle(int index0, int index1, int index2, double offset) { double angle1 = Math.atan2(histogramY[index1],histogramX[index1]); double deltaAngle; if( offset < 0 ) { double angle0 = Math.atan2(histogramY[index0],histogramX[index0]); deltaAngle = UtilAngle.dist(angle0,angle1); } else { double angle2 = Math.atan2(histogramY[index2], histogramX[index2]); deltaAngle = UtilAngle.dist(angle2,angle1); } return UtilAngle.bound(angle1 + deltaAngle*offset); }
[ "double", "interpolateAngle", "(", "int", "index0", ",", "int", "index1", ",", "int", "index2", ",", "double", "offset", ")", "{", "double", "angle1", "=", "Math", ".", "atan2", "(", "histogramY", "[", "index1", "]", ",", "histogramX", "[", "index1", "]"...
Given the interpolated index, compute the angle from the 3 indexes. The angle for each index is computed from the weighted gradients. @param offset Interpolated index offset relative to index0. range -1 to 1 @return Interpolated angle.
[ "Given", "the", "interpolated", "index", "compute", "the", "angle", "from", "the", "3", "indexes", ".", "The", "angle", "for", "each", "index", "is", "computed", "from", "the", "weighted", "gradients", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java#L281-L293
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java
OrientationHistogramSift.computeWeight
double computeWeight( double deltaX , double deltaY , double sigma ) { // the exact equation // return Math.exp(-0.5 * ((deltaX * deltaX + deltaY * deltaY) / (sigma * sigma))); // approximation below. when validating this approach it produced results that were within // floating point tolerance of the exact solution, but much faster double d = ((deltaX * deltaX + deltaY * deltaY) / (sigma * sigma))/approximateStep; if( approximateGauss.interpolate(d) ) { return approximateGauss.value; } else return 0; }
java
double computeWeight( double deltaX , double deltaY , double sigma ) { // the exact equation // return Math.exp(-0.5 * ((deltaX * deltaX + deltaY * deltaY) / (sigma * sigma))); // approximation below. when validating this approach it produced results that were within // floating point tolerance of the exact solution, but much faster double d = ((deltaX * deltaX + deltaY * deltaY) / (sigma * sigma))/approximateStep; if( approximateGauss.interpolate(d) ) { return approximateGauss.value; } else return 0; }
[ "double", "computeWeight", "(", "double", "deltaX", ",", "double", "deltaY", ",", "double", "sigma", ")", "{", "// the exact equation", "//\t\treturn Math.exp(-0.5 * ((deltaX * deltaX + deltaY * deltaY) / (sigma * sigma)));", "// approximation below. when validating this approach it p...
Computes the weight based on a centered Gaussian shaped function. Interpolation is used to speed up the process
[ "Computes", "the", "weight", "based", "on", "a", "centered", "Gaussian", "shaped", "function", ".", "Interpolation", "is", "used", "to", "speed", "up", "the", "process" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/orientation/OrientationHistogramSift.java#L298-L309
train
lessthanoptimal/BoofCV
integration/boofcv-android/examples/video/app/src/main/java/org/boofcv/video/GradientActivity.java
GradientActivity.onCameraResolutionChange
@Override protected void onCameraResolutionChange( int width , int height, int sensorOrientation ) { super.onCameraResolutionChange(width, height,sensorOrientation); derivX.reshape(width, height); derivY.reshape(width, height); }
java
@Override protected void onCameraResolutionChange( int width , int height, int sensorOrientation ) { super.onCameraResolutionChange(width, height,sensorOrientation); derivX.reshape(width, height); derivY.reshape(width, height); }
[ "@", "Override", "protected", "void", "onCameraResolutionChange", "(", "int", "width", ",", "int", "height", ",", "int", "sensorOrientation", ")", "{", "super", ".", "onCameraResolutionChange", "(", "width", ",", "height", ",", "sensorOrientation", ")", ";", "de...
During camera initialization this function is called once after the resolution is known. This is a good function to override and predeclare data structres which are dependent on the video feeds resolution.
[ "During", "camera", "initialization", "this", "function", "is", "called", "once", "after", "the", "resolution", "is", "known", ".", "This", "is", "a", "good", "function", "to", "override", "and", "predeclare", "data", "structres", "which", "are", "dependent", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/examples/video/app/src/main/java/org/boofcv/video/GradientActivity.java#L121-L127
train
lessthanoptimal/BoofCV
integration/boofcv-android/examples/video/app/src/main/java/org/boofcv/video/GradientActivity.java
GradientActivity.renderBitmapImage
@Override protected void renderBitmapImage(BitmapMode mode, ImageBase image) { switch( mode ) { case UNSAFE: { // this application is configured to use double buffer and could ignore all other modes VisualizeImageData.colorizeGradient(derivX, derivY, -1, bitmap, bitmapTmp); } break; case DOUBLE_BUFFER: { VisualizeImageData.colorizeGradient(derivX, derivY, -1, bitmapWork, bitmapTmp); if( bitmapLock.tryLock() ) { try { Bitmap tmp = bitmapWork; bitmapWork = bitmap; bitmap = tmp; } finally { bitmapLock.unlock(); } } } break; } }
java
@Override protected void renderBitmapImage(BitmapMode mode, ImageBase image) { switch( mode ) { case UNSAFE: { // this application is configured to use double buffer and could ignore all other modes VisualizeImageData.colorizeGradient(derivX, derivY, -1, bitmap, bitmapTmp); } break; case DOUBLE_BUFFER: { VisualizeImageData.colorizeGradient(derivX, derivY, -1, bitmapWork, bitmapTmp); if( bitmapLock.tryLock() ) { try { Bitmap tmp = bitmapWork; bitmapWork = bitmap; bitmap = tmp; } finally { bitmapLock.unlock(); } } } break; } }
[ "@", "Override", "protected", "void", "renderBitmapImage", "(", "BitmapMode", "mode", ",", "ImageBase", "image", ")", "{", "switch", "(", "mode", ")", "{", "case", "UNSAFE", ":", "{", "// this application is configured to use double buffer and could ignore all other modes...
Override the default behavior and colorize gradient instead of converting input image.
[ "Override", "the", "default", "behavior", "and", "colorize", "gradient", "instead", "of", "converting", "input", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/examples/video/app/src/main/java/org/boofcv/video/GradientActivity.java#L143-L164
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/FastCornerDetector.java
FastCornerDetector.process
public void process( T image , GrayF32 intensity ) { int maxFeatures = (int)(maxFeaturesFraction*image.width*image.height); candidatesLow.reset(); candidatesHigh.reset(); this.image = image; if( stride != image.stride ) { stride = image.stride; offsets = DiscretizedCircle.imageOffsets(radius, image.stride); } helper.setImage(image,offsets); for (int y = radius; y < image.height-radius; y++) { int indexIntensity = intensity.startIndex + y*intensity.stride + radius; int index = image.startIndex + y*image.stride + radius; for (int x = radius; x < image.width-radius; x++, index++,indexIntensity++) { int result = helper.checkPixel(index); if( result < 0 ) { intensity.data[indexIntensity] = helper.scoreLower(index); candidatesLow.add(x,y); } else if( result > 0) { intensity.data[indexIntensity] = helper.scoreUpper(index); candidatesHigh.add(x,y); } else { intensity.data[indexIntensity] = 0; } } // check on a per row basis to reduce impact on performance if( candidatesLow.size + candidatesHigh.size >= maxFeatures ) break; } }
java
public void process( T image , GrayF32 intensity ) { int maxFeatures = (int)(maxFeaturesFraction*image.width*image.height); candidatesLow.reset(); candidatesHigh.reset(); this.image = image; if( stride != image.stride ) { stride = image.stride; offsets = DiscretizedCircle.imageOffsets(radius, image.stride); } helper.setImage(image,offsets); for (int y = radius; y < image.height-radius; y++) { int indexIntensity = intensity.startIndex + y*intensity.stride + radius; int index = image.startIndex + y*image.stride + radius; for (int x = radius; x < image.width-radius; x++, index++,indexIntensity++) { int result = helper.checkPixel(index); if( result < 0 ) { intensity.data[indexIntensity] = helper.scoreLower(index); candidatesLow.add(x,y); } else if( result > 0) { intensity.data[indexIntensity] = helper.scoreUpper(index); candidatesHigh.add(x,y); } else { intensity.data[indexIntensity] = 0; } } // check on a per row basis to reduce impact on performance if( candidatesLow.size + candidatesHigh.size >= maxFeatures ) break; } }
[ "public", "void", "process", "(", "T", "image", ",", "GrayF32", "intensity", ")", "{", "int", "maxFeatures", "=", "(", "int", ")", "(", "maxFeaturesFraction", "*", "image", ".", "width", "*", "image", ".", "height", ")", ";", "candidatesLow", ".", "reset...
Computes fast corner features and their intensity. The intensity is needed if non-max suppression is used
[ "Computes", "fast", "corner", "features", "and", "their", "intensity", ".", "The", "intensity", "is", "needed", "if", "non", "-", "max", "suppression", "is", "used" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/FastCornerDetector.java#L123-L156
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java
BoofSwingUtil.selectZoomToShowAll
public static double selectZoomToShowAll(JComponent panel , int width , int height ) { int w = panel.getWidth(); int h = panel.getHeight(); if( w == 0 ) { w = panel.getPreferredSize().width; h = panel.getPreferredSize().height; } double scale = Math.max(width/(double)w,height/(double)h); if( scale > 1.0 ) { return 1.0/scale; } else { return 1.0; } }
java
public static double selectZoomToShowAll(JComponent panel , int width , int height ) { int w = panel.getWidth(); int h = panel.getHeight(); if( w == 0 ) { w = panel.getPreferredSize().width; h = panel.getPreferredSize().height; } double scale = Math.max(width/(double)w,height/(double)h); if( scale > 1.0 ) { return 1.0/scale; } else { return 1.0; } }
[ "public", "static", "double", "selectZoomToShowAll", "(", "JComponent", "panel", ",", "int", "width", ",", "int", "height", ")", "{", "int", "w", "=", "panel", ".", "getWidth", "(", ")", ";", "int", "h", "=", "panel", ".", "getHeight", "(", ")", ";", ...
Select a zoom which will allow the entire image to be shown in the panel
[ "Select", "a", "zoom", "which", "will", "allow", "the", "entire", "image", "to", "be", "shown", "in", "the", "panel" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java#L209-L223
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java
BoofSwingUtil.selectZoomToFitInDisplay
public static double selectZoomToFitInDisplay( int width , int height ) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); double w = screenSize.getWidth(); double h = screenSize.getHeight(); double scale = Math.max(width/w,height/h); if( scale > 1.0 ) { return 1.0/scale; } else { return 1.0; } }
java
public static double selectZoomToFitInDisplay( int width , int height ) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); double w = screenSize.getWidth(); double h = screenSize.getHeight(); double scale = Math.max(width/w,height/h); if( scale > 1.0 ) { return 1.0/scale; } else { return 1.0; } }
[ "public", "static", "double", "selectZoomToFitInDisplay", "(", "int", "width", ",", "int", "height", ")", "{", "Dimension", "screenSize", "=", "Toolkit", ".", "getDefaultToolkit", "(", ")", ".", "getScreenSize", "(", ")", ";", "double", "w", "=", "screenSize",...
Figures out what the scale should be to fit the window inside the default display
[ "Figures", "out", "what", "the", "scale", "should", "be", "to", "fit", "the", "window", "inside", "the", "default", "display" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java#L228-L240
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java
BoofSwingUtil.antialiasing
public static void antialiasing( Graphics2D g2 ) { g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); }
java
public static void antialiasing( Graphics2D g2 ) { g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); }
[ "public", "static", "void", "antialiasing", "(", "Graphics2D", "g2", ")", "{", "g2", ".", "setRenderingHint", "(", "RenderingHints", ".", "KEY_STROKE_CONTROL", ",", "RenderingHints", ".", "VALUE_STROKE_PURE", ")", ";", "g2", ".", "setRenderingHint", "(", "Renderin...
Sets rendering hints that will enable antialiasing and make sub pixel rendering look good @param g2
[ "Sets", "rendering", "hints", "that", "will", "enable", "antialiasing", "and", "make", "sub", "pixel", "rendering", "look", "good" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java#L287-L290
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java
BoofSwingUtil.isImage
public static boolean isImage( File file ){ try { String mimeType = Files.probeContentType(file.toPath()); if( mimeType == null ) { // In some OS there is a bug where it always returns null/ String extension = FilenameUtils.getExtension(file.getName()).toLowerCase(); String[] suffixes = ImageIO.getReaderFileSuffixes(); for( String s : suffixes ) { if( s.equals(extension)) { return true; } } } else { return mimeType.startsWith("image"); } } catch (IOException ignore) {} return false; }
java
public static boolean isImage( File file ){ try { String mimeType = Files.probeContentType(file.toPath()); if( mimeType == null ) { // In some OS there is a bug where it always returns null/ String extension = FilenameUtils.getExtension(file.getName()).toLowerCase(); String[] suffixes = ImageIO.getReaderFileSuffixes(); for( String s : suffixes ) { if( s.equals(extension)) { return true; } } } else { return mimeType.startsWith("image"); } } catch (IOException ignore) {} return false; }
[ "public", "static", "boolean", "isImage", "(", "File", "file", ")", "{", "try", "{", "String", "mimeType", "=", "Files", ".", "probeContentType", "(", "file", ".", "toPath", "(", ")", ")", ";", "if", "(", "mimeType", "==", "null", ")", "{", "// In some...
Uses mime type to determine if it's an image or not. If mime fails it will look at the suffix. This isn't 100% correct.
[ "Uses", "mime", "type", "to", "determine", "if", "it", "s", "an", "image", "or", "not", ".", "If", "mime", "fails", "it", "will", "look", "at", "the", "suffix", ".", "This", "isn", "t", "100%", "correct", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/BoofSwingUtil.java#L369-L386
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java
IntegralImageOps.print
public static void print( IntegralKernel kernel ) { int x0 = 0,x1=0,y0=0,y1=0; for( ImageRectangle k : kernel.blocks) { if( k.x0 < x0 ) x0 = k.x0; if( k.y0 < y0 ) y0 = k.y0; if( k.x1 > x1 ) x1 = k.x1; if( k.y1 > y1 ) y1 = k.y1; } int w = x1-x0; int h = y1-y0; int sum[] = new int[ w*h ]; for( int i = 0; i < kernel.blocks.length; i++ ) { ImageRectangle r = kernel.blocks[i]; int value = kernel.scales[i]; for( int y = r.y0; y < r.y1; y++ ) { int yy = y-y0; for( int x = r.x0; x < r.x1; x++ ) { int xx = x - x0; sum[ yy*w + xx ] += value; } } } System.out.println("IntegralKernel: TL = ("+(x0+1)+","+(y0+1)+") BR=("+x1+","+y1+")"); for( int y = 0; y < h; y++ ) { for( int x = 0; x < w; x++ ) { System.out.printf("%4d ",sum[y*w+x]); } System.out.println(); } }
java
public static void print( IntegralKernel kernel ) { int x0 = 0,x1=0,y0=0,y1=0; for( ImageRectangle k : kernel.blocks) { if( k.x0 < x0 ) x0 = k.x0; if( k.y0 < y0 ) y0 = k.y0; if( k.x1 > x1 ) x1 = k.x1; if( k.y1 > y1 ) y1 = k.y1; } int w = x1-x0; int h = y1-y0; int sum[] = new int[ w*h ]; for( int i = 0; i < kernel.blocks.length; i++ ) { ImageRectangle r = kernel.blocks[i]; int value = kernel.scales[i]; for( int y = r.y0; y < r.y1; y++ ) { int yy = y-y0; for( int x = r.x0; x < r.x1; x++ ) { int xx = x - x0; sum[ yy*w + xx ] += value; } } } System.out.println("IntegralKernel: TL = ("+(x0+1)+","+(y0+1)+") BR=("+x1+","+y1+")"); for( int y = 0; y < h; y++ ) { for( int x = 0; x < w; x++ ) { System.out.printf("%4d ",sum[y*w+x]); } System.out.println(); } }
[ "public", "static", "void", "print", "(", "IntegralKernel", "kernel", ")", "{", "int", "x0", "=", "0", ",", "x1", "=", "0", ",", "y0", "=", "0", ",", "y1", "=", "0", ";", "for", "(", "ImageRectangle", "k", ":", "kernel", ".", "blocks", ")", "{", ...
Prints out the kernel. @param kernel THe kernel which is to be printed.
[ "Prints", "out", "the", "kernel", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java#L508-L547
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java
IntegralImageOps.isInBounds
public static boolean isInBounds( int x , int y , IntegralKernel kernel , int width , int height ) { for(ImageRectangle r : kernel.blocks ) { if( x+r.x0 < 0 || y+r.y0 < 0 ) return false; if( x+r.x1 >= width || y+r.y1 >= height ) return false; } return true; }
java
public static boolean isInBounds( int x , int y , IntegralKernel kernel , int width , int height ) { for(ImageRectangle r : kernel.blocks ) { if( x+r.x0 < 0 || y+r.y0 < 0 ) return false; if( x+r.x1 >= width || y+r.y1 >= height ) return false; } return true; }
[ "public", "static", "boolean", "isInBounds", "(", "int", "x", ",", "int", "y", ",", "IntegralKernel", "kernel", ",", "int", "width", ",", "int", "height", ")", "{", "for", "(", "ImageRectangle", "r", ":", "kernel", ".", "blocks", ")", "{", "if", "(", ...
Checks to see if the kernel is applied at this specific spot if all the pixels would be inside the image bounds or not @param x location where the kernel is applied. x-axis @param y location where the kernel is applied. y-axis @param kernel The kernel @param width Image's width @param height Image's height @return true if in bounds and false if out of bounds
[ "Checks", "to", "see", "if", "the", "kernel", "is", "applied", "at", "this", "specific", "spot", "if", "all", "the", "pixels", "would", "be", "inside", "the", "image", "bounds", "or", "not" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/IntegralImageOps.java#L560-L570
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/pyramid/PyramidDiscrete.java
PyramidDiscrete.setScaleFactors
public void setScaleFactors( int ...scaleFactors ) { for( int i = 1; i < scaleFactors.length; i++ ){ if( scaleFactors[i] % scaleFactors[i-1] != 0 ) { throw new IllegalArgumentException("Layer "+i+" is not evenly divisible by its lower layer."); } } // set width/height to zero to force the image to be redeclared bottomWidth = bottomHeight = 0; this.scale = scaleFactors.clone(); checkScales(); }
java
public void setScaleFactors( int ...scaleFactors ) { for( int i = 1; i < scaleFactors.length; i++ ){ if( scaleFactors[i] % scaleFactors[i-1] != 0 ) { throw new IllegalArgumentException("Layer "+i+" is not evenly divisible by its lower layer."); } } // set width/height to zero to force the image to be redeclared bottomWidth = bottomHeight = 0; this.scale = scaleFactors.clone(); checkScales(); }
[ "public", "void", "setScaleFactors", "(", "int", "...", "scaleFactors", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<", "scaleFactors", ".", "length", ";", "i", "++", ")", "{", "if", "(", "scaleFactors", "[", "i", "]", "%", "scaleFactors",...
Specifies the pyramid's structure. Scale factors are in relative to the input image. @param scaleFactors Change in scale factor for each layer in the pyramid.
[ "Specifies", "the", "pyramid", "s", "structure", ".", "Scale", "factors", "are", "in", "relative", "to", "the", "input", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/pyramid/PyramidDiscrete.java#L60-L71
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFit.java
SplitMergeLineFit.process
public boolean process( List<Point2D_I32> list , GrowQueue_I32 vertexes ) { this.contour = list; this.minimumSideLengthPixel = minimumSideLength.computeI(contour.size()); splits.reset(); boolean result = _process(list); // remove reference so that it can be freed this.contour = null; vertexes.setTo(splits); return result; }
java
public boolean process( List<Point2D_I32> list , GrowQueue_I32 vertexes ) { this.contour = list; this.minimumSideLengthPixel = minimumSideLength.computeI(contour.size()); splits.reset(); boolean result = _process(list); // remove reference so that it can be freed this.contour = null; vertexes.setTo(splits); return result; }
[ "public", "boolean", "process", "(", "List", "<", "Point2D_I32", ">", "list", ",", "GrowQueue_I32", "vertexes", ")", "{", "this", ".", "contour", "=", "list", ";", "this", ".", "minimumSideLengthPixel", "=", "minimumSideLength", ".", "computeI", "(", "contour"...
Approximates the input list with a set of line segments @param list (Input) Ordered list of connected points. @param vertexes (Output) Indexes in the input list which are corners in the polyline @return true if it could fit a polygon to the points or false if not
[ "Approximates", "the", "input", "list", "with", "a", "set", "of", "line", "segments" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFit.java#L102-L113
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFit.java
SplitMergeLineFit.splitThresholdSq
protected double splitThresholdSq( Point2D_I32 a , Point2D_I32 b ) { return Math.max(2,a.distance2(b)* toleranceFractionSq); }
java
protected double splitThresholdSq( Point2D_I32 a , Point2D_I32 b ) { return Math.max(2,a.distance2(b)* toleranceFractionSq); }
[ "protected", "double", "splitThresholdSq", "(", "Point2D_I32", "a", ",", "Point2D_I32", "b", ")", "{", "return", "Math", ".", "max", "(", "2", ",", "a", ".", "distance2", "(", "b", ")", "*", "toleranceFractionSq", ")", ";", "}" ]
Computes the split threshold from the end point of two lines
[ "Computes", "the", "split", "threshold", "from", "the", "end", "point", "of", "two", "lines" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/splitmerge/SplitMergeLineFit.java#L120-L122
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/ImageInterleaved.java
ImageInterleaved.setTo
@SuppressWarnings({"SuspiciousSystemArraycopy"}) @Override public void setTo(T orig) { if (orig.width != width || orig.height != height || orig.numBands != numBands ) reshape(orig.width,orig.height,orig.numBands); if (!orig.isSubimage() && !isSubimage()) { System.arraycopy(orig._getData(), orig.startIndex, _getData(), startIndex, stride * height); } else { int indexSrc = orig.startIndex; int indexDst = startIndex; for (int y = 0; y < height; y++) { System.arraycopy(orig._getData(), indexSrc, _getData(), indexDst, width * numBands); indexSrc += orig.stride; indexDst += stride; } } }
java
@SuppressWarnings({"SuspiciousSystemArraycopy"}) @Override public void setTo(T orig) { if (orig.width != width || orig.height != height || orig.numBands != numBands ) reshape(orig.width,orig.height,orig.numBands); if (!orig.isSubimage() && !isSubimage()) { System.arraycopy(orig._getData(), orig.startIndex, _getData(), startIndex, stride * height); } else { int indexSrc = orig.startIndex; int indexDst = startIndex; for (int y = 0; y < height; y++) { System.arraycopy(orig._getData(), indexSrc, _getData(), indexDst, width * numBands); indexSrc += orig.stride; indexDst += stride; } } }
[ "@", "SuppressWarnings", "(", "{", "\"SuspiciousSystemArraycopy\"", "}", ")", "@", "Override", "public", "void", "setTo", "(", "T", "orig", ")", "{", "if", "(", "orig", ".", "width", "!=", "width", "||", "orig", ".", "height", "!=", "height", "||", "orig...
Sets this image equal to the specified image. Automatically resized to match the input image. @param orig The original image whose value is to be copied into this one
[ "Sets", "this", "image", "equal", "to", "the", "specified", "image", ".", "Automatically", "resized", "to", "match", "the", "input", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/ImageInterleaved.java#L143-L160
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/HessianBlobIntensity.java
HessianBlobIntensity.determinant
public static void determinant(GrayF32 featureIntensity , GrayF32 hessianXX, GrayF32 hessianYY , GrayF32 hessianXY ) { InputSanityCheck.checkSameShape(featureIntensity,hessianXX,hessianYY,hessianXY); ImplHessianBlobIntensity.determinant(featureIntensity,hessianXX,hessianYY,hessianXY); }
java
public static void determinant(GrayF32 featureIntensity , GrayF32 hessianXX, GrayF32 hessianYY , GrayF32 hessianXY ) { InputSanityCheck.checkSameShape(featureIntensity,hessianXX,hessianYY,hessianXY); ImplHessianBlobIntensity.determinant(featureIntensity,hessianXX,hessianYY,hessianXY); }
[ "public", "static", "void", "determinant", "(", "GrayF32", "featureIntensity", ",", "GrayF32", "hessianXX", ",", "GrayF32", "hessianYY", ",", "GrayF32", "hessianXY", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "featureIntensity", ",", "hessianXX", ",",...
Feature intensity using the Hessian matrix's determinant. @param featureIntensity Output feature intensity. Modified. @param hessianXX Second derivative along x-axis. Not modified. @param hessianYY Second derivative along y-axis. Not modified. @param hessianXY Second derivative along x-axis and y-axis. Not modified.
[ "Feature", "intensity", "using", "the", "Hessian", "matrix", "s", "determinant", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/HessianBlobIntensity.java#L69-L74
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/HessianBlobIntensity.java
HessianBlobIntensity.trace
public static void trace(GrayF32 featureIntensity , GrayF32 hessianXX, GrayF32 hessianYY ) { InputSanityCheck.checkSameShape(featureIntensity,hessianXX,hessianYY); ImplHessianBlobIntensity.trace(featureIntensity,hessianXX,hessianYY); }
java
public static void trace(GrayF32 featureIntensity , GrayF32 hessianXX, GrayF32 hessianYY ) { InputSanityCheck.checkSameShape(featureIntensity,hessianXX,hessianYY); ImplHessianBlobIntensity.trace(featureIntensity,hessianXX,hessianYY); }
[ "public", "static", "void", "trace", "(", "GrayF32", "featureIntensity", ",", "GrayF32", "hessianXX", ",", "GrayF32", "hessianYY", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "featureIntensity", ",", "hessianXX", ",", "hessianYY", ")", ";", "ImplHess...
Feature intensity using the trace of the Hessian matrix. This is also known as the Laplacian. @param featureIntensity Output feature intensity. Modified. @param hessianXX Second derivative along x-axis. Not modified. @param hessianYY Second derivative along y-axis. Not modified.
[ "Feature", "intensity", "using", "the", "trace", "of", "the", "Hessian", "matrix", ".", "This", "is", "also", "known", "as", "the", "Laplacian", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/intensity/HessianBlobIntensity.java#L83-L88
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/filter/binary/BinaryContourHelper.java
BinaryContourHelper.reshape
public void reshape(int width , int height ) { if( padded == null ) { binary.reshape(width, height); } else { binary.reshape(width + 2, height + 2); binary.subimage(1, 1, width + 1, height + 1, subimage); } }
java
public void reshape(int width , int height ) { if( padded == null ) { binary.reshape(width, height); } else { binary.reshape(width + 2, height + 2); binary.subimage(1, 1, width + 1, height + 1, subimage); } }
[ "public", "void", "reshape", "(", "int", "width", ",", "int", "height", ")", "{", "if", "(", "padded", "==", "null", ")", "{", "binary", ".", "reshape", "(", "width", ",", "height", ")", ";", "}", "else", "{", "binary", ".", "reshape", "(", "width"...
Reshapes data so that the un-padded image has the specified shape.
[ "Reshapes", "data", "so", "that", "the", "un", "-", "padded", "image", "has", "the", "specified", "shape", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/filter/binary/BinaryContourHelper.java#L49-L56
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/edge/EdgeIntensityPolygon.java
EdgeIntensityPolygon.computeEdge
public boolean computeEdge(Polygon2D_F64 polygon , boolean ccw ) { averageInside = 0; averageOutside = 0; double tangentSign = ccw ? 1 : -1; int totalSides = 0; for (int i = polygon.size()-1,j=0; j < polygon.size(); i=j,j++) { Point2D_F64 a = polygon.get(i); Point2D_F64 b = polygon.get(j); double dx = b.x-a.x; double dy = b.y-a.y; double t = Math.sqrt(dx*dx + dy*dy); dx /= t; dy /= t; // see if the side is too small if( t < 3*cornerOffset ) { offsetA.set(a); offsetB.set(b); } else { offsetA.x = a.x + cornerOffset * dx; offsetA.y = a.y + cornerOffset * dy; offsetB.x = b.x - cornerOffset * dx; offsetB.y = b.y - cornerOffset * dy; } double tanX = -dy*tangentDistance*tangentSign; double tanY = dx*tangentDistance*tangentSign; scorer.computeAverageDerivative(offsetA, offsetB, tanX,tanY); if( scorer.getSamplesInside() > 0 ) { totalSides++; averageInside += scorer.getAverageUp() / tangentDistance; averageOutside += scorer.getAverageDown() / tangentDistance; } } if( totalSides > 0 ) { averageInside /= totalSides; averageOutside /= totalSides; } else { averageInside = averageOutside = 0; return false; } return true; }
java
public boolean computeEdge(Polygon2D_F64 polygon , boolean ccw ) { averageInside = 0; averageOutside = 0; double tangentSign = ccw ? 1 : -1; int totalSides = 0; for (int i = polygon.size()-1,j=0; j < polygon.size(); i=j,j++) { Point2D_F64 a = polygon.get(i); Point2D_F64 b = polygon.get(j); double dx = b.x-a.x; double dy = b.y-a.y; double t = Math.sqrt(dx*dx + dy*dy); dx /= t; dy /= t; // see if the side is too small if( t < 3*cornerOffset ) { offsetA.set(a); offsetB.set(b); } else { offsetA.x = a.x + cornerOffset * dx; offsetA.y = a.y + cornerOffset * dy; offsetB.x = b.x - cornerOffset * dx; offsetB.y = b.y - cornerOffset * dy; } double tanX = -dy*tangentDistance*tangentSign; double tanY = dx*tangentDistance*tangentSign; scorer.computeAverageDerivative(offsetA, offsetB, tanX,tanY); if( scorer.getSamplesInside() > 0 ) { totalSides++; averageInside += scorer.getAverageUp() / tangentDistance; averageOutside += scorer.getAverageDown() / tangentDistance; } } if( totalSides > 0 ) { averageInside /= totalSides; averageOutside /= totalSides; } else { averageInside = averageOutside = 0; return false; } return true; }
[ "public", "boolean", "computeEdge", "(", "Polygon2D_F64", "polygon", ",", "boolean", "ccw", ")", "{", "averageInside", "=", "0", ";", "averageOutside", "=", "0", ";", "double", "tangentSign", "=", "ccw", "?", "1", ":", "-", "1", ";", "int", "totalSides", ...
Checks to see if its a valid polygon or a false positive by looking at edge intensity @param polygon The polygon being tested @param ccw True if the polygon is counter clockwise @return true if it could compute the edge intensity, otherwise false
[ "Checks", "to", "see", "if", "its", "a", "valid", "polygon", "or", "a", "false", "positive", "by", "looking", "at", "edge", "intensity" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/edge/EdgeIntensityPolygon.java#L95-L146
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/edge/EdgeIntensityPolygon.java
EdgeIntensityPolygon.checkIntensity
public boolean checkIntensity( boolean insideDark , double threshold ) { if( insideDark ) return averageOutside-averageInside >= threshold; else return averageInside-averageOutside >= threshold; }
java
public boolean checkIntensity( boolean insideDark , double threshold ) { if( insideDark ) return averageOutside-averageInside >= threshold; else return averageInside-averageOutside >= threshold; }
[ "public", "boolean", "checkIntensity", "(", "boolean", "insideDark", ",", "double", "threshold", ")", "{", "if", "(", "insideDark", ")", "return", "averageOutside", "-", "averageInside", ">=", "threshold", ";", "else", "return", "averageInside", "-", "averageOutsi...
Checks the edge intensity against a threshold. dark: outside-inside &ge; threshold light: inside-outside &ge; threshold @param insideDark is the inside of the polygon supposed to be dark or light? @param threshold threshold for average difference @return true if the edge intensity is significant enough
[ "Checks", "the", "edge", "intensity", "against", "a", "threshold", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/edge/EdgeIntensityPolygon.java#L158-L163
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationGuessAndCheckFocus.java
SelfCalibrationGuessAndCheckFocus.setCamera
public void setCamera( double skew , double cx , double cy , int width , int height ) { // Define normalization matrix // center points, remove skew, scale coordinates double d = Math.sqrt(width*width + height*height); V.zero(); V.set(0,0,d/2); V.set(0,1,skew); V.set(0,2,cx); V.set(1,1,d/2); V.set(1,2,cy); V.set(2,2,1); CommonOps_DDRM.invert(V,Vinv); }
java
public void setCamera( double skew , double cx , double cy , int width , int height ) { // Define normalization matrix // center points, remove skew, scale coordinates double d = Math.sqrt(width*width + height*height); V.zero(); V.set(0,0,d/2); V.set(0,1,skew); V.set(0,2,cx); V.set(1,1,d/2); V.set(1,2,cy); V.set(2,2,1); CommonOps_DDRM.invert(V,Vinv); }
[ "public", "void", "setCamera", "(", "double", "skew", ",", "double", "cx", ",", "double", "cy", ",", "int", "width", ",", "int", "height", ")", "{", "// Define normalization matrix", "// center points, remove skew, scale coordinates", "double", "d", "=", "Math", "...
Specifies known portions of camera intrinsic parameters @param skew skew @param cx image center x @param cy image center y @param width Image width @param height Image height
[ "Specifies", "known", "portions", "of", "camera", "intrinsic", "parameters" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationGuessAndCheckFocus.java#L134-L145
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationGuessAndCheckFocus.java
SelfCalibrationGuessAndCheckFocus.setSampling
public void setSampling( double min , double max , int total ) { this.sampleMin = min; this.sampleMax = max; this.numSamples = total; this.scores = new double[numSamples]; }
java
public void setSampling( double min , double max , int total ) { this.sampleMin = min; this.sampleMax = max; this.numSamples = total; this.scores = new double[numSamples]; }
[ "public", "void", "setSampling", "(", "double", "min", ",", "double", "max", ",", "int", "total", ")", "{", "this", ".", "sampleMin", "=", "min", ";", "this", ".", "sampleMax", "=", "max", ";", "this", ".", "numSamples", "=", "total", ";", "this", "....
Specifies how focal lengths are sampled on a log scale. Remember 1.0 = nominal length @param min min value. 0.3 is default @param max max value. 3.0 is default @param total Number of sample points. 50 is default
[ "Specifies", "how", "focal", "lengths", "are", "sampled", "on", "a", "log", "scale", ".", "Remember", "1", ".", "0", "=", "nominal", "length" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationGuessAndCheckFocus.java#L154-L159
train
lessthanoptimal/BoofCV
main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationGuessAndCheckFocus.java
SelfCalibrationGuessAndCheckFocus.computeRectifyH
boolean computeRectifyH( double f1 , double f2 , DMatrixRMaj P2, DMatrixRMaj H ) { estimatePlaneInf.setCamera1(f1,f1,0,0,0); estimatePlaneInf.setCamera2(f2,f2,0,0,0); if( !estimatePlaneInf.estimatePlaneAtInfinity(P2,planeInf) ) return false; // TODO add a cost for distance from nominal and scale other cost by focal length fx for each view // RefineDualQuadraticConstraint refine = new RefineDualQuadraticConstraint(); // refine.setZeroSkew(true); // refine.setAspectRatio(true); // refine.setZeroPrinciplePoint(true); // refine.setKnownIntrinsic1(true); // refine.setFixedCamera(false); // // CameraPinhole intrinsic = new CameraPinhole(f1,f1,0,0,0,0,0); // if( !refine.refine(normalizedP.toList(),intrinsic,planeInf)) // return false; K1.zero(); K1.set(0,0,f1); K1.set(1,1,f1); K1.set(2,2,1); MultiViewOps.createProjectiveToMetric(K1,planeInf.x,planeInf.y,planeInf.z,1,H); return true; }
java
boolean computeRectifyH( double f1 , double f2 , DMatrixRMaj P2, DMatrixRMaj H ) { estimatePlaneInf.setCamera1(f1,f1,0,0,0); estimatePlaneInf.setCamera2(f2,f2,0,0,0); if( !estimatePlaneInf.estimatePlaneAtInfinity(P2,planeInf) ) return false; // TODO add a cost for distance from nominal and scale other cost by focal length fx for each view // RefineDualQuadraticConstraint refine = new RefineDualQuadraticConstraint(); // refine.setZeroSkew(true); // refine.setAspectRatio(true); // refine.setZeroPrinciplePoint(true); // refine.setKnownIntrinsic1(true); // refine.setFixedCamera(false); // // CameraPinhole intrinsic = new CameraPinhole(f1,f1,0,0,0,0,0); // if( !refine.refine(normalizedP.toList(),intrinsic,planeInf)) // return false; K1.zero(); K1.set(0,0,f1); K1.set(1,1,f1); K1.set(2,2,1); MultiViewOps.createProjectiveToMetric(K1,planeInf.x,planeInf.y,planeInf.z,1,H); return true; }
[ "boolean", "computeRectifyH", "(", "double", "f1", ",", "double", "f2", ",", "DMatrixRMaj", "P2", ",", "DMatrixRMaj", "H", ")", "{", "estimatePlaneInf", ".", "setCamera1", "(", "f1", ",", "f1", ",", "0", ",", "0", ",", "0", ")", ";", "estimatePlaneInf", ...
Given the focal lengths for the first two views compute homography H @param f1 view 1 focal length @param f2 view 2 focal length @param P2 projective camera matrix for view 2 @param H (Output) homography @return true if successful
[ "Given", "the", "focal", "lengths", "for", "the", "first", "two", "views", "compute", "homography", "H" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationGuessAndCheckFocus.java#L302-L329
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.findLine
protected static List<NodeInfo> findLine(NodeInfo seed, NodeInfo next, int clusterSize, List<NodeInfo> line, boolean ccw ) { if( next == null ) return null; if( line == null ) line = new ArrayList<>(); else line.clear(); next.marked = true; double anglePrev = direction(next, seed); double prevDist = next.ellipse.center.distance(seed.ellipse.center); line.add( seed ); line.add( next ); NodeInfo previous = seed; for( int i = 0; i < clusterSize+1; i++) { // find the child of next which is within tolerance and closest to it double bestScore = Double.MAX_VALUE; double bestDistance = Double.MAX_VALUE; double bestAngle = Double.NaN; double closestDistance = Double.MAX_VALUE; NodeInfo best = null; double previousLength = next.ellipse.center.distance(previous.ellipse.center); // System.out.println("---- line connecting "+i); for (int j = 0; j < next.edges.size(); j++) { double angle = next.edges.get(j).angle; NodeInfo c = next.edges.get(j).target; if( c.marked ) continue; double candidateLength = next.ellipse.center.distance(c.ellipse.center); double ratioLengths = previousLength/candidateLength; double ratioSize = previous.ellipse.a/c.ellipse.a; if( ratioLengths > 1 ) { ratioLengths = 1.0/ratioLengths; ratioSize = 1.0/ratioSize; } if( Math.abs(ratioLengths-ratioSize) > 0.4 ) continue; double angleDist = ccw ? UtilAngle.distanceCCW(anglePrev,angle) : UtilAngle.distanceCW(anglePrev,angle); if( angleDist <= Math.PI+MAX_LINE_ANGLE_CHANGE ) { double d = c.ellipse.center.distance(next.ellipse.center); double score = d/prevDist+angleDist; if( score < bestScore ) { // System.out.println(" ratios: "+ratioLengths+" "+ratioSize); bestDistance = d; bestScore = score; bestAngle = angle; best = c; } closestDistance = Math.min(d,closestDistance); } } if( best == null || bestDistance > closestDistance*2.0) { return line; } else { best.marked = true; prevDist = bestDistance; line.add(best); anglePrev = UtilAngle.bound(bestAngle+Math.PI); previous = next; next = best; } } // if( verbose ) { // System.out.println("Stuck in a loop? Maximum line length exceeded"); // } return null; }
java
protected static List<NodeInfo> findLine(NodeInfo seed, NodeInfo next, int clusterSize, List<NodeInfo> line, boolean ccw ) { if( next == null ) return null; if( line == null ) line = new ArrayList<>(); else line.clear(); next.marked = true; double anglePrev = direction(next, seed); double prevDist = next.ellipse.center.distance(seed.ellipse.center); line.add( seed ); line.add( next ); NodeInfo previous = seed; for( int i = 0; i < clusterSize+1; i++) { // find the child of next which is within tolerance and closest to it double bestScore = Double.MAX_VALUE; double bestDistance = Double.MAX_VALUE; double bestAngle = Double.NaN; double closestDistance = Double.MAX_VALUE; NodeInfo best = null; double previousLength = next.ellipse.center.distance(previous.ellipse.center); // System.out.println("---- line connecting "+i); for (int j = 0; j < next.edges.size(); j++) { double angle = next.edges.get(j).angle; NodeInfo c = next.edges.get(j).target; if( c.marked ) continue; double candidateLength = next.ellipse.center.distance(c.ellipse.center); double ratioLengths = previousLength/candidateLength; double ratioSize = previous.ellipse.a/c.ellipse.a; if( ratioLengths > 1 ) { ratioLengths = 1.0/ratioLengths; ratioSize = 1.0/ratioSize; } if( Math.abs(ratioLengths-ratioSize) > 0.4 ) continue; double angleDist = ccw ? UtilAngle.distanceCCW(anglePrev,angle) : UtilAngle.distanceCW(anglePrev,angle); if( angleDist <= Math.PI+MAX_LINE_ANGLE_CHANGE ) { double d = c.ellipse.center.distance(next.ellipse.center); double score = d/prevDist+angleDist; if( score < bestScore ) { // System.out.println(" ratios: "+ratioLengths+" "+ratioSize); bestDistance = d; bestScore = score; bestAngle = angle; best = c; } closestDistance = Math.min(d,closestDistance); } } if( best == null || bestDistance > closestDistance*2.0) { return line; } else { best.marked = true; prevDist = bestDistance; line.add(best); anglePrev = UtilAngle.bound(bestAngle+Math.PI); previous = next; next = best; } } // if( verbose ) { // System.out.println("Stuck in a loop? Maximum line length exceeded"); // } return null; }
[ "protected", "static", "List", "<", "NodeInfo", ">", "findLine", "(", "NodeInfo", "seed", ",", "NodeInfo", "next", ",", "int", "clusterSize", ",", "List", "<", "NodeInfo", ">", "line", ",", "boolean", "ccw", ")", "{", "if", "(", "next", "==", "null", "...
Finds all the nodes which form an approximate line @param seed First ellipse @param next Second ellipse, specified direction of line relative to seed @param line @return All the nodes along the line
[ "Finds", "all", "the", "nodes", "which", "form", "an", "approximate", "line" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L88-L168
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.findClosestEdge
protected static NodeInfo findClosestEdge( NodeInfo n , Point2D_F64 p ) { double bestDistance = Double.MAX_VALUE; NodeInfo best = null; for (int i = 0; i < n.edges.size(); i++) { Edge e = n.edges.get(i); if( e.target.marked ) continue; double d = e.target.ellipse.center.distance2(p); if( d < bestDistance ) { bestDistance = d; best = e.target; } } return best; }
java
protected static NodeInfo findClosestEdge( NodeInfo n , Point2D_F64 p ) { double bestDistance = Double.MAX_VALUE; NodeInfo best = null; for (int i = 0; i < n.edges.size(); i++) { Edge e = n.edges.get(i); if( e.target.marked ) continue; double d = e.target.ellipse.center.distance2(p); if( d < bestDistance ) { bestDistance = d; best = e.target; } } return best; }
[ "protected", "static", "NodeInfo", "findClosestEdge", "(", "NodeInfo", "n", ",", "Point2D_F64", "p", ")", "{", "double", "bestDistance", "=", "Double", ".", "MAX_VALUE", ";", "NodeInfo", "best", "=", "null", ";", "for", "(", "int", "i", "=", "0", ";", "i...
Finds the node which is an edge of 'n' that is closest to point 'p'
[ "Finds", "the", "node", "which", "is", "an", "edge", "of", "n", "that", "is", "closest", "to", "point", "p" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L217-L234
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.checkDuplicates
boolean checkDuplicates(List<List<NodeInfo>> grid ) { for (int i = 0; i < listInfo.size; i++) { listInfo.get(i).marked = false; } for (int i = 0; i < grid.size(); i++) { List<NodeInfo> list = grid.get(i); for (int j = 0; j < list.size(); j++) { NodeInfo n = list.get(j); if( n.marked ) return true; n.marked = true; } } return false; }
java
boolean checkDuplicates(List<List<NodeInfo>> grid ) { for (int i = 0; i < listInfo.size; i++) { listInfo.get(i).marked = false; } for (int i = 0; i < grid.size(); i++) { List<NodeInfo> list = grid.get(i); for (int j = 0; j < list.size(); j++) { NodeInfo n = list.get(j); if( n.marked ) return true; n.marked = true; } } return false; }
[ "boolean", "checkDuplicates", "(", "List", "<", "List", "<", "NodeInfo", ">", ">", "grid", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listInfo", ".", "size", ";", "i", "++", ")", "{", "listInfo", ".", "get", "(", "i", ")", ".",...
Checks to see if any node is used more than once
[ "Checks", "to", "see", "if", "any", "node", "is", "used", "more", "than", "once" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L239-L255
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.addEdgesToInfo
void addEdgesToInfo(List<Node> cluster) { for (int i = 0; i < cluster.size(); i++) { Node n = cluster.get(i); NodeInfo infoA = listInfo.get(i); EllipseRotated_F64 a = infoA.ellipse; // create the edges and order them based on their direction for (int j = 0; j < n.connections.size(); j++) { NodeInfo infoB = listInfo.get( indexOf(cluster, n.connections.get(j))); EllipseRotated_F64 b = infoB.ellipse; Edge edge = infoA.edges.grow(); edge.target = infoB; edge.angle = Math.atan2( b.center.y - a.center.y , b.center.x - a.center.x ); } sorter.sort(infoA.edges.data, infoA.edges.size); } }
java
void addEdgesToInfo(List<Node> cluster) { for (int i = 0; i < cluster.size(); i++) { Node n = cluster.get(i); NodeInfo infoA = listInfo.get(i); EllipseRotated_F64 a = infoA.ellipse; // create the edges and order them based on their direction for (int j = 0; j < n.connections.size(); j++) { NodeInfo infoB = listInfo.get( indexOf(cluster, n.connections.get(j))); EllipseRotated_F64 b = infoB.ellipse; Edge edge = infoA.edges.grow(); edge.target = infoB; edge.angle = Math.atan2( b.center.y - a.center.y , b.center.x - a.center.x ); } sorter.sort(infoA.edges.data, infoA.edges.size); } }
[ "void", "addEdgesToInfo", "(", "List", "<", "Node", ">", "cluster", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "cluster", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Node", "n", "=", "cluster", ".", "get", "(", "i", ")",...
Adds edges to node info and computes their orientation
[ "Adds", "edges", "to", "node", "info", "and", "computes", "their", "orientation" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L288-L308
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.pruneNearlyIdenticalAngles
void pruneNearlyIdenticalAngles() { for (int i = 0; i < listInfo.size(); i++) { NodeInfo infoN = listInfo.get(i); for (int j = 0; j < infoN.edges.size(); ) { int k = (j+1)%infoN.edges.size; double angularDiff = UtilAngle.dist(infoN.edges.get(j).angle,infoN.edges.get(k).angle); if( angularDiff < UtilAngle.radian(5)) { NodeInfo infoJ = infoN.edges.get(j).target; NodeInfo infoK = infoN.edges.get(k).target; double distJ = infoN.ellipse.center.distance(infoJ.ellipse.center); double distK = infoN.ellipse.center.distance(infoK.ellipse.center); if( distJ < distK ) { infoN.edges.remove(k); } else { infoN.edges.remove(j); } } else { j++; } } } }
java
void pruneNearlyIdenticalAngles() { for (int i = 0; i < listInfo.size(); i++) { NodeInfo infoN = listInfo.get(i); for (int j = 0; j < infoN.edges.size(); ) { int k = (j+1)%infoN.edges.size; double angularDiff = UtilAngle.dist(infoN.edges.get(j).angle,infoN.edges.get(k).angle); if( angularDiff < UtilAngle.radian(5)) { NodeInfo infoJ = infoN.edges.get(j).target; NodeInfo infoK = infoN.edges.get(k).target; double distJ = infoN.ellipse.center.distance(infoJ.ellipse.center); double distK = infoN.ellipse.center.distance(infoK.ellipse.center); if( distJ < distK ) { infoN.edges.remove(k); } else { infoN.edges.remove(j); } } else { j++; } } } }
[ "void", "pruneNearlyIdenticalAngles", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listInfo", ".", "size", "(", ")", ";", "i", "++", ")", "{", "NodeInfo", "infoN", "=", "listInfo", ".", "get", "(", "i", ")", ";", "for", "(", ...
If there is a nearly perfect line a node farther down the line can come before. This just selects the closest
[ "If", "there", "is", "a", "nearly", "perfect", "line", "a", "node", "farther", "down", "the", "line", "can", "come", "before", ".", "This", "just", "selects", "the", "closest" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L313-L339
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.findLargestAnglesForAllNodes
void findLargestAnglesForAllNodes() { for (int i = 0; i < listInfo.size(); i++) { NodeInfo info = listInfo.get(i); if( info.edges.size < 2 ) continue; for (int k = 0, j = info.edges.size-1; k < info.edges.size; j=k,k++) { double angleA = info.edges.get(j).angle; double angleB = info.edges.get(k).angle; double distance = UtilAngle.distanceCCW(angleA,angleB); if( distance > info.angleBetween ) { info.angleBetween = distance; info.left = info.edges.get(j).target; info.right = info.edges.get(k).target; } } } }
java
void findLargestAnglesForAllNodes() { for (int i = 0; i < listInfo.size(); i++) { NodeInfo info = listInfo.get(i); if( info.edges.size < 2 ) continue; for (int k = 0, j = info.edges.size-1; k < info.edges.size; j=k,k++) { double angleA = info.edges.get(j).angle; double angleB = info.edges.get(k).angle; double distance = UtilAngle.distanceCCW(angleA,angleB); if( distance > info.angleBetween ) { info.angleBetween = distance; info.left = info.edges.get(j).target; info.right = info.edges.get(k).target; } } } }
[ "void", "findLargestAnglesForAllNodes", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "listInfo", ".", "size", "(", ")", ";", "i", "++", ")", "{", "NodeInfo", "info", "=", "listInfo", ".", "get", "(", "i", ")", ";", "if", "(", ...
Finds the two edges with the greatest angular distance between them.
[ "Finds", "the", "two", "edges", "with", "the", "greatest", "angular", "distance", "between", "them", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L344-L364
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.findContour
boolean findContour( boolean mustHaveInner ) { // find the node with the largest angleBetween NodeInfo seed = listInfo.get(0); for (int i = 1; i < listInfo.size(); i++) { NodeInfo info = listInfo.get(i); if( info.angleBetween > seed.angleBetween ) { seed = info; } } // trace around the contour contour.reset(); contour.add( seed ); seed.contour = true; NodeInfo prev = seed; NodeInfo current = seed.right; while( current != null && current != seed && contour.size() < listInfo.size() ) { if( prev != current.left ) return false; contour.add( current ); current.contour = true; prev = current; current = current.right; } // fail if it is too small or was cycling return !(contour.size < 4 || (mustHaveInner && contour.size >= listInfo.size())); }
java
boolean findContour( boolean mustHaveInner ) { // find the node with the largest angleBetween NodeInfo seed = listInfo.get(0); for (int i = 1; i < listInfo.size(); i++) { NodeInfo info = listInfo.get(i); if( info.angleBetween > seed.angleBetween ) { seed = info; } } // trace around the contour contour.reset(); contour.add( seed ); seed.contour = true; NodeInfo prev = seed; NodeInfo current = seed.right; while( current != null && current != seed && contour.size() < listInfo.size() ) { if( prev != current.left ) return false; contour.add( current ); current.contour = true; prev = current; current = current.right; } // fail if it is too small or was cycling return !(contour.size < 4 || (mustHaveInner && contour.size >= listInfo.size())); }
[ "boolean", "findContour", "(", "boolean", "mustHaveInner", ")", "{", "// find the node with the largest angleBetween", "NodeInfo", "seed", "=", "listInfo", ".", "get", "(", "0", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "listInfo", ".", "siz...
Finds nodes in the outside of the grid. First the node in the grid with the largest 'angleBetween' is selected as a seed. It is assumed at this node must be on the contour. Then the graph is traversed in CCW direction until a loop is formed. @return true if valid and false if invalid
[ "Finds", "nodes", "in", "the", "outside", "of", "the", "grid", ".", "First", "the", "node", "in", "the", "grid", "with", "the", "largest", "angleBetween", "is", "selected", "as", "a", "seed", ".", "It", "is", "assumed", "at", "this", "node", "must", "b...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L373-L401
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.indexOf
public static int indexOf(List<Node> list , int value ) { for (int i = 0; i < list.size(); i++) { if( list.get(i).which == value ) return i; } return -1; }
java
public static int indexOf(List<Node> list , int value ) { for (int i = 0; i < list.size(); i++) { if( list.get(i).which == value ) return i; } return -1; }
[ "public", "static", "int", "indexOf", "(", "List", "<", "Node", ">", "list", ",", "int", "value", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "list", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "list", ".", "g...
Finds the node with the index of 'value'
[ "Finds", "the", "node", "with", "the", "index", "of", "value" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L406-L414
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java
EllipseClustersIntoGrid.selectSeedCorner
NodeInfo selectSeedCorner() { NodeInfo best = null; double bestAngle = 0; for (int i = 0; i < contour.size; i++) { NodeInfo info = contour.get(i); if( info.angleBetween > bestAngle ) { bestAngle = info.angleBetween; best = info; } } best.marked = true; return best; }
java
NodeInfo selectSeedCorner() { NodeInfo best = null; double bestAngle = 0; for (int i = 0; i < contour.size; i++) { NodeInfo info = contour.get(i); if( info.angleBetween > bestAngle ) { bestAngle = info.angleBetween; best = info; } } best.marked = true; return best; }
[ "NodeInfo", "selectSeedCorner", "(", ")", "{", "NodeInfo", "best", "=", "null", ";", "double", "bestAngle", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "contour", ".", "size", ";", "i", "++", ")", "{", "NodeInfo", "info", "=", ...
Pick the node in the contour with the largest angle. Distortion tends to make the acute angle smaller. Without distortion it will be 270 degrees.
[ "Pick", "the", "node", "in", "the", "contour", "with", "the", "largest", "angle", ".", "Distortion", "tends", "to", "make", "the", "acute", "angle", "smaller", ".", "Without", "distortion", "it", "will", "be", "270", "degrees", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoGrid.java#L420-L435
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/depth/VisualDepthOps.java
VisualDepthOps.depthTo3D
public static void depthTo3D(CameraPinholeBrown param , GrayU16 depth , FastQueue<Point3D_F64> cloud ) { cloud.reset(); Point2Transform2_F64 p2n = LensDistortionFactory.narrow(param).undistort_F64(true,false); Point2D_F64 n = new Point2D_F64(); for( int y = 0; y < depth.height; y++ ) { int index = depth.startIndex + y*depth.stride; for( int x = 0; x < depth.width; x++ ) { int mm = depth.data[index++] & 0xFFFF; // skip pixels with no depth information if( mm == 0 ) continue; // this could all be precomputed to speed it up p2n.compute(x,y,n); Point3D_F64 p = cloud.grow(); p.z = mm; p.x = n.x*p.z; p.y = n.y*p.z; } } }
java
public static void depthTo3D(CameraPinholeBrown param , GrayU16 depth , FastQueue<Point3D_F64> cloud ) { cloud.reset(); Point2Transform2_F64 p2n = LensDistortionFactory.narrow(param).undistort_F64(true,false); Point2D_F64 n = new Point2D_F64(); for( int y = 0; y < depth.height; y++ ) { int index = depth.startIndex + y*depth.stride; for( int x = 0; x < depth.width; x++ ) { int mm = depth.data[index++] & 0xFFFF; // skip pixels with no depth information if( mm == 0 ) continue; // this could all be precomputed to speed it up p2n.compute(x,y,n); Point3D_F64 p = cloud.grow(); p.z = mm; p.x = n.x*p.z; p.y = n.y*p.z; } } }
[ "public", "static", "void", "depthTo3D", "(", "CameraPinholeBrown", "param", ",", "GrayU16", "depth", ",", "FastQueue", "<", "Point3D_F64", ">", "cloud", ")", "{", "cloud", ".", "reset", "(", ")", ";", "Point2Transform2_F64", "p2n", "=", "LensDistortionFactory",...
Creates a point cloud from a depth image. @param param Intrinsic camera parameters for depth image @param depth depth image. each value is in millimeters. @param cloud Output point cloud
[ "Creates", "a", "point", "cloud", "from", "a", "depth", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/depth/VisualDepthOps.java#L45-L70
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/depth/VisualDepthOps.java
VisualDepthOps.depthTo3D
public static void depthTo3D(CameraPinholeBrown param , Planar<GrayU8> rgb , GrayU16 depth , FastQueue<Point3D_F64> cloud , FastQueueArray_I32 cloudColor ) { cloud.reset(); cloudColor.reset(); RemoveBrownPtoN_F64 p2n = new RemoveBrownPtoN_F64(); p2n.setK(param.fx,param.fy,param.skew,param.cx,param.cy).setDistortion(param.radial,param.t1,param.t2); Point2D_F64 n = new Point2D_F64(); GrayU8 colorR = rgb.getBand(0); GrayU8 colorG = rgb.getBand(1); GrayU8 colorB = rgb.getBand(2); for( int y = 0; y < depth.height; y++ ) { int index = depth.startIndex + y*depth.stride; for( int x = 0; x < depth.width; x++ ) { int mm = depth.data[index++] & 0xFFFF; // skip pixels with no depth information if( mm == 0 ) continue; // this could all be precomputed to speed it up p2n.compute(x,y,n); Point3D_F64 p = cloud.grow(); p.z = mm; p.x = n.x*p.z; p.y = n.y*p.z; int color[] = cloudColor.grow(); color[0] = colorR.unsafe_get(x,y); color[1] = colorG.unsafe_get(x,y); color[2] = colorB.unsafe_get(x,y); } } }
java
public static void depthTo3D(CameraPinholeBrown param , Planar<GrayU8> rgb , GrayU16 depth , FastQueue<Point3D_F64> cloud , FastQueueArray_I32 cloudColor ) { cloud.reset(); cloudColor.reset(); RemoveBrownPtoN_F64 p2n = new RemoveBrownPtoN_F64(); p2n.setK(param.fx,param.fy,param.skew,param.cx,param.cy).setDistortion(param.radial,param.t1,param.t2); Point2D_F64 n = new Point2D_F64(); GrayU8 colorR = rgb.getBand(0); GrayU8 colorG = rgb.getBand(1); GrayU8 colorB = rgb.getBand(2); for( int y = 0; y < depth.height; y++ ) { int index = depth.startIndex + y*depth.stride; for( int x = 0; x < depth.width; x++ ) { int mm = depth.data[index++] & 0xFFFF; // skip pixels with no depth information if( mm == 0 ) continue; // this could all be precomputed to speed it up p2n.compute(x,y,n); Point3D_F64 p = cloud.grow(); p.z = mm; p.x = n.x*p.z; p.y = n.y*p.z; int color[] = cloudColor.grow(); color[0] = colorR.unsafe_get(x,y); color[1] = colorG.unsafe_get(x,y); color[2] = colorB.unsafe_get(x,y); } } }
[ "public", "static", "void", "depthTo3D", "(", "CameraPinholeBrown", "param", ",", "Planar", "<", "GrayU8", ">", "rgb", ",", "GrayU16", "depth", ",", "FastQueue", "<", "Point3D_F64", ">", "cloud", ",", "FastQueueArray_I32", "cloudColor", ")", "{", "cloud", ".",...
Creates a point cloud from a depth image and saves the color information. The depth and color images are assumed to be aligned. @param param Intrinsic camera parameters for depth image @param depth depth image. each value is in millimeters. @param rgb Color image that's aligned to the depth. @param cloud Output point cloud @param cloudColor Output color for each point in the cloud
[ "Creates", "a", "point", "cloud", "from", "a", "depth", "image", "and", "saves", "the", "color", "information", ".", "The", "depth", "and", "color", "images", "are", "assumed", "to", "be", "aligned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/depth/VisualDepthOps.java#L81-L119
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java
MinimizeEnergyPrune.prune
public boolean prune(List<Point2D_I32> contour, GrowQueue_I32 input, GrowQueue_I32 output) { this.contour = contour; output.setTo(input); removeDuplicates(output); // can't prune a corner and it will still be a polygon if( output.size() <= 3 ) return false; computeSegmentEnergy(output); double total = 0; for (int i = 0; i < output.size(); i++) { total += energySegment[i]; } FitLinesToContour fit = new FitLinesToContour(); fit.setContour(contour); boolean modified = false; while( output.size() > 3 ) { double bestEnergy = total; boolean betterFound = false; bestCorners.reset(); for (int i = 0; i < output.size(); i++) { // add all but the one which was removed workCorners1.reset(); for (int j = 0; j < output.size(); j++) { if( i != j ) { workCorners1.add(output.get(j)); } } // just in case it created a duplicate removeDuplicates(workCorners1); if( workCorners1.size() > 3 ) { // when looking at these anchors remember that they are relative to the new list without // the removed corner and that the two adjacent corners need to be optimized int anchor0 = CircularIndex.addOffset(i, -2, workCorners1.size()); int anchor1 = CircularIndex.addOffset(i, 1, workCorners1.size()); // optimize the two adjacent corners to the removed one if (fit.fitAnchored(anchor0, anchor1, workCorners1, workCorners2)) { // TODO this isn't taking advantage of previously computed line segment energy is it? // maybe a small speed up can be had by doing that double score = 0; for (int j = 0, k = workCorners2.size() - 1; j < workCorners2.size(); k = j, j++) { score += computeSegmentEnergy(workCorners2, k, j); } if (score < bestEnergy) { betterFound = true; bestEnergy = score; bestCorners.reset(); bestCorners.addAll(workCorners2); } } } } if ( betterFound ) { modified = true; total = bestEnergy; output.setTo(bestCorners); } else { break; } } return modified; }
java
public boolean prune(List<Point2D_I32> contour, GrowQueue_I32 input, GrowQueue_I32 output) { this.contour = contour; output.setTo(input); removeDuplicates(output); // can't prune a corner and it will still be a polygon if( output.size() <= 3 ) return false; computeSegmentEnergy(output); double total = 0; for (int i = 0; i < output.size(); i++) { total += energySegment[i]; } FitLinesToContour fit = new FitLinesToContour(); fit.setContour(contour); boolean modified = false; while( output.size() > 3 ) { double bestEnergy = total; boolean betterFound = false; bestCorners.reset(); for (int i = 0; i < output.size(); i++) { // add all but the one which was removed workCorners1.reset(); for (int j = 0; j < output.size(); j++) { if( i != j ) { workCorners1.add(output.get(j)); } } // just in case it created a duplicate removeDuplicates(workCorners1); if( workCorners1.size() > 3 ) { // when looking at these anchors remember that they are relative to the new list without // the removed corner and that the two adjacent corners need to be optimized int anchor0 = CircularIndex.addOffset(i, -2, workCorners1.size()); int anchor1 = CircularIndex.addOffset(i, 1, workCorners1.size()); // optimize the two adjacent corners to the removed one if (fit.fitAnchored(anchor0, anchor1, workCorners1, workCorners2)) { // TODO this isn't taking advantage of previously computed line segment energy is it? // maybe a small speed up can be had by doing that double score = 0; for (int j = 0, k = workCorners2.size() - 1; j < workCorners2.size(); k = j, j++) { score += computeSegmentEnergy(workCorners2, k, j); } if (score < bestEnergy) { betterFound = true; bestEnergy = score; bestCorners.reset(); bestCorners.addAll(workCorners2); } } } } if ( betterFound ) { modified = true; total = bestEnergy; output.setTo(bestCorners); } else { break; } } return modified; }
[ "public", "boolean", "prune", "(", "List", "<", "Point2D_I32", ">", "contour", ",", "GrowQueue_I32", "input", ",", "GrowQueue_I32", "output", ")", "{", "this", ".", "contour", "=", "contour", ";", "output", ".", "setTo", "(", "input", ")", ";", "removeDupl...
Given a contour and initial set of corners compute a new set of corner indexes @param contour List of points in the shape's contour @param input Initial set of corners @param output Pruned set of corners @return true if one or more corners were pruned, false if nothing changed
[ "Given", "a", "contour", "and", "initial", "set", "of", "corners", "compute", "a", "new", "set", "of", "corner", "indexes" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java#L70-L144
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java
MinimizeEnergyPrune.removeDuplicates
void removeDuplicates( GrowQueue_I32 corners ) { // remove duplicates for (int i = 0; i < corners.size(); i++) { Point2D_I32 a = contour.get(corners.get(i)); // start from the top so that removing a corner doesn't mess with the for loop for (int j = corners.size()-1; j > i; j--) { Point2D_I32 b = contour.get(corners.get(j)); if( a.x == b.x && a.y == b.y ) { // this is still ok if j == 0 because it wrapped around. 'i' will now be > size corners.remove(j); } } } }
java
void removeDuplicates( GrowQueue_I32 corners ) { // remove duplicates for (int i = 0; i < corners.size(); i++) { Point2D_I32 a = contour.get(corners.get(i)); // start from the top so that removing a corner doesn't mess with the for loop for (int j = corners.size()-1; j > i; j--) { Point2D_I32 b = contour.get(corners.get(j)); if( a.x == b.x && a.y == b.y ) { // this is still ok if j == 0 because it wrapped around. 'i' will now be > size corners.remove(j); } } } }
[ "void", "removeDuplicates", "(", "GrowQueue_I32", "corners", ")", "{", "// remove duplicates", "for", "(", "int", "i", "=", "0", ";", "i", "<", "corners", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Point2D_I32", "a", "=", "contour", ".", "get", ...
Look for two corners which point to the same point and removes one of them from the corner list
[ "Look", "for", "two", "corners", "which", "point", "to", "the", "same", "point", "and", "removes", "one", "of", "them", "from", "the", "corner", "list" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java#L149-L164
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java
MinimizeEnergyPrune.computeSegmentEnergy
void computeSegmentEnergy( GrowQueue_I32 corners ) { if( energySegment.length < corners.size() ) { energySegment = new double[ corners.size() ]; } for (int i = 0,j=corners.size()-1; i < corners.size(); j=i,i++) { energySegment[j] = computeSegmentEnergy(corners, j, i); } }
java
void computeSegmentEnergy( GrowQueue_I32 corners ) { if( energySegment.length < corners.size() ) { energySegment = new double[ corners.size() ]; } for (int i = 0,j=corners.size()-1; i < corners.size(); j=i,i++) { energySegment[j] = computeSegmentEnergy(corners, j, i); } }
[ "void", "computeSegmentEnergy", "(", "GrowQueue_I32", "corners", ")", "{", "if", "(", "energySegment", ".", "length", "<", "corners", ".", "size", "(", ")", ")", "{", "energySegment", "=", "new", "double", "[", "corners", ".", "size", "(", ")", "]", ";",...
Computes the energy of each segment individually
[ "Computes", "the", "energy", "of", "each", "segment", "individually" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java#L169-L177
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java
MinimizeEnergyPrune.energyRemoveCorner
protected double energyRemoveCorner( int removed , GrowQueue_I32 corners ) { double total = 0; int cornerA = CircularIndex.addOffset(removed, -1 , corners.size()); int cornerB = CircularIndex.addOffset(removed, 1 , corners.size()); total += computeSegmentEnergy(corners, cornerA, cornerB); if( cornerA > cornerB ) { for (int i = cornerB; i < cornerA; i++) total += energySegment[i]; } else { for (int i = 0; i < cornerA; i++) { total += energySegment[i]; } for (int i = cornerB; i < corners.size(); i++) { total += energySegment[i]; } } return total; }
java
protected double energyRemoveCorner( int removed , GrowQueue_I32 corners ) { double total = 0; int cornerA = CircularIndex.addOffset(removed, -1 , corners.size()); int cornerB = CircularIndex.addOffset(removed, 1 , corners.size()); total += computeSegmentEnergy(corners, cornerA, cornerB); if( cornerA > cornerB ) { for (int i = cornerB; i < cornerA; i++) total += energySegment[i]; } else { for (int i = 0; i < cornerA; i++) { total += energySegment[i]; } for (int i = cornerB; i < corners.size(); i++) { total += energySegment[i]; } } return total; }
[ "protected", "double", "energyRemoveCorner", "(", "int", "removed", ",", "GrowQueue_I32", "corners", ")", "{", "double", "total", "=", "0", ";", "int", "cornerA", "=", "CircularIndex", ".", "addOffset", "(", "removed", ",", "-", "1", ",", "corners", ".", "...
Returns the total energy after removing a corner @param removed index of the corner that is being removed @param corners list of corner indexes
[ "Returns", "the", "total", "energy", "after", "removing", "a", "corner" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java#L184-L205
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java
MinimizeEnergyPrune.computeSegmentEnergy
protected double computeSegmentEnergy(GrowQueue_I32 corners, int cornerA, int cornerB) { int indexA = corners.get(cornerA); int indexB = corners.get(cornerB); if( indexA == indexB ) { return 100000.0; } Point2D_I32 a = contour.get(indexA); Point2D_I32 b = contour.get(indexB); line.p.x = a.x; line.p.y = a.y; line.slope.set(b.x-a.x,b.y-a.y); double total = 0; int length = circularDistance(indexA,indexB); for (int k = 1; k < length; k++) { Point2D_I32 c = getContour(indexA + 1 + k); point.set(c.x, c.y); total += Distance2D_F64.distanceSq(line, point); } return (total+ splitPenalty)/a.distance2(b); }
java
protected double computeSegmentEnergy(GrowQueue_I32 corners, int cornerA, int cornerB) { int indexA = corners.get(cornerA); int indexB = corners.get(cornerB); if( indexA == indexB ) { return 100000.0; } Point2D_I32 a = contour.get(indexA); Point2D_I32 b = contour.get(indexB); line.p.x = a.x; line.p.y = a.y; line.slope.set(b.x-a.x,b.y-a.y); double total = 0; int length = circularDistance(indexA,indexB); for (int k = 1; k < length; k++) { Point2D_I32 c = getContour(indexA + 1 + k); point.set(c.x, c.y); total += Distance2D_F64.distanceSq(line, point); } return (total+ splitPenalty)/a.distance2(b); }
[ "protected", "double", "computeSegmentEnergy", "(", "GrowQueue_I32", "corners", ",", "int", "cornerA", ",", "int", "cornerB", ")", "{", "int", "indexA", "=", "corners", ".", "get", "(", "cornerA", ")", ";", "int", "indexB", "=", "corners", ".", "get", "(",...
Computes the energy for a segment defined by the two corner indexes
[ "Computes", "the", "energy", "for", "a", "segment", "defined", "by", "the", "two", "corner", "indexes" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/MinimizeEnergyPrune.java#L210-L236
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java
MergeSmallRegions.process
public void process( T image, GrayS32 pixelToRegion , GrowQueue_I32 regionMemberCount, FastQueue<float[]> regionColor ) { stopRequested = false; // iterate until no more regions need to be merged together while( !stopRequested ) { // Update the color of each region regionColor.resize(regionMemberCount.size); computeColor.process(image, pixelToRegion, regionMemberCount, regionColor); initializeMerge(regionMemberCount.size); // Create a list of regions which are to be pruned if( !setupPruneList(regionMemberCount) ) break; // Scan the image and create a list of regions which the pruned regions connect to findAdjacentRegions(pixelToRegion); // Select the closest match to merge into for( int i = 0; i < pruneGraph.size; i++ ) { selectMerge(i,regionColor); } // Do the usual merge stuff performMerge(pixelToRegion,regionMemberCount); } }
java
public void process( T image, GrayS32 pixelToRegion , GrowQueue_I32 regionMemberCount, FastQueue<float[]> regionColor ) { stopRequested = false; // iterate until no more regions need to be merged together while( !stopRequested ) { // Update the color of each region regionColor.resize(regionMemberCount.size); computeColor.process(image, pixelToRegion, regionMemberCount, regionColor); initializeMerge(regionMemberCount.size); // Create a list of regions which are to be pruned if( !setupPruneList(regionMemberCount) ) break; // Scan the image and create a list of regions which the pruned regions connect to findAdjacentRegions(pixelToRegion); // Select the closest match to merge into for( int i = 0; i < pruneGraph.size; i++ ) { selectMerge(i,regionColor); } // Do the usual merge stuff performMerge(pixelToRegion,regionMemberCount); } }
[ "public", "void", "process", "(", "T", "image", ",", "GrayS32", "pixelToRegion", ",", "GrowQueue_I32", "regionMemberCount", ",", "FastQueue", "<", "float", "[", "]", ">", "regionColor", ")", "{", "stopRequested", "=", "false", ";", "// iterate until no more region...
Merges together smaller regions. Segmented image, region member count, and region color are all updated. @param image Input image. Used to compute color of each region @param pixelToRegion (input/output) Segmented image with the ID of each region. Modified. @param regionMemberCount (input/output) Number of members in each region Modified. @param regionColor (Output) Storage for colors of each region. Will contains the color of each region on output.
[ "Merges", "together", "smaller", "regions", ".", "Segmented", "image", "region", "member", "count", "and", "region", "color", "are", "all", "updated", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java#L100-L130
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java
MergeSmallRegions.setupPruneList
protected boolean setupPruneList(GrowQueue_I32 regionMemberCount) { segmentPruneFlag.resize(regionMemberCount.size); pruneGraph.reset(); segmentToPruneID.resize(regionMemberCount.size); for( int i = 0; i < regionMemberCount.size; i++ ) { if( regionMemberCount.get(i) < minimumSize ) { segmentToPruneID.set(i, pruneGraph.size()); Node n = pruneGraph.grow(); n.init(i); segmentPruneFlag.set(i, true); } else { segmentPruneFlag.set(i, false); } } return pruneGraph.size() != 0; }
java
protected boolean setupPruneList(GrowQueue_I32 regionMemberCount) { segmentPruneFlag.resize(regionMemberCount.size); pruneGraph.reset(); segmentToPruneID.resize(regionMemberCount.size); for( int i = 0; i < regionMemberCount.size; i++ ) { if( regionMemberCount.get(i) < minimumSize ) { segmentToPruneID.set(i, pruneGraph.size()); Node n = pruneGraph.grow(); n.init(i); segmentPruneFlag.set(i, true); } else { segmentPruneFlag.set(i, false); } } return pruneGraph.size() != 0; }
[ "protected", "boolean", "setupPruneList", "(", "GrowQueue_I32", "regionMemberCount", ")", "{", "segmentPruneFlag", ".", "resize", "(", "regionMemberCount", ".", "size", ")", ";", "pruneGraph", ".", "reset", "(", ")", ";", "segmentToPruneID", ".", "resize", "(", ...
Identifies which regions are to be pruned based on their member counts. Then sets up data structures for graph and converting segment ID to prune ID. @return true If elements need to be pruned and false if not.
[ "Identifies", "which", "regions", "are", "to", "be", "pruned", "based", "on", "their", "member", "counts", ".", "Then", "sets", "up", "data", "structures", "for", "graph", "and", "converting", "segment", "ID", "to", "prune", "ID", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java#L138-L154
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java
MergeSmallRegions.findAdjacentRegions
protected void findAdjacentRegions(GrayS32 pixelToRegion) { // -------- Do the inner pixels first if( connect.length == 4 ) adjacentInner4(pixelToRegion); else if( connect.length == 8 ) { adjacentInner8(pixelToRegion); } adjacentBorder(pixelToRegion); }
java
protected void findAdjacentRegions(GrayS32 pixelToRegion) { // -------- Do the inner pixels first if( connect.length == 4 ) adjacentInner4(pixelToRegion); else if( connect.length == 8 ) { adjacentInner8(pixelToRegion); } adjacentBorder(pixelToRegion); }
[ "protected", "void", "findAdjacentRegions", "(", "GrayS32", "pixelToRegion", ")", "{", "// -------- Do the inner pixels first", "if", "(", "connect", ".", "length", "==", "4", ")", "adjacentInner4", "(", "pixelToRegion", ")", ";", "else", "if", "(", "connect", "."...
Go through each pixel in the image and examine its neighbors according to a 4-connect rule. If one of the pixels is in a region that is to be pruned mark them as neighbors. The image is traversed such that the number of comparisons is minimized.
[ "Go", "through", "each", "pixel", "in", "the", "image", "and", "examine", "its", "neighbors", "according", "to", "a", "4", "-", "connect", "rule", ".", "If", "one", "of", "the", "pixels", "is", "in", "a", "region", "that", "is", "to", "be", "pruned", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java#L161-L170
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java
MergeSmallRegions.selectMerge
protected void selectMerge( int pruneId , FastQueue<float[]> regionColor ) { // Grab information on the region which is being pruned Node n = pruneGraph.get(pruneId); float[] targetColor = regionColor.get(n.segment); // segment ID and distance away from the most similar neighbor int bestId = -1; float bestDistance = Float.MAX_VALUE; // Examine all the segments it is connected to to see which one it is most similar too for( int i = 0; i < n.edges.size; i++ ) { int segment = n.edges.get(i); float[] neighborColor = regionColor.get(segment); float d = SegmentMeanShiftSearch.distanceSq(targetColor, neighborColor); if( d < bestDistance ) { bestDistance = d; bestId = segment; } } if( bestId == -1 ) throw new RuntimeException("No neighbors? Something went really wrong."); markMerge(n.segment, bestId); }
java
protected void selectMerge( int pruneId , FastQueue<float[]> regionColor ) { // Grab information on the region which is being pruned Node n = pruneGraph.get(pruneId); float[] targetColor = regionColor.get(n.segment); // segment ID and distance away from the most similar neighbor int bestId = -1; float bestDistance = Float.MAX_VALUE; // Examine all the segments it is connected to to see which one it is most similar too for( int i = 0; i < n.edges.size; i++ ) { int segment = n.edges.get(i); float[] neighborColor = regionColor.get(segment); float d = SegmentMeanShiftSearch.distanceSq(targetColor, neighborColor); if( d < bestDistance ) { bestDistance = d; bestId = segment; } } if( bestId == -1 ) throw new RuntimeException("No neighbors? Something went really wrong."); markMerge(n.segment, bestId); }
[ "protected", "void", "selectMerge", "(", "int", "pruneId", ",", "FastQueue", "<", "float", "[", "]", ">", "regionColor", ")", "{", "// Grab information on the region which is being pruned", "Node", "n", "=", "pruneGraph", ".", "get", "(", "pruneId", ")", ";", "f...
Examine edges for the specified node and select node which it is the best match for it to merge with @param pruneId The prune Id of the segment which is to be merged into another segment @param regionColor List of region colors
[ "Examine", "edges", "for", "the", "specified", "node", "and", "select", "node", "which", "it", "is", "the", "best", "match", "for", "it", "to", "merge", "with" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeSmallRegions.java#L343-L368
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/EasyGeneralFeatureDetector.java
EasyGeneralFeatureDetector.declareDerivativeImages
private void declareDerivativeImages(ImageGradient<T, D> gradient, ImageHessian<D> hessian, Class<D> derivType) { if( gradient != null || hessian != null ) { derivX = GeneralizedImageOps.createSingleBand(derivType, 1, 1); derivY = GeneralizedImageOps.createSingleBand(derivType,1,1); } if( hessian != null ) { derivXX = GeneralizedImageOps.createSingleBand(derivType,1,1); derivYY = GeneralizedImageOps.createSingleBand(derivType,1,1); derivXY = GeneralizedImageOps.createSingleBand(derivType,1,1); } }
java
private void declareDerivativeImages(ImageGradient<T, D> gradient, ImageHessian<D> hessian, Class<D> derivType) { if( gradient != null || hessian != null ) { derivX = GeneralizedImageOps.createSingleBand(derivType, 1, 1); derivY = GeneralizedImageOps.createSingleBand(derivType,1,1); } if( hessian != null ) { derivXX = GeneralizedImageOps.createSingleBand(derivType,1,1); derivYY = GeneralizedImageOps.createSingleBand(derivType,1,1); derivXY = GeneralizedImageOps.createSingleBand(derivType,1,1); } }
[ "private", "void", "declareDerivativeImages", "(", "ImageGradient", "<", "T", ",", "D", ">", "gradient", ",", "ImageHessian", "<", "D", ">", "hessian", ",", "Class", "<", "D", ">", "derivType", ")", "{", "if", "(", "gradient", "!=", "null", "||", "hessia...
Declare storage for image derivatives as needed
[ "Declare", "storage", "for", "image", "derivatives", "as", "needed" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/EasyGeneralFeatureDetector.java#L91-L101
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/EasyGeneralFeatureDetector.java
EasyGeneralFeatureDetector.detect
public void detect(T input, QueueCorner exclude ) { initializeDerivatives(input); if (detector.getRequiresGradient() || detector.getRequiresHessian()) gradient.process(input, derivX, derivY); if (detector.getRequiresHessian()) hessian.process(derivX, derivY, derivXX, derivYY, derivXY); detector.setExcludeMaximum(exclude); detector.process(input, derivX, derivY, derivXX, derivYY, derivXY); }
java
public void detect(T input, QueueCorner exclude ) { initializeDerivatives(input); if (detector.getRequiresGradient() || detector.getRequiresHessian()) gradient.process(input, derivX, derivY); if (detector.getRequiresHessian()) hessian.process(derivX, derivY, derivXX, derivYY, derivXY); detector.setExcludeMaximum(exclude); detector.process(input, derivX, derivY, derivXX, derivYY, derivXY); }
[ "public", "void", "detect", "(", "T", "input", ",", "QueueCorner", "exclude", ")", "{", "initializeDerivatives", "(", "input", ")", ";", "if", "(", "detector", ".", "getRequiresGradient", "(", ")", "||", "detector", ".", "getRequiresHessian", "(", ")", ")", ...
Detect features inside the image. Excluding points in the exclude list. @param input Image being processed. @param exclude List of points that should not be returned.
[ "Detect", "features", "inside", "the", "image", ".", "Excluding", "points", "in", "the", "exclude", "list", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/EasyGeneralFeatureDetector.java#L109-L120
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/EasyGeneralFeatureDetector.java
EasyGeneralFeatureDetector.initializeDerivatives
private void initializeDerivatives(T input) { // reshape derivatives if the input image has changed size if (detector.getRequiresGradient() || detector.getRequiresHessian()) { derivX.reshape(input.width, input.height); derivY.reshape(input.width, input.height); } if (detector.getRequiresHessian()) { derivXX.reshape(input.width, input.height); derivYY.reshape(input.width, input.height); derivXY.reshape(input.width, input.height); } }
java
private void initializeDerivatives(T input) { // reshape derivatives if the input image has changed size if (detector.getRequiresGradient() || detector.getRequiresHessian()) { derivX.reshape(input.width, input.height); derivY.reshape(input.width, input.height); } if (detector.getRequiresHessian()) { derivXX.reshape(input.width, input.height); derivYY.reshape(input.width, input.height); derivXY.reshape(input.width, input.height); } }
[ "private", "void", "initializeDerivatives", "(", "T", "input", ")", "{", "// reshape derivatives if the input image has changed size", "if", "(", "detector", ".", "getRequiresGradient", "(", ")", "||", "detector", ".", "getRequiresHessian", "(", ")", ")", "{", "derivX...
Reshape derivative images to match the input image
[ "Reshape", "derivative", "images", "to", "match", "the", "input", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/interest/EasyGeneralFeatureDetector.java#L125-L136
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java
SquareGridTools.checkFlip
public boolean checkFlip( SquareGrid grid ) { if( grid.columns == 1 || grid.rows == 1 ) return false; Point2D_F64 a = grid.get(0,0).center; Point2D_F64 b = grid.get(0,grid.columns-1).center; Point2D_F64 c = grid.get(grid.rows-1,0).center; double x0 = b.x-a.x; double y0 = b.y-a.y; double x1 = c.x-a.x; double y1 = c.y-a.y; double z = x0 * y1 - y0 * x1; return z < 0; }
java
public boolean checkFlip( SquareGrid grid ) { if( grid.columns == 1 || grid.rows == 1 ) return false; Point2D_F64 a = grid.get(0,0).center; Point2D_F64 b = grid.get(0,grid.columns-1).center; Point2D_F64 c = grid.get(grid.rows-1,0).center; double x0 = b.x-a.x; double y0 = b.y-a.y; double x1 = c.x-a.x; double y1 = c.y-a.y; double z = x0 * y1 - y0 * x1; return z < 0; }
[ "public", "boolean", "checkFlip", "(", "SquareGrid", "grid", ")", "{", "if", "(", "grid", ".", "columns", "==", "1", "||", "grid", ".", "rows", "==", "1", ")", "return", "false", ";", "Point2D_F64", "a", "=", "grid", ".", "get", "(", "0", ",", "0",...
Checks to see if it needs to be flipped. Flipping is required if X and Y axis in 2D grid are not CCW.
[ "Checks", "to", "see", "if", "it", "needs", "to", "be", "flipped", ".", "Flipping", "is", "required", "if", "X", "and", "Y", "axis", "in", "2D", "grid", "are", "not", "CCW", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java#L95-L112
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java
SquareGridTools.orderNodeGrid
protected void orderNodeGrid(SquareGrid grid, int row, int col) { SquareNode node = grid.get(row,col); if(grid.rows==1 && grid.columns==1 ) { for (int i = 0; i < 4; i++) { ordered[i] = node.square.get(i); } } else if( grid.columns==1 ) { if (row == grid.rows - 1) { orderNode(node, grid.get(row - 1, col), false); rotateTwiceOrdered(); } else { orderNode(node, grid.get(row + 1, col), false); } } else { if( col == grid.columns-1) { orderNode(node, grid.get(row, col-1), true); rotateTwiceOrdered(); } else { orderNode(node, grid.get(row, col+1), true); } } }
java
protected void orderNodeGrid(SquareGrid grid, int row, int col) { SquareNode node = grid.get(row,col); if(grid.rows==1 && grid.columns==1 ) { for (int i = 0; i < 4; i++) { ordered[i] = node.square.get(i); } } else if( grid.columns==1 ) { if (row == grid.rows - 1) { orderNode(node, grid.get(row - 1, col), false); rotateTwiceOrdered(); } else { orderNode(node, grid.get(row + 1, col), false); } } else { if( col == grid.columns-1) { orderNode(node, grid.get(row, col-1), true); rotateTwiceOrdered(); } else { orderNode(node, grid.get(row, col+1), true); } } }
[ "protected", "void", "orderNodeGrid", "(", "SquareGrid", "grid", ",", "int", "row", ",", "int", "col", ")", "{", "SquareNode", "node", "=", "grid", ".", "get", "(", "row", ",", "col", ")", ";", "if", "(", "grid", ".", "rows", "==", "1", "&&", "grid...
Given the grid coordinate, order the corners for the node at that location. Takes in handles situations where there are no neighbors.
[ "Given", "the", "grid", "coordinate", "order", "the", "corners", "for", "the", "node", "at", "that", "location", ".", "Takes", "in", "handles", "situations", "where", "there", "are", "no", "neighbors", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java#L223-L245
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java
SquareGridTools.rotateTwiceOrdered
private void rotateTwiceOrdered() { Point2D_F64 a = ordered[0]; Point2D_F64 b = ordered[1]; Point2D_F64 c = ordered[2]; Point2D_F64 d = ordered[3]; ordered[0] = c; ordered[1] = d; ordered[2] = a; ordered[3] = b; }
java
private void rotateTwiceOrdered() { Point2D_F64 a = ordered[0]; Point2D_F64 b = ordered[1]; Point2D_F64 c = ordered[2]; Point2D_F64 d = ordered[3]; ordered[0] = c; ordered[1] = d; ordered[2] = a; ordered[3] = b; }
[ "private", "void", "rotateTwiceOrdered", "(", ")", "{", "Point2D_F64", "a", "=", "ordered", "[", "0", "]", ";", "Point2D_F64", "b", "=", "ordered", "[", "1", "]", ";", "Point2D_F64", "c", "=", "ordered", "[", "2", "]", ";", "Point2D_F64", "d", "=", "...
Reorders the list by the equivalent of two rotations
[ "Reorders", "the", "list", "by", "the", "equivalent", "of", "two", "rotations" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java#L250-L260
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java
SquareGridTools.orderNode
protected void orderNode(SquareNode target, SquareNode node, boolean pointingX) { int index0 = findIntersection(target,node); int index1 = (index0+1)%4; int index2 = (index0+2)%4; int index3 = (index0+3)%4; if( index0 < 0 ) throw new RuntimeException("Couldn't find intersection. Probable bug"); lineCenters.a = target.center; lineCenters.b = node.center; UtilLine2D_F64.convert(lineCenters,general); Polygon2D_F64 poly = target.square; if( pointingX ) { if (sign(general, poly.get(index0)) > 0) { ordered[1] = poly.get(index1); ordered[2] = poly.get(index0); } else { ordered[1] = poly.get(index0); ordered[2] = poly.get(index1); } if (sign(general, poly.get(index2)) > 0) { ordered[3] = poly.get(index2); ordered[0] = poly.get(index3); } else { ordered[3] = poly.get(index3); ordered[0] = poly.get(index2); } } else { if (sign(general, poly.get(index0)) > 0) { ordered[2] = poly.get(index1); ordered[3] = poly.get(index0); } else { ordered[2] = poly.get(index0); ordered[3] = poly.get(index1); } if (sign(general, poly.get(index2)) > 0) { ordered[0] = poly.get(index2); ordered[1] = poly.get(index3); } else { ordered[0] = poly.get(index3); ordered[1] = poly.get(index2); } } }
java
protected void orderNode(SquareNode target, SquareNode node, boolean pointingX) { int index0 = findIntersection(target,node); int index1 = (index0+1)%4; int index2 = (index0+2)%4; int index3 = (index0+3)%4; if( index0 < 0 ) throw new RuntimeException("Couldn't find intersection. Probable bug"); lineCenters.a = target.center; lineCenters.b = node.center; UtilLine2D_F64.convert(lineCenters,general); Polygon2D_F64 poly = target.square; if( pointingX ) { if (sign(general, poly.get(index0)) > 0) { ordered[1] = poly.get(index1); ordered[2] = poly.get(index0); } else { ordered[1] = poly.get(index0); ordered[2] = poly.get(index1); } if (sign(general, poly.get(index2)) > 0) { ordered[3] = poly.get(index2); ordered[0] = poly.get(index3); } else { ordered[3] = poly.get(index3); ordered[0] = poly.get(index2); } } else { if (sign(general, poly.get(index0)) > 0) { ordered[2] = poly.get(index1); ordered[3] = poly.get(index0); } else { ordered[2] = poly.get(index0); ordered[3] = poly.get(index1); } if (sign(general, poly.get(index2)) > 0) { ordered[0] = poly.get(index2); ordered[1] = poly.get(index3); } else { ordered[0] = poly.get(index3); ordered[1] = poly.get(index2); } } }
[ "protected", "void", "orderNode", "(", "SquareNode", "target", ",", "SquareNode", "node", ",", "boolean", "pointingX", ")", "{", "int", "index0", "=", "findIntersection", "(", "target", ",", "node", ")", ";", "int", "index1", "=", "(", "index0", "+", "1", ...
Fills the ordered list with the corners in target node in canonical order. @param pointingX true if 'node' is pointing along the x-axis from target. false for point along y-axis
[ "Fills", "the", "ordered", "list", "with", "the", "corners", "in", "target", "node", "in", "canonical", "order", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java#L274-L321
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java
SquareGridTools.findIntersection
protected int findIntersection( SquareNode target , SquareNode node ) { lineCenters.a = target.center; lineCenters.b = node.center; for (int i = 0; i < 4; i++) { int j = (i+1)%4; lineSide.a = target.square.get(i); lineSide.b = target.square.get(j); if(Intersection2D_F64.intersection(lineCenters,lineSide,dummy) != null ) { return i; } } return -1; }
java
protected int findIntersection( SquareNode target , SquareNode node ) { lineCenters.a = target.center; lineCenters.b = node.center; for (int i = 0; i < 4; i++) { int j = (i+1)%4; lineSide.a = target.square.get(i); lineSide.b = target.square.get(j); if(Intersection2D_F64.intersection(lineCenters,lineSide,dummy) != null ) { return i; } } return -1; }
[ "protected", "int", "findIntersection", "(", "SquareNode", "target", ",", "SquareNode", "node", ")", "{", "lineCenters", ".", "a", "=", "target", ".", "center", ";", "lineCenters", ".", "b", "=", "node", ".", "center", ";", "for", "(", "int", "i", "=", ...
Finds the side which intersects the line segment from the center of target to center of node
[ "Finds", "the", "side", "which", "intersects", "the", "line", "segment", "from", "the", "center", "of", "target", "to", "center", "of", "node" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java#L326-L341
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java
SquareGridTools.orderSquareCorners
public boolean orderSquareCorners( SquareGrid grid ) { // the first pass interleaves every other row for (int row = 0; row < grid.rows; row++) { for (int col = 0; col < grid.columns; col++) { orderNodeGrid(grid, row, col); Polygon2D_F64 square = grid.get(row,col).square; for (int i = 0; i < 4; i++) { square.vertexes.data[i] = ordered[i]; } } } return true; }
java
public boolean orderSquareCorners( SquareGrid grid ) { // the first pass interleaves every other row for (int row = 0; row < grid.rows; row++) { for (int col = 0; col < grid.columns; col++) { orderNodeGrid(grid, row, col); Polygon2D_F64 square = grid.get(row,col).square; for (int i = 0; i < 4; i++) { square.vertexes.data[i] = ordered[i]; } } } return true; }
[ "public", "boolean", "orderSquareCorners", "(", "SquareGrid", "grid", ")", "{", "// the first pass interleaves every other row", "for", "(", "int", "row", "=", "0", ";", "row", "<", "grid", ".", "rows", ";", "row", "++", ")", "{", "for", "(", "int", "col", ...
Adjust the corners in the square's polygon so that they are aligned along the grids overall length @return true if valid grid or false if not
[ "Adjust", "the", "corners", "in", "the", "square", "s", "polygon", "so", "that", "they", "are", "aligned", "along", "the", "grids", "overall", "length" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareGridTools.java#L350-L366
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleTemplateMatching.java
ExampleTemplateMatching.findMatches
private static List<Match> findMatches(GrayF32 image, GrayF32 template, GrayF32 mask, int expectedMatches) { // create template matcher. TemplateMatching<GrayF32> matcher = FactoryTemplateMatching.createMatcher(TemplateScoreType.SUM_DIFF_SQ, GrayF32.class); // Find the points which match the template the best matcher.setImage(image); matcher.setTemplate(template, mask,expectedMatches); matcher.process(); return matcher.getResults().toList(); }
java
private static List<Match> findMatches(GrayF32 image, GrayF32 template, GrayF32 mask, int expectedMatches) { // create template matcher. TemplateMatching<GrayF32> matcher = FactoryTemplateMatching.createMatcher(TemplateScoreType.SUM_DIFF_SQ, GrayF32.class); // Find the points which match the template the best matcher.setImage(image); matcher.setTemplate(template, mask,expectedMatches); matcher.process(); return matcher.getResults().toList(); }
[ "private", "static", "List", "<", "Match", ">", "findMatches", "(", "GrayF32", "image", ",", "GrayF32", "template", ",", "GrayF32", "mask", ",", "int", "expectedMatches", ")", "{", "// create template matcher.", "TemplateMatching", "<", "GrayF32", ">", "matcher", ...
Demonstrates how to search for matches of a template inside an image @param image Image being searched @param template Template being looked for @param mask Mask which determines the weight of each template pixel in the match score @param expectedMatches Number of expected matches it hopes to find @return List of match location and scores
[ "Demonstrates", "how", "to", "search", "for", "matches", "of", "a", "template", "inside", "an", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleTemplateMatching.java#L57-L70
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleTemplateMatching.java
ExampleTemplateMatching.showMatchIntensity
public static void showMatchIntensity(GrayF32 image, GrayF32 template, GrayF32 mask) { // create algorithm for computing intensity image TemplateMatchingIntensity<GrayF32> matchIntensity = FactoryTemplateMatching.createIntensity(TemplateScoreType.SUM_DIFF_SQ, GrayF32.class); // apply the template to the image matchIntensity.setInputImage(image); matchIntensity.process(template, mask); // get the results GrayF32 intensity = matchIntensity.getIntensity(); // adjust the intensity image so that white indicates a good match and black a poor match // the scale is kept linear to highlight how ambiguous the solution is float min = ImageStatistics.min(intensity); float max = ImageStatistics.max(intensity); float range = max - min; PixelMath.plus(intensity, -min, intensity); PixelMath.divide(intensity, range, intensity); PixelMath.multiply(intensity, 255.0f, intensity); BufferedImage output = new BufferedImage(image.width, image.height, BufferedImage.TYPE_INT_BGR); VisualizeImageData.grayMagnitude(intensity, output, -1); ShowImages.showWindow(output, "Match Intensity", true); }
java
public static void showMatchIntensity(GrayF32 image, GrayF32 template, GrayF32 mask) { // create algorithm for computing intensity image TemplateMatchingIntensity<GrayF32> matchIntensity = FactoryTemplateMatching.createIntensity(TemplateScoreType.SUM_DIFF_SQ, GrayF32.class); // apply the template to the image matchIntensity.setInputImage(image); matchIntensity.process(template, mask); // get the results GrayF32 intensity = matchIntensity.getIntensity(); // adjust the intensity image so that white indicates a good match and black a poor match // the scale is kept linear to highlight how ambiguous the solution is float min = ImageStatistics.min(intensity); float max = ImageStatistics.max(intensity); float range = max - min; PixelMath.plus(intensity, -min, intensity); PixelMath.divide(intensity, range, intensity); PixelMath.multiply(intensity, 255.0f, intensity); BufferedImage output = new BufferedImage(image.width, image.height, BufferedImage.TYPE_INT_BGR); VisualizeImageData.grayMagnitude(intensity, output, -1); ShowImages.showWindow(output, "Match Intensity", true); }
[ "public", "static", "void", "showMatchIntensity", "(", "GrayF32", "image", ",", "GrayF32", "template", ",", "GrayF32", "mask", ")", "{", "// create algorithm for computing intensity image", "TemplateMatchingIntensity", "<", "GrayF32", ">", "matchIntensity", "=", "FactoryT...
Computes the template match intensity image and displays the results. Brighter intensity indicates a better match to the template.
[ "Computes", "the", "template", "match", "intensity", "image", "and", "displays", "the", "results", ".", "Brighter", "intensity", "indicates", "a", "better", "match", "to", "the", "template", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleTemplateMatching.java#L76-L101
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleTemplateMatching.java
ExampleTemplateMatching.drawRectangles
private static void drawRectangles(Graphics2D g2, GrayF32 image, GrayF32 template, GrayF32 mask, int expectedMatches) { List<Match> found = findMatches(image, template, mask, expectedMatches); int r = 2; int w = template.width + 2 * r; int h = template.height + 2 * r; for (Match m : found) { System.out.println("Match "+m.x+" "+m.y+" score "+m.score); // this demonstrates how to filter out false positives // the meaning of score will depend on the template technique // if( m.score < -1000 ) // This line is commented out for demonstration purposes // continue; // the return point is the template's top left corner int x0 = m.x - r; int y0 = m.y - r; int x1 = x0 + w; int y1 = y0 + h; g2.drawLine(x0, y0, x1, y0); g2.drawLine(x1, y0, x1, y1); g2.drawLine(x1, y1, x0, y1); g2.drawLine(x0, y1, x0, y0); } }
java
private static void drawRectangles(Graphics2D g2, GrayF32 image, GrayF32 template, GrayF32 mask, int expectedMatches) { List<Match> found = findMatches(image, template, mask, expectedMatches); int r = 2; int w = template.width + 2 * r; int h = template.height + 2 * r; for (Match m : found) { System.out.println("Match "+m.x+" "+m.y+" score "+m.score); // this demonstrates how to filter out false positives // the meaning of score will depend on the template technique // if( m.score < -1000 ) // This line is commented out for demonstration purposes // continue; // the return point is the template's top left corner int x0 = m.x - r; int y0 = m.y - r; int x1 = x0 + w; int y1 = y0 + h; g2.drawLine(x0, y0, x1, y0); g2.drawLine(x1, y0, x1, y1); g2.drawLine(x1, y1, x0, y1); g2.drawLine(x0, y1, x0, y0); } }
[ "private", "static", "void", "drawRectangles", "(", "Graphics2D", "g2", ",", "GrayF32", "image", ",", "GrayF32", "template", ",", "GrayF32", "mask", ",", "int", "expectedMatches", ")", "{", "List", "<", "Match", ">", "found", "=", "findMatches", "(", "image"...
Helper function will is finds matches and displays the results as colored rectangles
[ "Helper", "function", "will", "is", "finds", "matches", "and", "displays", "the", "results", "as", "colored", "rectangles" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleTemplateMatching.java#L138-L165
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/SquareBase_to_FiducialDetector.java
SquareBase_to_FiducialDetector.getCenter
@Override public void getCenter(int which, Point2D_F64 location) { Quadrilateral_F64 q = alg.getFound().get(which).distortedPixels; // compute intersection in undistorted pixels so that the intersection is the true // geometric center of the square. Since distorted pixels are being used this will only be approximate UtilLine2D_F64.convert(q.a, q.c,line02); UtilLine2D_F64.convert(q.b, q.d,line13); Intersection2D_F64.intersection(line02,line13,location); }
java
@Override public void getCenter(int which, Point2D_F64 location) { Quadrilateral_F64 q = alg.getFound().get(which).distortedPixels; // compute intersection in undistorted pixels so that the intersection is the true // geometric center of the square. Since distorted pixels are being used this will only be approximate UtilLine2D_F64.convert(q.a, q.c,line02); UtilLine2D_F64.convert(q.b, q.d,line13); Intersection2D_F64.intersection(line02,line13,location); }
[ "@", "Override", "public", "void", "getCenter", "(", "int", "which", ",", "Point2D_F64", "location", ")", "{", "Quadrilateral_F64", "q", "=", "alg", ".", "getFound", "(", ")", ".", "get", "(", "which", ")", ".", "distortedPixels", ";", "// compute intersecti...
Return the intersection of two lines defined by opposing corners. This should also be the geometric center @param which Fiducial's index @param location (output) Storage for the transform. modified.
[ "Return", "the", "intersection", "of", "two", "lines", "defined", "by", "opposing", "corners", ".", "This", "should", "also", "be", "the", "geometric", "center" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/SquareBase_to_FiducialDetector.java#L91-L101
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareEdge.java
SquareEdge.destination
public <T extends SquareNode>T destination(SquareNode src) { if( a == src ) return (T)b; else if( b == src ) return (T)a; else throw new IllegalArgumentException("BUG! src is not a or b"); }
java
public <T extends SquareNode>T destination(SquareNode src) { if( a == src ) return (T)b; else if( b == src ) return (T)a; else throw new IllegalArgumentException("BUG! src is not a or b"); }
[ "public", "<", "T", "extends", "SquareNode", ">", "T", "destination", "(", "SquareNode", "src", ")", "{", "if", "(", "a", "==", "src", ")", "return", "(", "T", ")", "b", ";", "else", "if", "(", "b", "==", "src", ")", "return", "(", "T", ")", "a...
Returns the destination node.
[ "Returns", "the", "destination", "node", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareEdge.java#L51-L58
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/sfm/ExampleVisualOdometryDepth.java
ExampleVisualOdometryDepth.inlierPercent
public static String inlierPercent(VisualOdometry alg) { if( !(alg instanceof AccessPointTracks3D)) return ""; AccessPointTracks3D access = (AccessPointTracks3D)alg; int count = 0; int N = access.getAllTracks().size(); for( int i = 0; i < N; i++ ) { if( access.isInlier(i) ) count++; } return String.format("%%%5.3f", 100.0 * count / N); }
java
public static String inlierPercent(VisualOdometry alg) { if( !(alg instanceof AccessPointTracks3D)) return ""; AccessPointTracks3D access = (AccessPointTracks3D)alg; int count = 0; int N = access.getAllTracks().size(); for( int i = 0; i < N; i++ ) { if( access.isInlier(i) ) count++; } return String.format("%%%5.3f", 100.0 * count / N); }
[ "public", "static", "String", "inlierPercent", "(", "VisualOdometry", "alg", ")", "{", "if", "(", "!", "(", "alg", "instanceof", "AccessPointTracks3D", ")", ")", "return", "\"\"", ";", "AccessPointTracks3D", "access", "=", "(", "AccessPointTracks3D", ")", "alg",...
If the algorithm implements AccessPointTracks3D, then count the number of inlier features and return a string.
[ "If", "the", "algorithm", "implements", "AccessPointTracks3D", "then", "count", "the", "number", "of", "inlier", "features", "and", "return", "a", "string", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/sfm/ExampleVisualOdometryDepth.java#L109-L123
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleFitPolygon.java
ExampleFitPolygon.fitBinaryImage
public static void fitBinaryImage(GrayF32 input) { GrayU8 binary = new GrayU8(input.width,input.height); BufferedImage polygon = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB); // the mean pixel value is often a reasonable threshold when creating a binary image double mean = ImageStatistics.mean(input); // create a binary image by thresholding ThresholdImageOps.threshold(input, binary, (float) mean, true); // reduce noise with some filtering GrayU8 filtered = BinaryImageOps.erode8(binary, 1, null); filtered = BinaryImageOps.dilate8(filtered, 1, null); // Find internal and external contour around each shape List<Contour> contours = BinaryImageOps.contour(filtered, ConnectRule.EIGHT,null); // Fit a polygon to each shape and draw the results Graphics2D g2 = polygon.createGraphics(); g2.setStroke(new BasicStroke(2)); for( Contour c : contours ) { // Fit the polygon to the found external contour. Note loop = true List<PointIndex_I32> vertexes = ShapeFittingOps.fitPolygon(c.external,true, minSide,cornerPenalty); g2.setColor(Color.RED); VisualizeShapes.drawPolygon(vertexes,true,g2); // handle internal contours now g2.setColor(Color.BLUE); for( List<Point2D_I32> internal : c.internal ) { vertexes = ShapeFittingOps.fitPolygon(internal,true, minSide,cornerPenalty); VisualizeShapes.drawPolygon(vertexes,true,g2); } } gui.addImage(polygon, "Binary Blob Contours"); }
java
public static void fitBinaryImage(GrayF32 input) { GrayU8 binary = new GrayU8(input.width,input.height); BufferedImage polygon = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB); // the mean pixel value is often a reasonable threshold when creating a binary image double mean = ImageStatistics.mean(input); // create a binary image by thresholding ThresholdImageOps.threshold(input, binary, (float) mean, true); // reduce noise with some filtering GrayU8 filtered = BinaryImageOps.erode8(binary, 1, null); filtered = BinaryImageOps.dilate8(filtered, 1, null); // Find internal and external contour around each shape List<Contour> contours = BinaryImageOps.contour(filtered, ConnectRule.EIGHT,null); // Fit a polygon to each shape and draw the results Graphics2D g2 = polygon.createGraphics(); g2.setStroke(new BasicStroke(2)); for( Contour c : contours ) { // Fit the polygon to the found external contour. Note loop = true List<PointIndex_I32> vertexes = ShapeFittingOps.fitPolygon(c.external,true, minSide,cornerPenalty); g2.setColor(Color.RED); VisualizeShapes.drawPolygon(vertexes,true,g2); // handle internal contours now g2.setColor(Color.BLUE); for( List<Point2D_I32> internal : c.internal ) { vertexes = ShapeFittingOps.fitPolygon(internal,true, minSide,cornerPenalty); VisualizeShapes.drawPolygon(vertexes,true,g2); } } gui.addImage(polygon, "Binary Blob Contours"); }
[ "public", "static", "void", "fitBinaryImage", "(", "GrayF32", "input", ")", "{", "GrayU8", "binary", "=", "new", "GrayU8", "(", "input", ".", "width", ",", "input", ".", "height", ")", ";", "BufferedImage", "polygon", "=", "new", "BufferedImage", "(", "inp...
Fits polygons to found contours around binary blobs.
[ "Fits", "polygons", "to", "found", "contours", "around", "binary", "blobs", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleFitPolygon.java#L66-L104
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleFitPolygon.java
ExampleFitPolygon.fitCannyEdges
public static void fitCannyEdges( GrayF32 input ) { BufferedImage displayImage = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB); // Finds edges inside the image CannyEdge<GrayF32,GrayF32> canny = FactoryEdgeDetectors.canny(2, true, true, GrayF32.class, GrayF32.class); canny.process(input,0.1f,0.3f,null); List<EdgeContour> contours = canny.getContours(); Graphics2D g2 = displayImage.createGraphics(); g2.setStroke(new BasicStroke(2)); // used to select colors for each line Random rand = new Random(234); for( EdgeContour e : contours ) { g2.setColor(new Color(rand.nextInt())); for(EdgeSegment s : e.segments ) { // fit line segments to the point sequence. Note that loop is false List<PointIndex_I32> vertexes = ShapeFittingOps.fitPolygon(s.points,false, minSide,cornerPenalty); VisualizeShapes.drawPolygon(vertexes, false, g2); } } gui.addImage(displayImage, "Canny Trace"); }
java
public static void fitCannyEdges( GrayF32 input ) { BufferedImage displayImage = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB); // Finds edges inside the image CannyEdge<GrayF32,GrayF32> canny = FactoryEdgeDetectors.canny(2, true, true, GrayF32.class, GrayF32.class); canny.process(input,0.1f,0.3f,null); List<EdgeContour> contours = canny.getContours(); Graphics2D g2 = displayImage.createGraphics(); g2.setStroke(new BasicStroke(2)); // used to select colors for each line Random rand = new Random(234); for( EdgeContour e : contours ) { g2.setColor(new Color(rand.nextInt())); for(EdgeSegment s : e.segments ) { // fit line segments to the point sequence. Note that loop is false List<PointIndex_I32> vertexes = ShapeFittingOps.fitPolygon(s.points,false, minSide,cornerPenalty); VisualizeShapes.drawPolygon(vertexes, false, g2); } } gui.addImage(displayImage, "Canny Trace"); }
[ "public", "static", "void", "fitCannyEdges", "(", "GrayF32", "input", ")", "{", "BufferedImage", "displayImage", "=", "new", "BufferedImage", "(", "input", ".", "width", ",", "input", ".", "height", ",", "BufferedImage", ".", "TYPE_INT_RGB", ")", ";", "// Find...
Fits a sequence of line-segments into a sequence of points found using the Canny edge detector. In this case the points are not connected in a loop. The canny detector produces a more complex tree and the fitted points can be a bit noisy compared to the others.
[ "Fits", "a", "sequence", "of", "line", "-", "segments", "into", "a", "sequence", "of", "points", "found", "using", "the", "Canny", "edge", "detector", ".", "In", "this", "case", "the", "points", "are", "not", "connected", "in", "a", "loop", ".", "The", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleFitPolygon.java#L111-L140
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleFitPolygon.java
ExampleFitPolygon.fitCannyBinary
public static void fitCannyBinary( GrayF32 input ) { BufferedImage displayImage = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB); GrayU8 binary = new GrayU8(input.width,input.height); // Finds edges inside the image CannyEdge<GrayF32,GrayF32> canny = FactoryEdgeDetectors.canny(2, false, true, GrayF32.class, GrayF32.class); canny.process(input,0.1f,0.3f,binary); // Only external contours are relevant List<Contour> contours = BinaryImageOps.contourExternal(binary, ConnectRule.EIGHT); Graphics2D g2 = displayImage.createGraphics(); g2.setStroke(new BasicStroke(2)); // used to select colors for each line Random rand = new Random(234); for( Contour c : contours ) { List<PointIndex_I32> vertexes = ShapeFittingOps.fitPolygon(c.external,true, minSide,cornerPenalty); g2.setColor(new Color(rand.nextInt())); VisualizeShapes.drawPolygon(vertexes,true,g2); } gui.addImage(displayImage, "Canny Contour"); }
java
public static void fitCannyBinary( GrayF32 input ) { BufferedImage displayImage = new BufferedImage(input.width,input.height,BufferedImage.TYPE_INT_RGB); GrayU8 binary = new GrayU8(input.width,input.height); // Finds edges inside the image CannyEdge<GrayF32,GrayF32> canny = FactoryEdgeDetectors.canny(2, false, true, GrayF32.class, GrayF32.class); canny.process(input,0.1f,0.3f,binary); // Only external contours are relevant List<Contour> contours = BinaryImageOps.contourExternal(binary, ConnectRule.EIGHT); Graphics2D g2 = displayImage.createGraphics(); g2.setStroke(new BasicStroke(2)); // used to select colors for each line Random rand = new Random(234); for( Contour c : contours ) { List<PointIndex_I32> vertexes = ShapeFittingOps.fitPolygon(c.external,true, minSide,cornerPenalty); g2.setColor(new Color(rand.nextInt())); VisualizeShapes.drawPolygon(vertexes,true,g2); } gui.addImage(displayImage, "Canny Contour"); }
[ "public", "static", "void", "fitCannyBinary", "(", "GrayF32", "input", ")", "{", "BufferedImage", "displayImage", "=", "new", "BufferedImage", "(", "input", ".", "width", ",", "input", ".", "height", ",", "BufferedImage", ".", "TYPE_INT_RGB", ")", ";", "GrayU8...
Detects contours inside the binary image generated by canny. Only the external contour is relevant. Often easier to deal with than working with Canny edges directly.
[ "Detects", "contours", "inside", "the", "binary", "image", "generated", "by", "canny", ".", "Only", "the", "external", "contour", "is", "relevant", ".", "Often", "easier", "to", "deal", "with", "than", "working", "with", "Canny", "edges", "directly", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleFitPolygon.java#L146-L174
train
lessthanoptimal/BoofCV
main/boofcv-learning/src/main/java/boofcv/alg/bow/LearnSceneFromFiles.java
LearnSceneFromFiles.evaluate
protected Confusion evaluate( Map<String,List<String>> set ) { ClassificationHistogram histogram = new ClassificationHistogram(scenes.size()); int total = 0; for (int i = 0; i < scenes.size(); i++) { total += set.get(scenes.get(i)).size(); } System.out.println("total images "+total); for (int i = 0; i < scenes.size(); i++) { String scene = scenes.get(i); List<String> images = set.get(scene); System.out.println(" "+scene+" "+images.size()); for (String image : images) { int predicted = classify(image); histogram.increment(i, predicted); } } return histogram.createConfusion(); }
java
protected Confusion evaluate( Map<String,List<String>> set ) { ClassificationHistogram histogram = new ClassificationHistogram(scenes.size()); int total = 0; for (int i = 0; i < scenes.size(); i++) { total += set.get(scenes.get(i)).size(); } System.out.println("total images "+total); for (int i = 0; i < scenes.size(); i++) { String scene = scenes.get(i); List<String> images = set.get(scene); System.out.println(" "+scene+" "+images.size()); for (String image : images) { int predicted = classify(image); histogram.increment(i, predicted); } } return histogram.createConfusion(); }
[ "protected", "Confusion", "evaluate", "(", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "set", ")", "{", "ClassificationHistogram", "histogram", "=", "new", "ClassificationHistogram", "(", "scenes", ".", "size", "(", ")", ")", ";", "int", "t...
Given a set of images with known classification, predict which scene each one belongs in and compute a confusion matrix for the results. @param set Set of classified images @return Confusion matrix
[ "Given", "a", "set", "of", "images", "with", "known", "classification", "predict", "which", "scene", "each", "one", "belongs", "in", "and", "compute", "a", "confusion", "matrix", "for", "the", "results", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-learning/src/main/java/boofcv/alg/bow/LearnSceneFromFiles.java#L65-L86
train
lessthanoptimal/BoofCV
main/boofcv-learning/src/main/java/boofcv/alg/bow/LearnSceneFromFiles.java
LearnSceneFromFiles.findImages
public static Map<String,List<String>> findImages( File rootDir ) { File files[] = rootDir.listFiles(); if( files == null ) return null; List<File> imageDirectories = new ArrayList<>(); for( File f : files ) { if( f.isDirectory() ) { imageDirectories.add(f); } } Map<String,List<String>> out = new HashMap<>(); for( File d : imageDirectories ) { List<String> images = new ArrayList<>(); files = d.listFiles(); if( files == null ) throw new RuntimeException("Should be a directory!"); for( File f : files ) { if( f.isHidden() || f.isDirectory() || f.getName().endsWith(".txt") ) { continue; } images.add( f.getPath() ); } String key = d.getName().toLowerCase(); out.put(key,images); } return out; }
java
public static Map<String,List<String>> findImages( File rootDir ) { File files[] = rootDir.listFiles(); if( files == null ) return null; List<File> imageDirectories = new ArrayList<>(); for( File f : files ) { if( f.isDirectory() ) { imageDirectories.add(f); } } Map<String,List<String>> out = new HashMap<>(); for( File d : imageDirectories ) { List<String> images = new ArrayList<>(); files = d.listFiles(); if( files == null ) throw new RuntimeException("Should be a directory!"); for( File f : files ) { if( f.isHidden() || f.isDirectory() || f.getName().endsWith(".txt") ) { continue; } images.add( f.getPath() ); } String key = d.getName().toLowerCase(); out.put(key,images); } return out; }
[ "public", "static", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "findImages", "(", "File", "rootDir", ")", "{", "File", "files", "[", "]", "=", "rootDir", ".", "listFiles", "(", ")", ";", "if", "(", "files", "==", "null", ")", "retu...
Loads the paths to image files contained in subdirectories of the root directory. Each sub directory is assumed to be a different category of images.
[ "Loads", "the", "paths", "to", "image", "files", "contained", "in", "subdirectories", "of", "the", "root", "directory", ".", "Each", "sub", "directory", "is", "assumed", "to", "be", "a", "different", "category", "of", "images", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-learning/src/main/java/boofcv/alg/bow/LearnSceneFromFiles.java#L163-L196
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/feature/CompareTwoImagePanel.java
CompareTwoImagePanel.setImages
public synchronized void setImages(BufferedImage leftImage , BufferedImage rightImage ) { this.leftImage = leftImage; this.rightImage = rightImage; setPreferredSize(leftImage.getWidth(),leftImage.getHeight(),rightImage.getWidth(),rightImage.getHeight()); }
java
public synchronized void setImages(BufferedImage leftImage , BufferedImage rightImage ) { this.leftImage = leftImage; this.rightImage = rightImage; setPreferredSize(leftImage.getWidth(),leftImage.getHeight(),rightImage.getWidth(),rightImage.getHeight()); }
[ "public", "synchronized", "void", "setImages", "(", "BufferedImage", "leftImage", ",", "BufferedImage", "rightImage", ")", "{", "this", ".", "leftImage", "=", "leftImage", ";", "this", ".", "rightImage", "=", "rightImage", ";", "setPreferredSize", "(", "leftImage"...
Sets the internal images. Not thread safe. @param leftImage @param rightImage
[ "Sets", "the", "internal", "images", ".", "Not", "thread", "safe", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/feature/CompareTwoImagePanel.java#L93-L98
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/feature/CompareTwoImagePanel.java
CompareTwoImagePanel.computeScales
private void computeScales() { int width = getWidth(); int height = getHeight(); width = (width-borderSize)/2; // compute the scale factor for each image scaleLeft = scaleRight = 1; if( leftImage.getWidth() > width || leftImage.getHeight() > height ) { double scaleX = (double)width/(double)leftImage.getWidth(); double scaleY = (double)height/(double)leftImage.getHeight(); scaleLeft = Math.min(scaleX,scaleY); } if( rightImage.getWidth() > width || rightImage.getHeight() > height ) { double scaleX = (double)width/(double)rightImage.getWidth(); double scaleY = (double)height/(double)rightImage.getHeight(); scaleRight = Math.min(scaleX,scaleY); } }
java
private void computeScales() { int width = getWidth(); int height = getHeight(); width = (width-borderSize)/2; // compute the scale factor for each image scaleLeft = scaleRight = 1; if( leftImage.getWidth() > width || leftImage.getHeight() > height ) { double scaleX = (double)width/(double)leftImage.getWidth(); double scaleY = (double)height/(double)leftImage.getHeight(); scaleLeft = Math.min(scaleX,scaleY); } if( rightImage.getWidth() > width || rightImage.getHeight() > height ) { double scaleX = (double)width/(double)rightImage.getWidth(); double scaleY = (double)height/(double)rightImage.getHeight(); scaleRight = Math.min(scaleX,scaleY); } }
[ "private", "void", "computeScales", "(", ")", "{", "int", "width", "=", "getWidth", "(", ")", ";", "int", "height", "=", "getHeight", "(", ")", ";", "width", "=", "(", "width", "-", "borderSize", ")", "/", "2", ";", "// compute the scale factor for each im...
Compute individually how each image will be scaled
[ "Compute", "individually", "how", "each", "image", "will", "be", "scaled" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/feature/CompareTwoImagePanel.java#L157-L175
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java
DataManipulationOps.normalize
public static void normalize(GrayF32 image , float mean , float stdev ) { for (int y = 0; y < image.height; y++) { int index = image.startIndex + y*image.stride; int end = index + image.width; while( index < end ) { image.data[index] = (image.data[index]-mean)/stdev; index++; } } }
java
public static void normalize(GrayF32 image , float mean , float stdev ) { for (int y = 0; y < image.height; y++) { int index = image.startIndex + y*image.stride; int end = index + image.width; while( index < end ) { image.data[index] = (image.data[index]-mean)/stdev; index++; } } }
[ "public", "static", "void", "normalize", "(", "GrayF32", "image", ",", "float", "mean", ",", "float", "stdev", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "image", ".", "height", ";", "y", "++", ")", "{", "int", "index", "=", "imag...
Normalizes a gray scale image by first subtracting the mean then dividing by stdev. @param image Image that is to be normalized @param mean Value which is subtracted by it @param stdev The divisor
[ "Normalizes", "a", "gray", "scale", "image", "by", "first", "subtracting", "the", "mean", "then", "dividing", "by", "stdev", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java#L39-L48
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java
DataManipulationOps.create1D_F32
public static Kernel1D_F32 create1D_F32( double[] kernel ) { Kernel1D_F32 k = new Kernel1D_F32(kernel.length,kernel.length/2); for (int i = 0; i < kernel.length; i++) { k.data[i] = (float)kernel[i]; } return k; }
java
public static Kernel1D_F32 create1D_F32( double[] kernel ) { Kernel1D_F32 k = new Kernel1D_F32(kernel.length,kernel.length/2); for (int i = 0; i < kernel.length; i++) { k.data[i] = (float)kernel[i]; } return k; }
[ "public", "static", "Kernel1D_F32", "create1D_F32", "(", "double", "[", "]", "kernel", ")", "{", "Kernel1D_F32", "k", "=", "new", "Kernel1D_F32", "(", "kernel", ".", "length", ",", "kernel", ".", "length", "/", "2", ")", ";", "for", "(", "int", "i", "=...
Converts the double array into a 1D float kernel @param kernel Kernel in array format @return The kernel
[ "Converts", "the", "double", "array", "into", "a", "1D", "float", "kernel" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java#L55-L61
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java
DataManipulationOps.imageToTensor
public static void imageToTensor(Planar<GrayF32> input , Tensor_F32 output , int miniBatch) { if( input.isSubimage()) throw new RuntimeException("Subimages not accepted"); if( output.getDimension() != 4 ) throw new IllegalArgumentException("Output should be 4-DOF. batch + spatial (channel,height,width)"); if( output.length(1) != input.getNumBands() ) throw new IllegalArgumentException("Number of bands don't match"); if( output.length(2) != input.getHeight() ) throw new IllegalArgumentException("Spatial height doesn't match"); if( output.length(3) != input.getWidth() ) throw new IllegalArgumentException("Spatial width doesn't match"); for (int i = 0; i < input.getNumBands(); i++) { GrayF32 band = input.getBand(i); int indexOut = output.idx(miniBatch,i,0,0); int length = input.width*input.height; System.arraycopy(band.data, 0,output.d,indexOut,length); } }
java
public static void imageToTensor(Planar<GrayF32> input , Tensor_F32 output , int miniBatch) { if( input.isSubimage()) throw new RuntimeException("Subimages not accepted"); if( output.getDimension() != 4 ) throw new IllegalArgumentException("Output should be 4-DOF. batch + spatial (channel,height,width)"); if( output.length(1) != input.getNumBands() ) throw new IllegalArgumentException("Number of bands don't match"); if( output.length(2) != input.getHeight() ) throw new IllegalArgumentException("Spatial height doesn't match"); if( output.length(3) != input.getWidth() ) throw new IllegalArgumentException("Spatial width doesn't match"); for (int i = 0; i < input.getNumBands(); i++) { GrayF32 band = input.getBand(i); int indexOut = output.idx(miniBatch,i,0,0); int length = input.width*input.height; System.arraycopy(band.data, 0,output.d,indexOut,length); } }
[ "public", "static", "void", "imageToTensor", "(", "Planar", "<", "GrayF32", ">", "input", ",", "Tensor_F32", "output", ",", "int", "miniBatch", ")", "{", "if", "(", "input", ".", "isSubimage", "(", ")", ")", "throw", "new", "RuntimeException", "(", "\"Subi...
Converts an image into a spatial tensor @param input BoofCV planar image @param output Tensor @param miniBatch Which mini-batch in the tensor should the image be written to
[ "Converts", "an", "image", "into", "a", "spatial", "tensor" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/deepboof/DataManipulationOps.java#L70-L89
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearExternalContours.java
LinearExternalContours.process
public void process( GrayU8 binary , int adjustX , int adjustY ) { // Initialize data structures this.adjustX = adjustX; this.adjustY = adjustY; storagePoints.reset(); ImageMiscOps.fillBorder(binary, 0, 1); tracer.setInputs(binary); final byte binaryData[] = binary.data; // Scan through the image one row at a time looking for pixels with 1 for (int y = 1; y < binary.height-1; y++) { int x = 1; int indexBinary = binary.startIndex + y*binary.stride + 1; int end = indexBinary + binary.width - 2; while( true ) { int delta = findNotZero(binaryData, indexBinary, end) - indexBinary; indexBinary += delta; if (indexBinary == end) break; x += delta; // If this pixel has NOT already been labeled then trace until it runs into a labeled pixel or it // completes the trace. If a labeled pixel is not encountered then it must be an external contour if( binaryData[indexBinary] == 1 ) { if( tracer.trace(x,y,true) ) { int N = storagePoints.sizeOfTail(); if( N < minContourLength || N >= maxContourLength) storagePoints.removeTail(); } else { // it was really an internal contour storagePoints.removeTail(); } } // It's now inside a ones blob. Move forward until it hits a 0 pixel delta = findZero(binaryData, indexBinary, end) - indexBinary; indexBinary += delta; if (indexBinary == end) break; x += delta; // If this pixel has NOT already been labeled trace until it completes a loop or it encounters a // labeled pixel. This is always an internal contour if( binaryData[indexBinary-1] == 1 ) { tracer.trace(x-1,y,false); storagePoints.removeTail(); } else { // Can't be sure if it's entering a hole or leaving the blob. This marker will let the // tracer know it just traced an internal contour and not an external contour binaryData[indexBinary-1] = -2; } } } }
java
public void process( GrayU8 binary , int adjustX , int adjustY ) { // Initialize data structures this.adjustX = adjustX; this.adjustY = adjustY; storagePoints.reset(); ImageMiscOps.fillBorder(binary, 0, 1); tracer.setInputs(binary); final byte binaryData[] = binary.data; // Scan through the image one row at a time looking for pixels with 1 for (int y = 1; y < binary.height-1; y++) { int x = 1; int indexBinary = binary.startIndex + y*binary.stride + 1; int end = indexBinary + binary.width - 2; while( true ) { int delta = findNotZero(binaryData, indexBinary, end) - indexBinary; indexBinary += delta; if (indexBinary == end) break; x += delta; // If this pixel has NOT already been labeled then trace until it runs into a labeled pixel or it // completes the trace. If a labeled pixel is not encountered then it must be an external contour if( binaryData[indexBinary] == 1 ) { if( tracer.trace(x,y,true) ) { int N = storagePoints.sizeOfTail(); if( N < minContourLength || N >= maxContourLength) storagePoints.removeTail(); } else { // it was really an internal contour storagePoints.removeTail(); } } // It's now inside a ones blob. Move forward until it hits a 0 pixel delta = findZero(binaryData, indexBinary, end) - indexBinary; indexBinary += delta; if (indexBinary == end) break; x += delta; // If this pixel has NOT already been labeled trace until it completes a loop or it encounters a // labeled pixel. This is always an internal contour if( binaryData[indexBinary-1] == 1 ) { tracer.trace(x-1,y,false); storagePoints.removeTail(); } else { // Can't be sure if it's entering a hole or leaving the blob. This marker will let the // tracer know it just traced an internal contour and not an external contour binaryData[indexBinary-1] = -2; } } } }
[ "public", "void", "process", "(", "GrayU8", "binary", ",", "int", "adjustX", ",", "int", "adjustY", ")", "{", "// Initialize data structures", "this", ".", "adjustX", "=", "adjustX", ";", "this", ".", "adjustY", "=", "adjustY", ";", "storagePoints", ".", "re...
Detects contours inside the binary image. @param binary Binary image. Will be modified. See class description @param adjustX adjustment applied to coordinate in binary image for contour. 0 or 1 is typical @param adjustY adjustment applied to coordinate in binary image for contour. 0 or 1 is typical
[ "Detects", "contours", "inside", "the", "binary", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearExternalContours.java#L78-L134
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearExternalContours.java
LinearExternalContours.findNotZero
static int findNotZero( byte[] data , int index , int end ) { while( index < end && data[index] == 0 ) { index++; } return index; }
java
static int findNotZero( byte[] data , int index , int end ) { while( index < end && data[index] == 0 ) { index++; } return index; }
[ "static", "int", "findNotZero", "(", "byte", "[", "]", "data", ",", "int", "index", ",", "int", "end", ")", "{", "while", "(", "index", "<", "end", "&&", "data", "[", "index", "]", "==", "0", ")", "{", "index", "++", ";", "}", "return", "index", ...
Searches for a value in the array which is not zero.
[ "Searches", "for", "a", "value", "in", "the", "array", "which", "is", "not", "zero", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearExternalContours.java#L140-L145
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearExternalContours.java
LinearExternalContours.findZero
static int findZero( byte[] data , int index , int end ) { while( index < end && data[index] != 0 ) { index++; } return index; }
java
static int findZero( byte[] data , int index , int end ) { while( index < end && data[index] != 0 ) { index++; } return index; }
[ "static", "int", "findZero", "(", "byte", "[", "]", "data", ",", "int", "index", ",", "int", "end", ")", "{", "while", "(", "index", "<", "end", "&&", "data", "[", "index", "]", "!=", "0", ")", "{", "index", "++", ";", "}", "return", "index", "...
Searches for a value in the array which is zero.
[ "Searches", "for", "a", "value", "in", "the", "array", "which", "is", "zero", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/LinearExternalContours.java#L150-L155
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/SquareImage_to_FiducialDetector.java
SquareImage_to_FiducialDetector.addPatternImage
public void addPatternImage(T pattern, double threshold, double lengthSide) { GrayU8 binary = new GrayU8(pattern.width,pattern.height); GThresholdImageOps.threshold(pattern,binary,threshold,false); alg.addPattern(binary, lengthSide); }
java
public void addPatternImage(T pattern, double threshold, double lengthSide) { GrayU8 binary = new GrayU8(pattern.width,pattern.height); GThresholdImageOps.threshold(pattern,binary,threshold,false); alg.addPattern(binary, lengthSide); }
[ "public", "void", "addPatternImage", "(", "T", "pattern", ",", "double", "threshold", ",", "double", "lengthSide", ")", "{", "GrayU8", "binary", "=", "new", "GrayU8", "(", "pattern", ".", "width", ",", "pattern", ".", "height", ")", ";", "GThresholdImageOps"...
Add a new pattern to be detected. This function takes in a raw gray scale image and thresholds it. @param pattern Gray scale image of the pattern @param threshold Threshold used to convert it into a binary image @param lengthSide Length of a side on the square in world units.
[ "Add", "a", "new", "pattern", "to", "be", "detected", ".", "This", "function", "takes", "in", "a", "raw", "gray", "scale", "image", "and", "thresholds", "it", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/SquareImage_to_FiducialDetector.java#L48-L52
train