repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdBlock.java
ThresholdBlock.applyThreshold
protected void applyThreshold( T input, GrayU8 output ) { for (int blockY = 0; blockY < stats.height; blockY++) { for (int blockX = 0; blockX < stats.width; blockX++) { original.thresholdBlock(blockX,blockY,input,stats,output); } } }
java
protected void applyThreshold( T input, GrayU8 output ) { for (int blockY = 0; blockY < stats.height; blockY++) { for (int blockX = 0; blockX < stats.width; blockX++) { original.thresholdBlock(blockX,blockY,input,stats,output); } } }
[ "protected", "void", "applyThreshold", "(", "T", "input", ",", "GrayU8", "output", ")", "{", "for", "(", "int", "blockY", "=", "0", ";", "blockY", "<", "stats", ".", "height", ";", "blockY", "++", ")", "{", "for", "(", "int", "blockX", "=", "0", ";...
Applies the dynamically computed threshold to each pixel in the image, one block at a time
[ "Applies", "the", "dynamically", "computed", "threshold", "to", "each", "pixel", "in", "the", "image", "one", "block", "at", "a", "time" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdBlock.java#L132-L138
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/PairwiseImageMatching.java
PairwiseImageMatching.addImage
public void addImage(T image , String cameraName ) { PairwiseImageGraph.View view = new PairwiseImageGraph.View(graph.nodes.size(), new FastQueue<TupleDesc>(TupleDesc.class,true) { @Override protected TupleDesc createInstance() { return detDesc.createDescription(); } }); view.camera = graph.cameras.get(cameraName); if( view.camera == null ) throw new IllegalArgumentException("Must have added the camera first"); view.index = graph.nodes.size(); graph.nodes.add(view); detDesc.detect(image); // Pre-declare memory view.descriptions.growArray(detDesc.getNumberOfFeatures()); view.observationPixels.growArray(detDesc.getNumberOfFeatures()); for (int i = 0; i < detDesc.getNumberOfFeatures(); i++) { Point2D_F64 p = detDesc.getLocation(i); // save copies since detDesc recycles memory view.descriptions.grow().setTo(detDesc.getDescription(i)); view.observationPixels.grow().set(p); } if( view.camera.pixelToNorm == null ){ return; } view.observationNorm.growArray(detDesc.getNumberOfFeatures()); for (int i = 0; i < view.observationPixels.size; i++) { Point2D_F64 p = view.observationPixels.get(i); view.camera.pixelToNorm.compute(p.x,p.y,view.observationNorm.grow()); } if( verbose != null ) { verbose.println("Detected Features: "+detDesc.getNumberOfFeatures()); } }
java
public void addImage(T image , String cameraName ) { PairwiseImageGraph.View view = new PairwiseImageGraph.View(graph.nodes.size(), new FastQueue<TupleDesc>(TupleDesc.class,true) { @Override protected TupleDesc createInstance() { return detDesc.createDescription(); } }); view.camera = graph.cameras.get(cameraName); if( view.camera == null ) throw new IllegalArgumentException("Must have added the camera first"); view.index = graph.nodes.size(); graph.nodes.add(view); detDesc.detect(image); // Pre-declare memory view.descriptions.growArray(detDesc.getNumberOfFeatures()); view.observationPixels.growArray(detDesc.getNumberOfFeatures()); for (int i = 0; i < detDesc.getNumberOfFeatures(); i++) { Point2D_F64 p = detDesc.getLocation(i); // save copies since detDesc recycles memory view.descriptions.grow().setTo(detDesc.getDescription(i)); view.observationPixels.grow().set(p); } if( view.camera.pixelToNorm == null ){ return; } view.observationNorm.growArray(detDesc.getNumberOfFeatures()); for (int i = 0; i < view.observationPixels.size; i++) { Point2D_F64 p = view.observationPixels.get(i); view.camera.pixelToNorm.compute(p.x,p.y,view.observationNorm.grow()); } if( verbose != null ) { verbose.println("Detected Features: "+detDesc.getNumberOfFeatures()); } }
[ "public", "void", "addImage", "(", "T", "image", ",", "String", "cameraName", ")", "{", "PairwiseImageGraph", ".", "View", "view", "=", "new", "PairwiseImageGraph", ".", "View", "(", "graph", ".", "nodes", ".", "size", "(", ")", ",", "new", "FastQueue", ...
Adds a new observation from a camera. Detects features inside the and saves those. @param image The image
[ "Adds", "a", "new", "observation", "from", "a", "camera", ".", "Detects", "features", "inside", "the", "and", "saves", "those", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/PairwiseImageMatching.java#L118-L162
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/PairwiseImageMatching.java
PairwiseImageMatching.connectViews
protected boolean connectViews(PairwiseImageGraph.View viewA , PairwiseImageGraph.View viewB , FastQueue<AssociatedIndex> matches) { // Estimate fundamental/essential with RANSAC PairwiseImageGraph.Motion edge = new PairwiseImageGraph.Motion(); int inliersEpipolar; CameraPinhole pinhole0 = viewA.camera.pinhole; CameraPinhole pinhole1 = viewB.camera.pinhole; if( pinhole0 != null && pinhole1 != null ) { // Fully calibrated camera pair ransacEssential.setIntrinsic(0,pinhole0); ransacEssential.setIntrinsic(1,pinhole1); if( !fitEpipolar(matches, viewA.observationNorm.toList(), viewB.observationNorm.toList(),ransacEssential,edge) ) { if( verbose != null && verboseLevel >= 1 ) { verbose.println(" fit essential failed"); } return false; } edge.metric = true; inliersEpipolar = ransacEssential.getMatchSet().size(); edge.F.set(ransacEssential.getModelParameters()); } else if( fitEpipolar(matches, viewA.observationPixels.toList(), viewB.observationPixels.toList(), ransacFundamental,edge) ) { // transform is only known up to a projective transform edge.metric = false; inliersEpipolar = ransacFundamental.getMatchSet().size(); edge.F.set(ransacFundamental.getModelParameters()); } else { if( verbose != null && verboseLevel >= 1 ) { verbose.println(" fit fundamental failed"); } return false; } if( inliersEpipolar < MIN_FEATURE_ASSOCIATED ) { if( verbose != null && verboseLevel >= 1 ) { verbose.println(" too too few inliers. "+inliersEpipolar+" min="+MIN_FEATURE_ASSOCIATED+ " obsA="+viewA.observationNorm.size+" obsB="+viewB.observationNorm.size); } return false; } // If only a very small number of features are associated do not consider the view double fractionA = inliersEpipolar/(double)viewA.descriptions.size; double fractionB = inliersEpipolar/(double)viewB.descriptions.size; if( fractionA < MIN_ASSOCIATE_FRACTION | fractionB < MIN_ASSOCIATE_FRACTION ) return false; // If the geometry is good for triangulation this number will be lower edge.viewSrc = viewA; edge.viewDst = viewB; edge.index = graph.edges.size(); viewA.connections.add(edge); viewB.connections.add(edge); graph.edges.add(edge); return true; }
java
protected boolean connectViews(PairwiseImageGraph.View viewA , PairwiseImageGraph.View viewB , FastQueue<AssociatedIndex> matches) { // Estimate fundamental/essential with RANSAC PairwiseImageGraph.Motion edge = new PairwiseImageGraph.Motion(); int inliersEpipolar; CameraPinhole pinhole0 = viewA.camera.pinhole; CameraPinhole pinhole1 = viewB.camera.pinhole; if( pinhole0 != null && pinhole1 != null ) { // Fully calibrated camera pair ransacEssential.setIntrinsic(0,pinhole0); ransacEssential.setIntrinsic(1,pinhole1); if( !fitEpipolar(matches, viewA.observationNorm.toList(), viewB.observationNorm.toList(),ransacEssential,edge) ) { if( verbose != null && verboseLevel >= 1 ) { verbose.println(" fit essential failed"); } return false; } edge.metric = true; inliersEpipolar = ransacEssential.getMatchSet().size(); edge.F.set(ransacEssential.getModelParameters()); } else if( fitEpipolar(matches, viewA.observationPixels.toList(), viewB.observationPixels.toList(), ransacFundamental,edge) ) { // transform is only known up to a projective transform edge.metric = false; inliersEpipolar = ransacFundamental.getMatchSet().size(); edge.F.set(ransacFundamental.getModelParameters()); } else { if( verbose != null && verboseLevel >= 1 ) { verbose.println(" fit fundamental failed"); } return false; } if( inliersEpipolar < MIN_FEATURE_ASSOCIATED ) { if( verbose != null && verboseLevel >= 1 ) { verbose.println(" too too few inliers. "+inliersEpipolar+" min="+MIN_FEATURE_ASSOCIATED+ " obsA="+viewA.observationNorm.size+" obsB="+viewB.observationNorm.size); } return false; } // If only a very small number of features are associated do not consider the view double fractionA = inliersEpipolar/(double)viewA.descriptions.size; double fractionB = inliersEpipolar/(double)viewB.descriptions.size; if( fractionA < MIN_ASSOCIATE_FRACTION | fractionB < MIN_ASSOCIATE_FRACTION ) return false; // If the geometry is good for triangulation this number will be lower edge.viewSrc = viewA; edge.viewDst = viewB; edge.index = graph.edges.size(); viewA.connections.add(edge); viewB.connections.add(edge); graph.edges.add(edge); return true; }
[ "protected", "boolean", "connectViews", "(", "PairwiseImageGraph", ".", "View", "viewA", ",", "PairwiseImageGraph", ".", "View", "viewB", ",", "FastQueue", "<", "AssociatedIndex", ">", "matches", ")", "{", "// Estimate fundamental/essential with RANSAC", "PairwiseImageGra...
Associate features between the two views. Then compute a homography and essential matrix using LSMed. Add features to the edge if they an inlier in essential. Save fit score of homography vs essential.
[ "Associate", "features", "between", "the", "two", "views", ".", "Then", "compute", "a", "homography", "and", "essential", "matrix", "using", "LSMed", ".", "Add", "features", "to", "the", "edge", "if", "they", "an", "inlier", "in", "essential", ".", "Save", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/PairwiseImageMatching.java#L215-L277
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/PairwiseImageMatching.java
PairwiseImageMatching.fitEpipolar
boolean fitEpipolar(FastQueue<AssociatedIndex> matches , List<Point2D_F64> pointsA , List<Point2D_F64> pointsB , ModelMatcher<?,AssociatedPair> ransac , PairwiseImageGraph.Motion edge ) { pairs.resize(matches.size); for (int i = 0; i < matches.size; i++) { AssociatedIndex a = matches.get(i); pairs.get(i).p1.set(pointsA.get(a.src)); pairs.get(i).p2.set(pointsB.get(a.dst)); } if( !ransac.process(pairs.toList()) ) return false; int N = ransac.getMatchSet().size(); for (int i = 0; i < N; i++) { AssociatedIndex a = matches.get(ransac.getInputIndex(i)); edge.associated.add( a.copy() ); } return true; }
java
boolean fitEpipolar(FastQueue<AssociatedIndex> matches , List<Point2D_F64> pointsA , List<Point2D_F64> pointsB , ModelMatcher<?,AssociatedPair> ransac , PairwiseImageGraph.Motion edge ) { pairs.resize(matches.size); for (int i = 0; i < matches.size; i++) { AssociatedIndex a = matches.get(i); pairs.get(i).p1.set(pointsA.get(a.src)); pairs.get(i).p2.set(pointsB.get(a.dst)); } if( !ransac.process(pairs.toList()) ) return false; int N = ransac.getMatchSet().size(); for (int i = 0; i < N; i++) { AssociatedIndex a = matches.get(ransac.getInputIndex(i)); edge.associated.add( a.copy() ); } return true; }
[ "boolean", "fitEpipolar", "(", "FastQueue", "<", "AssociatedIndex", ">", "matches", ",", "List", "<", "Point2D_F64", ">", "pointsA", ",", "List", "<", "Point2D_F64", ">", "pointsB", ",", "ModelMatcher", "<", "?", ",", "AssociatedPair", ">", "ransac", ",", "P...
Uses ransac to fit an epipolar model to the associated features. Adds list of matched features to the edge. @param matches List of matched features by index @param pointsA Set of observations from image A @param pointsB Set of observations from image B @param ransac Model fitter @param edge Edge which will contain a description of found motion @return true if no error
[ "Uses", "ransac", "to", "fit", "an", "epipolar", "model", "to", "the", "associated", "features", ".", "Adds", "list", "of", "matched", "features", "to", "the", "edge", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/PairwiseImageMatching.java#L289-L308
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java
DetectPolygonFromContour.process
public void process(T gray, GrayU8 binary) { if( verbose ) System.out.println("ENTER DetectPolygonFromContour.process()"); if( contourPadded != null && !contourPadded.isCreatePaddedCopy() ) { int padding = 2; if( gray.width+padding != binary.width || gray.height+padding != binary.height ) { throw new IllegalArgumentException("Including padding, expected a binary image with shape " + (gray.width+padding)+"x"+(gray.height+padding)); } } else { InputSanityCheck.checkSameShape(binary, gray); } if( imageWidth != gray.width || imageHeight != gray.height ) configure(gray.width,gray.height); // reset storage for output. Call reset individually here to ensure that all references // are nulled from last time for (int i = 0; i < foundInfo.size; i++) { foundInfo.get(i).reset(); } foundInfo.reset(); if( contourEdgeIntensity != null ) contourEdgeIntensity.setImage(gray); long time0 = System.nanoTime(); // find all the contours contourFinder.process(binary); long time1 = System.nanoTime(); // Using the contours find the polygons findCandidateShapes(); long time2 = System.nanoTime(); double a = (time1-time0)*1e-6; double b = (time2-time1)*1e-6; milliContour.update(a); milliShapes.update(b); if( verbose ) System.out.println("EXIT DetectPolygonFromContour.process()"); }
java
public void process(T gray, GrayU8 binary) { if( verbose ) System.out.println("ENTER DetectPolygonFromContour.process()"); if( contourPadded != null && !contourPadded.isCreatePaddedCopy() ) { int padding = 2; if( gray.width+padding != binary.width || gray.height+padding != binary.height ) { throw new IllegalArgumentException("Including padding, expected a binary image with shape " + (gray.width+padding)+"x"+(gray.height+padding)); } } else { InputSanityCheck.checkSameShape(binary, gray); } if( imageWidth != gray.width || imageHeight != gray.height ) configure(gray.width,gray.height); // reset storage for output. Call reset individually here to ensure that all references // are nulled from last time for (int i = 0; i < foundInfo.size; i++) { foundInfo.get(i).reset(); } foundInfo.reset(); if( contourEdgeIntensity != null ) contourEdgeIntensity.setImage(gray); long time0 = System.nanoTime(); // find all the contours contourFinder.process(binary); long time1 = System.nanoTime(); // Using the contours find the polygons findCandidateShapes(); long time2 = System.nanoTime(); double a = (time1-time0)*1e-6; double b = (time2-time1)*1e-6; milliContour.update(a); milliShapes.update(b); if( verbose ) System.out.println("EXIT DetectPolygonFromContour.process()"); }
[ "public", "void", "process", "(", "T", "gray", ",", "GrayU8", "binary", ")", "{", "if", "(", "verbose", ")", "System", ".", "out", ".", "println", "(", "\"ENTER DetectPolygonFromContour.process()\"", ")", ";", "if", "(", "contourPadded", "!=", "null", "&&",...
Examines the undistorted gray scale input image for squares. If p @param gray Input image
[ "Examines", "the", "undistorted", "gray", "scale", "input", "image", "for", "squares", ".", "If", "p" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java#L212-L256
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java
DetectPolygonFromContour.determineCornersOnBorder
void determineCornersOnBorder( Polygon2D_F64 polygon , GrowQueue_B onImageBorder ) { onImageBorder.reset(); for (int i = 0; i < polygon.size(); i++) { Point2D_F64 p = polygon.get(i); onImageBorder.add( p.x <= 1 || p.y <= 1 || p.x >= imageWidth-2 || p.y >= imageHeight-2); } }
java
void determineCornersOnBorder( Polygon2D_F64 polygon , GrowQueue_B onImageBorder ) { onImageBorder.reset(); for (int i = 0; i < polygon.size(); i++) { Point2D_F64 p = polygon.get(i); onImageBorder.add( p.x <= 1 || p.y <= 1 || p.x >= imageWidth-2 || p.y >= imageHeight-2); } }
[ "void", "determineCornersOnBorder", "(", "Polygon2D_F64", "polygon", ",", "GrowQueue_B", "onImageBorder", ")", "{", "onImageBorder", ".", "reset", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "polygon", ".", "size", "(", ")", ";", "i",...
Check to see if corners are touching the image border @param polygon Polygon in distorted (original image) pixels @param onImageBorder storage for corner indexes
[ "Check", "to", "see", "if", "corners", "are", "touching", "the", "image", "border" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java#L442-L449
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java
DetectPolygonFromContour.getContour
public List<Point2D_I32> getContour( Info info ) { contourTmp.reset(); contourFinder.loadContour(info.contour.externalIndex,contourTmp); return contourTmp.toList(); }
java
public List<Point2D_I32> getContour( Info info ) { contourTmp.reset(); contourFinder.loadContour(info.contour.externalIndex,contourTmp); return contourTmp.toList(); }
[ "public", "List", "<", "Point2D_I32", ">", "getContour", "(", "Info", "info", ")", "{", "contourTmp", ".", "reset", "(", ")", ";", "contourFinder", ".", "loadContour", "(", "info", ".", "contour", ".", "externalIndex", ",", "contourTmp", ")", ";", "return"...
Returns the undistorted contour for a shape. Data is potentially recycled the next time any function in this class is invoked. @param info Which shape @return List of points in the contour
[ "Returns", "the", "undistorted", "contour", "for", "a", "shape", ".", "Data", "is", "potentially", "recycled", "the", "next", "time", "any", "function", "in", "this", "class", "is", "invoked", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java#L457-L461
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java
DetectPolygonFromContour.removeDistortionFromContour
private void removeDistortionFromContour(List<Point2D_I32> distorted , FastQueue<Point2D_I32> undistorted ) { undistorted.reset(); for (int j = 0; j < distorted.size(); j++) { // remove distortion Point2D_I32 p = distorted.get(j); Point2D_I32 q = undistorted.grow(); distToUndist.compute(p.x,p.y,distortedPoint); // round to minimize error q.x = Math.round(distortedPoint.x); q.y = Math.round(distortedPoint.y); } }
java
private void removeDistortionFromContour(List<Point2D_I32> distorted , FastQueue<Point2D_I32> undistorted ) { undistorted.reset(); for (int j = 0; j < distorted.size(); j++) { // remove distortion Point2D_I32 p = distorted.get(j); Point2D_I32 q = undistorted.grow(); distToUndist.compute(p.x,p.y,distortedPoint); // round to minimize error q.x = Math.round(distortedPoint.x); q.y = Math.round(distortedPoint.y); } }
[ "private", "void", "removeDistortionFromContour", "(", "List", "<", "Point2D_I32", ">", "distorted", ",", "FastQueue", "<", "Point2D_I32", ">", "undistorted", ")", "{", "undistorted", ".", "reset", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j",...
Removes lens distortion from the found contour
[ "Removes", "lens", "distortion", "from", "the", "found", "contour" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java#L499-L513
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java
DetectPolygonFromContour.touchesBorder
protected final boolean touchesBorder( List<Point2D_I32> contour ) { int endX = imageWidth-1; int endY = imageHeight-1; for (int j = 0; j < contour.size(); j++) { Point2D_I32 p = contour.get(j); if( p.x == 0 || p.y == 0 || p.x == endX || p.y == endY ) { return true; } } return false; }
java
protected final boolean touchesBorder( List<Point2D_I32> contour ) { int endX = imageWidth-1; int endY = imageHeight-1; for (int j = 0; j < contour.size(); j++) { Point2D_I32 p = contour.get(j); if( p.x == 0 || p.y == 0 || p.x == endX || p.y == endY ) { return true; } } return false; }
[ "protected", "final", "boolean", "touchesBorder", "(", "List", "<", "Point2D_I32", ">", "contour", ")", "{", "int", "endX", "=", "imageWidth", "-", "1", ";", "int", "endY", "=", "imageHeight", "-", "1", ";", "for", "(", "int", "j", "=", "0", ";", "j"...
Checks to see if some part of the contour touches the image border. Most likely cropped
[ "Checks", "to", "see", "if", "some", "part", "of", "the", "contour", "touches", "the", "image", "border", ".", "Most", "likely", "cropped" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/DetectPolygonFromContour.java#L518-L531
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/NormalizedToPixelError.java
NormalizedToPixelError.set
public void set(double fx, double fy, double skew) { this.fx = fx; this.fy = fy; this.skew = skew; }
java
public void set(double fx, double fy, double skew) { this.fx = fx; this.fy = fy; this.skew = skew; }
[ "public", "void", "set", "(", "double", "fx", ",", "double", "fy", ",", "double", "skew", ")", "{", "this", ".", "fx", "=", "fx", ";", "this", ".", "fy", "=", "fy", ";", "this", ".", "skew", "=", "skew", ";", "}" ]
Specify camera intrinsic parameters @param fx focal length x @param fy focal length y @param skew camera skew
[ "Specify", "camera", "intrinsic", "parameters" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/NormalizedToPixelError.java#L48-L52
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/geometry/ExampleImageStitching.java
ExampleImageStitching.computeTransform
public static<T extends ImageGray<T>, FD extends TupleDesc> Homography2D_F64 computeTransform( T imageA , T imageB , DetectDescribePoint<T,FD> detDesc , AssociateDescription<FD> associate , ModelMatcher<Homography2D_F64,AssociatedPair> modelMatcher ) { // get the length of the description List<Point2D_F64> pointsA = new ArrayList<>(); FastQueue<FD> descA = UtilFeature.createQueue(detDesc,100); List<Point2D_F64> pointsB = new ArrayList<>(); FastQueue<FD> descB = UtilFeature.createQueue(detDesc,100); // extract feature locations and descriptions from each image describeImage(imageA, detDesc, pointsA, descA); describeImage(imageB, detDesc, pointsB, descB); // Associate features between the two images associate.setSource(descA); associate.setDestination(descB); associate.associate(); // create a list of AssociatedPairs that tell the model matcher how a feature moved FastQueue<AssociatedIndex> matches = associate.getMatches(); List<AssociatedPair> pairs = new ArrayList<>(); for( int i = 0; i < matches.size(); i++ ) { AssociatedIndex match = matches.get(i); Point2D_F64 a = pointsA.get(match.src); Point2D_F64 b = pointsB.get(match.dst); pairs.add( new AssociatedPair(a,b,false)); } // find the best fit model to describe the change between these images if( !modelMatcher.process(pairs) ) throw new RuntimeException("Model Matcher failed!"); // return the found image transform return modelMatcher.getModelParameters().copy(); }
java
public static<T extends ImageGray<T>, FD extends TupleDesc> Homography2D_F64 computeTransform( T imageA , T imageB , DetectDescribePoint<T,FD> detDesc , AssociateDescription<FD> associate , ModelMatcher<Homography2D_F64,AssociatedPair> modelMatcher ) { // get the length of the description List<Point2D_F64> pointsA = new ArrayList<>(); FastQueue<FD> descA = UtilFeature.createQueue(detDesc,100); List<Point2D_F64> pointsB = new ArrayList<>(); FastQueue<FD> descB = UtilFeature.createQueue(detDesc,100); // extract feature locations and descriptions from each image describeImage(imageA, detDesc, pointsA, descA); describeImage(imageB, detDesc, pointsB, descB); // Associate features between the two images associate.setSource(descA); associate.setDestination(descB); associate.associate(); // create a list of AssociatedPairs that tell the model matcher how a feature moved FastQueue<AssociatedIndex> matches = associate.getMatches(); List<AssociatedPair> pairs = new ArrayList<>(); for( int i = 0; i < matches.size(); i++ ) { AssociatedIndex match = matches.get(i); Point2D_F64 a = pointsA.get(match.src); Point2D_F64 b = pointsB.get(match.dst); pairs.add( new AssociatedPair(a,b,false)); } // find the best fit model to describe the change between these images if( !modelMatcher.process(pairs) ) throw new RuntimeException("Model Matcher failed!"); // return the found image transform return modelMatcher.getModelParameters().copy(); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ",", "FD", "extends", "TupleDesc", ">", "Homography2D_F64", "computeTransform", "(", "T", "imageA", ",", "T", "imageB", ",", "DetectDescribePoint", "<", "T", ",", "FD", ">", "detDesc", ",...
Using abstracted code, find a transform which minimizes the difference between corresponding features in both images. This code is completely model independent and is the core algorithms.
[ "Using", "abstracted", "code", "find", "a", "transform", "which", "minimizes", "the", "difference", "between", "corresponding", "features", "in", "both", "images", ".", "This", "code", "is", "completely", "model", "independent", "and", "is", "the", "core", "algo...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/geometry/ExampleImageStitching.java#L82-L122
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/geometry/ExampleImageStitching.java
ExampleImageStitching.stitch
public static <T extends ImageGray<T>> void stitch( BufferedImage imageA , BufferedImage imageB , Class<T> imageType ) { T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType); T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType); // Detect using the standard SURF feature descriptor and describer DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable( new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null,null, imageType); ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class,true); AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer,2,true); // fit the images using a homography. This works well for rotations and distant objects. ModelMatcher<Homography2D_F64,AssociatedPair> modelMatcher = FactoryMultiViewRobust.homographyRansac(null,new ConfigRansac(60,3)); Homography2D_F64 H = computeTransform(inputA, inputB, detDesc, associate, modelMatcher); renderStitching(imageA,imageB,H); }
java
public static <T extends ImageGray<T>> void stitch( BufferedImage imageA , BufferedImage imageB , Class<T> imageType ) { T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType); T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType); // Detect using the standard SURF feature descriptor and describer DetectDescribePoint detDesc = FactoryDetectDescribe.surfStable( new ConfigFastHessian(1, 2, 200, 1, 9, 4, 4), null,null, imageType); ScoreAssociation<BrightFeature> scorer = FactoryAssociation.scoreEuclidean(BrightFeature.class,true); AssociateDescription<BrightFeature> associate = FactoryAssociation.greedy(scorer,2,true); // fit the images using a homography. This works well for rotations and distant objects. ModelMatcher<Homography2D_F64,AssociatedPair> modelMatcher = FactoryMultiViewRobust.homographyRansac(null,new ConfigRansac(60,3)); Homography2D_F64 H = computeTransform(inputA, inputB, detDesc, associate, modelMatcher); renderStitching(imageA,imageB,H); }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "void", "stitch", "(", "BufferedImage", "imageA", ",", "BufferedImage", "imageB", ",", "Class", "<", "T", ">", "imageType", ")", "{", "T", "inputA", "=", "ConvertBufferedImage", ".",...
Given two input images create and display an image where the two have been overlayed on top of each other.
[ "Given", "two", "input", "images", "create", "and", "display", "an", "image", "where", "the", "two", "have", "been", "overlayed", "on", "top", "of", "each", "other", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/geometry/ExampleImageStitching.java#L144-L163
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/d3/DisparityToColorPointCloud.java
DisparityToColorPointCloud.configure
public void configure(double baseline, DMatrixRMaj K, DMatrixRMaj rectifiedR, Point2Transform2_F64 rectifiedToColor, int minDisparity, int maxDisparity) { this.K = K; ConvertMatrixData.convert(rectifiedR,this.rectifiedR); this.rectifiedToColor = rectifiedToColor; this.baseline = (float)baseline; this.focalLengthX = (float)K.get(0,0); this.focalLengthY = (float)K.get(1,1); this.centerX = (float)K.get(0,2); this.centerY = (float)K.get(1,2); this.minDisparity = minDisparity; this.rangeDisparity = maxDisparity-minDisparity; }
java
public void configure(double baseline, DMatrixRMaj K, DMatrixRMaj rectifiedR, Point2Transform2_F64 rectifiedToColor, int minDisparity, int maxDisparity) { this.K = K; ConvertMatrixData.convert(rectifiedR,this.rectifiedR); this.rectifiedToColor = rectifiedToColor; this.baseline = (float)baseline; this.focalLengthX = (float)K.get(0,0); this.focalLengthY = (float)K.get(1,1); this.centerX = (float)K.get(0,2); this.centerY = (float)K.get(1,2); this.minDisparity = minDisparity; this.rangeDisparity = maxDisparity-minDisparity; }
[ "public", "void", "configure", "(", "double", "baseline", ",", "DMatrixRMaj", "K", ",", "DMatrixRMaj", "rectifiedR", ",", "Point2Transform2_F64", "rectifiedToColor", ",", "int", "minDisparity", ",", "int", "maxDisparity", ")", "{", "this", ".", "K", "=", "K", ...
Stereo and intrinsic camera parameters @param baseline Stereo baseline (world units) @param K Intrinsic camera calibration matrix of rectified camera @param rectifiedToColor Transform from rectified pixels to the color image pixels. @param minDisparity Minimum disparity that's computed (pixels) @param maxDisparity Maximum disparity that's computed (pixels)
[ "Stereo", "and", "intrinsic", "camera", "parameters" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/d3/DisparityToColorPointCloud.java#L93-L108
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/d3/DisparityToColorPointCloud.java
DisparityToColorPointCloud.process
public void process(ImageGray disparity , BufferedImage color ) { cloudRgb.setMaxSize(disparity.width*disparity.height); cloudXyz.setMaxSize(disparity.width*disparity.height*3); cloudRgb.reset(); cloudXyz.reset(); if( disparity instanceof GrayU8) process((GrayU8)disparity,color); else process((GrayF32)disparity,color); }
java
public void process(ImageGray disparity , BufferedImage color ) { cloudRgb.setMaxSize(disparity.width*disparity.height); cloudXyz.setMaxSize(disparity.width*disparity.height*3); cloudRgb.reset(); cloudXyz.reset(); if( disparity instanceof GrayU8) process((GrayU8)disparity,color); else process((GrayF32)disparity,color); }
[ "public", "void", "process", "(", "ImageGray", "disparity", ",", "BufferedImage", "color", ")", "{", "cloudRgb", ".", "setMaxSize", "(", "disparity", ".", "width", "*", "disparity", ".", "height", ")", ";", "cloudXyz", ".", "setMaxSize", "(", "disparity", "....
Given the disparity image compute the 3D location of valid points and save pixel colors at that point @param disparity Disparity image @param color Color image of left camera
[ "Given", "the", "disparity", "image", "compute", "the", "3D", "location", "of", "valid", "points", "and", "save", "pixel", "colors", "at", "that", "point" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/d3/DisparityToColorPointCloud.java#L117-L127
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/feature/detect/ImageCorruptPanel.java
ImageCorruptPanel.corruptImage
public <T extends ImageGray<T>> void corruptImage(T original , T corrupted ) { GGrayImageOps.stretch(original, valueScale, valueOffset, 255.0, corrupted); GImageMiscOps.addGaussian(corrupted, rand, valueNoise, 0, 255); GPixelMath.boundImage(corrupted,0,255); }
java
public <T extends ImageGray<T>> void corruptImage(T original , T corrupted ) { GGrayImageOps.stretch(original, valueScale, valueOffset, 255.0, corrupted); GImageMiscOps.addGaussian(corrupted, rand, valueNoise, 0, 255); GPixelMath.boundImage(corrupted,0,255); }
[ "public", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "void", "corruptImage", "(", "T", "original", ",", "T", "corrupted", ")", "{", "GGrayImageOps", ".", "stretch", "(", "original", ",", "valueScale", ",", "valueOffset", ",", "255.0", ",", "co...
Applies the specified corruption to the image. @param original Original uncorrupted image. @param corrupted Corrupted mage.
[ "Applies", "the", "specified", "corruption", "to", "the", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/feature/detect/ImageCorruptPanel.java#L95-L100
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/h/AdjustHomographyMatrix.java
AdjustHomographyMatrix.findScaleH
protected boolean findScaleH( DMatrixRMaj H ) { if( !svd.decompose(H) ) return false; Arrays.sort(svd.getSingularValues(), 0, 3); double scale = svd.getSingularValues()[1]; CommonOps_DDRM.divide(H,scale); return true; }
java
protected boolean findScaleH( DMatrixRMaj H ) { if( !svd.decompose(H) ) return false; Arrays.sort(svd.getSingularValues(), 0, 3); double scale = svd.getSingularValues()[1]; CommonOps_DDRM.divide(H,scale); return true; }
[ "protected", "boolean", "findScaleH", "(", "DMatrixRMaj", "H", ")", "{", "if", "(", "!", "svd", ".", "decompose", "(", "H", ")", ")", "return", "false", ";", "Arrays", ".", "sort", "(", "svd", ".", "getSingularValues", "(", ")", ",", "0", ",", "3", ...
The scale of H is found by computing the second smallest singular value.
[ "The", "scale", "of", "H", "is", "found", "by", "computing", "the", "second", "smallest", "singular", "value", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/h/AdjustHomographyMatrix.java#L66-L76
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/transform/wavelet/impl/ImplWaveletTransformNaive.java
ImplWaveletTransformNaive.vertical
public static void vertical(BorderIndex1D border , WlCoef_I32 coefficients , GrayI input , GrayI output ) { UtilWavelet.checkShape(input,output); final int offsetA = coefficients.offsetScaling; final int offsetB = coefficients.offsetWavelet; final int[] alpha = coefficients.scaling; final int[] beta = coefficients.wavelet; border.setLength(input.height+input.height%2); boolean isLarger = output.height > input.height; for( int x = 0; x < input.width; x++) { for( int y = 0; y < input.height; y += 2 ) { int scale = 0; int wavelet = 0; for( int i = 0; i < alpha.length; i++ ) { int yy = border.getIndex(y+i+offsetA); if( isLarger && yy >= input.height ) continue; scale += input.get(x,yy)*alpha[i]; } for( int i = 0; i < beta.length; i++ ) { int yy = border.getIndex(y+i+offsetB); if( isLarger && yy >= input.height ) continue; wavelet += input.get(x,yy)*beta[i]; } int outY = y/2; scale = 2*scale/coefficients.denominatorScaling; wavelet = 2*wavelet/coefficients.denominatorWavelet; output.set(x , outY,scale); output.set(x , output.height/2 + outY , wavelet ); } } }
java
public static void vertical(BorderIndex1D border , WlCoef_I32 coefficients , GrayI input , GrayI output ) { UtilWavelet.checkShape(input,output); final int offsetA = coefficients.offsetScaling; final int offsetB = coefficients.offsetWavelet; final int[] alpha = coefficients.scaling; final int[] beta = coefficients.wavelet; border.setLength(input.height+input.height%2); boolean isLarger = output.height > input.height; for( int x = 0; x < input.width; x++) { for( int y = 0; y < input.height; y += 2 ) { int scale = 0; int wavelet = 0; for( int i = 0; i < alpha.length; i++ ) { int yy = border.getIndex(y+i+offsetA); if( isLarger && yy >= input.height ) continue; scale += input.get(x,yy)*alpha[i]; } for( int i = 0; i < beta.length; i++ ) { int yy = border.getIndex(y+i+offsetB); if( isLarger && yy >= input.height ) continue; wavelet += input.get(x,yy)*beta[i]; } int outY = y/2; scale = 2*scale/coefficients.denominatorScaling; wavelet = 2*wavelet/coefficients.denominatorWavelet; output.set(x , outY,scale); output.set(x , output.height/2 + outY , wavelet ); } } }
[ "public", "static", "void", "vertical", "(", "BorderIndex1D", "border", ",", "WlCoef_I32", "coefficients", ",", "GrayI", "input", ",", "GrayI", "output", ")", "{", "UtilWavelet", ".", "checkShape", "(", "input", ",", "output", ")", ";", "final", "int", "offs...
Performs a single level wavelet transform along the vertical axis. @param coefficients Description of wavelet coefficients. @param input Input image which is being transform. Not modified. @param output where the output is written to. Modified
[ "Performs", "a", "single", "level", "wavelet", "transform", "along", "the", "vertical", "axis", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/wavelet/impl/ImplWaveletTransformNaive.java#L341-L382
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/filter/convolve/FactoryConvolve.java
FactoryConvolve.convolve
public static <Input extends ImageBase<Input>, Output extends ImageBase<Output>> ConvolveInterface<Input,Output> convolve(Kernel1D kernel, ImageType<Input> inputType, ImageType<Output> outputType , BorderType border , boolean isHorizontal ) { if( inputType.getFamily() != ImageType.Family.GRAY ) throw new IllegalArgumentException("Currently only gray scale image supported"); Class _inputType = inputType.getImageClass(); Class _outputType = outputType == null ? null : outputType.getImageClass(); _outputType = BoofTesting.convertToGenericType(_outputType); Class<?> borderClassType = FactoryImageBorder.lookupBorderClassType(_inputType); String direction = isHorizontal ? "horizontal" : "vertical"; Method m; try { switch( border ) { case SKIP: m = ConvolveImageNoBorder.class.getMethod(direction, kernel.getClass(), _inputType, _outputType); break; case EXTENDED: m = BoofTesting.findMethod(ConvolveImage.class,direction,kernel.getClass(),_inputType,_outputType,borderClassType); break; case REFLECT: m = BoofTesting.findMethod(ConvolveImage.class,direction,kernel.getClass(),_inputType,_outputType,borderClassType); break; case WRAP: m = BoofTesting.findMethod(ConvolveImage.class,direction,kernel.getClass(),_inputType,_outputType,borderClassType); break; case NORMALIZED: m = ConvolveImageNormalized.class.getMethod(direction,kernel.getClass(),_inputType,_outputType); break; default: throw new IllegalArgumentException("Unknown border type "+border); } } catch (NoSuchMethodException e) { throw new IllegalArgumentException("The specified convolution cannot be found"); } return new GenericConvolve<>(m, kernel, border, inputType, outputType); }
java
public static <Input extends ImageBase<Input>, Output extends ImageBase<Output>> ConvolveInterface<Input,Output> convolve(Kernel1D kernel, ImageType<Input> inputType, ImageType<Output> outputType , BorderType border , boolean isHorizontal ) { if( inputType.getFamily() != ImageType.Family.GRAY ) throw new IllegalArgumentException("Currently only gray scale image supported"); Class _inputType = inputType.getImageClass(); Class _outputType = outputType == null ? null : outputType.getImageClass(); _outputType = BoofTesting.convertToGenericType(_outputType); Class<?> borderClassType = FactoryImageBorder.lookupBorderClassType(_inputType); String direction = isHorizontal ? "horizontal" : "vertical"; Method m; try { switch( border ) { case SKIP: m = ConvolveImageNoBorder.class.getMethod(direction, kernel.getClass(), _inputType, _outputType); break; case EXTENDED: m = BoofTesting.findMethod(ConvolveImage.class,direction,kernel.getClass(),_inputType,_outputType,borderClassType); break; case REFLECT: m = BoofTesting.findMethod(ConvolveImage.class,direction,kernel.getClass(),_inputType,_outputType,borderClassType); break; case WRAP: m = BoofTesting.findMethod(ConvolveImage.class,direction,kernel.getClass(),_inputType,_outputType,borderClassType); break; case NORMALIZED: m = ConvolveImageNormalized.class.getMethod(direction,kernel.getClass(),_inputType,_outputType); break; default: throw new IllegalArgumentException("Unknown border type "+border); } } catch (NoSuchMethodException e) { throw new IllegalArgumentException("The specified convolution cannot be found"); } return new GenericConvolve<>(m, kernel, border, inputType, outputType); }
[ "public", "static", "<", "Input", "extends", "ImageBase", "<", "Input", ">", ",", "Output", "extends", "ImageBase", "<", "Output", ">", ">", "ConvolveInterface", "<", "Input", ",", "Output", ">", "convolve", "(", "Kernel1D", "kernel", ",", "ImageType", "<", ...
Creates a filter for convolving 1D kernels along the image. @param kernel Convolution kernel. @param inputType Specifies input image type. @param outputType Specifies input image type. @param border How the image border is handled. @return FilterInterface which will perform the specified convolution.
[ "Creates", "a", "filter", "for", "convolving", "1D", "kernels", "along", "the", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/convolve/FactoryConvolve.java#L53-L99
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/LensDistortionOps.java
LensDistortionOps.changeCameraModel
public static <T extends ImageBase<T>,O extends CameraPinhole, D extends CameraPinhole> ImageDistort<T,T> changeCameraModel(AdjustmentType type, BorderType borderType, O original, D desired, D modified, ImageType<T> imageType) { Class bandType = imageType.getImageClass(); boolean skip = borderType == BorderType.SKIP; // it has to process the border at some point, so if skip is requested just skip stuff truly outside the image if( skip ) borderType = BorderType.EXTENDED; InterpolatePixelS interp = FactoryInterpolation.createPixelS(0, 255, InterpolationType.BILINEAR,borderType, bandType); Point2Transform2_F32 undistToDist = LensDistortionOps_F32.transformChangeModel(type, original, desired, true, modified); ImageDistort<T,T> distort = FactoryDistort.distort(true, interp, imageType); distort.setModel(new PointToPixelTransform_F32(undistToDist)); distort.setRenderAll(!skip ); return distort; }
java
public static <T extends ImageBase<T>,O extends CameraPinhole, D extends CameraPinhole> ImageDistort<T,T> changeCameraModel(AdjustmentType type, BorderType borderType, O original, D desired, D modified, ImageType<T> imageType) { Class bandType = imageType.getImageClass(); boolean skip = borderType == BorderType.SKIP; // it has to process the border at some point, so if skip is requested just skip stuff truly outside the image if( skip ) borderType = BorderType.EXTENDED; InterpolatePixelS interp = FactoryInterpolation.createPixelS(0, 255, InterpolationType.BILINEAR,borderType, bandType); Point2Transform2_F32 undistToDist = LensDistortionOps_F32.transformChangeModel(type, original, desired, true, modified); ImageDistort<T,T> distort = FactoryDistort.distort(true, interp, imageType); distort.setModel(new PointToPixelTransform_F32(undistToDist)); distort.setRenderAll(!skip ); return distort; }
[ "public", "static", "<", "T", "extends", "ImageBase", "<", "T", ">", ",", "O", "extends", "CameraPinhole", ",", "D", "extends", "CameraPinhole", ">", "ImageDistort", "<", "T", ",", "T", ">", "changeCameraModel", "(", "AdjustmentType", "type", ",", "BorderTyp...
Creates a distortion for modifying the input image from one camera model into another camera model. If requested the camera model can be further modified to ensure certain visibility requirements are meet and the adjusted camera model will be returned. @param type How it should modify the image model to ensure visibility of pixels. @param borderType How the image border is handled @param original The original camera model @param desired The desired camera model @param modified (Optional) The desired camera model after being rescaled. Can be null. @param imageType Type of image. @return Image distortion from original camera model to the modified one.
[ "Creates", "a", "distortion", "for", "modifying", "the", "input", "image", "from", "one", "camera", "model", "into", "another", "camera", "model", ".", "If", "requested", "the", "camera", "model", "can", "be", "further", "modified", "to", "ensure", "certain", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/LensDistortionOps.java#L53-L77
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/impl/ImplBinaryNaiveOps.java
ImplBinaryNaiveOps.getT
public static boolean getT(GrayU8 image, int x, int y) { if (image.isInBounds(x, y)) { return image.get(x, y) != 0; } else { return true; } }
java
public static boolean getT(GrayU8 image, int x, int y) { if (image.isInBounds(x, y)) { return image.get(x, y) != 0; } else { return true; } }
[ "public", "static", "boolean", "getT", "(", "GrayU8", "image", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "image", ".", "isInBounds", "(", "x", ",", "y", ")", ")", "{", "return", "image", ".", "get", "(", "x", ",", "y", ")", "!=", ...
If a point is inside the image true is returned if its value is not zero, otherwise true is returned.
[ "If", "a", "point", "is", "inside", "the", "image", "true", "is", "returned", "if", "its", "value", "is", "not", "zero", "otherwise", "true", "is", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/impl/ImplBinaryNaiveOps.java#L183-L189
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/impl/ImplBinaryNaiveOps.java
ImplBinaryNaiveOps.getF
public static boolean getF(GrayU8 image, int x, int y) { if (image.isInBounds(x, y)) { return image.get(x, y) != 0; } else { return false; } }
java
public static boolean getF(GrayU8 image, int x, int y) { if (image.isInBounds(x, y)) { return image.get(x, y) != 0; } else { return false; } }
[ "public", "static", "boolean", "getF", "(", "GrayU8", "image", ",", "int", "x", ",", "int", "y", ")", "{", "if", "(", "image", ".", "isInBounds", "(", "x", ",", "y", ")", ")", "{", "return", "image", ".", "get", "(", "x", ",", "y", ")", "!=", ...
If a point is inside the image true is returned if its value is not zero, otherwise false is returned.
[ "If", "a", "point", "is", "inside", "the", "image", "true", "is", "returned", "if", "its", "value", "is", "not", "zero", "otherwise", "false", "is", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/impl/ImplBinaryNaiveOps.java#L194-L200
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java
ChessboardCornerClusterToGrid.convert
public boolean convert( ChessboardCornerGraph cluster , GridInfo info ) { // default to an invalid value to ensure a failure doesn't go unnoticed. info.reset(); // Get the edges in a consistent order if( !orderEdges(cluster) ) return false; // Now we need to order the nodes into a proper grid which follows right hand rule if( !orderNodes(cluster.corners,info) ) return false; // select a valid corner to be (0,0). If there are multiple options select the one which is int corner = selectCorner(info); if( corner == -1 ) { if( verbose != null) verbose.println("Failed to find valid corner."); return false; } // rotate the grid until the select corner is at (0,0) for (int i = 0; i < corner; i++) { rotateCCW(info); } return true; }
java
public boolean convert( ChessboardCornerGraph cluster , GridInfo info ) { // default to an invalid value to ensure a failure doesn't go unnoticed. info.reset(); // Get the edges in a consistent order if( !orderEdges(cluster) ) return false; // Now we need to order the nodes into a proper grid which follows right hand rule if( !orderNodes(cluster.corners,info) ) return false; // select a valid corner to be (0,0). If there are multiple options select the one which is int corner = selectCorner(info); if( corner == -1 ) { if( verbose != null) verbose.println("Failed to find valid corner."); return false; } // rotate the grid until the select corner is at (0,0) for (int i = 0; i < corner; i++) { rotateCCW(info); } return true; }
[ "public", "boolean", "convert", "(", "ChessboardCornerGraph", "cluster", ",", "GridInfo", "info", ")", "{", "// default to an invalid value to ensure a failure doesn't go unnoticed.", "info", ".", "reset", "(", ")", ";", "// Get the edges in a consistent order", "if", "(", ...
Puts cluster nodes into grid order and computes the number of rows and columns. If the cluster is not a complete grid this function will fail and return false @param cluster (Input) cluster. Edge order will be modified. @param info (Output) Contains ordered nodes and the grid's size. @return true if successful or false if it failed
[ "Puts", "cluster", "nodes", "into", "grid", "order", "and", "computes", "the", "number", "of", "rows", "and", "columns", ".", "If", "the", "cluster", "is", "not", "a", "complete", "grid", "this", "function", "will", "fail", "and", "return", "false" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java#L79-L103
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java
ChessboardCornerClusterToGrid.selectCorner
int selectCorner( GridInfo info ) { info.lookupGridCorners(cornerList); int bestCorner = -1; double bestScore = Double.MAX_VALUE; boolean bestIsCornerSquare = false; for (int i = 0; i < cornerList.size(); i++) { Node n = cornerList.get(i); boolean corner = isCornerValidOrigin(n); // If there are no corner points which are valid corners, then any corner can be the origin if // allowNoCorner is true if( corner || (allowNoCorner && !bestIsCornerSquare) ) { // sanity check the shape if( checkShape != null ) { if( i%2==0 ) { if( !checkShape.isValidShape(info.rows,info.cols)) { continue; } } else { if( !checkShape.isValidShape(info.cols,info.rows)) { continue; } } } // If the distance is to (0,0) pixel is smaller or this is a corner square and the other best // is not a corner square double distance = n.normSq(); if( distance < bestScore || (!bestIsCornerSquare && corner )) { bestIsCornerSquare |= corner; bestScore = distance; bestCorner = i; } } } info.hasCornerSquare = bestIsCornerSquare; return bestCorner; }
java
int selectCorner( GridInfo info ) { info.lookupGridCorners(cornerList); int bestCorner = -1; double bestScore = Double.MAX_VALUE; boolean bestIsCornerSquare = false; for (int i = 0; i < cornerList.size(); i++) { Node n = cornerList.get(i); boolean corner = isCornerValidOrigin(n); // If there are no corner points which are valid corners, then any corner can be the origin if // allowNoCorner is true if( corner || (allowNoCorner && !bestIsCornerSquare) ) { // sanity check the shape if( checkShape != null ) { if( i%2==0 ) { if( !checkShape.isValidShape(info.rows,info.cols)) { continue; } } else { if( !checkShape.isValidShape(info.cols,info.rows)) { continue; } } } // If the distance is to (0,0) pixel is smaller or this is a corner square and the other best // is not a corner square double distance = n.normSq(); if( distance < bestScore || (!bestIsCornerSquare && corner )) { bestIsCornerSquare |= corner; bestScore = distance; bestCorner = i; } } } info.hasCornerSquare = bestIsCornerSquare; return bestCorner; }
[ "int", "selectCorner", "(", "GridInfo", "info", ")", "{", "info", ".", "lookupGridCorners", "(", "cornerList", ")", ";", "int", "bestCorner", "=", "-", "1", ";", "double", "bestScore", "=", "Double", ".", "MAX_VALUE", ";", "boolean", "bestIsCornerSquare", "=...
Selects a corner to be the grid's origin. 0 = top-left, 1 = top-right, 2 = bottom-right, 3 = bottom-left. Looks at each grid and see if it can be valid. Out of the valid list
[ "Selects", "a", "corner", "to", "be", "the", "grid", "s", "origin", ".", "0", "=", "top", "-", "left", "1", "=", "top", "-", "right", "2", "=", "bottom", "-", "right", "3", "=", "bottom", "-", "left", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java#L110-L151
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java
ChessboardCornerClusterToGrid.orderNodes
boolean orderNodes( FastQueue<Node> corners , GridInfo info ) { // Find a node with just two edges. This is a corner and will be the arbitrary origin in our graph Node seed = null; for (int i = 0; i < corners.size; i++) { Node n = corners.get(i); if( n.countEdges() == 2 ) { seed = n; break; } } if( seed == null ) { if( verbose != null ) verbose.println("Can't find a corner with just two edges. Aborting"); return false; } // find one edge and mark that as the row direction int rowEdge = 0; while( seed.edges[rowEdge] == null ) rowEdge = (rowEdge+1)%4; int colEdge = (rowEdge+1)%4; while( seed.edges[colEdge] == null ) colEdge = (colEdge+2)%4; // if it's left handed swap the row and column direction if( !isRightHanded(seed,rowEdge,colEdge)) { int tmp = rowEdge; rowEdge = colEdge; colEdge = tmp; } // add the corns to list in a row major order while( seed != null ) { int before = info.nodes.size(); Node n = seed; do { info.nodes.add(n); n = n.edges[colEdge]; } while( n != null ); seed = seed.edges[rowEdge]; if( info.cols == -1 ) { info.cols = info.nodes.size(); } else { int columnsInRow = info.nodes.size()-before; if( columnsInRow != info.cols ) { if( verbose != null ) verbose.println("Number of columns in each row is variable"); return false; } } } info.rows = info.nodes.size()/info.cols; return true; }
java
boolean orderNodes( FastQueue<Node> corners , GridInfo info ) { // Find a node with just two edges. This is a corner and will be the arbitrary origin in our graph Node seed = null; for (int i = 0; i < corners.size; i++) { Node n = corners.get(i); if( n.countEdges() == 2 ) { seed = n; break; } } if( seed == null ) { if( verbose != null ) verbose.println("Can't find a corner with just two edges. Aborting"); return false; } // find one edge and mark that as the row direction int rowEdge = 0; while( seed.edges[rowEdge] == null ) rowEdge = (rowEdge+1)%4; int colEdge = (rowEdge+1)%4; while( seed.edges[colEdge] == null ) colEdge = (colEdge+2)%4; // if it's left handed swap the row and column direction if( !isRightHanded(seed,rowEdge,colEdge)) { int tmp = rowEdge; rowEdge = colEdge; colEdge = tmp; } // add the corns to list in a row major order while( seed != null ) { int before = info.nodes.size(); Node n = seed; do { info.nodes.add(n); n = n.edges[colEdge]; } while( n != null ); seed = seed.edges[rowEdge]; if( info.cols == -1 ) { info.cols = info.nodes.size(); } else { int columnsInRow = info.nodes.size()-before; if( columnsInRow != info.cols ) { if( verbose != null ) verbose.println("Number of columns in each row is variable"); return false; } } } info.rows = info.nodes.size()/info.cols; return true; }
[ "boolean", "orderNodes", "(", "FastQueue", "<", "Node", ">", "corners", ",", "GridInfo", "info", ")", "{", "// Find a node with just two edges. This is a corner and will be the arbitrary origin in our graph", "Node", "seed", "=", "null", ";", "for", "(", "int", "i", "="...
Put corners into a proper grid. Make sure its a rectangular grid or else return false. Rows and columns are selected to ensure right hand rule.
[ "Put", "corners", "into", "a", "proper", "grid", ".", "Make", "sure", "its", "a", "rectangular", "grid", "or", "else", "return", "false", ".", "Rows", "and", "columns", "are", "selected", "to", "ensure", "right", "hand", "rule", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java#L182-L236
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java
ChessboardCornerClusterToGrid.isRightHanded
static boolean isRightHanded( Node seed , int idxRow , int idxCol ) { Node r = seed.edges[idxRow]; Node c = seed.edges[idxCol]; double dirRow = Math.atan2(r.y-seed.y,r.x-seed.x); double dirCol = Math.atan2(c.y-seed.y,c.x-seed.x); return UtilAngle.distanceCW(dirRow,dirCol) < Math.PI; }
java
static boolean isRightHanded( Node seed , int idxRow , int idxCol ) { Node r = seed.edges[idxRow]; Node c = seed.edges[idxCol]; double dirRow = Math.atan2(r.y-seed.y,r.x-seed.x); double dirCol = Math.atan2(c.y-seed.y,c.x-seed.x); return UtilAngle.distanceCW(dirRow,dirCol) < Math.PI; }
[ "static", "boolean", "isRightHanded", "(", "Node", "seed", ",", "int", "idxRow", ",", "int", "idxCol", ")", "{", "Node", "r", "=", "seed", ".", "edges", "[", "idxRow", "]", ";", "Node", "c", "=", "seed", ".", "edges", "[", "idxCol", "]", ";", "doub...
Checks to see if the rows and columns for a coordinate system which is right handed @param idxRow Index for moving up a row @param idxCol index for moving up a column
[ "Checks", "to", "see", "if", "the", "rows", "and", "columns", "for", "a", "coordinate", "system", "which", "is", "right", "handed" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java#L244-L252
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java
ChessboardCornerClusterToGrid.sortEdgesCCW
void sortEdgesCCW(FastQueue<Node> corners) { for (int nodeIdx = 0; nodeIdx < corners.size; nodeIdx++) { Node na = corners.get(nodeIdx); // reference node to do angles relative to. double ref = Double.NaN; int count = 0; for (int i = 0; i < 4; i++) { order[i] = i; tmpEdges[i] = na.edges[i]; if( na.edges[i] == null ) { directions[i] = Double.MAX_VALUE; } else { Node nb = na.edges[i]; double angleB = Math.atan2(nb.y-na.y,nb.x-na.x); if( Double.isNaN(ref) ) { ref = angleB; directions[i] = 0; } else { directions[i] = UtilAngle.distanceCCW(ref,angleB); } count++; } } sorter.sort(directions,0,4,order); for (int i = 0; i < 4; i++) { na.edges[i] = tmpEdges[ order[i] ]; } if( count == 2 ) { // If there are only two then we define the order to be defined by the one which minimizes // CCW direction if( directions[order[1]] > Math.PI ) { na.edges[0] = tmpEdges[ order[1] ]; na.edges[1] = tmpEdges[ order[0] ]; } else { na.edges[0] = tmpEdges[ order[0] ]; na.edges[1] = tmpEdges[ order[1] ]; } } else if( count == 3 ) { // Edges need to point along the 4 possible directions, in the case of 3 edges, there might // need to be a gap at a different location than at the end int selected = -1; double largestAngle = 0; for (int i = 0,j=2; i < 3; j=i,i++) { double ccw = UtilAngle.distanceCCW(directions[order[j]],directions[order[i]]); if( ccw > largestAngle ) { largestAngle = ccw; selected = j; } } for (int i = 2; i > selected; i--) { na.edges[i+1] = na.edges[i]; } na.edges[selected+1]=null; } } }
java
void sortEdgesCCW(FastQueue<Node> corners) { for (int nodeIdx = 0; nodeIdx < corners.size; nodeIdx++) { Node na = corners.get(nodeIdx); // reference node to do angles relative to. double ref = Double.NaN; int count = 0; for (int i = 0; i < 4; i++) { order[i] = i; tmpEdges[i] = na.edges[i]; if( na.edges[i] == null ) { directions[i] = Double.MAX_VALUE; } else { Node nb = na.edges[i]; double angleB = Math.atan2(nb.y-na.y,nb.x-na.x); if( Double.isNaN(ref) ) { ref = angleB; directions[i] = 0; } else { directions[i] = UtilAngle.distanceCCW(ref,angleB); } count++; } } sorter.sort(directions,0,4,order); for (int i = 0; i < 4; i++) { na.edges[i] = tmpEdges[ order[i] ]; } if( count == 2 ) { // If there are only two then we define the order to be defined by the one which minimizes // CCW direction if( directions[order[1]] > Math.PI ) { na.edges[0] = tmpEdges[ order[1] ]; na.edges[1] = tmpEdges[ order[0] ]; } else { na.edges[0] = tmpEdges[ order[0] ]; na.edges[1] = tmpEdges[ order[1] ]; } } else if( count == 3 ) { // Edges need to point along the 4 possible directions, in the case of 3 edges, there might // need to be a gap at a different location than at the end int selected = -1; double largestAngle = 0; for (int i = 0,j=2; i < 3; j=i,i++) { double ccw = UtilAngle.distanceCCW(directions[order[j]],directions[order[i]]); if( ccw > largestAngle ) { largestAngle = ccw; selected = j; } } for (int i = 2; i > selected; i--) { na.edges[i+1] = na.edges[i]; } na.edges[selected+1]=null; } } }
[ "void", "sortEdgesCCW", "(", "FastQueue", "<", "Node", ">", "corners", ")", "{", "for", "(", "int", "nodeIdx", "=", "0", ";", "nodeIdx", "<", "corners", ".", "size", ";", "nodeIdx", "++", ")", "{", "Node", "na", "=", "corners", ".", "get", "(", "no...
Sorts edges so that they point towards nodes in an increasing counter clockwise direction
[ "Sorts", "edges", "so", "that", "they", "point", "towards", "nodes", "in", "an", "increasing", "counter", "clockwise", "direction" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java#L320-L379
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java
ChessboardCornerClusterToGrid.rotateCCW
public void rotateCCW(GridInfo grid ) { cornerList.clear(); for (int col = 0; col < grid.cols; col++) { for (int row = 0; row < grid.rows; row++) { cornerList.add(grid.get(row,grid.cols - col - 1)); } } int tmp = grid.rows; grid.rows = grid.cols; grid.cols = tmp; grid.nodes.clear(); grid.nodes.addAll(cornerList); }
java
public void rotateCCW(GridInfo grid ) { cornerList.clear(); for (int col = 0; col < grid.cols; col++) { for (int row = 0; row < grid.rows; row++) { cornerList.add(grid.get(row,grid.cols - col - 1)); } } int tmp = grid.rows; grid.rows = grid.cols; grid.cols = tmp; grid.nodes.clear(); grid.nodes.addAll(cornerList); }
[ "public", "void", "rotateCCW", "(", "GridInfo", "grid", ")", "{", "cornerList", ".", "clear", "(", ")", ";", "for", "(", "int", "col", "=", "0", ";", "col", "<", "grid", ".", "cols", ";", "col", "++", ")", "{", "for", "(", "int", "row", "=", "0...
Rotates the grid in the CCW direction
[ "Rotates", "the", "grid", "in", "the", "CCW", "direction" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerClusterToGrid.java#L384-L397
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/StereoProcessingBase.java
StereoProcessingBase.setCalibration
public void setCalibration(StereoParameters stereoParam) { CameraPinholeBrown left = stereoParam.getLeft(); CameraPinholeBrown right = stereoParam.getRight(); // adjust image size imageLeftRect.reshape(left.getWidth(), left.getHeight()); imageRightRect.reshape(right.getWidth(), right.getHeight()); // compute rectification RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated(); Se3_F64 leftToRight = stereoParam.getRightToLeft().invert(null); // original camera calibration matrices DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(left, (DMatrixRMaj)null); DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(right, (DMatrixRMaj)null); rectifyAlg.process(K1,new Se3_F64(),K2,leftToRight); // rectification matrix for each image rect1 = rectifyAlg.getRect1(); rect2 = rectifyAlg.getRect2(); // New calibration and rotation matrix, Both cameras are the same after rectification. rectK = rectifyAlg.getCalibrationMatrix(); rectR = rectifyAlg.getRectifiedRotation(); FMatrixRMaj rect1_F32 = new FMatrixRMaj(3,3); FMatrixRMaj rect2_F32 = new FMatrixRMaj(3,3); ConvertMatrixData.convert(rect1,rect1_F32); ConvertMatrixData.convert(rect2,rect2_F32); ImageType<T> imageType = imageLeftRect.getImageType(); distortLeftRect = RectifyImageOps.rectifyImage(stereoParam.left, rect1_F32, BorderType.SKIP, imageType); distortRightRect = RectifyImageOps.rectifyImage(stereoParam.right, rect2_F32, BorderType.SKIP, imageType); // Compute parameters that are needed when converting to 3D baseline = stereoParam.getBaseline(); fx = rectK.get(0,0); fy = rectK.get(1,1); cx = rectK.get(0,2); cy = rectK.get(1,2); }
java
public void setCalibration(StereoParameters stereoParam) { CameraPinholeBrown left = stereoParam.getLeft(); CameraPinholeBrown right = stereoParam.getRight(); // adjust image size imageLeftRect.reshape(left.getWidth(), left.getHeight()); imageRightRect.reshape(right.getWidth(), right.getHeight()); // compute rectification RectifyCalibrated rectifyAlg = RectifyImageOps.createCalibrated(); Se3_F64 leftToRight = stereoParam.getRightToLeft().invert(null); // original camera calibration matrices DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(left, (DMatrixRMaj)null); DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(right, (DMatrixRMaj)null); rectifyAlg.process(K1,new Se3_F64(),K2,leftToRight); // rectification matrix for each image rect1 = rectifyAlg.getRect1(); rect2 = rectifyAlg.getRect2(); // New calibration and rotation matrix, Both cameras are the same after rectification. rectK = rectifyAlg.getCalibrationMatrix(); rectR = rectifyAlg.getRectifiedRotation(); FMatrixRMaj rect1_F32 = new FMatrixRMaj(3,3); FMatrixRMaj rect2_F32 = new FMatrixRMaj(3,3); ConvertMatrixData.convert(rect1,rect1_F32); ConvertMatrixData.convert(rect2,rect2_F32); ImageType<T> imageType = imageLeftRect.getImageType(); distortLeftRect = RectifyImageOps.rectifyImage(stereoParam.left, rect1_F32, BorderType.SKIP, imageType); distortRightRect = RectifyImageOps.rectifyImage(stereoParam.right, rect2_F32, BorderType.SKIP, imageType); // Compute parameters that are needed when converting to 3D baseline = stereoParam.getBaseline(); fx = rectK.get(0,0); fy = rectK.get(1,1); cx = rectK.get(0,2); cy = rectK.get(1,2); }
[ "public", "void", "setCalibration", "(", "StereoParameters", "stereoParam", ")", "{", "CameraPinholeBrown", "left", "=", "stereoParam", ".", "getLeft", "(", ")", ";", "CameraPinholeBrown", "right", "=", "stereoParam", ".", "getRight", "(", ")", ";", "// adjust ima...
Specifies stereo parameters @param stereoParam stereo parameters
[ "Specifies", "stereo", "parameters" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/StereoProcessingBase.java#L95-L136
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/StereoProcessingBase.java
StereoProcessingBase.computeHomo3D
public void computeHomo3D(double x, double y, Point3D_F64 pointLeft) { // Coordinate in rectified camera frame pointRect.z = baseline*fx; pointRect.x = pointRect.z*(x - cx)/fx; pointRect.y = pointRect.z*(y - cy)/fy; // rotate into the original left camera frame GeometryMath_F64.multTran(rectR,pointRect,pointLeft); }
java
public void computeHomo3D(double x, double y, Point3D_F64 pointLeft) { // Coordinate in rectified camera frame pointRect.z = baseline*fx; pointRect.x = pointRect.z*(x - cx)/fx; pointRect.y = pointRect.z*(y - cy)/fy; // rotate into the original left camera frame GeometryMath_F64.multTran(rectR,pointRect,pointLeft); }
[ "public", "void", "computeHomo3D", "(", "double", "x", ",", "double", "y", ",", "Point3D_F64", "pointLeft", ")", "{", "// Coordinate in rectified camera frame", "pointRect", ".", "z", "=", "baseline", "*", "fx", ";", "pointRect", ".", "x", "=", "pointRect", "....
Given a coordinate of a point in the left rectified frame, compute the point's 3D coordinate in the camera's reference frame in homogeneous coordinates. To convert the coordinate into normal 3D, divide each element by the disparity. @param x x-coordinate of pixel in rectified left image @param y y-coordinate of pixel in rectified left image @param pointLeft Storage for 3D coordinate of point in homogeneous coordinates. w = disparity
[ "Given", "a", "coordinate", "of", "a", "point", "in", "the", "left", "rectified", "frame", "compute", "the", "point", "s", "3D", "coordinate", "in", "the", "camera", "s", "reference", "frame", "in", "homogeneous", "coordinates", ".", "To", "convert", "the", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/StereoProcessingBase.java#L147-L155
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/GIntegralImageOps.java
GIntegralImageOps.getIntegralType
public static <I extends ImageGray<I>, II extends ImageGray<II>> Class<II> getIntegralType( Class<I> inputType ) { if( inputType == GrayF32.class ) { return (Class<II>)GrayF32.class; } else if( inputType == GrayU8.class ){ return (Class<II>)GrayS32.class; } else if( inputType == GrayS32.class ){ return (Class<II>)GrayS32.class; } else { throw new IllegalArgumentException("Unknown input image type: "+inputType.getSimpleName()); } }
java
public static <I extends ImageGray<I>, II extends ImageGray<II>> Class<II> getIntegralType( Class<I> inputType ) { if( inputType == GrayF32.class ) { return (Class<II>)GrayF32.class; } else if( inputType == GrayU8.class ){ return (Class<II>)GrayS32.class; } else if( inputType == GrayS32.class ){ return (Class<II>)GrayS32.class; } else { throw new IllegalArgumentException("Unknown input image type: "+inputType.getSimpleName()); } }
[ "public", "static", "<", "I", "extends", "ImageGray", "<", "I", ">", ",", "II", "extends", "ImageGray", "<", "II", ">", ">", "Class", "<", "II", ">", "getIntegralType", "(", "Class", "<", "I", ">", "inputType", ")", "{", "if", "(", "inputType", "==",...
Given the input image, return the type of image the integral image should be.
[ "Given", "the", "input", "image", "return", "the", "type", "of", "image", "the", "integral", "image", "should", "be", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/transform/ii/GIntegralImageOps.java#L35-L46
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FiducialDetectorPnP.java
FiducialDetectorPnP.computeStability
@Override public boolean computeStability(int which, double disturbance, FiducialStability results) { if( !getFiducialToCamera(which, targetToCamera)) return false; stability.setShape(getSideWidth(which), getSideHeight(which)); stability.computeStability(targetToCamera,disturbance,results); return true; }
java
@Override public boolean computeStability(int which, double disturbance, FiducialStability results) { if( !getFiducialToCamera(which, targetToCamera)) return false; stability.setShape(getSideWidth(which), getSideHeight(which)); stability.computeStability(targetToCamera,disturbance,results); return true; }
[ "@", "Override", "public", "boolean", "computeStability", "(", "int", "which", ",", "double", "disturbance", ",", "FiducialStability", "results", ")", "{", "if", "(", "!", "getFiducialToCamera", "(", "which", ",", "targetToCamera", ")", ")", "return", "false", ...
Estimates the stability by perturbing each land mark by the specified number of pixels in the distorted image.
[ "Estimates", "the", "stability", "by", "perturbing", "each", "land", "mark", "by", "the", "specified", "number", "of", "pixels", "in", "the", "distorted", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FiducialDetectorPnP.java#L98-L108
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FiducialDetectorPnP.java
FiducialDetectorPnP.createDetectedList
private void createDetectedList(int which, List<PointIndex2D_F64> pixels) { detected2D3D.clear(); List<Point2D3D> all = getControl3D(which); for (int i = 0; i < pixels.size(); i++) { PointIndex2D_F64 a = pixels.get(i); Point2D3D b = all.get(i); pixelToNorm.compute(a.x,a.y, b.observation); detected2D3D.add( b ); } }
java
private void createDetectedList(int which, List<PointIndex2D_F64> pixels) { detected2D3D.clear(); List<Point2D3D> all = getControl3D(which); for (int i = 0; i < pixels.size(); i++) { PointIndex2D_F64 a = pixels.get(i); Point2D3D b = all.get(i); pixelToNorm.compute(a.x,a.y, b.observation); detected2D3D.add( b ); } }
[ "private", "void", "createDetectedList", "(", "int", "which", ",", "List", "<", "PointIndex2D_F64", ">", "pixels", ")", "{", "detected2D3D", ".", "clear", "(", ")", ";", "List", "<", "Point2D3D", ">", "all", "=", "getControl3D", "(", "which", ")", ";", "...
Create the list of observed points in 2D3D
[ "Create", "the", "list", "of", "observed", "points", "in", "2D3D" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FiducialDetectorPnP.java#L148-L158
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FiducialDetectorPnP.java
FiducialDetectorPnP.estimatePose
protected boolean estimatePose( int which ,List<Point2D3D> points , Se3_F64 fiducialToCamera ) { if( !estimatePnP.process(points, initialEstimate) ) { return false; } filtered.clear(); // Don't bother if there are hardly any points to work with if( points.size() > 6 ) { w2p.configure(lensDistortion, initialEstimate); // compute the error for each point in image pixels errors.reset(); for (int idx = 0; idx < detectedPixels.size(); idx++) { PointIndex2D_F64 foo = detectedPixels.get(idx); w2p.transform(points.get(idx).location, predicted); errors.add(predicted.distance2(foo)); } // compute the prune threshold based on the standard deviation. well variance really double stdev = 0; for (int i = 0; i < errors.size; i++) { stdev += errors.get(i); } // prune points 3 standard deviations away // Don't prune if 3 standard deviations is less than 1.5 pixels since that's about what // you would expect and you might make the solution worse double sigma3 = Math.max(1.5,4 * stdev); for (int i = 0; i < points.size(); i++) { if (errors.get(i) < sigma3) { filtered.add(points.get(i)); } } // recompute pose esitmate without the outliers if (filtered.size() != points.size()) { if (!estimatePnP.process(filtered, initialEstimate)) { return false; } } } else { filtered.addAll(points); } return refinePnP.fitModel(points, initialEstimate, fiducialToCamera); }
java
protected boolean estimatePose( int which ,List<Point2D3D> points , Se3_F64 fiducialToCamera ) { if( !estimatePnP.process(points, initialEstimate) ) { return false; } filtered.clear(); // Don't bother if there are hardly any points to work with if( points.size() > 6 ) { w2p.configure(lensDistortion, initialEstimate); // compute the error for each point in image pixels errors.reset(); for (int idx = 0; idx < detectedPixels.size(); idx++) { PointIndex2D_F64 foo = detectedPixels.get(idx); w2p.transform(points.get(idx).location, predicted); errors.add(predicted.distance2(foo)); } // compute the prune threshold based on the standard deviation. well variance really double stdev = 0; for (int i = 0; i < errors.size; i++) { stdev += errors.get(i); } // prune points 3 standard deviations away // Don't prune if 3 standard deviations is less than 1.5 pixels since that's about what // you would expect and you might make the solution worse double sigma3 = Math.max(1.5,4 * stdev); for (int i = 0; i < points.size(); i++) { if (errors.get(i) < sigma3) { filtered.add(points.get(i)); } } // recompute pose esitmate without the outliers if (filtered.size() != points.size()) { if (!estimatePnP.process(filtered, initialEstimate)) { return false; } } } else { filtered.addAll(points); } return refinePnP.fitModel(points, initialEstimate, fiducialToCamera); }
[ "protected", "boolean", "estimatePose", "(", "int", "which", ",", "List", "<", "Point2D3D", ">", "points", ",", "Se3_F64", "fiducialToCamera", ")", "{", "if", "(", "!", "estimatePnP", ".", "process", "(", "points", ",", "initialEstimate", ")", ")", "{", "r...
Given the mapping of 2D observations to known 3D points estimate the pose of the fiducial. This solves the P-n-P problem. Do a simple form of robust estimation. Prune points which are greater than 3 standard deviations and likely noise the recompute the pose
[ "Given", "the", "mapping", "of", "2D", "observations", "to", "known", "3D", "points", "estimate", "the", "pose", "of", "the", "fiducial", ".", "This", "solves", "the", "P", "-", "n", "-", "P", "problem", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/FiducialDetectorPnP.java#L167-L210
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLineFootOfNorm.java
HoughTransformLineFootOfNorm.transform
public <D extends ImageGray<D>> void transform(D derivX , D derivY , GrayU8 binary ) { InputSanityCheck.checkSameShape(derivX,derivY,binary); transform.reshape(derivX.width,derivY.height); ImageMiscOps.fill(transform,0); originX = derivX.width/2; originY = derivX.height/2; candidates.reset(); if( derivX instanceof GrayF32) _transform((GrayF32)derivX,(GrayF32)derivY,binary); else if( derivX instanceof GrayS16) _transform((GrayS16)derivX,(GrayS16)derivY,binary); else if( derivX instanceof GrayS32) _transform((GrayS32)derivX,(GrayS32)derivY,binary); else throw new IllegalArgumentException("Unsupported derivative image type: "+derivX.getClass().getSimpleName()); }
java
public <D extends ImageGray<D>> void transform(D derivX , D derivY , GrayU8 binary ) { InputSanityCheck.checkSameShape(derivX,derivY,binary); transform.reshape(derivX.width,derivY.height); ImageMiscOps.fill(transform,0); originX = derivX.width/2; originY = derivX.height/2; candidates.reset(); if( derivX instanceof GrayF32) _transform((GrayF32)derivX,(GrayF32)derivY,binary); else if( derivX instanceof GrayS16) _transform((GrayS16)derivX,(GrayS16)derivY,binary); else if( derivX instanceof GrayS32) _transform((GrayS32)derivX,(GrayS32)derivY,binary); else throw new IllegalArgumentException("Unsupported derivative image type: "+derivX.getClass().getSimpleName()); }
[ "public", "<", "D", "extends", "ImageGray", "<", "D", ">", ">", "void", "transform", "(", "D", "derivX", ",", "D", "derivY", ",", "GrayU8", "binary", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "derivX", ",", "derivY", ",", "binary", ")", ...
Computes the Hough transform using the image gradient and a binary image which flags pixels as being edges or not. @param derivX Image derivative along x-axis. @param derivY Image derivative along y-axis. @param binary Non-zero pixels are considered to be line pixels.
[ "Computes", "the", "Hough", "transform", "using", "the", "image", "gradient", "and", "a", "binary", "image", "which", "flags", "pixels", "as", "being", "edges", "or", "not", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLineFootOfNorm.java#L92-L111
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLineFootOfNorm.java
HoughTransformLineFootOfNorm.parameterize
public void parameterize( int x , int y , float derivX , float derivY ) { // put the point in a new coordinate system centered at the image's origin // this minimizes error, which is a function of distance from origin x -= originX; y -= originY; float v = (x*derivX + y*derivY)/(derivX*derivX + derivY*derivY); // finds the foot a line normal equation and put the point into image coordinates int x0 = (int)(v*derivX) + originX; int y0 = (int)(v*derivY) + originY; if( transform.isInBounds(x0,y0)) { int index = transform.startIndex+y0*transform.stride+x0; // keep track of candidate pixels so that a sparse search can be done // to detect lines if( transform.data[index]++ == 1 ) candidates.add(x0,y0); } }
java
public void parameterize( int x , int y , float derivX , float derivY ) { // put the point in a new coordinate system centered at the image's origin // this minimizes error, which is a function of distance from origin x -= originX; y -= originY; float v = (x*derivX + y*derivY)/(derivX*derivX + derivY*derivY); // finds the foot a line normal equation and put the point into image coordinates int x0 = (int)(v*derivX) + originX; int y0 = (int)(v*derivY) + originY; if( transform.isInBounds(x0,y0)) { int index = transform.startIndex+y0*transform.stride+x0; // keep track of candidate pixels so that a sparse search can be done // to detect lines if( transform.data[index]++ == 1 ) candidates.add(x0,y0); } }
[ "public", "void", "parameterize", "(", "int", "x", ",", "int", "y", ",", "float", "derivX", ",", "float", "derivY", ")", "{", "// put the point in a new coordinate system centered at the image's origin", "// this minimizes error, which is a function of distance from origin", "x...
Takes the detected point along the line and its gradient and converts it into transform space. @param x point in image. @param y point in image. @param derivX gradient of point. @param derivY gradient of point.
[ "Takes", "the", "detected", "point", "along", "the", "line", "and", "its", "gradient", "and", "converts", "it", "into", "transform", "space", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLineFootOfNorm.java#L150-L170
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/features/ExampleDenseImageFeatures.java
ExampleDenseImageFeatures.HighLevel
public static void HighLevel( GrayF32 input) { System.out.println("\n------------------- Dense High Level"); DescribeImageDense<GrayF32,TupleDesc_F64> describer = FactoryDescribeImageDense. hog(new ConfigDenseHoG(),input.getImageType()); // sift(new ConfigDenseSift(),GrayF32.class); // surfFast(new ConfigDenseSurfFast(),GrayF32.class); // process the image and compute the dense image features describer.process(input); // print out part of the first few features System.out.println("Total Features = "+describer.getLocations().size()); for (int i = 0; i < 5; i++) { Point2D_I32 p = describer.getLocations().get(i); TupleDesc_F64 d = describer.getDescriptions().get(i); System.out.printf("%3d %3d = [ %f %f %f %f\n",p.x,p.y,d.value[0],d.value[1],d.value[2],d.value[3]); // You would process the feature descriptor here } }
java
public static void HighLevel( GrayF32 input) { System.out.println("\n------------------- Dense High Level"); DescribeImageDense<GrayF32,TupleDesc_F64> describer = FactoryDescribeImageDense. hog(new ConfigDenseHoG(),input.getImageType()); // sift(new ConfigDenseSift(),GrayF32.class); // surfFast(new ConfigDenseSurfFast(),GrayF32.class); // process the image and compute the dense image features describer.process(input); // print out part of the first few features System.out.println("Total Features = "+describer.getLocations().size()); for (int i = 0; i < 5; i++) { Point2D_I32 p = describer.getLocations().get(i); TupleDesc_F64 d = describer.getDescriptions().get(i); System.out.printf("%3d %3d = [ %f %f %f %f\n",p.x,p.y,d.value[0],d.value[1],d.value[2],d.value[3]); // You would process the feature descriptor here } }
[ "public", "static", "void", "HighLevel", "(", "GrayF32", "input", ")", "{", "System", ".", "out", ".", "println", "(", "\"\\n------------------- Dense High Level\"", ")", ";", "DescribeImageDense", "<", "GrayF32", ",", "TupleDesc_F64", ">", "describer", "=", "Fact...
For much larger images you might need to shrink the image down or change the cell size to get good results.
[ "For", "much", "larger", "images", "you", "might", "need", "to", "shrink", "the", "image", "down", "or", "change", "the", "cell", "size", "to", "get", "good", "results", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleDenseImageFeatures.java#L52-L72
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java
StereoDisparityWtoNaiveFive.process
public void process( I left , I right , GrayF32 imageDisparity ) { // check inputs and initialize data structures InputSanityCheck.checkSameShape(left,right,imageDisparity); this.imageLeft = left; this.imageRight = right; w = left.width; h = left.height; // Compute disparity for each pixel for( int y = radiusY*2; y < h-radiusY*2; y++ ) { for( int x = radiusX*2+minDisparity; x < w-radiusX*2; x++ ) { // take in account image border when computing max disparity int max = x-Math.max(radiusX*2-1,x-score.length); // compute match score across all candidates processPixel(x, y, max); // select the best disparity imageDisparity.set(x,y,(float)selectBest(max)); } } }
java
public void process( I left , I right , GrayF32 imageDisparity ) { // check inputs and initialize data structures InputSanityCheck.checkSameShape(left,right,imageDisparity); this.imageLeft = left; this.imageRight = right; w = left.width; h = left.height; // Compute disparity for each pixel for( int y = radiusY*2; y < h-radiusY*2; y++ ) { for( int x = radiusX*2+minDisparity; x < w-radiusX*2; x++ ) { // take in account image border when computing max disparity int max = x-Math.max(radiusX*2-1,x-score.length); // compute match score across all candidates processPixel(x, y, max); // select the best disparity imageDisparity.set(x,y,(float)selectBest(max)); } } }
[ "public", "void", "process", "(", "I", "left", ",", "I", "right", ",", "GrayF32", "imageDisparity", ")", "{", "// check inputs and initialize data structures", "InputSanityCheck", ".", "checkSameShape", "(", "left", ",", "right", ",", "imageDisparity", ")", ";", "...
Computes the disparity for two stereo images along the image's right axis. Both image must be rectified. @param left Left camera image. @param right Right camera image.
[ "Computes", "the", "disparity", "for", "two", "stereo", "images", "along", "the", "image", "s", "right", "axis", ".", "Both", "image", "must", "be", "rectified", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java#L75-L96
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java
StereoDisparityWtoNaiveFive.processPixel
private void processPixel( int c_x , int c_y , int maxDisparity ) { for( int i = minDisparity; i < maxDisparity; i++ ) { score[i] = computeScore( c_x , c_x-i,c_y); } }
java
private void processPixel( int c_x , int c_y , int maxDisparity ) { for( int i = minDisparity; i < maxDisparity; i++ ) { score[i] = computeScore( c_x , c_x-i,c_y); } }
[ "private", "void", "processPixel", "(", "int", "c_x", ",", "int", "c_y", ",", "int", "maxDisparity", ")", "{", "for", "(", "int", "i", "=", "minDisparity", ";", "i", "<", "maxDisparity", ";", "i", "++", ")", "{", "score", "[", "i", "]", "=", "compu...
Computes fit score for each possible disparity @param c_x Center of region on left image. x-axis @param c_y Center of region on left image. y-axis @param maxDisparity Max allowed disparity
[ "Computes", "fit", "score", "for", "each", "possible", "disparity" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java#L105-L110
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java
StereoDisparityWtoNaiveFive.selectBest
protected double selectBest( int length ) { double best = Double.MAX_VALUE; int index = -1; for( int i = minDisparity; i < length; i++ ) { if( score[i] < best ) { best = score[i]; index = i; } } return index-minDisparity; }
java
protected double selectBest( int length ) { double best = Double.MAX_VALUE; int index = -1; for( int i = minDisparity; i < length; i++ ) { if( score[i] < best ) { best = score[i]; index = i; } } return index-minDisparity; }
[ "protected", "double", "selectBest", "(", "int", "length", ")", "{", "double", "best", "=", "Double", ".", "MAX_VALUE", ";", "int", "index", "=", "-", "1", ";", "for", "(", "int", "i", "=", "minDisparity", ";", "i", "<", "length", ";", "i", "++", "...
Select best disparity using the inner takes all approach @param length The max allowed disparity at this pixel @return The best disparity selected.
[ "Select", "best", "disparity", "using", "the", "inner", "takes", "all", "approach" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java#L118-L129
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java
StereoDisparityWtoNaiveFive.computeScore
protected double computeScore( int leftX , int rightX , int centerY ) { double center = computeScoreRect(leftX,rightX,centerY); four[0] = computeScoreRect(leftX-radiusX,rightX-radiusX,centerY-radiusY); four[1] = computeScoreRect(leftX+radiusX,rightX+radiusX,centerY-radiusY); four[2] = computeScoreRect(leftX-radiusX,rightX-radiusX,centerY+radiusY); four[3] = computeScoreRect(leftX+radiusX,rightX+radiusX,centerY+radiusY); Arrays.sort(four); return four[0] + four[1] + center; }
java
protected double computeScore( int leftX , int rightX , int centerY ) { double center = computeScoreRect(leftX,rightX,centerY); four[0] = computeScoreRect(leftX-radiusX,rightX-radiusX,centerY-radiusY); four[1] = computeScoreRect(leftX+radiusX,rightX+radiusX,centerY-radiusY); four[2] = computeScoreRect(leftX-radiusX,rightX-radiusX,centerY+radiusY); four[3] = computeScoreRect(leftX+radiusX,rightX+radiusX,centerY+radiusY); Arrays.sort(four); return four[0] + four[1] + center; }
[ "protected", "double", "computeScore", "(", "int", "leftX", ",", "int", "rightX", ",", "int", "centerY", ")", "{", "double", "center", "=", "computeScoreRect", "(", "leftX", ",", "rightX", ",", "centerY", ")", ";", "four", "[", "0", "]", "=", "computeSco...
Compute the score for five local regions and just use the center + the two best @param leftX X-axis center left image @param rightX X-axis center left image @param centerY Y-axis center for both images @return Fit score for both regions.
[ "Compute", "the", "score", "for", "five", "local", "regions", "and", "just", "use", "the", "center", "+", "the", "two", "best" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/StereoDisparityWtoNaiveFive.java#L139-L150
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeGenerator.java
QrCodeGenerator.render
public void render( QrCode qr ) { initialize(qr); render.init(); positionPattern(0,0, qr.ppCorner); positionPattern((numModules-7)*moduleWidth,0, qr.ppRight); positionPattern(0,(numModules-7)*moduleWidth, qr.ppDown); timingPattern(7*moduleWidth,6*moduleWidth,moduleWidth,0); timingPattern(6*moduleWidth,7*moduleWidth,0,moduleWidth); formatInformation(); if( qr.version >= QrCode.VERSION_ENCODED_AT) versionInformation(); // render alignment patterns int alignment[] = QrCode.VERSION_INFO[qr.version].alignment; for (int i = 0; i < alignment.length; i++) { int row = alignment[i]; for (int j = 0; j < alignment.length; j++) { if( i == 0 & j == 0 ) continue; if( i == alignment.length-1 & j == 0) continue; if( i == 0 & j == alignment.length-1) continue; int col = alignment[j]; alignmentPattern(col,row); } } if( renderData ) { if( qr.rawbits.length != QrCode.VERSION_INFO[qr.version].codewords ) throw new RuntimeException("Unexpected length of raw data."); // mark which modules can store data bitLocations = new QrCodeCodeWordLocations(qr.version).bits; int numBytes = bitLocations.size() / 8; if (numBytes != qr.rawbits.length) throw new RuntimeException("Egads. unexpected length of qrcode raw data"); // Render the output data renderData(); } qr.bounds.set(0,0,0); qr.bounds.set(1,markerWidth,0); qr.bounds.set(2,markerWidth,markerWidth); qr.bounds.set(3,0,markerWidth); }
java
public void render( QrCode qr ) { initialize(qr); render.init(); positionPattern(0,0, qr.ppCorner); positionPattern((numModules-7)*moduleWidth,0, qr.ppRight); positionPattern(0,(numModules-7)*moduleWidth, qr.ppDown); timingPattern(7*moduleWidth,6*moduleWidth,moduleWidth,0); timingPattern(6*moduleWidth,7*moduleWidth,0,moduleWidth); formatInformation(); if( qr.version >= QrCode.VERSION_ENCODED_AT) versionInformation(); // render alignment patterns int alignment[] = QrCode.VERSION_INFO[qr.version].alignment; for (int i = 0; i < alignment.length; i++) { int row = alignment[i]; for (int j = 0; j < alignment.length; j++) { if( i == 0 & j == 0 ) continue; if( i == alignment.length-1 & j == 0) continue; if( i == 0 & j == alignment.length-1) continue; int col = alignment[j]; alignmentPattern(col,row); } } if( renderData ) { if( qr.rawbits.length != QrCode.VERSION_INFO[qr.version].codewords ) throw new RuntimeException("Unexpected length of raw data."); // mark which modules can store data bitLocations = new QrCodeCodeWordLocations(qr.version).bits; int numBytes = bitLocations.size() / 8; if (numBytes != qr.rawbits.length) throw new RuntimeException("Egads. unexpected length of qrcode raw data"); // Render the output data renderData(); } qr.bounds.set(0,0,0); qr.bounds.set(1,markerWidth,0); qr.bounds.set(2,markerWidth,markerWidth); qr.bounds.set(3,0,markerWidth); }
[ "public", "void", "render", "(", "QrCode", "qr", ")", "{", "initialize", "(", "qr", ")", ";", "render", ".", "init", "(", ")", ";", "positionPattern", "(", "0", ",", "0", ",", "qr", ".", "ppCorner", ")", ";", "positionPattern", "(", "(", "numModules"...
Generates a QR Code with the specified message. An exception is thrown if the message is too long to be encoded.
[ "Generates", "a", "QR", "Code", "with", "the", "specified", "message", ".", "An", "exception", "is", "thrown", "if", "the", "message", "is", "too", "long", "to", "be", "encoded", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeGenerator.java#L67-L122
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeGenerator.java
QrCodeGenerator.renderData
private void renderData() { QrCodeMaskPattern mask = qr.mask; int count = 0; int length = bitLocations.size() - bitLocations.size()%8; while( count < length ) { int bits = qr.rawbits[count/8]&0xFF; int N = Math.min(8,bitLocations.size()-count); for (int i = 0; i < N; i++) { Point2D_I32 coor = bitLocations.get(count+i); int value = mask.apply(coor.y,coor.x, ((bits >> i ) & 0x01)); // int value = ((bits >> i ) & 0x01); if( value > 0 ) { square(coor.y,coor.x); } } count += 8; } }
java
private void renderData() { QrCodeMaskPattern mask = qr.mask; int count = 0; int length = bitLocations.size() - bitLocations.size()%8; while( count < length ) { int bits = qr.rawbits[count/8]&0xFF; int N = Math.min(8,bitLocations.size()-count); for (int i = 0; i < N; i++) { Point2D_I32 coor = bitLocations.get(count+i); int value = mask.apply(coor.y,coor.x, ((bits >> i ) & 0x01)); // int value = ((bits >> i ) & 0x01); if( value > 0 ) { square(coor.y,coor.x); } } count += 8; } }
[ "private", "void", "renderData", "(", ")", "{", "QrCodeMaskPattern", "mask", "=", "qr", ".", "mask", ";", "int", "count", "=", "0", ";", "int", "length", "=", "bitLocations", ".", "size", "(", ")", "-", "bitLocations", ".", "size", "(", ")", "%", "8"...
Renders the raw data bit output while applying the selected mask
[ "Renders", "the", "raw", "data", "bit", "output", "while", "applying", "the", "selected", "mask" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCodeGenerator.java#L134-L155
train
lessthanoptimal/BoofCV
integration/boofcv-javacv/src/main/java/boofcv/javacv/UtilOpenCV.java
UtilOpenCV.loadPinholeRadial
public static CameraPinholeBrown loadPinholeRadial(String fileName ) { FileStorage fs = new FileStorage( new File(fileName).getAbsolutePath(), FileStorage.READ); IntPointer width = new IntPointer(1); IntPointer height = new IntPointer(1); read(fs.get("image_width"),width,-1); read(fs.get("image_height"),height,-1); Mat K = new Mat(); read(fs.get("camera_matrix"),K); Mat distortion = new Mat(); read(fs.get("distortion_coefficients"),distortion); CameraPinholeBrown boof = new CameraPinholeBrown(); boof.width = width.get(); boof.height = height.get(); DoubleRawIndexer indexerK = K.createIndexer(); boof.fx = indexerK.get(0,0); boof.skew = indexerK.get(0,1); boof.fy = indexerK.get(1,1); boof.cx = indexerK.get(0,2); boof.cy = indexerK.get(1,2); DoubleRawIndexer indexerD = distortion.createIndexer(); if( distortion.rows() >= 5 ) boof.setRadial(indexerD.get(0,0),indexerD.get(1,0),indexerD.get(4,0)); else if( distortion.rows() >= 2 ) boof.setRadial(indexerD.get(0,0),indexerD.get(1,0)); if( distortion.rows() >= 5 ) boof.fsetTangental(indexerD.get(2,0),indexerD.get(3,0)); return boof; }
java
public static CameraPinholeBrown loadPinholeRadial(String fileName ) { FileStorage fs = new FileStorage( new File(fileName).getAbsolutePath(), FileStorage.READ); IntPointer width = new IntPointer(1); IntPointer height = new IntPointer(1); read(fs.get("image_width"),width,-1); read(fs.get("image_height"),height,-1); Mat K = new Mat(); read(fs.get("camera_matrix"),K); Mat distortion = new Mat(); read(fs.get("distortion_coefficients"),distortion); CameraPinholeBrown boof = new CameraPinholeBrown(); boof.width = width.get(); boof.height = height.get(); DoubleRawIndexer indexerK = K.createIndexer(); boof.fx = indexerK.get(0,0); boof.skew = indexerK.get(0,1); boof.fy = indexerK.get(1,1); boof.cx = indexerK.get(0,2); boof.cy = indexerK.get(1,2); DoubleRawIndexer indexerD = distortion.createIndexer(); if( distortion.rows() >= 5 ) boof.setRadial(indexerD.get(0,0),indexerD.get(1,0),indexerD.get(4,0)); else if( distortion.rows() >= 2 ) boof.setRadial(indexerD.get(0,0),indexerD.get(1,0)); if( distortion.rows() >= 5 ) boof.fsetTangental(indexerD.get(2,0),indexerD.get(3,0)); return boof; }
[ "public", "static", "CameraPinholeBrown", "loadPinholeRadial", "(", "String", "fileName", ")", "{", "FileStorage", "fs", "=", "new", "FileStorage", "(", "new", "File", "(", "fileName", ")", ".", "getAbsolutePath", "(", ")", ",", "FileStorage", ".", "READ", ")"...
Loads a pinhole camera model with radian and tangential distortion in OpenCV format @param fileName path to file @return CameraPinholeRadial
[ "Loads", "a", "pinhole", "camera", "model", "with", "radian", "and", "tangential", "distortion", "in", "OpenCV", "format" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-javacv/src/main/java/boofcv/javacv/UtilOpenCV.java#L44-L79
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java
SquareNode.distanceSqCorner
public double distanceSqCorner( Point2D_F64 p ) { double best = Double.MAX_VALUE; for (int i = 0; i < 4; i++) { double d = square.get(i).distance2(p); if( d < best ) { best = d; } } return best; }
java
public double distanceSqCorner( Point2D_F64 p ) { double best = Double.MAX_VALUE; for (int i = 0; i < 4; i++) { double d = square.get(i).distance2(p); if( d < best ) { best = d; } } return best; }
[ "public", "double", "distanceSqCorner", "(", "Point2D_F64", "p", ")", "{", "double", "best", "=", "Double", ".", "MAX_VALUE", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "4", ";", "i", "++", ")", "{", "double", "d", "=", "square", ".", ...
Finds the Euclidean distance squared of the closest corner to point p
[ "Finds", "the", "Euclidean", "distance", "squared", "of", "the", "closest", "corner", "to", "point", "p" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java#L59-L68
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java
SquareNode.reset
public void reset() { square = null; touch = null; center.set(-1,-1); largestSide = 0; smallestSide = Double.MAX_VALUE; graph = RESET_GRAPH; for (int i = 0; i < edges.length; i++) { if ( edges[i] != null ) throw new RuntimeException("BUG!"); sideLengths[i] = 0; } }
java
public void reset() { square = null; touch = null; center.set(-1,-1); largestSide = 0; smallestSide = Double.MAX_VALUE; graph = RESET_GRAPH; for (int i = 0; i < edges.length; i++) { if ( edges[i] != null ) throw new RuntimeException("BUG!"); sideLengths[i] = 0; } }
[ "public", "void", "reset", "(", ")", "{", "square", "=", "null", ";", "touch", "=", "null", ";", "center", ".", "set", "(", "-", "1", ",", "-", "1", ")", ";", "largestSide", "=", "0", ";", "smallestSide", "=", "Double", ".", "MAX_VALUE", ";", "gr...
Discards previous information
[ "Discards", "previous", "information" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java#L73-L85
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java
SquareNode.updateArrayLength
public void updateArrayLength() { if( edges.length != square.size() ) { edges = new SquareEdge[square.size()]; sideLengths = new double[square.size()]; } }
java
public void updateArrayLength() { if( edges.length != square.size() ) { edges = new SquareEdge[square.size()]; sideLengths = new double[square.size()]; } }
[ "public", "void", "updateArrayLength", "(", ")", "{", "if", "(", "edges", ".", "length", "!=", "square", ".", "size", "(", ")", ")", "{", "edges", "=", "new", "SquareEdge", "[", "square", ".", "size", "(", ")", "]", ";", "sideLengths", "=", "new", ...
touch the border?
[ "touch", "the", "border?" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java#L91-L96
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java
SquareNode.getNumberOfConnections
public int getNumberOfConnections() { int ret = 0; for (int i = 0; i < square.size(); i++) { if( edges[i] != null ) ret++; } return ret; }
java
public int getNumberOfConnections() { int ret = 0; for (int i = 0; i < square.size(); i++) { if( edges[i] != null ) ret++; } return ret; }
[ "public", "int", "getNumberOfConnections", "(", ")", "{", "int", "ret", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "square", ".", "size", "(", ")", ";", "i", "++", ")", "{", "if", "(", "edges", "[", "i", "]", "!=", "null"...
Computes the number of edges attached to this node
[ "Computes", "the", "number", "of", "edges", "attached", "to", "this", "node" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/squares/SquareNode.java#L101-L108
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/interpolate/FactoryInterpolation.java
FactoryInterpolation.createPixelS
public static <T extends ImageGray<T>> InterpolatePixelS<T> createPixelS(double min, double max, InterpolationType type, BorderType borderType, Class<T> imageType) { InterpolatePixelS<T> alg; switch( type ) { case NEAREST_NEIGHBOR: alg = nearestNeighborPixelS(imageType); break; case BILINEAR: return bilinearPixelS(imageType, borderType); case BICUBIC: alg = bicubicS(-0.5f, (float) min, (float) max, imageType); break; case POLYNOMIAL4: alg = polynomialS(4, min, max, imageType); break; default: throw new IllegalArgumentException("Add type: "+type); } if( borderType != null ) alg.setBorder(FactoryImageBorder.single(imageType, borderType)); return alg; }
java
public static <T extends ImageGray<T>> InterpolatePixelS<T> createPixelS(double min, double max, InterpolationType type, BorderType borderType, Class<T> imageType) { InterpolatePixelS<T> alg; switch( type ) { case NEAREST_NEIGHBOR: alg = nearestNeighborPixelS(imageType); break; case BILINEAR: return bilinearPixelS(imageType, borderType); case BICUBIC: alg = bicubicS(-0.5f, (float) min, (float) max, imageType); break; case POLYNOMIAL4: alg = polynomialS(4, min, max, imageType); break; default: throw new IllegalArgumentException("Add type: "+type); } if( borderType != null ) alg.setBorder(FactoryImageBorder.single(imageType, borderType)); return alg; }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "InterpolatePixelS", "<", "T", ">", "createPixelS", "(", "double", "min", ",", "double", "max", ",", "InterpolationType", "type", ",", "BorderType", "borderType", ",", "Class", "<", ...
Creates an interpolation class of the specified type for the specified image type. @param min Minimum possible pixel value. Inclusive. @param max Maximum possible pixel value. Inclusive. @param type Interpolation type @param borderType Border type. If null then it will not be set here. @param imageType Type of input image @return Interpolation
[ "Creates", "an", "interpolation", "class", "of", "the", "specified", "type", "for", "the", "specified", "image", "type", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/interpolate/FactoryInterpolation.java#L80-L108
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/interpolate/FactoryInterpolation.java
FactoryInterpolation.createPixelMB
public static <T extends ImageBase<T>> InterpolatePixelMB<T> createPixelMB(double min, double max, InterpolationType type, BorderType borderType, ImageType<T> imageType ) { switch (imageType.getFamily()) { case PLANAR: return (InterpolatePixelMB<T>) createPixelPL((InterpolatePixelS)createPixelS(min, max, type, borderType, imageType.getDataType())); case GRAY:{ InterpolatePixelS interpS = createPixelS(min,max,type,borderType,imageType.getImageClass()); return new InterpolatePixel_S_to_MB(interpS); } case INTERLEAVED: switch( type ) { case NEAREST_NEIGHBOR: return nearestNeighborPixelMB((ImageType) imageType, borderType); case BILINEAR: return bilinearPixelMB((ImageType)imageType,borderType); default: throw new IllegalArgumentException("Interpolate type not yet support for ImageInterleaved"); } default: throw new IllegalArgumentException("Add type: "+type); } }
java
public static <T extends ImageBase<T>> InterpolatePixelMB<T> createPixelMB(double min, double max, InterpolationType type, BorderType borderType, ImageType<T> imageType ) { switch (imageType.getFamily()) { case PLANAR: return (InterpolatePixelMB<T>) createPixelPL((InterpolatePixelS)createPixelS(min, max, type, borderType, imageType.getDataType())); case GRAY:{ InterpolatePixelS interpS = createPixelS(min,max,type,borderType,imageType.getImageClass()); return new InterpolatePixel_S_to_MB(interpS); } case INTERLEAVED: switch( type ) { case NEAREST_NEIGHBOR: return nearestNeighborPixelMB((ImageType) imageType, borderType); case BILINEAR: return bilinearPixelMB((ImageType)imageType,borderType); default: throw new IllegalArgumentException("Interpolate type not yet support for ImageInterleaved"); } default: throw new IllegalArgumentException("Add type: "+type); } }
[ "public", "static", "<", "T", "extends", "ImageBase", "<", "T", ">", ">", "InterpolatePixelMB", "<", "T", ">", "createPixelMB", "(", "double", "min", ",", "double", "max", ",", "InterpolationType", "type", ",", "BorderType", "borderType", ",", "ImageType", "...
Pixel based interpolation on multi-band image @param min Minimum possible pixel value. Inclusive. @param max Maximum possible pixel value. Inclusive. @param type Interpolation type @param imageType Type of input image
[ "Pixel", "based", "interpolation", "on", "multi", "-", "band", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/interpolate/FactoryInterpolation.java#L118-L146
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertYV12.java
ConvertYV12.yu12ToBoof
public static void yu12ToBoof(byte[] data, int width, int height, ImageBase output) { if( output instanceof Planar) { Planar ms = (Planar) output; ms.reshape(width,height,3); if( BoofConcurrency.USE_CONCURRENT ) { if (ms.getBandType() == GrayU8.class) { ImplConvertYV12_MT.yv12ToPlanarRgb_U8(data, ms); } else if (ms.getBandType() == GrayF32.class) { ImplConvertYV12_MT.yv12ToPlanarRgb_F32(data, ms); } else { throw new IllegalArgumentException("Unsupported output band format"); } } else { if (ms.getBandType() == GrayU8.class) { ImplConvertYV12.yv12ToPlanarRgb_U8(data, ms); } else if (ms.getBandType() == GrayF32.class) { ImplConvertYV12.yv12ToPlanarRgb_F32(data, ms); } else { throw new IllegalArgumentException("Unsupported output band format"); } } } else if( output instanceof ImageGray) { if (output.getClass() == GrayU8.class) { yu12ToGray(data, width, height, (GrayU8) output); } else if (output.getClass() == GrayF32.class) { yu12ToGray(data, width, height, (GrayF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else if( output instanceof ImageInterleaved ) { ((ImageMultiBand)output).reshape(width,height,3); if( BoofConcurrency.USE_CONCURRENT ) { if (output.getClass() == InterleavedU8.class) { ImplConvertYV12_MT.yv12ToInterleaved(data, (InterleavedU8) output); } else if (output.getClass() == InterleavedF32.class) { ImplConvertYV12_MT.yv12ToInterleaved(data, (InterleavedF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else { if (output.getClass() == InterleavedU8.class) { ImplConvertYV12.yv12ToInterleaved(data, (InterleavedU8) output); } else if (output.getClass() == InterleavedF32.class) { ImplConvertYV12.yv12ToInterleaved(data, (InterleavedF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } } else { throw new IllegalArgumentException("Boofcv image type not yet supported"); } }
java
public static void yu12ToBoof(byte[] data, int width, int height, ImageBase output) { if( output instanceof Planar) { Planar ms = (Planar) output; ms.reshape(width,height,3); if( BoofConcurrency.USE_CONCURRENT ) { if (ms.getBandType() == GrayU8.class) { ImplConvertYV12_MT.yv12ToPlanarRgb_U8(data, ms); } else if (ms.getBandType() == GrayF32.class) { ImplConvertYV12_MT.yv12ToPlanarRgb_F32(data, ms); } else { throw new IllegalArgumentException("Unsupported output band format"); } } else { if (ms.getBandType() == GrayU8.class) { ImplConvertYV12.yv12ToPlanarRgb_U8(data, ms); } else if (ms.getBandType() == GrayF32.class) { ImplConvertYV12.yv12ToPlanarRgb_F32(data, ms); } else { throw new IllegalArgumentException("Unsupported output band format"); } } } else if( output instanceof ImageGray) { if (output.getClass() == GrayU8.class) { yu12ToGray(data, width, height, (GrayU8) output); } else if (output.getClass() == GrayF32.class) { yu12ToGray(data, width, height, (GrayF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else if( output instanceof ImageInterleaved ) { ((ImageMultiBand)output).reshape(width,height,3); if( BoofConcurrency.USE_CONCURRENT ) { if (output.getClass() == InterleavedU8.class) { ImplConvertYV12_MT.yv12ToInterleaved(data, (InterleavedU8) output); } else if (output.getClass() == InterleavedF32.class) { ImplConvertYV12_MT.yv12ToInterleaved(data, (InterleavedF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else { if (output.getClass() == InterleavedU8.class) { ImplConvertYV12.yv12ToInterleaved(data, (InterleavedU8) output); } else if (output.getClass() == InterleavedF32.class) { ImplConvertYV12.yv12ToInterleaved(data, (InterleavedF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } } else { throw new IllegalArgumentException("Boofcv image type not yet supported"); } }
[ "public", "static", "void", "yu12ToBoof", "(", "byte", "[", "]", "data", ",", "int", "width", ",", "int", "height", ",", "ImageBase", "output", ")", "{", "if", "(", "output", "instanceof", "Planar", ")", "{", "Planar", "ms", "=", "(", "Planar", ")", ...
Converts a YU12 encoded byte array into a BoofCV formatted image. @param data (input) YU12 byte array @param width (input) image width @param height (input) image height @param output (output) BoofCV image
[ "Converts", "a", "YU12", "encoded", "byte", "array", "into", "a", "BoofCV", "formatted", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertYV12.java#L45-L99
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertYV12.java
ConvertYV12.yu12ToGray
public static GrayU8 yu12ToGray(byte[] data , int width , int height , GrayU8 output ) { if( output != null ) { if( output.width != width || output.height != height ) throw new IllegalArgumentException("output width and height must be "+width+" "+height); } else { output = new GrayU8(width,height); } if(BoofConcurrency.USE_CONCURRENT ) { ImplConvertNV21_MT.nv21ToGray(data, output); } else { ImplConvertNV21.nv21ToGray(data, output); } return output; }
java
public static GrayU8 yu12ToGray(byte[] data , int width , int height , GrayU8 output ) { if( output != null ) { if( output.width != width || output.height != height ) throw new IllegalArgumentException("output width and height must be "+width+" "+height); } else { output = new GrayU8(width,height); } if(BoofConcurrency.USE_CONCURRENT ) { ImplConvertNV21_MT.nv21ToGray(data, output); } else { ImplConvertNV21.nv21ToGray(data, output); } return output; }
[ "public", "static", "GrayU8", "yu12ToGray", "(", "byte", "[", "]", "data", ",", "int", "width", ",", "int", "height", ",", "GrayU8", "output", ")", "{", "if", "(", "output", "!=", "null", ")", "{", "if", "(", "output", ".", "width", "!=", "width", ...
Converts an YV12 image into a gray scale U8 image. @param data Input: YV12 image data @param width Input: image width @param height Input: image height @param output Output: Optional storage for output image. Can be null. @return Gray scale image
[ "Converts", "an", "YV12", "image", "into", "a", "gray", "scale", "U8", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertYV12.java#L110-L125
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/factory/feature/associate/FactoryAssociation.java
FactoryAssociation.scoreEuclidean
public static <D> ScoreAssociation<D> scoreEuclidean( Class<D> tupleType , boolean squared ) { if( TupleDesc_F64.class.isAssignableFrom(tupleType) ) { if( squared ) return (ScoreAssociation)new ScoreAssociateEuclideanSq_F64(); else return (ScoreAssociation)new ScoreAssociateEuclidean_F64(); } else if( tupleType == TupleDesc_F32.class ) { if( squared ) return (ScoreAssociation)new ScoreAssociateEuclideanSq_F32(); } throw new IllegalArgumentException("Euclidean score not yet supported for type "+tupleType.getSimpleName()); }
java
public static <D> ScoreAssociation<D> scoreEuclidean( Class<D> tupleType , boolean squared ) { if( TupleDesc_F64.class.isAssignableFrom(tupleType) ) { if( squared ) return (ScoreAssociation)new ScoreAssociateEuclideanSq_F64(); else return (ScoreAssociation)new ScoreAssociateEuclidean_F64(); } else if( tupleType == TupleDesc_F32.class ) { if( squared ) return (ScoreAssociation)new ScoreAssociateEuclideanSq_F32(); } throw new IllegalArgumentException("Euclidean score not yet supported for type "+tupleType.getSimpleName()); }
[ "public", "static", "<", "D", ">", "ScoreAssociation", "<", "D", ">", "scoreEuclidean", "(", "Class", "<", "D", ">", "tupleType", ",", "boolean", "squared", ")", "{", "if", "(", "TupleDesc_F64", ".", "class", ".", "isAssignableFrom", "(", "tupleType", ")",...
Scores features based on the Euclidean distance between them. The square is often used instead of the Euclidean distance since it is much faster to compute. @param tupleType Type of descriptor being scored @param squared IF true the distance squared is returned. Usually true @return Euclidean distance measure
[ "Scores", "features", "based", "on", "the", "Euclidean", "distance", "between", "them", ".", "The", "square", "is", "often", "used", "instead", "of", "the", "Euclidean", "distance", "since", "it", "is", "much", "faster", "to", "compute", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/associate/FactoryAssociation.java#L196-L209
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/factory/feature/associate/FactoryAssociation.java
FactoryAssociation.scoreHamming
public static <D> ScoreAssociation<D> scoreHamming( Class<D> tupleType ) { if( tupleType == TupleDesc_B.class ) { return (ScoreAssociation)new ScoreAssociateHamming_B(); } throw new IllegalArgumentException("Hamming distance not yet supported for type "+tupleType.getSimpleName()); }
java
public static <D> ScoreAssociation<D> scoreHamming( Class<D> tupleType ) { if( tupleType == TupleDesc_B.class ) { return (ScoreAssociation)new ScoreAssociateHamming_B(); } throw new IllegalArgumentException("Hamming distance not yet supported for type "+tupleType.getSimpleName()); }
[ "public", "static", "<", "D", ">", "ScoreAssociation", "<", "D", ">", "scoreHamming", "(", "Class", "<", "D", ">", "tupleType", ")", "{", "if", "(", "tupleType", "==", "TupleDesc_B", ".", "class", ")", "{", "return", "(", "ScoreAssociation", ")", "new", ...
Hamming distance between two binary descriptors. @param tupleType Type of descriptor being scored @return Hamming distance measure
[ "Hamming", "distance", "between", "two", "binary", "descriptors", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/associate/FactoryAssociation.java#L217-L224
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/extract/ThresholdCornerExtractor.java
ThresholdCornerExtractor.process
public void process(GrayF32 intensity, QueueCorner corners ) { corners.reset(); float data[] = intensity.data; for( int y = 0; y < intensity.height; y++ ) { int startIndex = intensity.startIndex + y*intensity.stride; int endIndex = startIndex + intensity.width; for( int index = startIndex; index < endIndex; index++ ) { if( data[index] > thresh ) { int x = index-startIndex; corners.add(x,y); } } } }
java
public void process(GrayF32 intensity, QueueCorner corners ) { corners.reset(); float data[] = intensity.data; for( int y = 0; y < intensity.height; y++ ) { int startIndex = intensity.startIndex + y*intensity.stride; int endIndex = startIndex + intensity.width; for( int index = startIndex; index < endIndex; index++ ) { if( data[index] > thresh ) { int x = index-startIndex; corners.add(x,y); } } } }
[ "public", "void", "process", "(", "GrayF32", "intensity", ",", "QueueCorner", "corners", ")", "{", "corners", ".", "reset", "(", ")", ";", "float", "data", "[", "]", "=", "intensity", ".", "data", ";", "for", "(", "int", "y", "=", "0", ";", "y", "<...
Selects pixels as corners which are above the threshold.
[ "Selects", "pixels", "as", "corners", "which", "are", "above", "the", "threshold", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/extract/ThresholdCornerExtractor.java#L44-L60
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateSurfBasic.java
AssociateSurfBasic.swapLists
public void swapLists() { FastQueue<Helper> tmp = srcPositive; srcPositive = dstPositive; dstPositive = tmp; tmp = srcNegative; srcNegative = dstNegative; dstNegative = tmp; }
java
public void swapLists() { FastQueue<Helper> tmp = srcPositive; srcPositive = dstPositive; dstPositive = tmp; tmp = srcNegative; srcNegative = dstNegative; dstNegative = tmp; }
[ "public", "void", "swapLists", "(", ")", "{", "FastQueue", "<", "Helper", ">", "tmp", "=", "srcPositive", ";", "srcPositive", "=", "dstPositive", ";", "dstPositive", "=", "tmp", ";", "tmp", "=", "srcNegative", ";", "srcNegative", "=", "dstNegative", ";", "...
Swaps the source and dest feature list. Useful when processing a sequence of images and don't want to resort everything.
[ "Swaps", "the", "source", "and", "dest", "feature", "list", ".", "Useful", "when", "processing", "a", "sequence", "of", "images", "and", "don", "t", "want", "to", "resort", "everything", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateSurfBasic.java#L70-L78
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateSurfBasic.java
AssociateSurfBasic.associate
public void associate() { // initialize data structures matches.reset(); unassociatedSrc.reset(); if( srcPositive.size == 0 && srcNegative.size == 0 ) return; if( dstPositive.size == 0 && dstNegative.size == 0 ) return; // find and add the matches assoc.setSource((FastQueue)srcPositive); assoc.setDestination((FastQueue) dstPositive); assoc.associate(); FastQueue<AssociatedIndex> m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcPositive.data[a.src].index; int globalDstIndex = dstPositive.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); } GrowQueue_I32 un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcPositive.data[un.get(i)].index); } assoc.setSource((FastQueue)srcNegative); assoc.setDestination((FastQueue) dstNegative); assoc.associate(); m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcNegative.data[a.src].index; int globalDstIndex = dstNegative.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); } un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcNegative.data[un.get(i)].index); } }
java
public void associate() { // initialize data structures matches.reset(); unassociatedSrc.reset(); if( srcPositive.size == 0 && srcNegative.size == 0 ) return; if( dstPositive.size == 0 && dstNegative.size == 0 ) return; // find and add the matches assoc.setSource((FastQueue)srcPositive); assoc.setDestination((FastQueue) dstPositive); assoc.associate(); FastQueue<AssociatedIndex> m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcPositive.data[a.src].index; int globalDstIndex = dstPositive.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); } GrowQueue_I32 un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcPositive.data[un.get(i)].index); } assoc.setSource((FastQueue)srcNegative); assoc.setDestination((FastQueue) dstNegative); assoc.associate(); m = assoc.getMatches(); for( int i = 0; i < m.size; i++ ) { AssociatedIndex a = m.data[i]; int globalSrcIndex = srcNegative.data[a.src].index; int globalDstIndex = dstNegative.data[a.dst].index; matches.grow().setAssociation(globalSrcIndex,globalDstIndex,a.fitScore); } un = assoc.getUnassociatedSource(); for( int i = 0; i < un.size; i++ ) { unassociatedSrc.add(srcNegative.data[un.get(i)].index); } }
[ "public", "void", "associate", "(", ")", "{", "// initialize data structures", "matches", ".", "reset", "(", ")", ";", "unassociatedSrc", ".", "reset", "(", ")", ";", "if", "(", "srcPositive", ".", "size", "==", "0", "&&", "srcNegative", ".", "size", "==",...
Associates the features together.
[ "Associates", "the", "features", "together", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateSurfBasic.java#L83-L123
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateSurfBasic.java
AssociateSurfBasic.sort
private void sort(FastQueue<BrightFeature> input , FastQueue<Helper> pos , FastQueue<Helper> neg ) { pos.reset(); neg.reset(); for( int i = 0; i < input.size; i++ ) { BrightFeature f = input.get(i); if( f.white) { pos.grow().wrap(f,i); } else { neg.grow().wrap(f,i); } } }
java
private void sort(FastQueue<BrightFeature> input , FastQueue<Helper> pos , FastQueue<Helper> neg ) { pos.reset(); neg.reset(); for( int i = 0; i < input.size; i++ ) { BrightFeature f = input.get(i); if( f.white) { pos.grow().wrap(f,i); } else { neg.grow().wrap(f,i); } } }
[ "private", "void", "sort", "(", "FastQueue", "<", "BrightFeature", ">", "input", ",", "FastQueue", "<", "Helper", ">", "pos", ",", "FastQueue", "<", "Helper", ">", "neg", ")", "{", "pos", ".", "reset", "(", ")", ";", "neg", ".", "reset", "(", ")", ...
Splits the set of input features into positive and negative laplacian lists. Keep track of the feature's index in the original input list. This is the index that needs to be returned.
[ "Splits", "the", "set", "of", "input", "features", "into", "positive", "and", "negative", "laplacian", "lists", ".", "Keep", "track", "of", "the", "feature", "s", "index", "in", "the", "original", "input", "list", ".", "This", "is", "the", "index", "that",...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateSurfBasic.java#L137-L150
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivative.java
FactoryDerivative.gradientReduce
public static <I extends ImageMultiBand<I>, M extends ImageMultiBand<M>, D extends ImageGray<D>> ImageGradient<I,D> gradientReduce( ImageGradient<I,M> gradient , DerivativeReduceType type, Class<D> outputType ) { String name; switch( type ) { case MAX_F: name = "maxf"; break; default: throw new RuntimeException("Unknown reduce type "+type); } Class middleType; switch( gradient.getDerivativeType().getFamily()) { case PLANAR: middleType = Planar.class; break; case GRAY: throw new IllegalArgumentException("Can't have gradient output be single band"); default: middleType = gradient.getDerivativeType().getImageClass(); } Method m = findReduce(name,middleType, outputType); GradientMultiToSingleBand_Reflection<M,D> reducer = new GradientMultiToSingleBand_Reflection<>(m, gradient.getDerivativeType(), outputType); return new ImageGradientThenReduce<>(gradient, reducer); }
java
public static <I extends ImageMultiBand<I>, M extends ImageMultiBand<M>, D extends ImageGray<D>> ImageGradient<I,D> gradientReduce( ImageGradient<I,M> gradient , DerivativeReduceType type, Class<D> outputType ) { String name; switch( type ) { case MAX_F: name = "maxf"; break; default: throw new RuntimeException("Unknown reduce type "+type); } Class middleType; switch( gradient.getDerivativeType().getFamily()) { case PLANAR: middleType = Planar.class; break; case GRAY: throw new IllegalArgumentException("Can't have gradient output be single band"); default: middleType = gradient.getDerivativeType().getImageClass(); } Method m = findReduce(name,middleType, outputType); GradientMultiToSingleBand_Reflection<M,D> reducer = new GradientMultiToSingleBand_Reflection<>(m, gradient.getDerivativeType(), outputType); return new ImageGradientThenReduce<>(gradient, reducer); }
[ "public", "static", "<", "I", "extends", "ImageMultiBand", "<", "I", ">", ",", "M", "extends", "ImageMultiBand", "<", "M", ">", ",", "D", "extends", "ImageGray", "<", "D", ">", ">", "ImageGradient", "<", "I", ",", "D", ">", "gradientReduce", "(", "Imag...
Computes the image gradient inside a multi-band image then reduces the output to a single band before returning the results @param gradient Computes the multi-band image gradient @param type Specifies which method is to be used to reduce the output into single band image @param outputType Type of output image @param <I> Input type @param <M> Intermediate type @param <D> Output type @return Gradient
[ "Computes", "the", "image", "gradient", "inside", "a", "multi", "-", "band", "image", "then", "reduces", "the", "output", "to", "a", "single", "band", "before", "returning", "the", "results" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivative.java#L52-L85
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivative.java
FactoryDerivative.gradientSB
public static <I extends ImageGray<I>, D extends ImageGray<D>> ImageGradient<I,D> gradientSB( DerivativeType type , Class<I> inputType , Class<D> derivType ) { if( derivType == null ) derivType = GImageDerivativeOps.getDerivativeType(inputType); Class which; switch( type ) { case PREWITT: which = GradientPrewitt.class; break; case SOBEL: which = GradientSobel.class; break; case THREE: which = GradientThree.class; break; case TWO_0: which = GradientTwo0.class; break; case TWO_1: which = GradientTwo1.class; break; default: throw new IllegalArgumentException("Unknown type "+type); } Method m = findDerivative(which,inputType,derivType); return new ImageGradient_Reflection<>(m); }
java
public static <I extends ImageGray<I>, D extends ImageGray<D>> ImageGradient<I,D> gradientSB( DerivativeType type , Class<I> inputType , Class<D> derivType ) { if( derivType == null ) derivType = GImageDerivativeOps.getDerivativeType(inputType); Class which; switch( type ) { case PREWITT: which = GradientPrewitt.class; break; case SOBEL: which = GradientSobel.class; break; case THREE: which = GradientThree.class; break; case TWO_0: which = GradientTwo0.class; break; case TWO_1: which = GradientTwo1.class; break; default: throw new IllegalArgumentException("Unknown type "+type); } Method m = findDerivative(which,inputType,derivType); return new ImageGradient_Reflection<>(m); }
[ "public", "static", "<", "I", "extends", "ImageGray", "<", "I", ">", ",", "D", "extends", "ImageGray", "<", "D", ">", ">", "ImageGradient", "<", "I", ",", "D", ">", "gradientSB", "(", "DerivativeType", "type", ",", "Class", "<", "I", ">", "inputType", ...
Returns the gradient for single band images of the specified type @param type Type of gradient @param inputType Type of input image @param derivType Type of gradient image. null for default @param <I> Input image @param <D> Derivative image @return gradient filter
[ "Returns", "the", "gradient", "for", "single", "band", "images", "of", "the", "specified", "type" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivative.java#L96-L131
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/DetectFiducialSquareImage.java
DetectFiducialSquareImage.addPattern
public int addPattern(GrayU8 inputBinary, double lengthSide) { if( inputBinary == null ) { throw new IllegalArgumentException("Input image is null."); } else if( lengthSide <= 0 ) { throw new IllegalArgumentException("Parameter lengthSide must be more than zero"); } else if(ImageStatistics.max(inputBinary) > 1 ) throw new IllegalArgumentException("A binary image is composed on 0 and 1 pixels. This isn't binary!"); // see if it needs to be resized if ( inputBinary.width != squareLength || inputBinary.height != squareLength ) { // need to create a new image and rescale it to better handle the resizing GrayF32 inputGray = new GrayF32(inputBinary.width,inputBinary.height); ConvertImage.convert(inputBinary,inputGray); PixelMath.multiply(inputGray,255,inputGray); GrayF32 scaled = new GrayF32(squareLength,squareLength); // See if it can use the better algorithm for scaling down the image if( inputBinary.width > squareLength && inputBinary.height > squareLength ) { AverageDownSampleOps.down(inputGray,scaled); } else { new FDistort(inputGray,scaled).scaleExt().apply(); } GThresholdImageOps.threshold(scaled,binary,255/2.0,false); } else { binary.setTo(inputBinary); } // describe it in 4 different orientations FiducialDef def = new FiducialDef(); def.lengthSide = lengthSide; // CCW rotation so that the index refers to how many CW rotation it takes to put it into the nominal pose binaryToDef(binary, def.desc[0]); ImageMiscOps.rotateCCW(binary); binaryToDef(binary, def.desc[1]); ImageMiscOps.rotateCCW(binary); binaryToDef(binary, def.desc[2]); ImageMiscOps.rotateCCW(binary); binaryToDef(binary, def.desc[3]); int index = targets.size(); targets.add( def ); return index; }
java
public int addPattern(GrayU8 inputBinary, double lengthSide) { if( inputBinary == null ) { throw new IllegalArgumentException("Input image is null."); } else if( lengthSide <= 0 ) { throw new IllegalArgumentException("Parameter lengthSide must be more than zero"); } else if(ImageStatistics.max(inputBinary) > 1 ) throw new IllegalArgumentException("A binary image is composed on 0 and 1 pixels. This isn't binary!"); // see if it needs to be resized if ( inputBinary.width != squareLength || inputBinary.height != squareLength ) { // need to create a new image and rescale it to better handle the resizing GrayF32 inputGray = new GrayF32(inputBinary.width,inputBinary.height); ConvertImage.convert(inputBinary,inputGray); PixelMath.multiply(inputGray,255,inputGray); GrayF32 scaled = new GrayF32(squareLength,squareLength); // See if it can use the better algorithm for scaling down the image if( inputBinary.width > squareLength && inputBinary.height > squareLength ) { AverageDownSampleOps.down(inputGray,scaled); } else { new FDistort(inputGray,scaled).scaleExt().apply(); } GThresholdImageOps.threshold(scaled,binary,255/2.0,false); } else { binary.setTo(inputBinary); } // describe it in 4 different orientations FiducialDef def = new FiducialDef(); def.lengthSide = lengthSide; // CCW rotation so that the index refers to how many CW rotation it takes to put it into the nominal pose binaryToDef(binary, def.desc[0]); ImageMiscOps.rotateCCW(binary); binaryToDef(binary, def.desc[1]); ImageMiscOps.rotateCCW(binary); binaryToDef(binary, def.desc[2]); ImageMiscOps.rotateCCW(binary); binaryToDef(binary, def.desc[3]); int index = targets.size(); targets.add( def ); return index; }
[ "public", "int", "addPattern", "(", "GrayU8", "inputBinary", ",", "double", "lengthSide", ")", "{", "if", "(", "inputBinary", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Input image is null.\"", ")", ";", "}", "else", "if", "(",...
Adds a new image to the detector. Image must be gray-scale and is converted into a binary image using the specified threshold. All input images are rescaled to be square and of the appropriate size. Thus the original shape of the image doesn't matter. Square shapes are highly recommended since that's what the target looks like. @param inputBinary Binary input image pattern. 0 = black, 1 = white. @param lengthSide How long one of the sides of the target is in world units. @return The ID of the provided image
[ "Adds", "a", "new", "image", "to", "the", "detector", ".", "Image", "must", "be", "gray", "-", "scale", "and", "is", "converted", "into", "a", "binary", "image", "using", "the", "specified", "threshold", ".", "All", "input", "images", "are", "rescaled", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/DetectFiducialSquareImage.java#L114-L158
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/DetectFiducialSquareImage.java
DetectFiducialSquareImage.binaryToDef
protected static void binaryToDef(GrayU8 binary , short[] desc ) { for (int i = 0; i < binary.data.length; i+=16) { int value = 0; for (int j = 0; j < 16; j++) { value |= binary.data[i+j] << j; } desc[i/16] = (short)value; } }
java
protected static void binaryToDef(GrayU8 binary , short[] desc ) { for (int i = 0; i < binary.data.length; i+=16) { int value = 0; for (int j = 0; j < 16; j++) { value |= binary.data[i+j] << j; } desc[i/16] = (short)value; } }
[ "protected", "static", "void", "binaryToDef", "(", "GrayU8", "binary", ",", "short", "[", "]", "desc", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "binary", ".", "data", ".", "length", ";", "i", "+=", "16", ")", "{", "int", "value"...
Converts a binary image into the compressed bit format
[ "Converts", "a", "binary", "image", "into", "the", "compressed", "bit", "format" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/DetectFiducialSquareImage.java#L163-L171
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/DetectFiducialSquareImage.java
DetectFiducialSquareImage.hamming
protected int hamming(short[] a, short[] b) { int distance = 0; for (int i = 0; i < a.length; i++) { distance += DescriptorDistance.hamming((a[i]&0xFFFF) ^ (b[i]&0xFFFF)); } return distance; }
java
protected int hamming(short[] a, short[] b) { int distance = 0; for (int i = 0; i < a.length; i++) { distance += DescriptorDistance.hamming((a[i]&0xFFFF) ^ (b[i]&0xFFFF)); } return distance; }
[ "protected", "int", "hamming", "(", "short", "[", "]", "a", ",", "short", "[", "]", "b", ")", "{", "int", "distance", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "a", ".", "length", ";", "i", "++", ")", "{", "distance", ...
Computes the hamming score between two descriptions. Larger the number better the fit
[ "Computes", "the", "hamming", "score", "between", "two", "descriptions", ".", "Larger", "the", "number", "better", "the", "fit" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/DetectFiducialSquareImage.java#L211-L217
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/descriptor/UtilFeature.java
UtilFeature.combine
public static TupleDesc_F64 combine( List<TupleDesc_F64> inputs , TupleDesc_F64 combined ) { int N = 0; for (int i = 0; i < inputs.size(); i++) { N += inputs.get(i).size(); } if( combined == null ) { combined = new TupleDesc_F64(N); } else { if (N != combined.size()) throw new RuntimeException("The combined feature needs to be " + N + " not " + combined.size()); } int start = 0; for (int i = 0; i < inputs.size(); i++) { double v[] = inputs.get(i).value; System.arraycopy(v,0,combined.value,start,v.length); start += v.length; } return combined; }
java
public static TupleDesc_F64 combine( List<TupleDesc_F64> inputs , TupleDesc_F64 combined ) { int N = 0; for (int i = 0; i < inputs.size(); i++) { N += inputs.get(i).size(); } if( combined == null ) { combined = new TupleDesc_F64(N); } else { if (N != combined.size()) throw new RuntimeException("The combined feature needs to be " + N + " not " + combined.size()); } int start = 0; for (int i = 0; i < inputs.size(); i++) { double v[] = inputs.get(i).value; System.arraycopy(v,0,combined.value,start,v.length); start += v.length; } return combined; }
[ "public", "static", "TupleDesc_F64", "combine", "(", "List", "<", "TupleDesc_F64", ">", "inputs", ",", "TupleDesc_F64", "combined", ")", "{", "int", "N", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "inputs", ".", "size", "(", ")",...
Concats the list of tuples together into one big feature. The combined feature must be large enough to store all the inputs. @param inputs List of tuples. @param combined Storage for combined output. If null a new instance will be declared. @return Resulting combined.
[ "Concats", "the", "list", "of", "tuples", "together", "into", "one", "big", "feature", ".", "The", "combined", "feature", "must", "be", "large", "enough", "to", "store", "all", "the", "inputs", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/descriptor/UtilFeature.java#L67-L87
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java
VideoDisplayActivity.setProcessing
public void setProcessing( VideoProcessing processing ) { if( this.processing != null ) { // kill the old process this.processing.stopProcessing(); } if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Not called from a GUI thread. Bad stuff could happen"); } this.processing = processing; // if the camera is null then it will be initialized when the camera is initialized if( processing != null && mCamera != null ) { processing.init(mDraw,mCamera,mCameraInfo,previewRotation); } }
java
public void setProcessing( VideoProcessing processing ) { if( this.processing != null ) { // kill the old process this.processing.stopProcessing(); } if (Looper.getMainLooper().getThread() != Thread.currentThread()) { throw new RuntimeException("Not called from a GUI thread. Bad stuff could happen"); } this.processing = processing; // if the camera is null then it will be initialized when the camera is initialized if( processing != null && mCamera != null ) { processing.init(mDraw,mCamera,mCameraInfo,previewRotation); } }
[ "public", "void", "setProcessing", "(", "VideoProcessing", "processing", ")", "{", "if", "(", "this", ".", "processing", "!=", "null", ")", "{", "// kill the old process", "this", ".", "processing", ".", "stopProcessing", "(", ")", ";", "}", "if", "(", "Loop...
Changes the CV algorithm running. Should only be called from a GUI thread.
[ "Changes", "the", "CV", "algorithm", "running", ".", "Should", "only", "be", "called", "from", "a", "GUI", "thread", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java#L88-L103
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java
VideoDisplayActivity.setUpAndConfigureCamera
private void setUpAndConfigureCamera() { // Open and configure the camera mCamera = openConfigureCamera(mCameraInfo); setCameraDisplayOrientation(mCameraInfo,mCamera); // Create an instance of Camera mPreview.setCamera(mCamera); if( processing != null ) { processing.init(mDraw,mCamera,mCameraInfo,previewRotation); } }
java
private void setUpAndConfigureCamera() { // Open and configure the camera mCamera = openConfigureCamera(mCameraInfo); setCameraDisplayOrientation(mCameraInfo,mCamera); // Create an instance of Camera mPreview.setCamera(mCamera); if( processing != null ) { processing.init(mDraw,mCamera,mCameraInfo,previewRotation); } }
[ "private", "void", "setUpAndConfigureCamera", "(", ")", "{", "// Open and configure the camera", "mCamera", "=", "openConfigureCamera", "(", "mCameraInfo", ")", ";", "setCameraDisplayOrientation", "(", "mCameraInfo", ",", "mCamera", ")", ";", "// Create an instance of Camer...
Sets up the camera if it is not already setup.
[ "Sets", "up", "the", "camera", "if", "it", "is", "not", "already", "setup", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java#L179-L190
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java
VideoDisplayActivity.setProgressMessage
protected void setProgressMessage(final String message) { runOnUiThread(new Runnable() { public void run() { synchronized ( lockProgress ) { if( progressDialog != null ) { // a dialog is already open, change the message progressDialog.setMessage(message); return; } progressDialog = new ProgressDialog(VideoDisplayActivity.this); progressDialog.setMessage(message); progressDialog.setIndeterminate(true); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } // don't show the dialog until 1 second has passed long showTime = System.currentTimeMillis()+1000; while( showTime > System.currentTimeMillis() ) { Thread.yield(); } // if it hasn't been dismissed, show the dialog synchronized ( lockProgress ) { if( progressDialog != null ) progressDialog.show(); } }}); // block until the GUI thread has been called while( progressDialog == null ) { Thread.yield(); } }
java
protected void setProgressMessage(final String message) { runOnUiThread(new Runnable() { public void run() { synchronized ( lockProgress ) { if( progressDialog != null ) { // a dialog is already open, change the message progressDialog.setMessage(message); return; } progressDialog = new ProgressDialog(VideoDisplayActivity.this); progressDialog.setMessage(message); progressDialog.setIndeterminate(true); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); } // don't show the dialog until 1 second has passed long showTime = System.currentTimeMillis()+1000; while( showTime > System.currentTimeMillis() ) { Thread.yield(); } // if it hasn't been dismissed, show the dialog synchronized ( lockProgress ) { if( progressDialog != null ) progressDialog.show(); } }}); // block until the GUI thread has been called while( progressDialog == null ) { Thread.yield(); } }
[ "protected", "void", "setProgressMessage", "(", "final", "String", "message", ")", "{", "runOnUiThread", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "synchronized", "(", "lockProgress", ")", "{", "if", "(", "progressDialog"...
Displays an indeterminate progress dialog. If the dialog is already open this will change the message being displayed. Function blocks until the dialog has been declared. @param message Text shown in dialog
[ "Displays", "an", "indeterminate", "progress", "dialog", ".", "If", "the", "dialog", "is", "already", "open", "this", "will", "change", "the", "message", "being", "displayed", ".", "Function", "blocks", "until", "the", "dialog", "has", "been", "declared", "." ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java#L294-L325
train
lessthanoptimal/BoofCV
integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java
VideoDisplayActivity.hideProgressDialog
protected void hideProgressDialog() { // do nothing if the dialog is already being displayed synchronized ( lockProgress ) { if( progressDialog == null ) return; } if (Looper.getMainLooper().getThread() == Thread.currentThread()) { // if inside the UI thread just dismiss the dialog and avoid a potential locking condition synchronized ( lockProgress ) { progressDialog.dismiss(); progressDialog = null; } } else { runOnUiThread(new Runnable() { public void run() { synchronized ( lockProgress ) { progressDialog.dismiss(); progressDialog = null; } }}); // block until dialog has been dismissed while( progressDialog != null ) { Thread.yield(); } } }
java
protected void hideProgressDialog() { // do nothing if the dialog is already being displayed synchronized ( lockProgress ) { if( progressDialog == null ) return; } if (Looper.getMainLooper().getThread() == Thread.currentThread()) { // if inside the UI thread just dismiss the dialog and avoid a potential locking condition synchronized ( lockProgress ) { progressDialog.dismiss(); progressDialog = null; } } else { runOnUiThread(new Runnable() { public void run() { synchronized ( lockProgress ) { progressDialog.dismiss(); progressDialog = null; } }}); // block until dialog has been dismissed while( progressDialog != null ) { Thread.yield(); } } }
[ "protected", "void", "hideProgressDialog", "(", ")", "{", "// do nothing if the dialog is already being displayed", "synchronized", "(", "lockProgress", ")", "{", "if", "(", "progressDialog", "==", "null", ")", "return", ";", "}", "if", "(", "Looper", ".", "getMainL...
Dismisses the progress dialog. Can be called even if there is no progressDialog being shown.
[ "Dismisses", "the", "progress", "dialog", ".", "Can", "be", "called", "even", "if", "there", "is", "no", "progressDialog", "being", "shown", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera/VideoDisplayActivity.java#L330-L357
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/struct/calib/CameraUniversalOmni.java
CameraUniversalOmni.set
public void set( CameraUniversalOmni original ) { super.set(original); this.mirrorOffset = original.mirrorOffset; if( radial.length != original.radial.length ) radial = new double[ original.radial.length ]; System.arraycopy(original.radial,0,radial,0,radial.length); this.t1 = original.t1; this.t2 = original.t2; }
java
public void set( CameraUniversalOmni original ) { super.set(original); this.mirrorOffset = original.mirrorOffset; if( radial.length != original.radial.length ) radial = new double[ original.radial.length ]; System.arraycopy(original.radial,0,radial,0,radial.length); this.t1 = original.t1; this.t2 = original.t2; }
[ "public", "void", "set", "(", "CameraUniversalOmni", "original", ")", "{", "super", ".", "set", "(", "original", ")", ";", "this", ".", "mirrorOffset", "=", "original", ".", "mirrorOffset", ";", "if", "(", "radial", ".", "length", "!=", "original", ".", ...
Assigns this model to be identical to the passed in model @param original Model which is to be copied
[ "Assigns", "this", "model", "to", "be", "identical", "to", "the", "passed", "in", "model" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/struct/calib/CameraUniversalOmni.java#L110-L121
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/flow/HornSchunck.java
HornSchunck.process
public void process( T image1 , T image2 , ImageFlow output) { InputSanityCheck.checkSameShape(image1,image2); derivX.reshape(image1.width,image1.height); derivY.reshape(image1.width,image1.height); derivT.reshape(image1.width,image1.height); averageFlow.reshape(output.width,output.height); if( resetOutput ) output.fillZero(); computeDerivX(image1,image2,derivX); computeDerivY(image1,image2,derivY); computeDerivT(image1,image2,derivT); findFlow(derivX,derivY,derivT,output); }
java
public void process( T image1 , T image2 , ImageFlow output) { InputSanityCheck.checkSameShape(image1,image2); derivX.reshape(image1.width,image1.height); derivY.reshape(image1.width,image1.height); derivT.reshape(image1.width,image1.height); averageFlow.reshape(output.width,output.height); if( resetOutput ) output.fillZero(); computeDerivX(image1,image2,derivX); computeDerivY(image1,image2,derivY); computeDerivT(image1,image2,derivT); findFlow(derivX,derivY,derivT,output); }
[ "public", "void", "process", "(", "T", "image1", ",", "T", "image2", ",", "ImageFlow", "output", ")", "{", "InputSanityCheck", ".", "checkSameShape", "(", "image1", ",", "image2", ")", ";", "derivX", ".", "reshape", "(", "image1", ".", "width", ",", "ima...
Computes dense optical flow from the first image's gradient and the difference between the second and the first image. @param image1 First image @param image2 Second image @param output Found dense optical flow
[ "Computes", "dense", "optical", "flow", "from", "the", "first", "image", "s", "gradient", "and", "the", "difference", "between", "the", "second", "and", "the", "first", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/flow/HornSchunck.java#L92-L110
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/flow/HornSchunck.java
HornSchunck.innerAverageFlow
protected static void innerAverageFlow( ImageFlow flow , ImageFlow averageFlow ) { int endX = flow.width-1; int endY = flow.height-1; for( int y = 1; y < endY; y++ ) { int index = flow.width*y + 1; for( int x = 1; x < endX; x++ , index++) { ImageFlow.D average = averageFlow.data[index]; ImageFlow.D f0 = flow.data[index-1]; ImageFlow.D f1 = flow.data[index+1]; ImageFlow.D f2 = flow.data[index-flow.width]; ImageFlow.D f3 = flow.data[index+flow.width]; ImageFlow.D f4 = flow.data[index-1-flow.width]; ImageFlow.D f5 = flow.data[index+1-flow.width]; ImageFlow.D f6 = flow.data[index-1+flow.width]; ImageFlow.D f7 = flow.data[index+1+flow.width]; average.x = 0.1666667f*(f0.x + f1.x + f2.x + f3.x) + 0.08333333f*(f4.x + f5.x + f6.x + f7.x); average.y = 0.1666667f*(f0.y + f1.y + f2.y + f3.y) + 0.08333333f*(f4.y + f5.y + f6.y + f7.y); } } }
java
protected static void innerAverageFlow( ImageFlow flow , ImageFlow averageFlow ) { int endX = flow.width-1; int endY = flow.height-1; for( int y = 1; y < endY; y++ ) { int index = flow.width*y + 1; for( int x = 1; x < endX; x++ , index++) { ImageFlow.D average = averageFlow.data[index]; ImageFlow.D f0 = flow.data[index-1]; ImageFlow.D f1 = flow.data[index+1]; ImageFlow.D f2 = flow.data[index-flow.width]; ImageFlow.D f3 = flow.data[index+flow.width]; ImageFlow.D f4 = flow.data[index-1-flow.width]; ImageFlow.D f5 = flow.data[index+1-flow.width]; ImageFlow.D f6 = flow.data[index-1+flow.width]; ImageFlow.D f7 = flow.data[index+1+flow.width]; average.x = 0.1666667f*(f0.x + f1.x + f2.x + f3.x) + 0.08333333f*(f4.x + f5.x + f6.x + f7.x); average.y = 0.1666667f*(f0.y + f1.y + f2.y + f3.y) + 0.08333333f*(f4.y + f5.y + f6.y + f7.y); } } }
[ "protected", "static", "void", "innerAverageFlow", "(", "ImageFlow", "flow", ",", "ImageFlow", "averageFlow", ")", "{", "int", "endX", "=", "flow", ".", "width", "-", "1", ";", "int", "endY", "=", "flow", ".", "height", "-", "1", ";", "for", "(", "int"...
Computes average flow using an 8-connect neighborhood for the inner image
[ "Computes", "average", "flow", "using", "an", "8", "-", "connect", "neighborhood", "for", "the", "inner", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/flow/HornSchunck.java#L125-L149
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/flow/HornSchunck.java
HornSchunck.borderAverageFlow
protected static void borderAverageFlow( ImageFlow flow , ImageFlow averageFlow) { for( int y = 0; y < flow.height; y++ ) { computeBorder(flow,averageFlow, 0, y); computeBorder(flow,averageFlow, flow.width-1, y); } for( int x = 1; x < flow.width-1; x++ ) { computeBorder(flow,averageFlow, x, 0); computeBorder(flow,averageFlow, x, flow.height-1); } }
java
protected static void borderAverageFlow( ImageFlow flow , ImageFlow averageFlow) { for( int y = 0; y < flow.height; y++ ) { computeBorder(flow,averageFlow, 0, y); computeBorder(flow,averageFlow, flow.width-1, y); } for( int x = 1; x < flow.width-1; x++ ) { computeBorder(flow,averageFlow, x, 0); computeBorder(flow,averageFlow, x, flow.height-1); } }
[ "protected", "static", "void", "borderAverageFlow", "(", "ImageFlow", "flow", ",", "ImageFlow", "averageFlow", ")", "{", "for", "(", "int", "y", "=", "0", ";", "y", "<", "flow", ".", "height", ";", "y", "++", ")", "{", "computeBorder", "(", "flow", ","...
Computes average flow using an 8-connect neighborhood for the image border
[ "Computes", "average", "flow", "using", "an", "8", "-", "connect", "neighborhood", "for", "the", "image", "border" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/flow/HornSchunck.java#L154-L165
train
lessthanoptimal/BoofCV
main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java
SimulatePlanarWorld.computeProjectionTable
void computeProjectionTable( int width , int height ) { output.reshape(width,height); depthMap.reshape(width,height); ImageMiscOps.fill(depthMap,-1); pointing = new float[width*height*3]; for (int y = 0; y < output.height; y++) { for (int x = 0; x < output.width; x++) { // Should this add 0.5 so that the ray goes out of the pixel's center? Seems to increase reprojection // error in calibration tests if I do... pixelTo3.compute(x, y, p3); if(UtilEjml.isUncountable(p3.x)) { depthMap.unsafe_set(x,y,Float.NaN); } else { pointing[(y*output.width+x)*3 ] = (float)p3.x; pointing[(y*output.width+x)*3+1 ] = (float)p3.y; pointing[(y*output.width+x)*3+2 ] = (float)p3.z; } } } }
java
void computeProjectionTable( int width , int height ) { output.reshape(width,height); depthMap.reshape(width,height); ImageMiscOps.fill(depthMap,-1); pointing = new float[width*height*3]; for (int y = 0; y < output.height; y++) { for (int x = 0; x < output.width; x++) { // Should this add 0.5 so that the ray goes out of the pixel's center? Seems to increase reprojection // error in calibration tests if I do... pixelTo3.compute(x, y, p3); if(UtilEjml.isUncountable(p3.x)) { depthMap.unsafe_set(x,y,Float.NaN); } else { pointing[(y*output.width+x)*3 ] = (float)p3.x; pointing[(y*output.width+x)*3+1 ] = (float)p3.y; pointing[(y*output.width+x)*3+2 ] = (float)p3.z; } } } }
[ "void", "computeProjectionTable", "(", "int", "width", ",", "int", "height", ")", "{", "output", ".", "reshape", "(", "width", ",", "height", ")", ";", "depthMap", ".", "reshape", "(", "width", ",", "height", ")", ";", "ImageMiscOps", ".", "fill", "(", ...
Computes 3D pointing vector for every pixel in the simulated camera frame @param width width of simulated camera @param height height of simulated camera
[ "Computes", "3D", "pointing", "vector", "for", "every", "pixel", "in", "the", "simulated", "camera", "frame" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java#L120-L142
train
lessthanoptimal/BoofCV
main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java
SimulatePlanarWorld.render
public GrayF32 render() { ImageMiscOps.fill(output,background); ImageMiscOps.fill(depthMap,Float.MAX_VALUE); for (int i = 0; i < scene.size(); i++) { SurfaceRect r = scene.get(i); r.rectInCamera(); } if( BoofConcurrency.USE_CONCURRENT ) { renderMultiThread(); } else { renderSingleThread(); } return getOutput(); }
java
public GrayF32 render() { ImageMiscOps.fill(output,background); ImageMiscOps.fill(depthMap,Float.MAX_VALUE); for (int i = 0; i < scene.size(); i++) { SurfaceRect r = scene.get(i); r.rectInCamera(); } if( BoofConcurrency.USE_CONCURRENT ) { renderMultiThread(); } else { renderSingleThread(); } return getOutput(); }
[ "public", "GrayF32", "render", "(", ")", "{", "ImageMiscOps", ".", "fill", "(", "output", ",", "background", ")", ";", "ImageMiscOps", ".", "fill", "(", "depthMap", ",", "Float", ".", "MAX_VALUE", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i",...
Render the scene and returns the rendered image. @see #getOutput() @return rendered image
[ "Render", "the", "scene", "and", "returns", "the", "rendered", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java#L177-L194
train
lessthanoptimal/BoofCV
main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java
SimulatePlanarWorld.computePixel
public void computePixel(int which, double x, double y, Point2D_F64 output) { SurfaceRect r = scene.get(which); Point3D_F64 p3 = new Point3D_F64(-x,-y,0); SePointOps_F64.transform(r.rectToCamera, p3, p3); // unit sphere p3.scale(1.0/p3.norm()); sphereToPixel.compute(p3.x,p3.y,p3.z,output); }
java
public void computePixel(int which, double x, double y, Point2D_F64 output) { SurfaceRect r = scene.get(which); Point3D_F64 p3 = new Point3D_F64(-x,-y,0); SePointOps_F64.transform(r.rectToCamera, p3, p3); // unit sphere p3.scale(1.0/p3.norm()); sphereToPixel.compute(p3.x,p3.y,p3.z,output); }
[ "public", "void", "computePixel", "(", "int", "which", ",", "double", "x", ",", "double", "y", ",", "Point2D_F64", "output", ")", "{", "SurfaceRect", "r", "=", "scene", ".", "get", "(", "which", ")", ";", "Point3D_F64", "p3", "=", "new", "Point3D_F64", ...
Project a point which lies on the 2D planar polygon's surface onto the rendered image
[ "Project", "a", "point", "which", "lies", "on", "the", "2D", "planar", "polygon", "s", "surface", "onto", "the", "rendered", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-simulation/src/main/java/boofcv/simulation/SimulatePlanarWorld.java#L307-L317
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/DepthSparse3D.java
DepthSparse3D.configure
public void configure(LensDistortionNarrowFOV model , PixelTransform<Point2D_F32> visualToDepth ) { this.visualToDepth = visualToDepth; this.p2n = model.undistort_F64(true,false); }
java
public void configure(LensDistortionNarrowFOV model , PixelTransform<Point2D_F32> visualToDepth ) { this.visualToDepth = visualToDepth; this.p2n = model.undistort_F64(true,false); }
[ "public", "void", "configure", "(", "LensDistortionNarrowFOV", "model", ",", "PixelTransform", "<", "Point2D_F32", ">", "visualToDepth", ")", "{", "this", ".", "visualToDepth", "=", "visualToDepth", ";", "this", ".", "p2n", "=", "model", ".", "undistort_F64", "(...
Configures intrinsic camera parameters @param model Model for narrow FOV cameras @param visualToDepth Transform from visual to depth camera pixel coordinate systems.
[ "Configures", "intrinsic", "camera", "parameters" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/DepthSparse3D.java#L79-L82
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/DepthSparse3D.java
DepthSparse3D.process
public boolean process( int x , int y ) { visualToDepth.compute(x, y,distorted); int depthX = (int)distorted.x; int depthY = (int)distorted.y; if( depthImage.isInBounds(depthX,depthY) ) { // get the depth at the specified location double value = lookupDepth(depthX, depthY); // see if its an invalid value if( value == 0 ) return false; // convert visual pixel into normalized image coordinate p2n.compute(x,y,norm); // project into 3D space worldPt.z = value*depthScale; worldPt.x = worldPt.z*norm.x; worldPt.y = worldPt.z*norm.y; return true; } else { return false; } }
java
public boolean process( int x , int y ) { visualToDepth.compute(x, y,distorted); int depthX = (int)distorted.x; int depthY = (int)distorted.y; if( depthImage.isInBounds(depthX,depthY) ) { // get the depth at the specified location double value = lookupDepth(depthX, depthY); // see if its an invalid value if( value == 0 ) return false; // convert visual pixel into normalized image coordinate p2n.compute(x,y,norm); // project into 3D space worldPt.z = value*depthScale; worldPt.x = worldPt.z*norm.x; worldPt.y = worldPt.z*norm.y; return true; } else { return false; } }
[ "public", "boolean", "process", "(", "int", "x", ",", "int", "y", ")", "{", "visualToDepth", ".", "compute", "(", "x", ",", "y", ",", "distorted", ")", ";", "int", "depthX", "=", "(", "int", ")", "distorted", ".", "x", ";", "int", "depthY", "=", ...
Given a pixel coordinate in the visual camera, compute the 3D coordinate of that point. @param x x-coordinate of point in visual camera @param y y-coordinate of point in visual camera @return true if a 3D point could be computed and false if not
[ "Given", "a", "pixel", "coordinate", "in", "the", "visual", "camera", "compute", "the", "3D", "coordinate", "of", "that", "point", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/DepthSparse3D.java#L101-L127
train
lessthanoptimal/BoofCV
applications/src/main/java/boofcv/app/calib/AssistedCalibration.java
AssistedCalibration.captureFiducialPoints
private void captureFiducialPoints() { Polygon2D_F64 p = regions.grow(); p.vertexes.resize(sidesCollision.size()); for (int i = 0; i < sidesCollision.size(); i++) { p.get(i).set( sidesCollision.get(i) ); } quality.addObservations(detector.getDetectedPoints()); gui.getInfoPanel().updateGeometry(quality.getScore()); // once the user has sufficient geometric variation enable save geometryTrigger |= quality.getScore() >= 1.0; if( geometryTrigger && magnets.isEmpty() ) { gui.getInfoPanel().enabledFinishedButton(); } }
java
private void captureFiducialPoints() { Polygon2D_F64 p = regions.grow(); p.vertexes.resize(sidesCollision.size()); for (int i = 0; i < sidesCollision.size(); i++) { p.get(i).set( sidesCollision.get(i) ); } quality.addObservations(detector.getDetectedPoints()); gui.getInfoPanel().updateGeometry(quality.getScore()); // once the user has sufficient geometric variation enable save geometryTrigger |= quality.getScore() >= 1.0; if( geometryTrigger && magnets.isEmpty() ) { gui.getInfoPanel().enabledFinishedButton(); } }
[ "private", "void", "captureFiducialPoints", "(", ")", "{", "Polygon2D_F64", "p", "=", "regions", ".", "grow", "(", ")", ";", "p", ".", "vertexes", ".", "resize", "(", "sidesCollision", ".", "size", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0"...
Record the area covered in the image by the fiducial, update the quality calculation, and see if it should enable the save button.
[ "Record", "the", "area", "covered", "in", "the", "image", "by", "the", "fiducial", "update", "the", "quality", "calculation", "and", "see", "if", "it", "should", "enable", "the", "save", "button", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/calib/AssistedCalibration.java#L477-L491
train
lessthanoptimal/BoofCV
applications/src/main/java/boofcv/app/calib/AssistedCalibration.java
AssistedCalibration.checkMagnetCapturePicture
private boolean checkMagnetCapturePicture() { boolean captured = false; Iterator<Magnet> iter = magnets.iterator(); while( iter.hasNext() ) { Magnet i = iter.next(); if( i.handlePictureTaken() ) { iter.remove(); captured = true; } } return captured; }
java
private boolean checkMagnetCapturePicture() { boolean captured = false; Iterator<Magnet> iter = magnets.iterator(); while( iter.hasNext() ) { Magnet i = iter.next(); if( i.handlePictureTaken() ) { iter.remove(); captured = true; } } return captured; }
[ "private", "boolean", "checkMagnetCapturePicture", "(", ")", "{", "boolean", "captured", "=", "false", ";", "Iterator", "<", "Magnet", ">", "iter", "=", "magnets", ".", "iterator", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", ...
Checks to see if its near one of the magnets in the image broder
[ "Checks", "to", "see", "if", "its", "near", "one", "of", "the", "magnets", "in", "the", "image", "broder" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/calib/AssistedCalibration.java#L496-L507
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java
RefinePolyLineCorner.fit
public boolean fit( List<Point2D_I32> contour , GrowQueue_I32 corners ) { if( corners.size() < 3 ) { return false; } searchRadius = Math.min(6,Math.max(contour.size()/12,3)); int startCorner,endCorner; if( looping ) { startCorner = 0; endCorner = corners.size; } else { // the end point positions are fixed startCorner = 1; endCorner = corners.size-1; } boolean change = true; for( int iteration = 0; iteration < maxIterations && change; iteration++ ) { change = false; for (int i = startCorner; i < endCorner; i++) { int c0 = CircularIndex.minusPOffset(i, 1, corners.size()); int c2 = CircularIndex.plusPOffset(i, 1, corners.size()); int improved = optimize(contour, corners.get(c0), corners.get(i), corners.get(c2)); if( improved != corners.get(i)) { corners.set(i,improved); change = true; } } } return true; }
java
public boolean fit( List<Point2D_I32> contour , GrowQueue_I32 corners ) { if( corners.size() < 3 ) { return false; } searchRadius = Math.min(6,Math.max(contour.size()/12,3)); int startCorner,endCorner; if( looping ) { startCorner = 0; endCorner = corners.size; } else { // the end point positions are fixed startCorner = 1; endCorner = corners.size-1; } boolean change = true; for( int iteration = 0; iteration < maxIterations && change; iteration++ ) { change = false; for (int i = startCorner; i < endCorner; i++) { int c0 = CircularIndex.minusPOffset(i, 1, corners.size()); int c2 = CircularIndex.plusPOffset(i, 1, corners.size()); int improved = optimize(contour, corners.get(c0), corners.get(i), corners.get(c2)); if( improved != corners.get(i)) { corners.set(i,improved); change = true; } } } return true; }
[ "public", "boolean", "fit", "(", "List", "<", "Point2D_I32", ">", "contour", ",", "GrowQueue_I32", "corners", ")", "{", "if", "(", "corners", ".", "size", "(", ")", "<", "3", ")", "{", "return", "false", ";", "}", "searchRadius", "=", "Math", ".", "m...
Fits a polygon to the contour given an initial set of candidate corners. If not looping the corners must include the end points still. Minimum of 3 points required. Otherwise there's no corner!. @param contour Contours around the shape @param corners (Input) initial set of corners. (output) refined set of corners
[ "Fits", "a", "polygon", "to", "the", "contour", "given", "an", "initial", "set", "of", "candidate", "corners", ".", "If", "not", "looping", "the", "corners", "must", "include", "the", "end", "points", "still", ".", "Minimum", "of", "3", "points", "required...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java#L92-L125
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java
RefinePolyLineCorner.optimize
protected int optimize( List<Point2D_I32> contour , int c0,int c1,int c2 ) { double bestDistance = computeCost(contour,c0,c1,c2,0); int bestIndex = 0; for( int i = -searchRadius; i <= searchRadius; i++ ) { if( i == 0 ) { // if it found a better point in the first half stop the search since that's probably the correct // direction. Could be improved by remember past search direction if( bestIndex != 0 ) break; } else { double found = computeCost(contour, c0, c1, c2, i); if (found < bestDistance) { bestDistance = found; bestIndex = i; } } } return CircularIndex.addOffset(c1, bestIndex, contour.size()); }
java
protected int optimize( List<Point2D_I32> contour , int c0,int c1,int c2 ) { double bestDistance = computeCost(contour,c0,c1,c2,0); int bestIndex = 0; for( int i = -searchRadius; i <= searchRadius; i++ ) { if( i == 0 ) { // if it found a better point in the first half stop the search since that's probably the correct // direction. Could be improved by remember past search direction if( bestIndex != 0 ) break; } else { double found = computeCost(contour, c0, c1, c2, i); if (found < bestDistance) { bestDistance = found; bestIndex = i; } } } return CircularIndex.addOffset(c1, bestIndex, contour.size()); }
[ "protected", "int", "optimize", "(", "List", "<", "Point2D_I32", ">", "contour", ",", "int", "c0", ",", "int", "c1", ",", "int", "c2", ")", "{", "double", "bestDistance", "=", "computeCost", "(", "contour", ",", "c0", ",", "c1", ",", "c2", ",", "0", ...
Searches around the current c1 point for the best place to put the corner @return location of best corner in local search region
[ "Searches", "around", "the", "current", "c1", "point", "for", "the", "best", "place", "to", "put", "the", "corner" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java#L133-L152
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java
RefinePolyLineCorner.computeCost
protected double computeCost(List<Point2D_I32> contour, int c0, int c1, int c2, int offset) { c1 = CircularIndex.addOffset(c1, offset, contour.size()); createLine(c0,c1,contour,line0); createLine(c1,c2,contour,line1); return distanceSum(line0,c0,c1,contour)+distanceSum(line1,c1,c2,contour); }
java
protected double computeCost(List<Point2D_I32> contour, int c0, int c1, int c2, int offset) { c1 = CircularIndex.addOffset(c1, offset, contour.size()); createLine(c0,c1,contour,line0); createLine(c1,c2,contour,line1); return distanceSum(line0,c0,c1,contour)+distanceSum(line1,c1,c2,contour); }
[ "protected", "double", "computeCost", "(", "List", "<", "Point2D_I32", ">", "contour", ",", "int", "c0", ",", "int", "c1", ",", "int", "c2", ",", "int", "offset", ")", "{", "c1", "=", "CircularIndex", ".", "addOffset", "(", "c1", ",", "offset", ",", ...
Computes the distance between the two lines defined by corner points in the contour @param contour list of contour points @param c0 end point of line 0 @param c1 start of line 0 and 1 @param c2 end point of line 1 @param offset added to c1 to make start of lines @return sum of distance of points along contour
[ "Computes", "the", "distance", "between", "the", "two", "lines", "defined", "by", "corner", "points", "in", "the", "contour" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java#L163-L170
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java
RefinePolyLineCorner.distanceSum
protected double distanceSum( LineGeneral2D_F64 line , int c0 , int c1 , List<Point2D_I32> contour ) { double total = 0; if( c0 < c1 ) { int length = c1-c0+1; int samples = Math.min(maxLineSamples,length); for (int i = 0; i < samples; i++) { int index = c0 + i*(length-1)/(samples-1); total += distance(line,contour.get(index)); } } else { int lengthFirst = contour.size()-c0; int lengthSecond = c1+1; int length = lengthFirst+c1+1; int samples = Math.min(maxLineSamples,length); int samplesFirst = samples*lengthFirst/length; int samplesSecond = samples*lengthSecond/length; for (int i = 0; i < samplesFirst; i++) { int index = c0 + i*lengthFirst/(samples-1); total += distance(line,contour.get(index)); } for (int i = 0; i < samplesSecond; i++) { int index = i*lengthSecond/(samples-1); total += distance(line,contour.get(index)); } } return total; }
java
protected double distanceSum( LineGeneral2D_F64 line , int c0 , int c1 , List<Point2D_I32> contour ) { double total = 0; if( c0 < c1 ) { int length = c1-c0+1; int samples = Math.min(maxLineSamples,length); for (int i = 0; i < samples; i++) { int index = c0 + i*(length-1)/(samples-1); total += distance(line,contour.get(index)); } } else { int lengthFirst = contour.size()-c0; int lengthSecond = c1+1; int length = lengthFirst+c1+1; int samples = Math.min(maxLineSamples,length); int samplesFirst = samples*lengthFirst/length; int samplesSecond = samples*lengthSecond/length; for (int i = 0; i < samplesFirst; i++) { int index = c0 + i*lengthFirst/(samples-1); total += distance(line,contour.get(index)); } for (int i = 0; i < samplesSecond; i++) { int index = i*lengthSecond/(samples-1); total += distance(line,contour.get(index)); } } return total; }
[ "protected", "double", "distanceSum", "(", "LineGeneral2D_F64", "line", ",", "int", "c0", ",", "int", "c1", ",", "List", "<", "Point2D_I32", ">", "contour", ")", "{", "double", "total", "=", "0", ";", "if", "(", "c0", "<", "c1", ")", "{", "int", "len...
Sum of Euclidean distance of contour points along the line
[ "Sum", "of", "Euclidean", "distance", "of", "contour", "points", "along", "the", "line" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java#L175-L205
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java
RefinePolyLineCorner.createLine
private void createLine( int index0 , int index1 , List<Point2D_I32> contour , LineGeneral2D_F64 line ) { if( index1 < 0 ) System.out.println("SHIT"); Point2D_I32 p0 = contour.get(index0); Point2D_I32 p1 = contour.get(index1); // System.out.println("createLine "+p0+" "+p1); work.a.set(p0.x, p0.y); work.b.set(p1.x, p1.y); UtilLine2D_F64.convert(work,line); // ensure A*A + B*B = 1 line.normalize(); }
java
private void createLine( int index0 , int index1 , List<Point2D_I32> contour , LineGeneral2D_F64 line ) { if( index1 < 0 ) System.out.println("SHIT"); Point2D_I32 p0 = contour.get(index0); Point2D_I32 p1 = contour.get(index1); // System.out.println("createLine "+p0+" "+p1); work.a.set(p0.x, p0.y); work.b.set(p1.x, p1.y); UtilLine2D_F64.convert(work,line); // ensure A*A + B*B = 1 line.normalize(); }
[ "private", "void", "createLine", "(", "int", "index0", ",", "int", "index1", ",", "List", "<", "Point2D_I32", ">", "contour", ",", "LineGeneral2D_F64", "line", ")", "{", "if", "(", "index1", "<", "0", ")", "System", ".", "out", ".", "println", "(", "\"...
Given segment information create a line in general notation which has been normalized
[ "Given", "segment", "information", "create", "a", "line", "in", "general", "notation", "which", "has", "been", "normalized" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polyline/RefinePolyLineCorner.java#L217-L233
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/image/ImageGray.java
ImageGray.createSameShape
public <B extends ImageGray<B>> B createSameShape( Class<B> type ) { return GeneralizedImageOps.createSingleBand(type,width,height); }
java
public <B extends ImageGray<B>> B createSameShape( Class<B> type ) { return GeneralizedImageOps.createSingleBand(type,width,height); }
[ "public", "<", "B", "extends", "ImageGray", "<", "B", ">", ">", "B", "createSameShape", "(", "Class", "<", "B", ">", "type", ")", "{", "return", "GeneralizedImageOps", ".", "createSingleBand", "(", "type", ",", "width", ",", "height", ")", ";", "}" ]
Creates a single band image of the specified type that will have the same shape as this image
[ "Creates", "a", "single", "band", "image", "of", "the", "specified", "type", "that", "will", "have", "the", "same", "shape", "as", "this", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/ImageGray.java#L190-L193
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/feature/disparity/VisualizeStereoDisparity.java
VisualizeStereoDisparity.changeImageView
private synchronized void changeImageView() { JComponent comp; if( control.selectedView < 3 ) { BufferedImage img; switch (control.selectedView) { case 0: img = disparityOut; break; case 1: img = colorLeft; break; case 2: img = colorRight; break; default: throw new RuntimeException("Unknown option"); } gui.setImage(img); gui.setPreferredSize(new Dimension(origLeft.getWidth(), origLeft.getHeight())); comp = gui; } else { if( !computedCloud ) { computedCloud = true; DisparityToColorPointCloud d2c = new DisparityToColorPointCloud(); double baseline = calib.getRightToLeft().getT().norm(); d2c.configure(baseline, rectK,rectR, leftRectToPixel, control.minDisparity,control.maxDisparity); d2c.process(activeAlg.getDisparity(),colorLeft); CameraPinhole rectifiedPinhole = PerspectiveOps.matrixToPinhole( rectK,colorLeft.getWidth(),colorLeft.getHeight(),null); pcv.clearPoints(); pcv.setCameraHFov(PerspectiveOps.computeHFov(rectifiedPinhole)); pcv.setTranslationStep(5); pcv.addCloud(d2c.getCloud(),d2c.getCloudColor()); } comp = pcv.getComponent(); comp.requestFocusInWindow(); } panel.remove(gui); panel.remove(pcv.getComponent()); panel.add(comp,BorderLayout.CENTER); panel.validate(); comp.repaint(); processedImage = true; }
java
private synchronized void changeImageView() { JComponent comp; if( control.selectedView < 3 ) { BufferedImage img; switch (control.selectedView) { case 0: img = disparityOut; break; case 1: img = colorLeft; break; case 2: img = colorRight; break; default: throw new RuntimeException("Unknown option"); } gui.setImage(img); gui.setPreferredSize(new Dimension(origLeft.getWidth(), origLeft.getHeight())); comp = gui; } else { if( !computedCloud ) { computedCloud = true; DisparityToColorPointCloud d2c = new DisparityToColorPointCloud(); double baseline = calib.getRightToLeft().getT().norm(); d2c.configure(baseline, rectK,rectR, leftRectToPixel, control.minDisparity,control.maxDisparity); d2c.process(activeAlg.getDisparity(),colorLeft); CameraPinhole rectifiedPinhole = PerspectiveOps.matrixToPinhole( rectK,colorLeft.getWidth(),colorLeft.getHeight(),null); pcv.clearPoints(); pcv.setCameraHFov(PerspectiveOps.computeHFov(rectifiedPinhole)); pcv.setTranslationStep(5); pcv.addCloud(d2c.getCloud(),d2c.getCloudColor()); } comp = pcv.getComponent(); comp.requestFocusInWindow(); } panel.remove(gui); panel.remove(pcv.getComponent()); panel.add(comp,BorderLayout.CENTER); panel.validate(); comp.repaint(); processedImage = true; }
[ "private", "synchronized", "void", "changeImageView", "(", ")", "{", "JComponent", "comp", ";", "if", "(", "control", ".", "selectedView", "<", "3", ")", "{", "BufferedImage", "img", ";", "switch", "(", "control", ".", "selectedView", ")", "{", "case", "0"...
Changes which image is being displayed depending on GUI selection
[ "Changes", "which", "image", "is", "being", "displayed", "depending", "on", "GUI", "selection" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/feature/disparity/VisualizeStereoDisparity.java#L164-L215
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/feature/disparity/VisualizeStereoDisparity.java
VisualizeStereoDisparity.rectifyInputImages
private void rectifyInputImages() { // get intrinsic camera calibration matrices DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(calib.left, (DMatrixRMaj)null); DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(calib.right, (DMatrixRMaj)null); // compute rectification matrices rectifyAlg.process(K1,new Se3_F64(),K2,calib.getRightToLeft().invert(null)); DMatrixRMaj rect1 = rectifyAlg.getRect1(); DMatrixRMaj rect2 = rectifyAlg.getRect2(); rectK = rectifyAlg.getCalibrationMatrix(); rectR = rectifyAlg.getRectifiedRotation(); // adjust view to maximize viewing area while not including black regions RectifyImageOps.allInsideLeft(calib.left, rect1, rect2, rectK); // compute transforms to apply rectify the images leftRectToPixel = transformRectToPixel(calib.left, rect1); ImageType<T> imageType = ImageType.single(activeAlg.getInputType()); FMatrixRMaj rect1_F32 = new FMatrixRMaj(3,3); // TODO simplify code some how FMatrixRMaj rect2_F32 = new FMatrixRMaj(3,3); ConvertMatrixData.convert(rect1, rect1_F32); ConvertMatrixData.convert(rect2, rect2_F32); ImageDistort<T,T> distortRect1 = RectifyImageOps.rectifyImage( calib.left, rect1_F32, BorderType.SKIP,imageType); ImageDistort<T,T> distortRect2 = RectifyImageOps.rectifyImage( calib.right, rect2_F32, BorderType.SKIP, imageType); // rectify and undo distortion distortRect1.apply(inputLeft, rectLeft); distortRect2.apply(inputRight,rectRight); rectifiedImages = true; }
java
private void rectifyInputImages() { // get intrinsic camera calibration matrices DMatrixRMaj K1 = PerspectiveOps.pinholeToMatrix(calib.left, (DMatrixRMaj)null); DMatrixRMaj K2 = PerspectiveOps.pinholeToMatrix(calib.right, (DMatrixRMaj)null); // compute rectification matrices rectifyAlg.process(K1,new Se3_F64(),K2,calib.getRightToLeft().invert(null)); DMatrixRMaj rect1 = rectifyAlg.getRect1(); DMatrixRMaj rect2 = rectifyAlg.getRect2(); rectK = rectifyAlg.getCalibrationMatrix(); rectR = rectifyAlg.getRectifiedRotation(); // adjust view to maximize viewing area while not including black regions RectifyImageOps.allInsideLeft(calib.left, rect1, rect2, rectK); // compute transforms to apply rectify the images leftRectToPixel = transformRectToPixel(calib.left, rect1); ImageType<T> imageType = ImageType.single(activeAlg.getInputType()); FMatrixRMaj rect1_F32 = new FMatrixRMaj(3,3); // TODO simplify code some how FMatrixRMaj rect2_F32 = new FMatrixRMaj(3,3); ConvertMatrixData.convert(rect1, rect1_F32); ConvertMatrixData.convert(rect2, rect2_F32); ImageDistort<T,T> distortRect1 = RectifyImageOps.rectifyImage( calib.left, rect1_F32, BorderType.SKIP,imageType); ImageDistort<T,T> distortRect2 = RectifyImageOps.rectifyImage( calib.right, rect2_F32, BorderType.SKIP, imageType); // rectify and undo distortion distortRect1.apply(inputLeft, rectLeft); distortRect2.apply(inputRight,rectRight); rectifiedImages = true; }
[ "private", "void", "rectifyInputImages", "(", ")", "{", "// get intrinsic camera calibration matrices", "DMatrixRMaj", "K1", "=", "PerspectiveOps", ".", "pinholeToMatrix", "(", "calib", ".", "left", ",", "(", "DMatrixRMaj", ")", "null", ")", ";", "DMatrixRMaj", "K2"...
Removes distortion and rectifies images.
[ "Removes", "distortion", "and", "rectifies", "images", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/feature/disparity/VisualizeStereoDisparity.java#L247-L283
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/feature/disparity/VisualizeStereoDisparity.java
VisualizeStereoDisparity.changeGuiActive
private void changeGuiActive( final boolean error , final boolean reverse ) { SwingUtilities.invokeLater(new Runnable() { public void run() { control.setActiveGui(error,reverse); } }); }
java
private void changeGuiActive( final boolean error , final boolean reverse ) { SwingUtilities.invokeLater(new Runnable() { public void run() { control.setActiveGui(error,reverse); } }); }
[ "private", "void", "changeGuiActive", "(", "final", "boolean", "error", ",", "final", "boolean", "reverse", ")", "{", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "control", ".", "setA...
Active and deactivates different GUI configurations
[ "Active", "and", "deactivates", "different", "GUI", "configurations" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/feature/disparity/VisualizeStereoDisparity.java#L386-L392
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/EciEncoding.java
EciEncoding.guessEncoding
public static String guessEncoding( byte[] message ) { // this function is inspired by a similarly named function in ZXing, but was written from scratch // using specifications for each encoding since I didn't understand what they were doing boolean isUtf8 = true; boolean isJis = true; boolean isIso = true; for (int i = 0; i < message.length; i++) { int v = message[i]&0xFF; if( isUtf8 ) isUtf8 = isValidUTF8(v); if( isJis ) isJis = isValidJIS(v); if( isIso ) isIso = isValidIso8869_1(v); } // System.out.printf("UTF-8=%s ISO=%s JIS=%s\n",isUtf8,isIso,isJis); // If there is ambiguity do it based on how common it is and what the specification says if( isUtf8 ) return UTF8; if( isIso ) return ISO8859_1; if( isJis ) return JIS; return UTF8; }
java
public static String guessEncoding( byte[] message ) { // this function is inspired by a similarly named function in ZXing, but was written from scratch // using specifications for each encoding since I didn't understand what they were doing boolean isUtf8 = true; boolean isJis = true; boolean isIso = true; for (int i = 0; i < message.length; i++) { int v = message[i]&0xFF; if( isUtf8 ) isUtf8 = isValidUTF8(v); if( isJis ) isJis = isValidJIS(v); if( isIso ) isIso = isValidIso8869_1(v); } // System.out.printf("UTF-8=%s ISO=%s JIS=%s\n",isUtf8,isIso,isJis); // If there is ambiguity do it based on how common it is and what the specification says if( isUtf8 ) return UTF8; if( isIso ) return ISO8859_1; if( isJis ) return JIS; return UTF8; }
[ "public", "static", "String", "guessEncoding", "(", "byte", "[", "]", "message", ")", "{", "// this function is inspired by a similarly named function in ZXing, but was written from scratch", "// using specifications for each encoding since I didn't understand what they were doing", "boole...
The encoding for byte messages should be ISO8859_1 or JIS, depending on which version of the specification you follow. In reality people use whatever they want and expect it to magically work. This attempts to figure out if it's ISO8859_1, JIS, or UTF8. UTF-8 is the most common and is used if its ambiguous. @param message The raw byte message with an unknown encoding @return
[ "The", "encoding", "for", "byte", "messages", "should", "be", "ISO8859_1", "or", "JIS", "depending", "on", "which", "version", "of", "the", "specification", "you", "follow", ".", "In", "reality", "people", "use", "whatever", "they", "want", "and", "expect", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/EciEncoding.java#L39-L68
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/core/image/GConvertImage.java
GConvertImage.convert
public static <T extends ImageGray<T>> T convert(ImageGray<?> src , T dst , Class<T> typeDst ) { if (dst == null) { dst =(T) GeneralizedImageOps.createSingleBand(typeDst, src.width, src.height); } else { InputSanityCheck.checkSameShape(src, dst); } convert(src,dst); return dst; }
java
public static <T extends ImageGray<T>> T convert(ImageGray<?> src , T dst , Class<T> typeDst ) { if (dst == null) { dst =(T) GeneralizedImageOps.createSingleBand(typeDst, src.width, src.height); } else { InputSanityCheck.checkSameShape(src, dst); } convert(src,dst); return dst; }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "T", "convert", "(", "ImageGray", "<", "?", ">", "src", ",", "T", "dst", ",", "Class", "<", "T", ">", "typeDst", ")", "{", "if", "(", "dst", "==", "null", ")", "{", "dst"...
Converts an image from one type to another type. Creates a new image instance if an output is not provided. @param src Input image. Not modified. @param dst Converted output image. If null a new one will be declared. Modified. @param typeDst The type of output image. @return Converted image.
[ "Converts", "an", "image", "from", "one", "type", "to", "another", "type", ".", "Creates", "a", "new", "image", "instance", "if", "an", "output", "is", "not", "provided", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/image/GConvertImage.java#L299-L309
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalExtractGeometries.java
TrifocalExtractGeometries.setTensor
public void setTensor( TrifocalTensor tensor ) { this.tensor = tensor; if( !svd.decompose(tensor.T1) ) throw new RuntimeException("SVD failed?!"); SingularOps_DDRM.nullVector(svd, true, v1); SingularOps_DDRM.nullVector(svd, false,u1); // DMatrixRMaj zero = new DMatrixRMaj(3,1); // CommonOps_DDRM.mult(tensor.T1,v1,zero);zero.print(); // CommonOps_DDRM.multTransA(u1,tensor.T1,zero);zero.print(); if( !svd.decompose(tensor.T2) ) throw new RuntimeException("SVD failed?!"); SingularOps_DDRM.nullVector(svd,true,v2); SingularOps_DDRM.nullVector(svd,false,u2); // CommonOps_DDRM.mult(tensor.T2,v2,zero);zero.print(); // CommonOps_DDRM.multTransA(u2,tensor.T2,zero);zero.print(); if( !svd.decompose(tensor.T3) ) throw new RuntimeException("SVD failed?!"); SingularOps_DDRM.nullVector(svd,true,v3); SingularOps_DDRM.nullVector(svd,false,u3); // CommonOps_DDRM.mult(tensor.T3,v3,zero);zero.print(); // CommonOps_DDRM.multTransA(u3,tensor.T3,zero);zero.print(); for( int i = 0; i < 3; i++ ) { U.set(i,0,u1.get(i)); U.set(i,1,u2.get(i)); U.set(i,2,u3.get(i)); V.set(i, 0, v1.get(i)); V.set(i, 1, v2.get(i)); V.set(i, 2, v3.get(i)); } svd.decompose(U); SingularOps_DDRM.nullVector(svd, false, tempE); e2.set(tempE.get(0), tempE.get(1), tempE.get(2)); svd.decompose(V); SingularOps_DDRM.nullVector(svd, false, tempE); e3.set(tempE.get(0), tempE.get(1), tempE.get(2)); }
java
public void setTensor( TrifocalTensor tensor ) { this.tensor = tensor; if( !svd.decompose(tensor.T1) ) throw new RuntimeException("SVD failed?!"); SingularOps_DDRM.nullVector(svd, true, v1); SingularOps_DDRM.nullVector(svd, false,u1); // DMatrixRMaj zero = new DMatrixRMaj(3,1); // CommonOps_DDRM.mult(tensor.T1,v1,zero);zero.print(); // CommonOps_DDRM.multTransA(u1,tensor.T1,zero);zero.print(); if( !svd.decompose(tensor.T2) ) throw new RuntimeException("SVD failed?!"); SingularOps_DDRM.nullVector(svd,true,v2); SingularOps_DDRM.nullVector(svd,false,u2); // CommonOps_DDRM.mult(tensor.T2,v2,zero);zero.print(); // CommonOps_DDRM.multTransA(u2,tensor.T2,zero);zero.print(); if( !svd.decompose(tensor.T3) ) throw new RuntimeException("SVD failed?!"); SingularOps_DDRM.nullVector(svd,true,v3); SingularOps_DDRM.nullVector(svd,false,u3); // CommonOps_DDRM.mult(tensor.T3,v3,zero);zero.print(); // CommonOps_DDRM.multTransA(u3,tensor.T3,zero);zero.print(); for( int i = 0; i < 3; i++ ) { U.set(i,0,u1.get(i)); U.set(i,1,u2.get(i)); U.set(i,2,u3.get(i)); V.set(i, 0, v1.get(i)); V.set(i, 1, v2.get(i)); V.set(i, 2, v3.get(i)); } svd.decompose(U); SingularOps_DDRM.nullVector(svd, false, tempE); e2.set(tempE.get(0), tempE.get(1), tempE.get(2)); svd.decompose(V); SingularOps_DDRM.nullVector(svd, false, tempE); e3.set(tempE.get(0), tempE.get(1), tempE.get(2)); }
[ "public", "void", "setTensor", "(", "TrifocalTensor", "tensor", ")", "{", "this", ".", "tensor", "=", "tensor", ";", "if", "(", "!", "svd", ".", "decompose", "(", "tensor", ".", "T1", ")", ")", "throw", "new", "RuntimeException", "(", "\"SVD failed?!\"", ...
Specifies the input tensor. The epipoles are immediately extracted since they are needed to extract all other data structures @param tensor The tensor. Reference is saved but not modified
[ "Specifies", "the", "input", "tensor", ".", "The", "epipoles", "are", "immediately", "extracted", "since", "they", "are", "needed", "to", "extract", "all", "other", "data", "structures" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalExtractGeometries.java#L92-L135
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalExtractGeometries.java
TrifocalExtractGeometries.extractEpipoles
public void extractEpipoles( Point3D_F64 e2 , Point3D_F64 e3 ) { e2.set(this.e2); e3.set(this.e3); }
java
public void extractEpipoles( Point3D_F64 e2 , Point3D_F64 e3 ) { e2.set(this.e2); e3.set(this.e3); }
[ "public", "void", "extractEpipoles", "(", "Point3D_F64", "e2", ",", "Point3D_F64", "e3", ")", "{", "e2", ".", "set", "(", "this", ".", "e2", ")", ";", "e3", ".", "set", "(", "this", ".", "e3", ")", ";", "}" ]
Extracts the epipoles from the trifocal tensor. Extracted epipoles will have a norm of 1 as an artifact of using SVD. @param e2 Output: Epipole in image 2. Homogeneous coordinates. Modified @param e3 Output: Epipole in image 3. Homogeneous coordinates. Modified
[ "Extracts", "the", "epipoles", "from", "the", "trifocal", "tensor", ".", "Extracted", "epipoles", "will", "have", "a", "norm", "of", "1", "as", "an", "artifact", "of", "using", "SVD", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalExtractGeometries.java#L144-L147
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/color/GHistogramFeatureOps.java
GHistogramFeatureOps.histogram
public static <T extends ImageGray<T>> void histogram( T image , double minPixelValue , double maxPixelValue , TupleDesc_F64 histogram ) { if( image.getClass() == GrayU8.class ) { HistogramFeatureOps.histogram((GrayU8) image, (int) maxPixelValue, histogram); } else if( image.getClass() == GrayU16.class ) { HistogramFeatureOps.histogram((GrayU16) image, (int) maxPixelValue, histogram); } else if( image.getClass() == GrayF32.class ) { HistogramFeatureOps.histogram((GrayF32) image, (float) minPixelValue, (float) maxPixelValue, histogram); } else { throw new IllegalArgumentException("Unsupported band type"); } }
java
public static <T extends ImageGray<T>> void histogram( T image , double minPixelValue , double maxPixelValue , TupleDesc_F64 histogram ) { if( image.getClass() == GrayU8.class ) { HistogramFeatureOps.histogram((GrayU8) image, (int) maxPixelValue, histogram); } else if( image.getClass() == GrayU16.class ) { HistogramFeatureOps.histogram((GrayU16) image, (int) maxPixelValue, histogram); } else if( image.getClass() == GrayF32.class ) { HistogramFeatureOps.histogram((GrayF32) image, (float) minPixelValue, (float) maxPixelValue, histogram); } else { throw new IllegalArgumentException("Unsupported band type"); } }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "void", "histogram", "(", "T", "image", ",", "double", "minPixelValue", ",", "double", "maxPixelValue", ",", "TupleDesc_F64", "histogram", ")", "{", "if", "(", "image", ".", "getClas...
Computes a single-band normalized histogram for any single band image. @param image Input image. Not modified. @param minPixelValue Minimum possible value for a pixel. @param maxPixelValue Maximum possible value for a pixel. @param histogram The output histogram.
[ "Computes", "a", "single", "-", "band", "normalized", "histogram", "for", "any", "single", "band", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/color/GHistogramFeatureOps.java#L41-L52
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/color/GHistogramFeatureOps.java
GHistogramFeatureOps.histogram
public static void histogram( double[] colors, int length , Histogram_F64 histogram ) { if( length % histogram.getDimensions() != 0 ) throw new IllegalArgumentException("Length does not match dimensions"); int coordinate[] = new int[ histogram.getDimensions() ]; histogram.fill(0); for (int i = 0; i < length; ) { for (int j = 0; j < coordinate.length; j++, i++) { coordinate[j] = histogram.getDimensionIndex(j,colors[i]); } int index = histogram.getIndex(coordinate); histogram.value[index] += 1.0; } }
java
public static void histogram( double[] colors, int length , Histogram_F64 histogram ) { if( length % histogram.getDimensions() != 0 ) throw new IllegalArgumentException("Length does not match dimensions"); int coordinate[] = new int[ histogram.getDimensions() ]; histogram.fill(0); for (int i = 0; i < length; ) { for (int j = 0; j < coordinate.length; j++, i++) { coordinate[j] = histogram.getDimensionIndex(j,colors[i]); } int index = histogram.getIndex(coordinate); histogram.value[index] += 1.0; } }
[ "public", "static", "void", "histogram", "(", "double", "[", "]", "colors", ",", "int", "length", ",", "Histogram_F64", "histogram", ")", "{", "if", "(", "length", "%", "histogram", ".", "getDimensions", "(", ")", "!=", "0", ")", "throw", "new", "Illegal...
Computes a coupled histogram from a list of colors. If the input is for integer values then add one to the maximum value. For example if the range of values is 0 to 255, then make it 0 to 256. @param colors List of colors stored in an interleaved format @param length Length of usable portion of colors @param histogram Output and histogram configuration.
[ "Computes", "a", "coupled", "histogram", "from", "a", "list", "of", "colors", ".", "If", "the", "input", "is", "for", "integer", "values", "then", "add", "one", "to", "the", "maximum", "value", ".", "For", "example", "if", "the", "range", "of", "values",...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/color/GHistogramFeatureOps.java#L84-L101
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/ScaleSceneStructure.java
ScaleSceneStructure.computePointStatistics
void computePointStatistics(Point[] points ) { final int length = points.length; double v[] = new double[length]; for (int axis = 0; axis < 3; axis++) { double maxAbs = 0; for (int i = 0; i < length; i++) { v[i] = points[i].coordinate[axis]; maxAbs = Math.max( maxAbs , Math.abs(v[i])); } double median = QuickSelect.select(v,length/2,length); switch( axis ) { case 0: medianPoint.x = median; break; case 1: medianPoint.y = median; break; case 2: medianPoint.z = median; break; } } for (int i = 0; i < length; i++) { v[i] = points[i].distanceSq(medianPoint); } medianDistancePoint = Math.sqrt(QuickSelect.select(v,length/2,length)); // System.out.println("Median P ="+ medianPoint); // System.out.println("Median R ="+ medianDistancePoint); // System.out.println("Scale ="+ (desiredDistancePoint / medianDistancePoint)); }
java
void computePointStatistics(Point[] points ) { final int length = points.length; double v[] = new double[length]; for (int axis = 0; axis < 3; axis++) { double maxAbs = 0; for (int i = 0; i < length; i++) { v[i] = points[i].coordinate[axis]; maxAbs = Math.max( maxAbs , Math.abs(v[i])); } double median = QuickSelect.select(v,length/2,length); switch( axis ) { case 0: medianPoint.x = median; break; case 1: medianPoint.y = median; break; case 2: medianPoint.z = median; break; } } for (int i = 0; i < length; i++) { v[i] = points[i].distanceSq(medianPoint); } medianDistancePoint = Math.sqrt(QuickSelect.select(v,length/2,length)); // System.out.println("Median P ="+ medianPoint); // System.out.println("Median R ="+ medianDistancePoint); // System.out.println("Scale ="+ (desiredDistancePoint / medianDistancePoint)); }
[ "void", "computePointStatistics", "(", "Point", "[", "]", "points", ")", "{", "final", "int", "length", "=", "points", ".", "length", ";", "double", "v", "[", "]", "=", "new", "double", "[", "length", "]", ";", "for", "(", "int", "axis", "=", "0", ...
For 3D points, computes the median value and variance along each dimension.
[ "For", "3D", "points", "computes", "the", "median", "value", "and", "variance", "along", "each", "dimension", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/ScaleSceneStructure.java#L217-L244
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/ScaleSceneStructure.java
ScaleSceneStructure.undoScale
public void undoScale( SceneStructureMetric structure , SceneObservations observations ) { if( structure.homogenous ) return; double scale = desiredDistancePoint / medianDistancePoint; undoNormPoints3D(structure, scale); Point3D_F64 c = new Point3D_F64(); for (int i = 0; i < structure.views.length; i++) { SceneStructureMetric.View view = structure.views[i]; // X_w = R'*(X_c - T) let X_c = 0 then X_w = -R'*T is center of camera in world GeometryMath_F64.multTran(view.worldToView.R,view.worldToView.T,c); // Apply transform c.x = (-c.x/scale + medianPoint.x); c.y = (-c.y/scale + medianPoint.y); c.z = (-c.z/scale + medianPoint.z); // -R*T GeometryMath_F64.mult(view.worldToView.R,c,view.worldToView.T); view.worldToView.T.scale(-1); } }
java
public void undoScale( SceneStructureMetric structure , SceneObservations observations ) { if( structure.homogenous ) return; double scale = desiredDistancePoint / medianDistancePoint; undoNormPoints3D(structure, scale); Point3D_F64 c = new Point3D_F64(); for (int i = 0; i < structure.views.length; i++) { SceneStructureMetric.View view = structure.views[i]; // X_w = R'*(X_c - T) let X_c = 0 then X_w = -R'*T is center of camera in world GeometryMath_F64.multTran(view.worldToView.R,view.worldToView.T,c); // Apply transform c.x = (-c.x/scale + medianPoint.x); c.y = (-c.y/scale + medianPoint.y); c.z = (-c.z/scale + medianPoint.z); // -R*T GeometryMath_F64.mult(view.worldToView.R,c,view.worldToView.T); view.worldToView.T.scale(-1); } }
[ "public", "void", "undoScale", "(", "SceneStructureMetric", "structure", ",", "SceneObservations", "observations", ")", "{", "if", "(", "structure", ".", "homogenous", ")", "return", ";", "double", "scale", "=", "desiredDistancePoint", "/", "medianDistancePoint", ";...
Undoes scale transform for metric. @param structure scene's structure @param observations observations of the scene
[ "Undoes", "scale", "transform", "for", "metric", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/ScaleSceneStructure.java#L282-L308
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/RemovePerspectiveDistortion.java
RemovePerspectiveDistortion.apply
public boolean apply( T input , Point2D_F64 corner0 , Point2D_F64 corner1 , Point2D_F64 corner2 , Point2D_F64 corner3 ) { if( createTransform(corner0, corner1, corner2, corner3)) { distort.input(input).apply(); return true; } else { return false; } }
java
public boolean apply( T input , Point2D_F64 corner0 , Point2D_F64 corner1 , Point2D_F64 corner2 , Point2D_F64 corner3 ) { if( createTransform(corner0, corner1, corner2, corner3)) { distort.input(input).apply(); return true; } else { return false; } }
[ "public", "boolean", "apply", "(", "T", "input", ",", "Point2D_F64", "corner0", ",", "Point2D_F64", "corner1", ",", "Point2D_F64", "corner2", ",", "Point2D_F64", "corner3", ")", "{", "if", "(", "createTransform", "(", "corner0", ",", "corner1", ",", "corner2",...
Applies distortion removal to the specified region in the input image. The undistorted image is returned. @param input Input image @param corner0 Top left corner @param corner1 Top right corner @param corner2 Bottom right corner @param corner3 Bottom left corner @return true if successful or false if it failed
[ "Applies", "distortion", "removal", "to", "the", "specified", "region", "in", "the", "input", "image", ".", "The", "undistorted", "image", "is", "returned", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/RemovePerspectiveDistortion.java#L103-L114
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/RemovePerspectiveDistortion.java
RemovePerspectiveDistortion.createTransform
public boolean createTransform( Point2D_F64 tl , Point2D_F64 tr , Point2D_F64 br , Point2D_F64 bl ) { associatedPairs.get(0).p2.set(tl); associatedPairs.get(1).p2.set(tr); associatedPairs.get(2).p2.set(br); associatedPairs.get(3).p2.set(bl); if( !computeHomography.process(associatedPairs, H) ) return false; // if( !refineHomography.fitModel(associatedPairs,H,Hrefined) ) { // return false; // } // homography.set(Hrefined); ConvertMatrixData.convert(H,H32); transform.set(H32); return true; }
java
public boolean createTransform( Point2D_F64 tl , Point2D_F64 tr , Point2D_F64 br , Point2D_F64 bl ) { associatedPairs.get(0).p2.set(tl); associatedPairs.get(1).p2.set(tr); associatedPairs.get(2).p2.set(br); associatedPairs.get(3).p2.set(bl); if( !computeHomography.process(associatedPairs, H) ) return false; // if( !refineHomography.fitModel(associatedPairs,H,Hrefined) ) { // return false; // } // homography.set(Hrefined); ConvertMatrixData.convert(H,H32); transform.set(H32); return true; }
[ "public", "boolean", "createTransform", "(", "Point2D_F64", "tl", ",", "Point2D_F64", "tr", ",", "Point2D_F64", "br", ",", "Point2D_F64", "bl", ")", "{", "associatedPairs", ".", "get", "(", "0", ")", ".", "p2", ".", "set", "(", "tl", ")", ";", "associate...
Compues the distortion removal transform @param tl Top left corner @param tr Top right corner @param br Bottom right corner @param bl Bottom left corner @return true if successful or false if it failed
[ "Compues", "the", "distortion", "removal", "transform" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/RemovePerspectiveDistortion.java#L125-L145
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/filter/convolve/ConvolveImageDownNormalized.java
ConvolveImageDownNormalized.vertical
public static void vertical(Kernel1D_F32 kernel, GrayF32 image, GrayF32 dest , int skip ) { checkParameters(image, dest, skip); if( kernel.width >= image.width ) { ConvolveDownNormalizedNaive.vertical(kernel,image,dest,skip); } else { ConvolveImageDownNoBorder.vertical(kernel,image,dest,skip); ConvolveDownNormalized_JustBorder.vertical(kernel,image,dest,skip); } }
java
public static void vertical(Kernel1D_F32 kernel, GrayF32 image, GrayF32 dest , int skip ) { checkParameters(image, dest, skip); if( kernel.width >= image.width ) { ConvolveDownNormalizedNaive.vertical(kernel,image,dest,skip); } else { ConvolveImageDownNoBorder.vertical(kernel,image,dest,skip); ConvolveDownNormalized_JustBorder.vertical(kernel,image,dest,skip); } }
[ "public", "static", "void", "vertical", "(", "Kernel1D_F32", "kernel", ",", "GrayF32", "image", ",", "GrayF32", "dest", ",", "int", "skip", ")", "{", "checkParameters", "(", "image", ",", "dest", ",", "skip", ")", ";", "if", "(", "kernel", ".", "width", ...
Performs a vertical 1D down convolution across the image while re-normalizing the kernel depending on its overlap with the image. @param image The original image. Not modified. @param dest Where the resulting image is written to. Modified. @param kernel The kernel that is being convolved. Not modified.
[ "Performs", "a", "vertical", "1D", "down", "convolution", "across", "the", "image", "while", "re", "-", "normalizing", "the", "kernel", "depending", "on", "its", "overlap", "with", "the", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/convolve/ConvolveImageDownNormalized.java#L71-L80
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/distort/brown/RemoveBrownNtoN_F32.java
RemoveBrownNtoN_F32.removeRadial
public static void removeRadial(float x, float y, float[] radial, float t1, float t2, Point2D_F32 out, float tol ) { float origX = x; float origY = y; float prevSum = 0; for( int iter = 0; iter < 500; iter++ ) { // estimate the radial distance float r2 = x*x + y*y; float ri2 = r2; float sum = 0; for( int i = 0; i < radial.length; i++ ) { sum += radial[i]*ri2; ri2 *= r2; } float tx = 2.0f*t1*x*y + t2*(r2 + 2.0f*x*x); float ty = t1*(r2 + 2.0f*y*y) + 2.0f*t2*x*y; x = (origX - tx)/(1.0f + sum); y = (origY - ty)/(1.0f + sum); if( (float)Math.abs(prevSum-sum) <= tol ) { break; } else { prevSum = sum; } } out.set(x,y); }
java
public static void removeRadial(float x, float y, float[] radial, float t1, float t2, Point2D_F32 out, float tol ) { float origX = x; float origY = y; float prevSum = 0; for( int iter = 0; iter < 500; iter++ ) { // estimate the radial distance float r2 = x*x + y*y; float ri2 = r2; float sum = 0; for( int i = 0; i < radial.length; i++ ) { sum += radial[i]*ri2; ri2 *= r2; } float tx = 2.0f*t1*x*y + t2*(r2 + 2.0f*x*x); float ty = t1*(r2 + 2.0f*y*y) + 2.0f*t2*x*y; x = (origX - tx)/(1.0f + sum); y = (origY - ty)/(1.0f + sum); if( (float)Math.abs(prevSum-sum) <= tol ) { break; } else { prevSum = sum; } } out.set(x,y); }
[ "public", "static", "void", "removeRadial", "(", "float", "x", ",", "float", "y", ",", "float", "[", "]", "radial", ",", "float", "t1", ",", "float", "t2", ",", "Point2D_F32", "out", ",", "float", "tol", ")", "{", "float", "origX", "=", "x", ";", "...
Static function for removing radial and tangential distortion @param x Distorted x-coordinate normalized image coordinate @param y Distorted y-coordinate normalized image coordinate @param radial Radial distortion parameters @param t1 tangential distortion @param t2 tangential distortion @param out Undistorted normalized image coordinate @param tol convergence tolerance
[ "Static", "function", "for", "removing", "radial", "and", "tangential", "distortion" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/distort/brown/RemoveBrownNtoN_F32.java#L85-L117
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/SnapToEllipseEdge.java
SnapToEllipseEdge.process
public boolean process(EllipseRotated_F64 input, EllipseRotated_F64 refined) { refined.set(input); previous.set(input); for (int iteration = 0; iteration < maxIterations; iteration++) { refined.set(previous); computePointsAndWeights(refined); if( fitter.process(samplePts.toList(),weights.data) ) { // Get the results in local coordinates UtilEllipse_F64.convert(fitter.getEllipse(),refined); // convert back into image coordinates double scale = previous.a; refined.center.x = refined.center.x*scale + previous.center.x; refined.center.y = refined.center.y*scale + previous.center.y; refined.a *= scale; refined.b *= scale; } else { return false; } // stop once the change between two iterations is insignificant if( change(previous,refined) <= convergenceTol) { return true; } else { previous.set(refined); } } return true; }
java
public boolean process(EllipseRotated_F64 input, EllipseRotated_F64 refined) { refined.set(input); previous.set(input); for (int iteration = 0; iteration < maxIterations; iteration++) { refined.set(previous); computePointsAndWeights(refined); if( fitter.process(samplePts.toList(),weights.data) ) { // Get the results in local coordinates UtilEllipse_F64.convert(fitter.getEllipse(),refined); // convert back into image coordinates double scale = previous.a; refined.center.x = refined.center.x*scale + previous.center.x; refined.center.y = refined.center.y*scale + previous.center.y; refined.a *= scale; refined.b *= scale; } else { return false; } // stop once the change between two iterations is insignificant if( change(previous,refined) <= convergenceTol) { return true; } else { previous.set(refined); } } return true; }
[ "public", "boolean", "process", "(", "EllipseRotated_F64", "input", ",", "EllipseRotated_F64", "refined", ")", "{", "refined", ".", "set", "(", "input", ")", ";", "previous", ".", "set", "(", "input", ")", ";", "for", "(", "int", "iteration", "=", "0", "...
Refines provided list by snapping it to edges found in the image @param input (Output) Close approximation of the ellipse in the image @param refined (Output) Storage for refined estimate. Can be same instance as input @return True if a refined estimate could be found, false if it failed
[ "Refines", "provided", "list", "by", "snapping", "it", "to", "edges", "found", "in", "the", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/SnapToEllipseEdge.java#L81-L111
train