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/misc/GPixelMath.java
GPixelMath.boundImage
public static <T extends ImageBase<T>> void boundImage(T input , double min , double max ) { if( input instanceof ImageGray ) { if (GrayU8.class == input.getClass()) { PixelMath.boundImage((GrayU8) input, (int) min, (int) max); } else if (GrayS8.class == input.getClass()) { PixelMath.boundImage((GrayS8) input, (int) min, (int) max); } else if (GrayU16.class == input.getClass()) { PixelMath.boundImage((GrayU16) input, (int) min, (int) max); } else if (GrayS16.class == input.getClass()) { PixelMath.boundImage((GrayS16) input, (int) min, (int) max); } else if (GrayS32.class == input.getClass()) { PixelMath.boundImage((GrayS32) input, (int) min, (int) max); } else if (GrayS64.class == input.getClass()) { PixelMath.boundImage((GrayS64) input, (long) min, (long) max); } else if (GrayF32.class == input.getClass()) { PixelMath.boundImage((GrayF32) input, (float) min, (float) max); } else if (GrayF64.class == input.getClass()) { PixelMath.boundImage((GrayF64) input, min, max); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); } } else if( input instanceof Planar ) { Planar in = (Planar)input; for (int i = 0; i < in.getNumBands(); i++) { boundImage( in.getBand(i), min, max); } } }
java
public static <T extends ImageBase<T>> void boundImage(T input , double min , double max ) { if( input instanceof ImageGray ) { if (GrayU8.class == input.getClass()) { PixelMath.boundImage((GrayU8) input, (int) min, (int) max); } else if (GrayS8.class == input.getClass()) { PixelMath.boundImage((GrayS8) input, (int) min, (int) max); } else if (GrayU16.class == input.getClass()) { PixelMath.boundImage((GrayU16) input, (int) min, (int) max); } else if (GrayS16.class == input.getClass()) { PixelMath.boundImage((GrayS16) input, (int) min, (int) max); } else if (GrayS32.class == input.getClass()) { PixelMath.boundImage((GrayS32) input, (int) min, (int) max); } else if (GrayS64.class == input.getClass()) { PixelMath.boundImage((GrayS64) input, (long) min, (long) max); } else if (GrayF32.class == input.getClass()) { PixelMath.boundImage((GrayF32) input, (float) min, (float) max); } else if (GrayF64.class == input.getClass()) { PixelMath.boundImage((GrayF64) input, min, max); } else { throw new IllegalArgumentException("Unknown image Type: " + input.getClass().getSimpleName()); } } else if( input instanceof Planar ) { Planar in = (Planar)input; for (int i = 0; i < in.getNumBands(); i++) { boundImage( in.getBand(i), min, max); } } }
[ "public", "static", "<", "T", "extends", "ImageBase", "<", "T", ">", ">", "void", "boundImage", "(", "T", "input", ",", "double", "min", ",", "double", "max", ")", "{", "if", "(", "input", "instanceof", "ImageGray", ")", "{", "if", "(", "GrayU8", "."...
Bounds image pixels to be between these two values. @param input Input image. @param min minimum value. Inclusive. @param max maximum value. Inclusive.
[ "Bounds", "image", "pixels", "to", "be", "between", "these", "two", "values", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/misc/GPixelMath.java#L1039-L1067
train
lessthanoptimal/BoofCV
demonstrations/src/main/java/boofcv/demonstrations/feature/describe/VisualizeRegionDescriptionApp.java
VisualizeRegionDescriptionApp.updateTargetDescription
private void updateTargetDescription() { if( targetPt != null ) { TupleDesc feature = describe.createDescription(); describe.process(targetPt.x,targetPt.y,targetOrientation,targetRadius,feature); tuplePanel.setDescription(feature); } else { tuplePanel.setDescription(null); } tuplePanel.repaint(); }
java
private void updateTargetDescription() { if( targetPt != null ) { TupleDesc feature = describe.createDescription(); describe.process(targetPt.x,targetPt.y,targetOrientation,targetRadius,feature); tuplePanel.setDescription(feature); } else { tuplePanel.setDescription(null); } tuplePanel.repaint(); }
[ "private", "void", "updateTargetDescription", "(", ")", "{", "if", "(", "targetPt", "!=", "null", ")", "{", "TupleDesc", "feature", "=", "describe", ".", "createDescription", "(", ")", ";", "describe", ".", "process", "(", "targetPt", ".", "x", ",", "targe...
Extracts the target description and updates the panel. Should only be called from a swing thread
[ "Extracts", "the", "target", "description", "and", "updates", "the", "panel", ".", "Should", "only", "be", "called", "from", "a", "swing", "thread" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/feature/describe/VisualizeRegionDescriptionApp.java#L163-L172
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.inducedHomography13
public static DMatrixRMaj inducedHomography13( TrifocalTensor tensor , Vector3D_F64 line2 , DMatrixRMaj output ) { if( output == null ) output = new DMatrixRMaj(3,3); DMatrixRMaj T = tensor.T1; // H(:,0) = transpose(T1)*line output.data[0] = T.data[0]*line2.x + T.data[3]*line2.y + T.data[6]*line2.z; output.data[3] = T.data[1]*line2.x + T.data[4]*line2.y + T.data[7]*line2.z; output.data[6] = T.data[2]*line2.x + T.data[5]*line2.y + T.data[8]*line2.z; // H(:,1) = transpose(T2)*line T = tensor.T2; output.data[1] = T.data[0]*line2.x + T.data[3]*line2.y + T.data[6]*line2.z; output.data[4] = T.data[1]*line2.x + T.data[4]*line2.y + T.data[7]*line2.z; output.data[7] = T.data[2]*line2.x + T.data[5]*line2.y + T.data[8]*line2.z; // H(:,2) = transpose(T3)*line T = tensor.T3; output.data[2] = T.data[0]*line2.x + T.data[3]*line2.y + T.data[6]*line2.z; output.data[5] = T.data[1]*line2.x + T.data[4]*line2.y + T.data[7]*line2.z; output.data[8] = T.data[2]*line2.x + T.data[5]*line2.y + T.data[8]*line2.z; // Vector3D_F64 temp = new Vector3D_F64(); // // for( int i = 0; i < 3; i++ ) { // GeometryMath_F64.multTran(tensor.getT(i),line,temp); // output.unsafe_set(0,i,temp.x); // output.unsafe_set(1,i,temp.y); // output.unsafe_set(2,i,temp.z); // } return output; }
java
public static DMatrixRMaj inducedHomography13( TrifocalTensor tensor , Vector3D_F64 line2 , DMatrixRMaj output ) { if( output == null ) output = new DMatrixRMaj(3,3); DMatrixRMaj T = tensor.T1; // H(:,0) = transpose(T1)*line output.data[0] = T.data[0]*line2.x + T.data[3]*line2.y + T.data[6]*line2.z; output.data[3] = T.data[1]*line2.x + T.data[4]*line2.y + T.data[7]*line2.z; output.data[6] = T.data[2]*line2.x + T.data[5]*line2.y + T.data[8]*line2.z; // H(:,1) = transpose(T2)*line T = tensor.T2; output.data[1] = T.data[0]*line2.x + T.data[3]*line2.y + T.data[6]*line2.z; output.data[4] = T.data[1]*line2.x + T.data[4]*line2.y + T.data[7]*line2.z; output.data[7] = T.data[2]*line2.x + T.data[5]*line2.y + T.data[8]*line2.z; // H(:,2) = transpose(T3)*line T = tensor.T3; output.data[2] = T.data[0]*line2.x + T.data[3]*line2.y + T.data[6]*line2.z; output.data[5] = T.data[1]*line2.x + T.data[4]*line2.y + T.data[7]*line2.z; output.data[8] = T.data[2]*line2.x + T.data[5]*line2.y + T.data[8]*line2.z; // Vector3D_F64 temp = new Vector3D_F64(); // // for( int i = 0; i < 3; i++ ) { // GeometryMath_F64.multTran(tensor.getT(i),line,temp); // output.unsafe_set(0,i,temp.x); // output.unsafe_set(1,i,temp.y); // output.unsafe_set(2,i,temp.z); // } return output; }
[ "public", "static", "DMatrixRMaj", "inducedHomography13", "(", "TrifocalTensor", "tensor", ",", "Vector3D_F64", "line2", ",", "DMatrixRMaj", "output", ")", "{", "if", "(", "output", "==", "null", ")", "output", "=", "new", "DMatrixRMaj", "(", "3", ",", "3", ...
Computes the homography induced from view 1 to 3 by a line in view 2. The provided line in view 2 must contain the view 2 observation. p3 = H13*p1 @param tensor Input: Trifocal tensor @param line2 Input: Line in view 2. {@link LineGeneral2D_F64 General notation}. @param output Output: Optional storage for homography. 3x3 matrix @return Homography from view 1 to 3
[ "Computes", "the", "homography", "induced", "from", "view", "1", "to", "3", "by", "a", "line", "in", "view", "2", ".", "The", "provided", "line", "in", "view", "2", "must", "contain", "the", "view", "2", "observation", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L438-L473
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.inducedHomography12
public static DMatrixRMaj inducedHomography12( TrifocalTensor tensor , Vector3D_F64 line3 , DMatrixRMaj output ) { if( output == null ) output = new DMatrixRMaj(3,3); // H(:,0) = T1*line DMatrixRMaj T = tensor.T1; output.data[0] = T.data[0]*line3.x + T.data[1]*line3.y + T.data[2]*line3.z; output.data[3] = T.data[3]*line3.x + T.data[4]*line3.y + T.data[5]*line3.z; output.data[6] = T.data[6]*line3.x + T.data[7]*line3.y + T.data[8]*line3.z; // H(:,0) = T2*line T = tensor.T2; output.data[1] = T.data[0]*line3.x + T.data[1]*line3.y + T.data[2]*line3.z; output.data[4] = T.data[3]*line3.x + T.data[4]*line3.y + T.data[5]*line3.z; output.data[7] = T.data[6]*line3.x + T.data[7]*line3.y + T.data[8]*line3.z; // H(:,0) = T3*line T = tensor.T3; output.data[2] = T.data[0]*line3.x + T.data[1]*line3.y + T.data[2]*line3.z; output.data[5] = T.data[3]*line3.x + T.data[4]*line3.y + T.data[5]*line3.z; output.data[8] = T.data[6]*line3.x + T.data[7]*line3.y + T.data[8]*line3.z; // Vector3D_F64 temp = new Vector3D_F64(); // // for( int i = 0; i < 3; i++ ) { // GeometryMath_F64.mult(tensor.getT(i), line, temp); // output.unsafe_set(0,i,temp.x); // output.unsafe_set(1,i,temp.y); // output.unsafe_set(2,i,temp.z); // } return output; }
java
public static DMatrixRMaj inducedHomography12( TrifocalTensor tensor , Vector3D_F64 line3 , DMatrixRMaj output ) { if( output == null ) output = new DMatrixRMaj(3,3); // H(:,0) = T1*line DMatrixRMaj T = tensor.T1; output.data[0] = T.data[0]*line3.x + T.data[1]*line3.y + T.data[2]*line3.z; output.data[3] = T.data[3]*line3.x + T.data[4]*line3.y + T.data[5]*line3.z; output.data[6] = T.data[6]*line3.x + T.data[7]*line3.y + T.data[8]*line3.z; // H(:,0) = T2*line T = tensor.T2; output.data[1] = T.data[0]*line3.x + T.data[1]*line3.y + T.data[2]*line3.z; output.data[4] = T.data[3]*line3.x + T.data[4]*line3.y + T.data[5]*line3.z; output.data[7] = T.data[6]*line3.x + T.data[7]*line3.y + T.data[8]*line3.z; // H(:,0) = T3*line T = tensor.T3; output.data[2] = T.data[0]*line3.x + T.data[1]*line3.y + T.data[2]*line3.z; output.data[5] = T.data[3]*line3.x + T.data[4]*line3.y + T.data[5]*line3.z; output.data[8] = T.data[6]*line3.x + T.data[7]*line3.y + T.data[8]*line3.z; // Vector3D_F64 temp = new Vector3D_F64(); // // for( int i = 0; i < 3; i++ ) { // GeometryMath_F64.mult(tensor.getT(i), line, temp); // output.unsafe_set(0,i,temp.x); // output.unsafe_set(1,i,temp.y); // output.unsafe_set(2,i,temp.z); // } return output; }
[ "public", "static", "DMatrixRMaj", "inducedHomography12", "(", "TrifocalTensor", "tensor", ",", "Vector3D_F64", "line3", ",", "DMatrixRMaj", "output", ")", "{", "if", "(", "output", "==", "null", ")", "output", "=", "new", "DMatrixRMaj", "(", "3", ",", "3", ...
Computes the homography induced from view 1 to 2 by a line in view 3. The provided line in view 3 must contain the view 3 observation. p2 = H12*p1 @param tensor Input: Trifocal tensor @param line3 Input: Line in view 3. {@link LineGeneral2D_F64 General notation}. @param output Output: Optional storage for homography. 3x3 matrix @return Homography from view 1 to 2
[ "Computes", "the", "homography", "induced", "from", "view", "1", "to", "2", "by", "a", "line", "in", "view", "3", ".", "The", "provided", "line", "in", "view", "3", "must", "contain", "the", "view", "3", "observation", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L486-L520
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.homographyStereo3Pts
public static DMatrixRMaj homographyStereo3Pts( DMatrixRMaj F , AssociatedPair p1, AssociatedPair p2, AssociatedPair p3) { HomographyInducedStereo3Pts alg = new HomographyInducedStereo3Pts(); alg.setFundamental(F,null); if( !alg.process(p1,p2,p3) ) return null; return alg.getHomography(); }
java
public static DMatrixRMaj homographyStereo3Pts( DMatrixRMaj F , AssociatedPair p1, AssociatedPair p2, AssociatedPair p3) { HomographyInducedStereo3Pts alg = new HomographyInducedStereo3Pts(); alg.setFundamental(F,null); if( !alg.process(p1,p2,p3) ) return null; return alg.getHomography(); }
[ "public", "static", "DMatrixRMaj", "homographyStereo3Pts", "(", "DMatrixRMaj", "F", ",", "AssociatedPair", "p1", ",", "AssociatedPair", "p2", ",", "AssociatedPair", "p3", ")", "{", "HomographyInducedStereo3Pts", "alg", "=", "new", "HomographyInducedStereo3Pts", "(", "...
Computes the homography induced from a planar surface when viewed from two views using correspondences of three points. Observations must be on the planar surface. @see boofcv.alg.geo.h.HomographyInducedStereo3Pts @param F Fundamental matrix @param p1 Associated point observation @param p2 Associated point observation @param p3 Associated point observation @return The homography from view 1 to view 2 or null if it fails
[ "Computes", "the", "homography", "induced", "from", "a", "planar", "surface", "when", "viewed", "from", "two", "views", "using", "correspondences", "of", "three", "points", ".", "Observations", "must", "be", "on", "the", "planar", "surface", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L534-L541
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.homographyStereoLinePt
public static DMatrixRMaj homographyStereoLinePt( DMatrixRMaj F , PairLineNorm line, AssociatedPair point) { HomographyInducedStereoLinePt alg = new HomographyInducedStereoLinePt(); alg.setFundamental(F,null); alg.process(line,point); return alg.getHomography(); }
java
public static DMatrixRMaj homographyStereoLinePt( DMatrixRMaj F , PairLineNorm line, AssociatedPair point) { HomographyInducedStereoLinePt alg = new HomographyInducedStereoLinePt(); alg.setFundamental(F,null); alg.process(line,point); return alg.getHomography(); }
[ "public", "static", "DMatrixRMaj", "homographyStereoLinePt", "(", "DMatrixRMaj", "F", ",", "PairLineNorm", "line", ",", "AssociatedPair", "point", ")", "{", "HomographyInducedStereoLinePt", "alg", "=", "new", "HomographyInducedStereoLinePt", "(", ")", ";", "alg", ".",...
Computes the homography induced from a planar surface when viewed from two views using correspondences of a line and a point. Observations must be on the planar surface. @see HomographyInducedStereoLinePt @param F Fundamental matrix @param line Line on the plane @param point Point on the plane @return The homography from view 1 to view 2 or null if it fails
[ "Computes", "the", "homography", "induced", "from", "a", "planar", "surface", "when", "viewed", "from", "two", "views", "using", "correspondences", "of", "a", "line", "and", "a", "point", ".", "Observations", "must", "be", "on", "the", "planar", "surface", "...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L554-L560
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.homographyStereo2Lines
public static DMatrixRMaj homographyStereo2Lines( DMatrixRMaj F , PairLineNorm line0, PairLineNorm line1) { HomographyInducedStereo2Line alg = new HomographyInducedStereo2Line(); alg.setFundamental(F,null); if( !alg.process(line0,line1) ) return null; return alg.getHomography(); }
java
public static DMatrixRMaj homographyStereo2Lines( DMatrixRMaj F , PairLineNorm line0, PairLineNorm line1) { HomographyInducedStereo2Line alg = new HomographyInducedStereo2Line(); alg.setFundamental(F,null); if( !alg.process(line0,line1) ) return null; return alg.getHomography(); }
[ "public", "static", "DMatrixRMaj", "homographyStereo2Lines", "(", "DMatrixRMaj", "F", ",", "PairLineNorm", "line0", ",", "PairLineNorm", "line1", ")", "{", "HomographyInducedStereo2Line", "alg", "=", "new", "HomographyInducedStereo2Line", "(", ")", ";", "alg", ".", ...
Computes the homography induced from a planar surface when viewed from two views using correspondences of two lines. Observations must be on the planar surface. @see HomographyInducedStereo2Line @param F Fundamental matrix @param line0 Line on the plane @param line1 Line on the plane @return The homography from view 1 to view 2 or null if it fails
[ "Computes", "the", "homography", "induced", "from", "a", "planar", "surface", "when", "viewed", "from", "two", "views", "using", "correspondences", "of", "two", "lines", ".", "Observations", "must", "be", "on", "the", "planar", "surface", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L573-L580
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.createFundamental
public static DMatrixRMaj createFundamental(DMatrixRMaj E, CameraPinhole intrinsic ) { DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(intrinsic,(DMatrixRMaj)null); return createFundamental(E,K); }
java
public static DMatrixRMaj createFundamental(DMatrixRMaj E, CameraPinhole intrinsic ) { DMatrixRMaj K = PerspectiveOps.pinholeToMatrix(intrinsic,(DMatrixRMaj)null); return createFundamental(E,K); }
[ "public", "static", "DMatrixRMaj", "createFundamental", "(", "DMatrixRMaj", "E", ",", "CameraPinhole", "intrinsic", ")", "{", "DMatrixRMaj", "K", "=", "PerspectiveOps", ".", "pinholeToMatrix", "(", "intrinsic", ",", "(", "DMatrixRMaj", ")", "null", ")", ";", "re...
Computes a Fundamental matrix given an Essential matrix and the camera's intrinsic parameters. @see #createFundamental(DMatrixRMaj, DMatrixRMaj) @param E Essential matrix @param intrinsic Intrinsic camera calibration @return Fundamental matrix
[ "Computes", "a", "Fundamental", "matrix", "given", "an", "Essential", "matrix", "and", "the", "camera", "s", "intrinsic", "parameters", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L707-L710
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.projectiveToMetric
public static void projectiveToMetric( DMatrixRMaj cameraMatrix , DMatrixRMaj H , Se3_F64 worldToView , DMatrixRMaj K ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(cameraMatrix,H,tmp); MultiViewOps.decomposeMetricCamera(tmp,K,worldToView); }
java
public static void projectiveToMetric( DMatrixRMaj cameraMatrix , DMatrixRMaj H , Se3_F64 worldToView , DMatrixRMaj K ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(cameraMatrix,H,tmp); MultiViewOps.decomposeMetricCamera(tmp,K,worldToView); }
[ "public", "static", "void", "projectiveToMetric", "(", "DMatrixRMaj", "cameraMatrix", ",", "DMatrixRMaj", "H", ",", "Se3_F64", "worldToView", ",", "DMatrixRMaj", "K", ")", "{", "DMatrixRMaj", "tmp", "=", "new", "DMatrixRMaj", "(", "3", ",", "4", ")", ";", "C...
Elevates a projective camera matrix into a metric one using the rectifying homography. Extracts calibration and Se3 pose. <pre> P'=P*H K,R,t = decompose(P') </pre> where P is the camera matrix, H is the homography, (K,R,t) are the intrinsic calibration matrix, rotation, and translation @see MultiViewOps#absoluteQuadraticToH @see #decomposeMetricCamera(DMatrixRMaj, DMatrixRMaj, Se3_F64) @param cameraMatrix (Input) camera matrix. 3x4 @param H (Input) Rectifying homography. 4x4 @param worldToView (Output) Transform from world to camera view @param K (Output) Camera calibration matrix
[ "Elevates", "a", "projective", "camera", "matrix", "into", "a", "metric", "one", "using", "the", "rectifying", "homography", ".", "Extracts", "calibration", "and", "Se3", "pose", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L1358-L1365
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.projectiveToMetricKnownK
public static void projectiveToMetricKnownK( DMatrixRMaj cameraMatrix , DMatrixRMaj H , DMatrixRMaj K, Se3_F64 worldToView ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(cameraMatrix,H,tmp); DMatrixRMaj K_inv = new DMatrixRMaj(3,3); CommonOps_DDRM.invert(K,K_inv); DMatrixRMaj P = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(K_inv,tmp,P); CommonOps_DDRM.extract(P,0,0,worldToView.R); worldToView.T.x = P.get(0,3); worldToView.T.y = P.get(1,3); worldToView.T.z = P.get(2,3); SingularValueDecomposition_F64<DMatrixRMaj> svd = DecompositionFactory_DDRM.svd(true,true,true); DMatrixRMaj R = worldToView.R; if( !svd.decompose(R)) throw new RuntimeException("SVD Failed"); CommonOps_DDRM.multTransB(svd.getU(null,false),svd.getV(null,false),R); // determinant should be +1 double det = CommonOps_DDRM.det(R); if( det < 0 ) { CommonOps_DDRM.scale(-1,R); worldToView.T.scale(-1); } }
java
public static void projectiveToMetricKnownK( DMatrixRMaj cameraMatrix , DMatrixRMaj H , DMatrixRMaj K, Se3_F64 worldToView ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(cameraMatrix,H,tmp); DMatrixRMaj K_inv = new DMatrixRMaj(3,3); CommonOps_DDRM.invert(K,K_inv); DMatrixRMaj P = new DMatrixRMaj(3,4); CommonOps_DDRM.mult(K_inv,tmp,P); CommonOps_DDRM.extract(P,0,0,worldToView.R); worldToView.T.x = P.get(0,3); worldToView.T.y = P.get(1,3); worldToView.T.z = P.get(2,3); SingularValueDecomposition_F64<DMatrixRMaj> svd = DecompositionFactory_DDRM.svd(true,true,true); DMatrixRMaj R = worldToView.R; if( !svd.decompose(R)) throw new RuntimeException("SVD Failed"); CommonOps_DDRM.multTransB(svd.getU(null,false),svd.getV(null,false),R); // determinant should be +1 double det = CommonOps_DDRM.det(R); if( det < 0 ) { CommonOps_DDRM.scale(-1,R); worldToView.T.scale(-1); } }
[ "public", "static", "void", "projectiveToMetricKnownK", "(", "DMatrixRMaj", "cameraMatrix", ",", "DMatrixRMaj", "H", ",", "DMatrixRMaj", "K", ",", "Se3_F64", "worldToView", ")", "{", "DMatrixRMaj", "tmp", "=", "new", "DMatrixRMaj", "(", "3", ",", "4", ")", ";"...
Convert the projective camera matrix into a metric transform given the rectifying homography and a known calibration matrix. {@code P = K*[R|T]*H} where H is the inverse of the rectifying homography. @param cameraMatrix (Input) camera matrix. 3x4 @param H (Input) Rectifying homography. 4x4 @param K (Input) Known calibration matrix @param worldToView (Output) transform from world to camera view
[ "Convert", "the", "projective", "camera", "matrix", "into", "a", "metric", "transform", "given", "the", "rectifying", "homography", "and", "a", "known", "calibration", "matrix", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L1378-L1410
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.rectifyHToAbsoluteQuadratic
public static void rectifyHToAbsoluteQuadratic(DMatrixRMaj H , DMatrixRMaj Q ) { int indexQ = 0; for (int rowA = 0; rowA < 4; rowA++) { for (int colB = 0; colB < 4; colB++) { int indexA = rowA*4; int indexB = colB*4; double sum = 0; for (int i = 0; i < 3; i++) { // sum += H.get(rowA,i)*H.get(colB,i); sum += H.data[indexA++]*H.data[indexB++]; } // Q.set(rowA,colB,sum); Q.data[indexQ++] = sum; } } }
java
public static void rectifyHToAbsoluteQuadratic(DMatrixRMaj H , DMatrixRMaj Q ) { int indexQ = 0; for (int rowA = 0; rowA < 4; rowA++) { for (int colB = 0; colB < 4; colB++) { int indexA = rowA*4; int indexB = colB*4; double sum = 0; for (int i = 0; i < 3; i++) { // sum += H.get(rowA,i)*H.get(colB,i); sum += H.data[indexA++]*H.data[indexB++]; } // Q.set(rowA,colB,sum); Q.data[indexQ++] = sum; } } }
[ "public", "static", "void", "rectifyHToAbsoluteQuadratic", "(", "DMatrixRMaj", "H", ",", "DMatrixRMaj", "Q", ")", "{", "int", "indexQ", "=", "0", ";", "for", "(", "int", "rowA", "=", "0", ";", "rowA", "<", "4", ";", "rowA", "++", ")", "{", "for", "("...
Rectifying homography to dual absolute quadratic. <p>Q = H*I*H<sup>T</sup> = H(:,1:3)*H(:,1:3)'</p> <p>where I = diag(1 1 1 0)</p> @param H (Input) 4x4 rectifying homography. @param Q (Output) Absolute quadratic. Typically found in auto calibration. Not modified.
[ "Rectifying", "homography", "to", "dual", "absolute", "quadratic", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L1489-L1506
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.intrinsicFromAbsoluteQuadratic
public static void intrinsicFromAbsoluteQuadratic( DMatrixRMaj Q , DMatrixRMaj P , CameraPinhole intrinsic ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); DMatrixRMaj tmp2 = new DMatrixRMaj(3,3); CommonOps_DDRM.mult(P,Q,tmp); CommonOps_DDRM.multTransB(tmp,P,tmp2); decomposeDiac(tmp2,intrinsic); }
java
public static void intrinsicFromAbsoluteQuadratic( DMatrixRMaj Q , DMatrixRMaj P , CameraPinhole intrinsic ) { DMatrixRMaj tmp = new DMatrixRMaj(3,4); DMatrixRMaj tmp2 = new DMatrixRMaj(3,3); CommonOps_DDRM.mult(P,Q,tmp); CommonOps_DDRM.multTransB(tmp,P,tmp2); decomposeDiac(tmp2,intrinsic); }
[ "public", "static", "void", "intrinsicFromAbsoluteQuadratic", "(", "DMatrixRMaj", "Q", ",", "DMatrixRMaj", "P", ",", "CameraPinhole", "intrinsic", ")", "{", "DMatrixRMaj", "tmp", "=", "new", "DMatrixRMaj", "(", "3", ",", "4", ")", ";", "DMatrixRMaj", "tmp2", "...
Extracts the intrinsic camera matrix from a view given its camera matrix and the dual absolute quadratic. <p>w<sub>i</sub> = P<sub>i</sub>*Q*P<sub>i</sub><sup>T</sup>, where w<sub>i</sub> = K<sub>i</sub>*K'<sub>i</sub></p> @param Q (Input) Dual absolute qudratic @param P (Input) Camera matrix for a view @param intrinsic (Output) found intrinsic parameters
[ "Extracts", "the", "intrinsic", "camera", "matrix", "from", "a", "view", "given", "its", "camera", "matrix", "and", "the", "dual", "absolute", "quadratic", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L1517-L1525
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.split2
public static Tuple2<List<Point2D_F64>,List<Point2D_F64>> split2( List<AssociatedPair> input ) { List<Point2D_F64> list1 = new ArrayList<>(); List<Point2D_F64> list2 = new ArrayList<>(); for (int i = 0; i < input.size(); i++) { list1.add( input.get(i).p1 ); list2.add( input.get(i).p2 ); } return new Tuple2<>(list1,list2); }
java
public static Tuple2<List<Point2D_F64>,List<Point2D_F64>> split2( List<AssociatedPair> input ) { List<Point2D_F64> list1 = new ArrayList<>(); List<Point2D_F64> list2 = new ArrayList<>(); for (int i = 0; i < input.size(); i++) { list1.add( input.get(i).p1 ); list2.add( input.get(i).p2 ); } return new Tuple2<>(list1,list2); }
[ "public", "static", "Tuple2", "<", "List", "<", "Point2D_F64", ">", ",", "List", "<", "Point2D_F64", ">", ">", "split2", "(", "List", "<", "AssociatedPair", ">", "input", ")", "{", "List", "<", "Point2D_F64", ">", "list1", "=", "new", "ArrayList", "<>", ...
Splits the associated pairs into two lists @param input List of associated features @return two lists containing each set of features
[ "Splits", "the", "associated", "pairs", "into", "two", "lists" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L1623-L1634
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java
MultiViewOps.split3
public static Tuple3<List<Point2D_F64>,List<Point2D_F64>,List<Point2D_F64>> split3(List<AssociatedTriple> input ) { List<Point2D_F64> list1 = new ArrayList<>(); List<Point2D_F64> list2 = new ArrayList<>(); List<Point2D_F64> list3 = new ArrayList<>(); for (int i = 0; i < input.size(); i++) { list1.add( input.get(i).p1 ); list2.add( input.get(i).p2 ); list3.add( input.get(i).p3 ); } return new Tuple3<>(list1,list2,list3); }
java
public static Tuple3<List<Point2D_F64>,List<Point2D_F64>,List<Point2D_F64>> split3(List<AssociatedTriple> input ) { List<Point2D_F64> list1 = new ArrayList<>(); List<Point2D_F64> list2 = new ArrayList<>(); List<Point2D_F64> list3 = new ArrayList<>(); for (int i = 0; i < input.size(); i++) { list1.add( input.get(i).p1 ); list2.add( input.get(i).p2 ); list3.add( input.get(i).p3 ); } return new Tuple3<>(list1,list2,list3); }
[ "public", "static", "Tuple3", "<", "List", "<", "Point2D_F64", ">", ",", "List", "<", "Point2D_F64", ">", ",", "List", "<", "Point2D_F64", ">", ">", "split3", "(", "List", "<", "AssociatedTriple", ">", "input", ")", "{", "List", "<", "Point2D_F64", ">", ...
Splits the associated triple into three lists @param input List of associated features @return three lists containing each set of features
[ "Splits", "the", "associated", "triple", "into", "three", "lists" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/MultiViewOps.java#L1641-L1654
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/SubbandShrink.java
SubbandShrink.performShrinkage
protected void performShrinkage( I transform , int numLevels ) { // step through each layer in the pyramid. for( int i = 0; i < numLevels; i++ ) { int w = transform.width; int h = transform.height; int ww = w/2; int hh = h/2; Number threshold; I subband; // HL subband = transform.subimage(ww,0,w,hh, null); threshold = computeThreshold(subband); rule.process(subband,threshold); // System.out.print("HL = "+threshold); // LH subband = transform.subimage(0,hh,ww,h, null); threshold = computeThreshold(subband); rule.process(subband,threshold); // System.out.print(" LH = "+threshold); // HH subband = transform.subimage(ww,hh,w,h, null); threshold = computeThreshold(subband); rule.process(subband,threshold); // System.out.println(" HH = "+threshold); transform = transform.subimage(0,0,ww,hh, null); } }
java
protected void performShrinkage( I transform , int numLevels ) { // step through each layer in the pyramid. for( int i = 0; i < numLevels; i++ ) { int w = transform.width; int h = transform.height; int ww = w/2; int hh = h/2; Number threshold; I subband; // HL subband = transform.subimage(ww,0,w,hh, null); threshold = computeThreshold(subband); rule.process(subband,threshold); // System.out.print("HL = "+threshold); // LH subband = transform.subimage(0,hh,ww,h, null); threshold = computeThreshold(subband); rule.process(subband,threshold); // System.out.print(" LH = "+threshold); // HH subband = transform.subimage(ww,hh,w,h, null); threshold = computeThreshold(subband); rule.process(subband,threshold); // System.out.println(" HH = "+threshold); transform = transform.subimage(0,0,ww,hh, null); } }
[ "protected", "void", "performShrinkage", "(", "I", "transform", ",", "int", "numLevels", ")", "{", "// step through each layer in the pyramid.", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numLevels", ";", "i", "++", ")", "{", "int", "w", "=", "trans...
Performs wavelet shrinking using the specified rule and by computing a threshold for each subband. @param transform The image being transformed. @param numLevels Number of levels in the transform.
[ "Performs", "wavelet", "shrinking", "using", "the", "specified", "rule", "and", "by", "computing", "a", "threshold", "for", "each", "subband", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/SubbandShrink.java#L56-L91
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/DenoiseVisuShrink_F32.java
DenoiseVisuShrink_F32.denoise
@Override public void denoise(GrayF32 transform , int numLevels ) { int scale = UtilWavelet.computeScale(numLevels); final int h = transform.height; final int w = transform.width; // width and height of scaling image final int innerWidth = w/scale; final int innerHeight = h/scale; GrayF32 subbandHH = transform.subimage(w/2,h/2,w,h, null); float sigma = UtilDenoiseWavelet.estimateNoiseStdDev(subbandHH,null); float threshold = (float) UtilDenoiseWavelet.universalThreshold(subbandHH,sigma); // apply same threshold to all wavelet coefficients rule.process(transform.subimage(innerWidth,0,w,h, null),threshold); rule.process(transform.subimage(0,innerHeight,innerWidth,h, null),threshold); }
java
@Override public void denoise(GrayF32 transform , int numLevels ) { int scale = UtilWavelet.computeScale(numLevels); final int h = transform.height; final int w = transform.width; // width and height of scaling image final int innerWidth = w/scale; final int innerHeight = h/scale; GrayF32 subbandHH = transform.subimage(w/2,h/2,w,h, null); float sigma = UtilDenoiseWavelet.estimateNoiseStdDev(subbandHH,null); float threshold = (float) UtilDenoiseWavelet.universalThreshold(subbandHH,sigma); // apply same threshold to all wavelet coefficients rule.process(transform.subimage(innerWidth,0,w,h, null),threshold); rule.process(transform.subimage(0,innerHeight,innerWidth,h, null),threshold); }
[ "@", "Override", "public", "void", "denoise", "(", "GrayF32", "transform", ",", "int", "numLevels", ")", "{", "int", "scale", "=", "UtilWavelet", ".", "computeScale", "(", "numLevels", ")", ";", "final", "int", "h", "=", "transform", ".", "height", ";", ...
Applies VisuShrink denoising to the provided multilevel wavelet transform using the provided threshold. @param transform Mult-level wavelet transform. Modified. @param numLevels Number of levels in the transform.
[ "Applies", "VisuShrink", "denoising", "to", "the", "provided", "multilevel", "wavelet", "transform", "using", "the", "provided", "threshold", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/DenoiseVisuShrink_F32.java#L51-L69
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/factory/transform/wavelet/FactoryWaveletCoiflet.java
FactoryWaveletCoiflet.generate_F32
public static WaveletDescription<WlCoef_F32> generate_F32( int I ) { if( I != 6 ) { throw new IllegalArgumentException("Only 6 is currently supported"); } WlCoef_F32 coef = new WlCoef_F32(); coef.offsetScaling = -2; coef.offsetWavelet = -2; coef.scaling = new float[6]; coef.wavelet = new float[6]; double sqrt7 = Math.sqrt(7); double div = 16.0*Math.sqrt(2); coef.scaling[0] = (float)((1.0-sqrt7)/div); coef.scaling[1] = (float)((5.0+sqrt7)/div); coef.scaling[2] = (float)((14.0+2.0*sqrt7)/div); coef.scaling[3] = (float)((14.0-2.0*sqrt7)/div); coef.scaling[4] = (float)((1.0-sqrt7)/div); coef.scaling[5] = (float)((-3.0+sqrt7)/div); coef.wavelet[0] = coef.scaling[5]; coef.wavelet[1] = -coef.scaling[4]; coef.wavelet[2] = coef.scaling[3]; coef.wavelet[3] = -coef.scaling[2]; coef.wavelet[4] = coef.scaling[1]; coef.wavelet[5] = -coef.scaling[0]; WlBorderCoefStandard<WlCoef_F32> inverse = new WlBorderCoefStandard<>(coef); return new WaveletDescription<>(new BorderIndex1D_Wrap(), coef, inverse); }
java
public static WaveletDescription<WlCoef_F32> generate_F32( int I ) { if( I != 6 ) { throw new IllegalArgumentException("Only 6 is currently supported"); } WlCoef_F32 coef = new WlCoef_F32(); coef.offsetScaling = -2; coef.offsetWavelet = -2; coef.scaling = new float[6]; coef.wavelet = new float[6]; double sqrt7 = Math.sqrt(7); double div = 16.0*Math.sqrt(2); coef.scaling[0] = (float)((1.0-sqrt7)/div); coef.scaling[1] = (float)((5.0+sqrt7)/div); coef.scaling[2] = (float)((14.0+2.0*sqrt7)/div); coef.scaling[3] = (float)((14.0-2.0*sqrt7)/div); coef.scaling[4] = (float)((1.0-sqrt7)/div); coef.scaling[5] = (float)((-3.0+sqrt7)/div); coef.wavelet[0] = coef.scaling[5]; coef.wavelet[1] = -coef.scaling[4]; coef.wavelet[2] = coef.scaling[3]; coef.wavelet[3] = -coef.scaling[2]; coef.wavelet[4] = coef.scaling[1]; coef.wavelet[5] = -coef.scaling[0]; WlBorderCoefStandard<WlCoef_F32> inverse = new WlBorderCoefStandard<>(coef); return new WaveletDescription<>(new BorderIndex1D_Wrap(), coef, inverse); }
[ "public", "static", "WaveletDescription", "<", "WlCoef_F32", ">", "generate_F32", "(", "int", "I", ")", "{", "if", "(", "I", "!=", "6", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Only 6 is currently supported\"", ")", ";", "}", "WlCoef_F32", ...
Creates a description of a Coiflet of order I wavelet. @param I order of the wavelet. @return Wavelet description.
[ "Creates", "a", "description", "of", "a", "Coiflet", "of", "order", "I", "wavelet", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/transform/wavelet/FactoryWaveletCoiflet.java#L58-L90
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java
ShapeFittingOps.fitEllipse_F64
public static FitData<EllipseRotated_F64> fitEllipse_F64( List<Point2D_F64> points, int iterations , boolean computeError , FitData<EllipseRotated_F64> outputStorage ) { if( outputStorage == null ) { outputStorage = new FitData<>(new EllipseRotated_F64()); } // Compute the optimal algebraic error FitEllipseAlgebraic_F64 algebraic = new FitEllipseAlgebraic_F64(); if( !algebraic.process(points)) { // could be a line or some other weird case. Create a crude estimate instead FitData<Circle2D_F64> circleData = averageCircle_F64(points,null,null); Circle2D_F64 circle = circleData.shape; outputStorage.shape.set(circle.center.x,circle.center.y,circle.radius,circle.radius,0); } else { UtilEllipse_F64.convert(algebraic.getEllipse(),outputStorage.shape); } // Improve the solution from algebraic into Euclidean if( iterations > 0 ) { RefineEllipseEuclideanLeastSquares_F64 leastSquares = new RefineEllipseEuclideanLeastSquares_F64(); leastSquares.setMaxIterations(iterations); leastSquares.refine(outputStorage.shape,points); outputStorage.shape.set( leastSquares.getFound() ); } // compute the average Euclidean error if the user requests it if( computeError ) { ClosestPointEllipseAngle_F64 closestPoint = new ClosestPointEllipseAngle_F64(1e-8,100); closestPoint.setEllipse(outputStorage.shape); double total = 0; for( Point2D_F64 p : points ) { closestPoint.process(p); total += p.distance(closestPoint.getClosest()); } outputStorage.error = total/points.size(); } else { outputStorage.error = 0; } return outputStorage; }
java
public static FitData<EllipseRotated_F64> fitEllipse_F64( List<Point2D_F64> points, int iterations , boolean computeError , FitData<EllipseRotated_F64> outputStorage ) { if( outputStorage == null ) { outputStorage = new FitData<>(new EllipseRotated_F64()); } // Compute the optimal algebraic error FitEllipseAlgebraic_F64 algebraic = new FitEllipseAlgebraic_F64(); if( !algebraic.process(points)) { // could be a line or some other weird case. Create a crude estimate instead FitData<Circle2D_F64> circleData = averageCircle_F64(points,null,null); Circle2D_F64 circle = circleData.shape; outputStorage.shape.set(circle.center.x,circle.center.y,circle.radius,circle.radius,0); } else { UtilEllipse_F64.convert(algebraic.getEllipse(),outputStorage.shape); } // Improve the solution from algebraic into Euclidean if( iterations > 0 ) { RefineEllipseEuclideanLeastSquares_F64 leastSquares = new RefineEllipseEuclideanLeastSquares_F64(); leastSquares.setMaxIterations(iterations); leastSquares.refine(outputStorage.shape,points); outputStorage.shape.set( leastSquares.getFound() ); } // compute the average Euclidean error if the user requests it if( computeError ) { ClosestPointEllipseAngle_F64 closestPoint = new ClosestPointEllipseAngle_F64(1e-8,100); closestPoint.setEllipse(outputStorage.shape); double total = 0; for( Point2D_F64 p : points ) { closestPoint.process(p); total += p.distance(closestPoint.getClosest()); } outputStorage.error = total/points.size(); } else { outputStorage.error = 0; } return outputStorage; }
[ "public", "static", "FitData", "<", "EllipseRotated_F64", ">", "fitEllipse_F64", "(", "List", "<", "Point2D_F64", ">", "points", ",", "int", "iterations", ",", "boolean", "computeError", ",", "FitData", "<", "EllipseRotated_F64", ">", "outputStorage", ")", "{", ...
Computes the best fit ellipse based on minimizing Euclidean distance. An estimate is initially provided using algebraic algorithm which is then refined using non-linear optimization. The amount of non-linear optimization can be controlled using 'iterations' parameter. Will work with partial and complete contours of objects. <p>NOTE: To improve speed, make calls directly to classes in Georegression. Look at the code for details.</p> @param points (Input) Set of unordered points. Not modified. @param iterations Number of iterations used to refine the fit. If set to zero then an algebraic solution is returned. @param computeError If true it will compute the average Euclidean distance error @param outputStorage (Output/Optional) Storage for the ellipse. Can be null. @return Found ellipse.
[ "Computes", "the", "best", "fit", "ellipse", "based", "on", "minimizing", "Euclidean", "distance", ".", "An", "estimate", "is", "initially", "provided", "using", "algebraic", "algorithm", "which", "is", "then", "refined", "using", "non", "-", "linear", "optimiza...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java#L104-L148
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java
ShapeFittingOps.convert_I32_F64
public static List<Point2D_F64> convert_I32_F64(List<Point2D_I32> points) { return convert_I32_F64(points,null).toList(); }
java
public static List<Point2D_F64> convert_I32_F64(List<Point2D_I32> points) { return convert_I32_F64(points,null).toList(); }
[ "public", "static", "List", "<", "Point2D_F64", ">", "convert_I32_F64", "(", "List", "<", "Point2D_I32", ">", "points", ")", "{", "return", "convert_I32_F64", "(", "points", ",", "null", ")", ".", "toList", "(", ")", ";", "}" ]
Converts a list of I32 points into F64 @param points Original points @return Converted points
[ "Converts", "a", "list", "of", "I32", "points", "into", "F64" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java#L174-L176
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java
ShapeFittingOps.averageCircle_I32
public static FitData<Circle2D_F64> averageCircle_I32(List<Point2D_I32> points, GrowQueue_F64 optional, FitData<Circle2D_F64> outputStorage) { if( outputStorage == null ) { outputStorage = new FitData<>(new Circle2D_F64()); } if( optional == null ) { optional = new GrowQueue_F64(); } Circle2D_F64 circle = outputStorage.shape; int N = points.size(); // find center of the circle by computing the mean x and y int sumX=0,sumY=0; for( int i = 0; i < N; i++ ) { Point2D_I32 p = points.get(i); sumX += p.x; sumY += p.y; } optional.reset(); double centerX = circle.center.x = sumX/(double)N; double centerY = circle.center.y = sumY/(double)N; double meanR = 0; for( int i = 0; i < N; i++ ) { Point2D_I32 p = points.get(i); double dx = p.x-centerX; double dy = p.y-centerY; double r = Math.sqrt(dx*dx + dy*dy); optional.push(r); meanR += r; } meanR /= N; circle.radius = meanR; // compute radius variance double variance = 0; for( int i = 0; i < N; i++ ) { double diff = optional.get(i)-meanR; variance += diff*diff; } outputStorage.error = variance/N; return outputStorage; }
java
public static FitData<Circle2D_F64> averageCircle_I32(List<Point2D_I32> points, GrowQueue_F64 optional, FitData<Circle2D_F64> outputStorage) { if( outputStorage == null ) { outputStorage = new FitData<>(new Circle2D_F64()); } if( optional == null ) { optional = new GrowQueue_F64(); } Circle2D_F64 circle = outputStorage.shape; int N = points.size(); // find center of the circle by computing the mean x and y int sumX=0,sumY=0; for( int i = 0; i < N; i++ ) { Point2D_I32 p = points.get(i); sumX += p.x; sumY += p.y; } optional.reset(); double centerX = circle.center.x = sumX/(double)N; double centerY = circle.center.y = sumY/(double)N; double meanR = 0; for( int i = 0; i < N; i++ ) { Point2D_I32 p = points.get(i); double dx = p.x-centerX; double dy = p.y-centerY; double r = Math.sqrt(dx*dx + dy*dy); optional.push(r); meanR += r; } meanR /= N; circle.radius = meanR; // compute radius variance double variance = 0; for( int i = 0; i < N; i++ ) { double diff = optional.get(i)-meanR; variance += diff*diff; } outputStorage.error = variance/N; return outputStorage; }
[ "public", "static", "FitData", "<", "Circle2D_F64", ">", "averageCircle_I32", "(", "List", "<", "Point2D_I32", ">", "points", ",", "GrowQueue_F64", "optional", ",", "FitData", "<", "Circle2D_F64", ">", "outputStorage", ")", "{", "if", "(", "outputStorage", "==",...
Computes a circle which has it's center at the mean position of the provided points and radius is equal to the average distance of each point from the center. While fast to compute the provided circle is not a best fit circle by any reasonable metric, except for special cases. @param points (Input) Set of unordered points. Not modified. @param optional (Optional) Used internally to store the distance of each point from the center. Can be null. @param outputStorage (Output/Optional) Storage for results. If null then a new circle instance will be returned. @return The found circle fit.
[ "Computes", "a", "circle", "which", "has", "it", "s", "center", "at", "the", "mean", "position", "of", "the", "provided", "points", "and", "radius", "is", "equal", "to", "the", "average", "distance", "of", "each", "point", "from", "the", "center", ".", "...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ShapeFittingOps.java#L218-L265
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.fixate
public void fixate() { ransac = FactoryMultiViewRobust.trifocalRansac(configTriRansac,configError,configRansac); sba = FactoryMultiView.bundleSparseProjective(configSBA); }
java
public void fixate() { ransac = FactoryMultiViewRobust.trifocalRansac(configTriRansac,configError,configRansac); sba = FactoryMultiView.bundleSparseProjective(configSBA); }
[ "public", "void", "fixate", "(", ")", "{", "ransac", "=", "FactoryMultiViewRobust", ".", "trifocalRansac", "(", "configTriRansac", ",", "configError", ",", "configRansac", ")", ";", "sba", "=", "FactoryMultiView", ".", "bundleSparseProjective", "(", "configSBA", "...
Must call if you change configurations.
[ "Must", "call", "if", "you", "change", "configurations", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L128-L131
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.selectInitialTriplet
boolean selectInitialTriplet( View seed , GrowQueue_I32 motions , int selected[] ) { double bestScore = 0; for (int i = 0; i < motions.size; i++) { View viewB = seed.connections.get(i).other(seed); for (int j = i+1; j < motions.size; j++) { View viewC = seed.connections.get(j).other(seed); double s = scoreTripleView(seed,viewB,viewC); if( s > bestScore ) { bestScore = s; selected[0] = i; selected[1] = j; } } } return bestScore != 0; }
java
boolean selectInitialTriplet( View seed , GrowQueue_I32 motions , int selected[] ) { double bestScore = 0; for (int i = 0; i < motions.size; i++) { View viewB = seed.connections.get(i).other(seed); for (int j = i+1; j < motions.size; j++) { View viewC = seed.connections.get(j).other(seed); double s = scoreTripleView(seed,viewB,viewC); if( s > bestScore ) { bestScore = s; selected[0] = i; selected[1] = j; } } } return bestScore != 0; }
[ "boolean", "selectInitialTriplet", "(", "View", "seed", ",", "GrowQueue_I32", "motions", ",", "int", "selected", "[", "]", ")", "{", "double", "bestScore", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "motions", ".", "size", ";", "...
Exhaustively look at all triplets that connect with the seed view
[ "Exhaustively", "look", "at", "all", "triplets", "that", "connect", "with", "the", "seed", "view" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L185-L202
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.triangulateFeatures
private void triangulateFeatures(List<AssociatedTriple> inliers, DMatrixRMaj P1, DMatrixRMaj P2, DMatrixRMaj P3) { List<DMatrixRMaj> cameraMatrices = new ArrayList<>(); cameraMatrices.add(P1); cameraMatrices.add(P2); cameraMatrices.add(P3); // need elements to be non-empty so that it can use set(). probably over optimization List<Point2D_F64> triangObs = new ArrayList<>(); triangObs.add(null); triangObs.add(null); triangObs.add(null); Point4D_F64 X = new Point4D_F64(); for (int i = 0; i < inliers.size(); i++) { AssociatedTriple t = inliers.get(i); triangObs.set(0,t.p1); triangObs.set(1,t.p2); triangObs.set(2,t.p3); // triangulation can fail if all 3 views have the same pixel value. This has been observed in // simulated 3D scenes if( triangulator.triangulate(triangObs,cameraMatrices,X)) { structure.points[i].set(X.x,X.y,X.z,X.w); } else { throw new RuntimeException("Failed to triangulate a point in the inlier set?! Handle if this is common"); } } }
java
private void triangulateFeatures(List<AssociatedTriple> inliers, DMatrixRMaj P1, DMatrixRMaj P2, DMatrixRMaj P3) { List<DMatrixRMaj> cameraMatrices = new ArrayList<>(); cameraMatrices.add(P1); cameraMatrices.add(P2); cameraMatrices.add(P3); // need elements to be non-empty so that it can use set(). probably over optimization List<Point2D_F64> triangObs = new ArrayList<>(); triangObs.add(null); triangObs.add(null); triangObs.add(null); Point4D_F64 X = new Point4D_F64(); for (int i = 0; i < inliers.size(); i++) { AssociatedTriple t = inliers.get(i); triangObs.set(0,t.p1); triangObs.set(1,t.p2); triangObs.set(2,t.p3); // triangulation can fail if all 3 views have the same pixel value. This has been observed in // simulated 3D scenes if( triangulator.triangulate(triangObs,cameraMatrices,X)) { structure.points[i].set(X.x,X.y,X.z,X.w); } else { throw new RuntimeException("Failed to triangulate a point in the inlier set?! Handle if this is common"); } } }
[ "private", "void", "triangulateFeatures", "(", "List", "<", "AssociatedTriple", ">", "inliers", ",", "DMatrixRMaj", "P1", ",", "DMatrixRMaj", "P2", ",", "DMatrixRMaj", "P3", ")", "{", "List", "<", "DMatrixRMaj", ">", "cameraMatrices", "=", "new", "ArrayList", ...
Triangulates the location of each features in homogenous space
[ "Triangulates", "the", "location", "of", "each", "features", "in", "homogenous", "space" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L275-L304
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.initializeProjective3
private void initializeProjective3(FastQueue<AssociatedTriple> associated , FastQueue<AssociatedTripleIndex> associatedIdx , int totalViews, View viewA , View viewB , View viewC , int idxViewB , int idxViewC ) { ransac.process(associated.toList()); List<AssociatedTriple> inliers = ransac.getMatchSet(); TrifocalTensor model = ransac.getModelParameters(); if( verbose != null ) verbose.println("Remaining after RANSAC "+inliers.size()+" / "+associated.size()); // projective camera matrices for each view DMatrixRMaj P1 = CommonOps_DDRM.identity(3,4); DMatrixRMaj P2 = new DMatrixRMaj(3,4); DMatrixRMaj P3 = new DMatrixRMaj(3,4); MultiViewOps.extractCameraMatrices(model,P2,P3); // Initialize the 3D scene structure, stored in a format understood by bundle adjustment structure.initialize(totalViews,inliers.size()); // specify the found projective camera matrices db.lookupShape(viewA.id,shape); // The first view is assumed to be the coordinate system's origin and is identity by definition structure.setView(0,true, P1,shape.width,shape.height); db.lookupShape(viewB.id,shape); structure.setView(idxViewB,false,P2,shape.width,shape.height); db.lookupShape(viewC.id,shape); structure.setView(idxViewC,false,P3,shape.width,shape.height); // triangulate homogenous coordinates for each point in the inlier set triangulateFeatures(inliers, P1, P2, P3); // Update the list of common features by pruning features not in the inlier set seedToStructure.resize(viewA.totalFeatures); seedToStructure.fill(-1); // -1 indicates no match inlierToSeed.resize(inliers.size()); for (int i = 0; i < inliers.size(); i++) { int inputIdx = ransac.getInputIndex(i); // table to go from inlier list into seed feature index inlierToSeed.data[i] = matchesTripleIdx.get(inputIdx).a; // seed feature index into the ouptut structure index seedToStructure.data[inlierToSeed.data[i]] = i; } }
java
private void initializeProjective3(FastQueue<AssociatedTriple> associated , FastQueue<AssociatedTripleIndex> associatedIdx , int totalViews, View viewA , View viewB , View viewC , int idxViewB , int idxViewC ) { ransac.process(associated.toList()); List<AssociatedTriple> inliers = ransac.getMatchSet(); TrifocalTensor model = ransac.getModelParameters(); if( verbose != null ) verbose.println("Remaining after RANSAC "+inliers.size()+" / "+associated.size()); // projective camera matrices for each view DMatrixRMaj P1 = CommonOps_DDRM.identity(3,4); DMatrixRMaj P2 = new DMatrixRMaj(3,4); DMatrixRMaj P3 = new DMatrixRMaj(3,4); MultiViewOps.extractCameraMatrices(model,P2,P3); // Initialize the 3D scene structure, stored in a format understood by bundle adjustment structure.initialize(totalViews,inliers.size()); // specify the found projective camera matrices db.lookupShape(viewA.id,shape); // The first view is assumed to be the coordinate system's origin and is identity by definition structure.setView(0,true, P1,shape.width,shape.height); db.lookupShape(viewB.id,shape); structure.setView(idxViewB,false,P2,shape.width,shape.height); db.lookupShape(viewC.id,shape); structure.setView(idxViewC,false,P3,shape.width,shape.height); // triangulate homogenous coordinates for each point in the inlier set triangulateFeatures(inliers, P1, P2, P3); // Update the list of common features by pruning features not in the inlier set seedToStructure.resize(viewA.totalFeatures); seedToStructure.fill(-1); // -1 indicates no match inlierToSeed.resize(inliers.size()); for (int i = 0; i < inliers.size(); i++) { int inputIdx = ransac.getInputIndex(i); // table to go from inlier list into seed feature index inlierToSeed.data[i] = matchesTripleIdx.get(inputIdx).a; // seed feature index into the ouptut structure index seedToStructure.data[inlierToSeed.data[i]] = i; } }
[ "private", "void", "initializeProjective3", "(", "FastQueue", "<", "AssociatedTriple", ">", "associated", ",", "FastQueue", "<", "AssociatedTripleIndex", ">", "associatedIdx", ",", "int", "totalViews", ",", "View", "viewA", ",", "View", "viewB", ",", "View", "view...
Initializes projective reconstruction from 3-views. 1) RANSAC to fit a trifocal tensor 2) Extract camera matrices that have a common projective space 3) Triangulate location of 3D homogenous points @param associated List of associated pixels @param associatedIdx List of associated feature indexes
[ "Initializes", "projective", "reconstruction", "from", "3", "-", "views", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L331-L377
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.findRemainingCameraMatrices
boolean findRemainingCameraMatrices(LookupSimilarImages db, View seed, GrowQueue_I32 motions) { points3D.reset(); // points in 3D for (int i = 0; i < structure.points.length; i++) { structure.points[i].get(points3D.grow()); } // contains associated pairs of pixel observations // save a call to db by using the previously loaded points assocPixel.reset(); for (int i = 0; i < inlierToSeed.size; i++) { // inliers from triple RANSAC // each of these inliers was declared a feature in the world reference frame assocPixel.grow().p1.set(matchesTriple.get(i).p1); } DMatrixRMaj cameraMatrix = new DMatrixRMaj(3,4); for (int motionIdx = 0; motionIdx < motions.size; motionIdx++) { // skip views already in the scene's structure if( motionIdx == selectedTriple[0] || motionIdx == selectedTriple[1]) continue; int connectionIdx = motions.get(motionIdx); Motion edge = seed.connections.get(connectionIdx); View viewI = edge.other(seed); // Lookup pixel locations of features in the connected view db.lookupPixelFeats(viewI.id,featsB); if ( !computeCameraMatrix(seed, edge,featsB,cameraMatrix) ) { if( verbose != null ) { verbose.println("Pose estimator failed! motionIdx="+motionIdx); } return false; } db.lookupShape(edge.other(seed).id,shape); structure.setView(motionIdx,false,cameraMatrix,shape.width,shape.height); } return true; }
java
boolean findRemainingCameraMatrices(LookupSimilarImages db, View seed, GrowQueue_I32 motions) { points3D.reset(); // points in 3D for (int i = 0; i < structure.points.length; i++) { structure.points[i].get(points3D.grow()); } // contains associated pairs of pixel observations // save a call to db by using the previously loaded points assocPixel.reset(); for (int i = 0; i < inlierToSeed.size; i++) { // inliers from triple RANSAC // each of these inliers was declared a feature in the world reference frame assocPixel.grow().p1.set(matchesTriple.get(i).p1); } DMatrixRMaj cameraMatrix = new DMatrixRMaj(3,4); for (int motionIdx = 0; motionIdx < motions.size; motionIdx++) { // skip views already in the scene's structure if( motionIdx == selectedTriple[0] || motionIdx == selectedTriple[1]) continue; int connectionIdx = motions.get(motionIdx); Motion edge = seed.connections.get(connectionIdx); View viewI = edge.other(seed); // Lookup pixel locations of features in the connected view db.lookupPixelFeats(viewI.id,featsB); if ( !computeCameraMatrix(seed, edge,featsB,cameraMatrix) ) { if( verbose != null ) { verbose.println("Pose estimator failed! motionIdx="+motionIdx); } return false; } db.lookupShape(edge.other(seed).id,shape); structure.setView(motionIdx,false,cameraMatrix,shape.width,shape.height); } return true; }
[ "boolean", "findRemainingCameraMatrices", "(", "LookupSimilarImages", "db", ",", "View", "seed", ",", "GrowQueue_I32", "motions", ")", "{", "points3D", ".", "reset", "(", ")", ";", "// points in 3D", "for", "(", "int", "i", "=", "0", ";", "i", "<", "structur...
Uses the triangulated points and observations in the root view to estimate the camera matrix for all the views which are remaining @return true if successful or false if not
[ "Uses", "the", "triangulated", "points", "and", "observations", "in", "the", "root", "view", "to", "estimate", "the", "camera", "matrix", "for", "all", "the", "views", "which", "are", "remaining" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L384-L421
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.computeCameraMatrix
private boolean computeCameraMatrix(View seed, Motion edge, FastQueue<Point2D_F64> featsB, DMatrixRMaj cameraMatrix ) { boolean seedSrc = edge.src == seed; int matched = 0; for (int i = 0; i < edge.inliers.size; i++) { // need to go from i to index of detected features in view 'seed' to index index of feature in // the reconstruction AssociatedIndex a = edge.inliers.get(i); int featId = seedToStructure.data[seedSrc ? a.src : a.dst]; if( featId == -1 ) continue; assocPixel.get(featId).p2.set( featsB.get(seedSrc?a.dst:a.src) ); matched++; } // All views should have matches for all features, simple sanity check if( matched != assocPixel.size) throw new RuntimeException("BUG! Didn't find all features in the view"); // Estimate the camera matrix given homogenous pixel observations if( poseEstimator.processHomogenous(assocPixel.toList(),points3D.toList()) ) { cameraMatrix.set(poseEstimator.getProjective()); return true; } else { return false; } }
java
private boolean computeCameraMatrix(View seed, Motion edge, FastQueue<Point2D_F64> featsB, DMatrixRMaj cameraMatrix ) { boolean seedSrc = edge.src == seed; int matched = 0; for (int i = 0; i < edge.inliers.size; i++) { // need to go from i to index of detected features in view 'seed' to index index of feature in // the reconstruction AssociatedIndex a = edge.inliers.get(i); int featId = seedToStructure.data[seedSrc ? a.src : a.dst]; if( featId == -1 ) continue; assocPixel.get(featId).p2.set( featsB.get(seedSrc?a.dst:a.src) ); matched++; } // All views should have matches for all features, simple sanity check if( matched != assocPixel.size) throw new RuntimeException("BUG! Didn't find all features in the view"); // Estimate the camera matrix given homogenous pixel observations if( poseEstimator.processHomogenous(assocPixel.toList(),points3D.toList()) ) { cameraMatrix.set(poseEstimator.getProjective()); return true; } else { return false; } }
[ "private", "boolean", "computeCameraMatrix", "(", "View", "seed", ",", "Motion", "edge", ",", "FastQueue", "<", "Point2D_F64", ">", "featsB", ",", "DMatrixRMaj", "cameraMatrix", ")", "{", "boolean", "seedSrc", "=", "edge", ".", "src", "==", "seed", ";", "int...
Computes camera matrix between the seed view and a connected view @param seed This will be the source view. It's observations have already been added to assocPixel @param edge The edge which connects them @param featsB The dst view @param cameraMatrix (Output) resulting camera matrix @return true if successful
[ "Computes", "camera", "matrix", "between", "the", "seed", "view", "and", "a", "connected", "view" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L431-L456
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.createObservationsForBundleAdjustment
private SceneObservations createObservationsForBundleAdjustment(LookupSimilarImages db, View seed, GrowQueue_I32 motions) { // seed view + the motions SceneObservations observations = new SceneObservations(motions.size+1); // Observations for the seed view are a special case SceneObservations.View obsView = observations.getView(0); for (int i = 0; i < inlierToSeed.size; i++) { int id = inlierToSeed.data[i]; Point2D_F64 o = featsA.get(id); // featsA is never modified after initially loaded id = seedToStructure.data[id]; obsView.add(id,(float)o.x,(float)o.y); } // Now add observations for edges connected to the seed for (int i = 0; i < motions.size(); i++) { obsView = observations.getView(i+1); Motion m = seed.connections.get(motions.get(i)); View v = m.other(seed); boolean seedIsSrc = m.src == seed; db.lookupPixelFeats(v.id,featsB); for (int j = 0; j < m.inliers.size; j++) { AssociatedIndex a = m.inliers.get(j); int id = seedToStructure.data[seedIsSrc?a.src:a.dst]; if( id < 0 ) continue; Point2D_F64 o = featsB.get(seedIsSrc?a.dst:a.src); obsView.add(id,(float)o.x,(float)o.y); } } return observations; }
java
private SceneObservations createObservationsForBundleAdjustment(LookupSimilarImages db, View seed, GrowQueue_I32 motions) { // seed view + the motions SceneObservations observations = new SceneObservations(motions.size+1); // Observations for the seed view are a special case SceneObservations.View obsView = observations.getView(0); for (int i = 0; i < inlierToSeed.size; i++) { int id = inlierToSeed.data[i]; Point2D_F64 o = featsA.get(id); // featsA is never modified after initially loaded id = seedToStructure.data[id]; obsView.add(id,(float)o.x,(float)o.y); } // Now add observations for edges connected to the seed for (int i = 0; i < motions.size(); i++) { obsView = observations.getView(i+1); Motion m = seed.connections.get(motions.get(i)); View v = m.other(seed); boolean seedIsSrc = m.src == seed; db.lookupPixelFeats(v.id,featsB); for (int j = 0; j < m.inliers.size; j++) { AssociatedIndex a = m.inliers.get(j); int id = seedToStructure.data[seedIsSrc?a.src:a.dst]; if( id < 0 ) continue; Point2D_F64 o = featsB.get(seedIsSrc?a.dst:a.src); obsView.add(id,(float)o.x,(float)o.y); } } return observations; }
[ "private", "SceneObservations", "createObservationsForBundleAdjustment", "(", "LookupSimilarImages", "db", ",", "View", "seed", ",", "GrowQueue_I32", "motions", ")", "{", "// seed view + the motions", "SceneObservations", "observations", "=", "new", "SceneObservations", "(", ...
Convert observations into a format which bundle adjustment will understand @param seed The first view which all other views are connected to @param motions Which edges in seed @return observations for SBA
[ "Convert", "observations", "into", "a", "format", "which", "bundle", "adjustment", "will", "understand" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L464-L495
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java
ProjectiveInitializeAllCommon.refineWithBundleAdjustment
private boolean refineWithBundleAdjustment(SceneObservations observations) { if( scaleSBA ) { scaler.applyScale(structure,observations); } sba.setVerbose(verbose,verboseLevel); sba.setParameters(structure,observations); sba.configure(converge.ftol,converge.gtol,converge.maxIterations); if( !sba.optimize(structure) ) { return false; } if( scaleSBA ) { // only undo scaling on camera matrices since observations are discarded for (int i = 0; i < structure.views.length; i++) { DMatrixRMaj P = structure.views[i].worldToView; scaler.pixelScaling.get(i).remove(P,P); } scaler.undoScale(structure,observations); } return true; }
java
private boolean refineWithBundleAdjustment(SceneObservations observations) { if( scaleSBA ) { scaler.applyScale(structure,observations); } sba.setVerbose(verbose,verboseLevel); sba.setParameters(structure,observations); sba.configure(converge.ftol,converge.gtol,converge.maxIterations); if( !sba.optimize(structure) ) { return false; } if( scaleSBA ) { // only undo scaling on camera matrices since observations are discarded for (int i = 0; i < structure.views.length; i++) { DMatrixRMaj P = structure.views[i].worldToView; scaler.pixelScaling.get(i).remove(P,P); } scaler.undoScale(structure,observations); } return true; }
[ "private", "boolean", "refineWithBundleAdjustment", "(", "SceneObservations", "observations", ")", "{", "if", "(", "scaleSBA", ")", "{", "scaler", ".", "applyScale", "(", "structure", ",", "observations", ")", ";", "}", "sba", ".", "setVerbose", "(", "verbose", ...
Last step is to refine the current initial estimate with bundle adjustment
[ "Last", "step", "is", "to", "refine", "the", "current", "initial", "estimate", "with", "bundle", "adjustment" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure2/ProjectiveInitializeAllCommon.java#L500-L522
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertNV21.java
ConvertNV21.nv21ToBoof
public static void nv21ToBoof(byte[] data, int width, int height, ImageBase output) { if( output instanceof Planar) { Planar ms = (Planar) output; if (ms.getBandType() == GrayU8.class) { ConvertNV21.nv21TPlanarRgb_U8(data, width, height, ms); } else if (ms.getBandType() == GrayF32.class) { ConvertNV21.nv21ToPlanarRgb_F32(data, width, height , ms); } else { throw new IllegalArgumentException("Unsupported output band format"); } } else if( output instanceof ImageGray) { if (output.getClass() == GrayU8.class) { nv21ToGray(data, width, height, (GrayU8) output); } else if (output.getClass() == GrayF32.class) { nv21ToGray(data, width, height, (GrayF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else if( output instanceof ImageInterleaved ) { if( output.getClass() == InterleavedU8.class ) { ConvertNV21.nv21ToInterleaved(data, width, height, (InterleavedU8) output); } else if( output.getClass() == InterleavedF32.class ) { ConvertNV21.nv21ToInterleaved(data, width, height, (InterleavedF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else { throw new IllegalArgumentException("Boofcv image type not yet supported"); } }
java
public static void nv21ToBoof(byte[] data, int width, int height, ImageBase output) { if( output instanceof Planar) { Planar ms = (Planar) output; if (ms.getBandType() == GrayU8.class) { ConvertNV21.nv21TPlanarRgb_U8(data, width, height, ms); } else if (ms.getBandType() == GrayF32.class) { ConvertNV21.nv21ToPlanarRgb_F32(data, width, height , ms); } else { throw new IllegalArgumentException("Unsupported output band format"); } } else if( output instanceof ImageGray) { if (output.getClass() == GrayU8.class) { nv21ToGray(data, width, height, (GrayU8) output); } else if (output.getClass() == GrayF32.class) { nv21ToGray(data, width, height, (GrayF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else if( output instanceof ImageInterleaved ) { if( output.getClass() == InterleavedU8.class ) { ConvertNV21.nv21ToInterleaved(data, width, height, (InterleavedU8) output); } else if( output.getClass() == InterleavedF32.class ) { ConvertNV21.nv21ToInterleaved(data, width, height, (InterleavedF32) output); } else { throw new IllegalArgumentException("Unsupported output type"); } } else { throw new IllegalArgumentException("Boofcv image type not yet supported"); } }
[ "public", "static", "void", "nv21ToBoof", "(", "byte", "[", "]", "data", ",", "int", "width", ",", "int", "height", ",", "ImageBase", "output", ")", "{", "if", "(", "output", "instanceof", "Planar", ")", "{", "Planar", "ms", "=", "(", "Planar", ")", ...
Converts a NV21 encoded byte array into a BoofCV formatted image. @param data (input) NV21 byte array @param width (input) image width @param height (input) image height @param output (output) BoofCV image
[ "Converts", "a", "NV21", "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/ConvertNV21.java#L44-L75
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertNV21.java
ConvertNV21.nv21ToGray
public static <T extends ImageGray<T>> T nv21ToGray( byte[] data , int width , int height , T output , Class<T> outputType ) { if( outputType == GrayU8.class ) { return (T)nv21ToGray(data,width,height,(GrayU8)output); } else if( outputType == GrayF32.class ) { return (T)nv21ToGray(data,width,height,(GrayF32)output); } else { throw new IllegalArgumentException("Unsupported BoofCV Image Type "+outputType.getSimpleName()); } }
java
public static <T extends ImageGray<T>> T nv21ToGray( byte[] data , int width , int height , T output , Class<T> outputType ) { if( outputType == GrayU8.class ) { return (T)nv21ToGray(data,width,height,(GrayU8)output); } else if( outputType == GrayF32.class ) { return (T)nv21ToGray(data,width,height,(GrayF32)output); } else { throw new IllegalArgumentException("Unsupported BoofCV Image Type "+outputType.getSimpleName()); } }
[ "public", "static", "<", "T", "extends", "ImageGray", "<", "T", ">", ">", "T", "nv21ToGray", "(", "byte", "[", "]", "data", ",", "int", "width", ",", "int", "height", ",", "T", "output", ",", "Class", "<", "T", ">", "outputType", ")", "{", "if", ...
Converts an NV21 image into a gray scale image. Image type is determined at runtime. @param data Input: NV21 image data @param width Input: NV21 image width @param height Input: NV21 image height @param output Output: Optional storage for output image. Can be null. @param outputType Output: Type of output image @param <T> Output image type @return Gray scale image
[ "Converts", "an", "NV21", "image", "into", "a", "gray", "scale", "image", ".", "Image", "type", "is", "determined", "at", "runtime", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertNV21.java#L88-L99
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertNV21.java
ConvertNV21.nv21ToGray
public static GrayU8 nv21ToGray(byte[] data , int width , int height , GrayU8 output ) { if( output != null ) { output.reshape(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 nv21ToGray(byte[] data , int width , int height , GrayU8 output ) { if( output != null ) { output.reshape(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", "nv21ToGray", "(", "byte", "[", "]", "data", ",", "int", "width", ",", "int", "height", ",", "GrayU8", "output", ")", "{", "if", "(", "output", "!=", "null", ")", "{", "output", ".", "reshape", "(", "width", ",", "height...
Converts an NV21 image into a gray scale U8 image. @param data Input: NV21 image data @param width Input: NV21 image width @param height Input: NV21 image height @param output Output: Optional storage for output image. Can be null. @return Gray scale image
[ "Converts", "an", "NV21", "image", "into", "a", "gray", "scale", "U8", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertNV21.java#L110-L124
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/FiducialSquareGenerator.java
FiducialSquareGenerator.generate
public void generate( long value , int gridWidth ) { renderer.init(); drawBorder(); double whiteBorder = whiteBorderDoc /markerWidth; double X0 = whiteBorder+blackBorder; double Y0 = whiteBorder+blackBorder; double bw = (1.0-2*X0)/gridWidth; // Draw the black corner used to ID the orientation square(X0,1.0-whiteBorder-blackBorder-bw,bw); final int bitCount = gridWidth*gridWidth - 4; for (int j = 0; j < bitCount; j++) { if( (value & (1L<<j)) != 0 ) { box(bw,j,gridWidth); } } // int s2 = (int)Math.round(ret.width*borderFraction); // int s5 = s2+square*(gridWidth-1); // // int N = gridWidth*gridWidth-4; // for (int i = 0; i < N; i++) { // if( (value& (1<<i)) != 0 ) // continue; // // int where = index(i, gridWidth); // int x = where%gridWidth; // int y = gridWidth-1-(where/gridWidth); // // x = s2 + square*x; // y = s2 + square*y; // // ImageMiscOps.fillRectangle(ret,0xFF,x,y,square,square); // } // ImageMiscOps.fillRectangle(ret,0xFF,s2,s2,square,square); // ImageMiscOps.fillRectangle(ret,0xFF,s5,s5,square,square); // ImageMiscOps.fillRectangle(ret,0xFF,s5,s2,square,square); }
java
public void generate( long value , int gridWidth ) { renderer.init(); drawBorder(); double whiteBorder = whiteBorderDoc /markerWidth; double X0 = whiteBorder+blackBorder; double Y0 = whiteBorder+blackBorder; double bw = (1.0-2*X0)/gridWidth; // Draw the black corner used to ID the orientation square(X0,1.0-whiteBorder-blackBorder-bw,bw); final int bitCount = gridWidth*gridWidth - 4; for (int j = 0; j < bitCount; j++) { if( (value & (1L<<j)) != 0 ) { box(bw,j,gridWidth); } } // int s2 = (int)Math.round(ret.width*borderFraction); // int s5 = s2+square*(gridWidth-1); // // int N = gridWidth*gridWidth-4; // for (int i = 0; i < N; i++) { // if( (value& (1<<i)) != 0 ) // continue; // // int where = index(i, gridWidth); // int x = where%gridWidth; // int y = gridWidth-1-(where/gridWidth); // // x = s2 + square*x; // y = s2 + square*y; // // ImageMiscOps.fillRectangle(ret,0xFF,x,y,square,square); // } // ImageMiscOps.fillRectangle(ret,0xFF,s2,s2,square,square); // ImageMiscOps.fillRectangle(ret,0xFF,s5,s5,square,square); // ImageMiscOps.fillRectangle(ret,0xFF,s5,s2,square,square); }
[ "public", "void", "generate", "(", "long", "value", ",", "int", "gridWidth", ")", "{", "renderer", ".", "init", "(", ")", ";", "drawBorder", "(", ")", ";", "double", "whiteBorder", "=", "whiteBorderDoc", "/", "markerWidth", ";", "double", "X0", "=", "whi...
Renders a binary square fiducial @param value Value encoded in the fiducial @param gridWidth number of cells wide the grid is
[ "Renders", "a", "binary", "square", "fiducial" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/FiducialSquareGenerator.java#L92-L133
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java
CameraPlaneProjection.setConfiguration
public void setConfiguration( Se3_F64 planeToCamera , CameraPinholeBrown intrinsic ) { this.planeToCamera = planeToCamera; normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); pixelToNorm = LensDistortionFactory.narrow(intrinsic).undistort_F64(true, false); planeToCamera.invert(cameraToPlane); }
java
public void setConfiguration( Se3_F64 planeToCamera , CameraPinholeBrown intrinsic ) { this.planeToCamera = planeToCamera; normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); pixelToNorm = LensDistortionFactory.narrow(intrinsic).undistort_F64(true, false); planeToCamera.invert(cameraToPlane); }
[ "public", "void", "setConfiguration", "(", "Se3_F64", "planeToCamera", ",", "CameraPinholeBrown", "intrinsic", ")", "{", "this", ".", "planeToCamera", "=", "planeToCamera", ";", "normToPixel", "=", "LensDistortionFactory", ".", "narrow", "(", "intrinsic", ")", ".", ...
Configures the camera's intrinsic and extrinsic parameters @param planeToCamera Transform from the plane to the camera @param intrinsic Pixel to normalized image coordinates
[ "Configures", "the", "camera", "s", "intrinsic", "and", "extrinsic", "parameters" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java#L64-L72
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java
CameraPlaneProjection.setIntrinsic
public void setIntrinsic(CameraPinholeBrown intrinsic ) { normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); pixelToNorm = LensDistortionFactory.narrow(intrinsic).undistort_F64(true, false); }
java
public void setIntrinsic(CameraPinholeBrown intrinsic ) { normToPixel = LensDistortionFactory.narrow(intrinsic).distort_F64(false, true); pixelToNorm = LensDistortionFactory.narrow(intrinsic).undistort_F64(true, false); }
[ "public", "void", "setIntrinsic", "(", "CameraPinholeBrown", "intrinsic", ")", "{", "normToPixel", "=", "LensDistortionFactory", ".", "narrow", "(", "intrinsic", ")", ".", "distort_F64", "(", "false", ",", "true", ")", ";", "pixelToNorm", "=", "LensDistortionFacto...
Configures the camera's intrinsic parameters @param intrinsic Intrinsic camera parameters
[ "Configures", "the", "camera", "s", "intrinsic", "parameters" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java#L78-L82
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java
CameraPlaneProjection.setPlaneToCamera
public void setPlaneToCamera(Se3_F64 planeToCamera, boolean computeInverse ) { this.planeToCamera = planeToCamera; if( computeInverse ) planeToCamera.invert(cameraToPlane); }
java
public void setPlaneToCamera(Se3_F64 planeToCamera, boolean computeInverse ) { this.planeToCamera = planeToCamera; if( computeInverse ) planeToCamera.invert(cameraToPlane); }
[ "public", "void", "setPlaneToCamera", "(", "Se3_F64", "planeToCamera", ",", "boolean", "computeInverse", ")", "{", "this", ".", "planeToCamera", "=", "planeToCamera", ";", "if", "(", "computeInverse", ")", "planeToCamera", ".", "invert", "(", "cameraToPlane", ")",...
Specifies camera's extrinsic parameters. @param planeToCamera Transform from plane to camera reference frame @param computeInverse Set to true if pixelToPlane is going to be called. performs extra calculation
[ "Specifies", "camera", "s", "extrinsic", "parameters", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java#L90-L95
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java
CameraPlaneProjection.planeToPixel
public boolean planeToPixel( double pointX , double pointY , Point2D_F64 pixel ) { // convert it into a 3D coordinate and transform into camera reference frame plain3D.set(-pointY, 0, pointX); SePointOps_F64.transform(planeToCamera, plain3D, camera3D); // if it's behind the camera it can't be seen if( camera3D.z <= 0 ) return false; // normalized image coordinates and convert into pixels double normX = camera3D.x / camera3D.z; double normY = camera3D.y / camera3D.z; normToPixel.compute(normX,normY,pixel); return true; }
java
public boolean planeToPixel( double pointX , double pointY , Point2D_F64 pixel ) { // convert it into a 3D coordinate and transform into camera reference frame plain3D.set(-pointY, 0, pointX); SePointOps_F64.transform(planeToCamera, plain3D, camera3D); // if it's behind the camera it can't be seen if( camera3D.z <= 0 ) return false; // normalized image coordinates and convert into pixels double normX = camera3D.x / camera3D.z; double normY = camera3D.y / camera3D.z; normToPixel.compute(normX,normY,pixel); return true; }
[ "public", "boolean", "planeToPixel", "(", "double", "pointX", ",", "double", "pointY", ",", "Point2D_F64", "pixel", ")", "{", "// convert it into a 3D coordinate and transform into camera reference frame", "plain3D", ".", "set", "(", "-", "pointY", ",", "0", ",", "poi...
Given a point on the plane find the pixel in the image. @param pointX (input) Point on the plane, x-axis @param pointY (input) Point on the plane, y-axis @param pixel (output) Pixel in the image @return true if the point is in front of the camera. False if not.
[ "Given", "a", "point", "on", "the", "plane", "find", "the", "pixel", "in", "the", "image", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java#L105-L120
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java
CameraPlaneProjection.planeToNormalized
public boolean planeToNormalized( double pointX , double pointY , Point2D_F64 normalized ) { // convert it into a 3D coordinate and transform into camera reference frame plain3D.set(-pointY, 0, pointX); SePointOps_F64.transform(planeToCamera, plain3D, camera3D); // if it's behind the camera it can't be seen if( camera3D.z <= 0 ) return false; // normalized image coordinates and convert into pixels normalized.x = camera3D.x / camera3D.z; normalized.y = camera3D.y / camera3D.z; return true; }
java
public boolean planeToNormalized( double pointX , double pointY , Point2D_F64 normalized ) { // convert it into a 3D coordinate and transform into camera reference frame plain3D.set(-pointY, 0, pointX); SePointOps_F64.transform(planeToCamera, plain3D, camera3D); // if it's behind the camera it can't be seen if( camera3D.z <= 0 ) return false; // normalized image coordinates and convert into pixels normalized.x = camera3D.x / camera3D.z; normalized.y = camera3D.y / camera3D.z; return true; }
[ "public", "boolean", "planeToNormalized", "(", "double", "pointX", ",", "double", "pointY", ",", "Point2D_F64", "normalized", ")", "{", "// convert it into a 3D coordinate and transform into camera reference frame", "plain3D", ".", "set", "(", "-", "pointY", ",", "0", "...
Given a point on the plane find the normalized image coordinate @param pointX (input) Point on the plane, x-axis @param pointY (input) Point on the plane, y-axis @param normalized (output) Normalized image coordinate of pixel @return true if the point is in front of the camera. False if not.
[ "Given", "a", "point", "on", "the", "plane", "find", "the", "normalized", "image", "coordinate" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/overhead/CameraPlaneProjection.java#L130-L144
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerGraph.java
ChessboardCornerGraph.convert
public void convert( FeatureGraph2D graph ) { graph.nodes.resize(corners.size); graph.reset(); for (int i = 0; i < corners.size; i++) { Node c = corners.get(i); FeatureGraph2D.Node n = graph.nodes.grow(); n.reset(); n.set(c.x,c.y); n.index = c.index; } for (int i = 0; i < corners.size; i++) { Node c = corners.get(i); for (int j = 0; j < 4; j++) { if( c.edges[j] == null ) continue; graph.connect(c.index,c.edges[j].index); } } }
java
public void convert( FeatureGraph2D graph ) { graph.nodes.resize(corners.size); graph.reset(); for (int i = 0; i < corners.size; i++) { Node c = corners.get(i); FeatureGraph2D.Node n = graph.nodes.grow(); n.reset(); n.set(c.x,c.y); n.index = c.index; } for (int i = 0; i < corners.size; i++) { Node c = corners.get(i); for (int j = 0; j < 4; j++) { if( c.edges[j] == null ) continue; graph.connect(c.index,c.edges[j].index); } } }
[ "public", "void", "convert", "(", "FeatureGraph2D", "graph", ")", "{", "graph", ".", "nodes", ".", "resize", "(", "corners", ".", "size", ")", ";", "graph", ".", "reset", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "corners", ...
Convert into a generic graph.
[ "Convert", "into", "a", "generic", "graph", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardCornerGraph.java#L42-L61
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/ImageMotionPointTrackerKey.java
ImageMotionPointTrackerKey.process
public boolean process( I frame ) { keyFrame = false; // update the feature tracker tracker.process(frame); totalFramesProcessed++; List<PointTrack> tracks = tracker.getActiveTracks(null); if( tracks.size() == 0 ) return false; List<AssociatedPair> pairs = new ArrayList<>(); for( PointTrack t : tracks ) { pairs.add((AssociatedPair)t.getCookie()); } // fit the motion model to the feature tracks if( !modelMatcher.process((List)pairs) ) { return false; } if( modelRefiner != null ) { if( !modelRefiner.fitModel(modelMatcher.getMatchSet(),modelMatcher.getModelParameters(),keyToCurr) ) return false; } else { keyToCurr.set(modelMatcher.getModelParameters()); } // mark that the track is in the inlier set for( AssociatedPair p : modelMatcher.getMatchSet() ) { ((AssociatedPairTrack)p).lastUsed = totalFramesProcessed; } // prune tracks which aren't being used pruneUnusedTracks(); // Update the motion worldToKey.concat(keyToCurr, worldToCurr); return true; }
java
public boolean process( I frame ) { keyFrame = false; // update the feature tracker tracker.process(frame); totalFramesProcessed++; List<PointTrack> tracks = tracker.getActiveTracks(null); if( tracks.size() == 0 ) return false; List<AssociatedPair> pairs = new ArrayList<>(); for( PointTrack t : tracks ) { pairs.add((AssociatedPair)t.getCookie()); } // fit the motion model to the feature tracks if( !modelMatcher.process((List)pairs) ) { return false; } if( modelRefiner != null ) { if( !modelRefiner.fitModel(modelMatcher.getMatchSet(),modelMatcher.getModelParameters(),keyToCurr) ) return false; } else { keyToCurr.set(modelMatcher.getModelParameters()); } // mark that the track is in the inlier set for( AssociatedPair p : modelMatcher.getMatchSet() ) { ((AssociatedPairTrack)p).lastUsed = totalFramesProcessed; } // prune tracks which aren't being used pruneUnusedTracks(); // Update the motion worldToKey.concat(keyToCurr, worldToCurr); return true; }
[ "public", "boolean", "process", "(", "I", "frame", ")", "{", "keyFrame", "=", "false", ";", "// update the feature tracker", "tracker", ".", "process", "(", "frame", ")", ";", "totalFramesProcessed", "++", ";", "List", "<", "PointTrack", ">", "tracks", "=", ...
Processes the next frame in the sequence. @param frame Next frame in the video sequence @return true if motion was estimated and false if no motion was estimated
[ "Processes", "the", "next", "frame", "in", "the", "sequence", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/ImageMotionPointTrackerKey.java#L110-L152
train
lessthanoptimal/BoofCV
main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/ImageMotionPointTrackerKey.java
ImageMotionPointTrackerKey.changeKeyFrame
public void changeKeyFrame() { // drop all inactive tracks since their location is unknown in the current frame List<PointTrack> inactive = tracker.getInactiveTracks(null); for( PointTrack l : inactive ) { tracker.dropTrack(l); } // set the keyframe for active tracks as their current location List<PointTrack> active = tracker.getActiveTracks(null); for( PointTrack l : active ) { AssociatedPairTrack p = l.getCookie(); p.p1.set(l); p.lastUsed = totalFramesProcessed; } tracker.spawnTracks(); List<PointTrack> spawned = tracker.getNewTracks(null); for( PointTrack l : spawned ) { AssociatedPairTrack p = l.getCookie(); if( p == null ) { l.cookie = p = new AssociatedPairTrack(); // little bit of trickery here. Save the reference so that the point // in the current frame is updated for free as PointTrack is p.p2 = l; } p.p1.set(l); p.lastUsed = totalFramesProcessed; } worldToKey.set(worldToCurr); keyToCurr.reset(); keyFrame = true; }
java
public void changeKeyFrame() { // drop all inactive tracks since their location is unknown in the current frame List<PointTrack> inactive = tracker.getInactiveTracks(null); for( PointTrack l : inactive ) { tracker.dropTrack(l); } // set the keyframe for active tracks as their current location List<PointTrack> active = tracker.getActiveTracks(null); for( PointTrack l : active ) { AssociatedPairTrack p = l.getCookie(); p.p1.set(l); p.lastUsed = totalFramesProcessed; } tracker.spawnTracks(); List<PointTrack> spawned = tracker.getNewTracks(null); for( PointTrack l : spawned ) { AssociatedPairTrack p = l.getCookie(); if( p == null ) { l.cookie = p = new AssociatedPairTrack(); // little bit of trickery here. Save the reference so that the point // in the current frame is updated for free as PointTrack is p.p2 = l; } p.p1.set(l); p.lastUsed = totalFramesProcessed; } worldToKey.set(worldToCurr); keyToCurr.reset(); keyFrame = true; }
[ "public", "void", "changeKeyFrame", "(", ")", "{", "// drop all inactive tracks since their location is unknown in the current frame", "List", "<", "PointTrack", ">", "inactive", "=", "tracker", ".", "getInactiveTracks", "(", "null", ")", ";", "for", "(", "PointTrack", ...
Change the current frame into the keyframe. p1 location of existing tracks is set to their current location and new tracks are spawned. Reference frame transformations are also updated
[ "Change", "the", "current", "frame", "into", "the", "keyframe", ".", "p1", "location", "of", "existing", "tracks", "is", "set", "to", "their", "current", "location", "and", "new", "tracks", "are", "spawned", ".", "Reference", "frame", "transformations", "are",...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/ImageMotionPointTrackerKey.java#L170-L203
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/cloud/PointCloudUtils.java
PointCloudUtils.autoScale
public static double autoScale( List<Point3D_F64> cloud , double target ) { Point3D_F64 mean = new Point3D_F64(); Point3D_F64 stdev = new Point3D_F64(); statistics(cloud, mean, stdev); double scale = target/(Math.max(Math.max(stdev.x,stdev.y),stdev.z)); int N = cloud.size(); for (int i = 0; i < N ; i++) { cloud.get(i).scale(scale); } return scale; }
java
public static double autoScale( List<Point3D_F64> cloud , double target ) { Point3D_F64 mean = new Point3D_F64(); Point3D_F64 stdev = new Point3D_F64(); statistics(cloud, mean, stdev); double scale = target/(Math.max(Math.max(stdev.x,stdev.y),stdev.z)); int N = cloud.size(); for (int i = 0; i < N ; i++) { cloud.get(i).scale(scale); } return scale; }
[ "public", "static", "double", "autoScale", "(", "List", "<", "Point3D_F64", ">", "cloud", ",", "double", "target", ")", "{", "Point3D_F64", "mean", "=", "new", "Point3D_F64", "(", ")", ";", "Point3D_F64", "stdev", "=", "new", "Point3D_F64", "(", ")", ";", ...
Automatically rescales the point cloud based so that it has a standard deviation of 'target' @param cloud The point cloud @param target The desired standard deviation of the cloud. Try 100 @return The selected scale factor
[ "Automatically", "rescales", "the", "point", "cloud", "based", "so", "that", "it", "has", "a", "standard", "deviation", "of", "target" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/cloud/PointCloudUtils.java#L42-L57
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/cloud/PointCloudUtils.java
PointCloudUtils.statistics
public static void statistics( List<Point3D_F64> cloud , Point3D_F64 mean , Point3D_F64 stdev ) { final int N = cloud.size(); for (int i = 0; i < N; i++) { Point3D_F64 p = cloud.get(i); mean.x += p.x / N; mean.y += p.y / N; mean.z += p.z / N; } for (int i = 0; i < N; i++) { Point3D_F64 p = cloud.get(i); double dx = p.x-mean.x; double dy = p.y-mean.y; double dz = p.z-mean.z; stdev.x += dx*dx/N; stdev.y += dy*dy/N; stdev.z += dz*dz/N; } stdev.x = Math.sqrt(stdev.x); stdev.y = Math.sqrt(stdev.y); stdev.z = Math.sqrt(stdev.z); }
java
public static void statistics( List<Point3D_F64> cloud , Point3D_F64 mean , Point3D_F64 stdev ) { final int N = cloud.size(); for (int i = 0; i < N; i++) { Point3D_F64 p = cloud.get(i); mean.x += p.x / N; mean.y += p.y / N; mean.z += p.z / N; } for (int i = 0; i < N; i++) { Point3D_F64 p = cloud.get(i); double dx = p.x-mean.x; double dy = p.y-mean.y; double dz = p.z-mean.z; stdev.x += dx*dx/N; stdev.y += dy*dy/N; stdev.z += dz*dz/N; } stdev.x = Math.sqrt(stdev.x); stdev.y = Math.sqrt(stdev.y); stdev.z = Math.sqrt(stdev.z); }
[ "public", "static", "void", "statistics", "(", "List", "<", "Point3D_F64", ">", "cloud", ",", "Point3D_F64", "mean", ",", "Point3D_F64", "stdev", ")", "{", "final", "int", "N", "=", "cloud", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0...
Computes the mean and standard deviation of each axis in the point cloud computed in dependently @param cloud (Input) Cloud @param mean (Output) mean of each axis @param stdev (Output) standard deviation of each axis
[ "Computes", "the", "mean", "and", "standard", "deviation", "of", "each", "axis", "in", "the", "point", "cloud", "computed", "in", "dependently" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/cloud/PointCloudUtils.java#L65-L87
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/cloud/PointCloudUtils.java
PointCloudUtils.prune
public static void prune(List<Point3D_F64> cloud , int minNeighbors , double radius ) { if( minNeighbors < 0 ) throw new IllegalArgumentException("minNeighbors must be >= 0"); NearestNeighbor<Point3D_F64> nn = FactoryNearestNeighbor.kdtree(new KdTreePoint3D_F64() ); NearestNeighbor.Search<Point3D_F64> search = nn.createSearch(); nn.setPoints(cloud,false); FastQueue<NnData<Point3D_F64>> results = new FastQueue(NnData.class,true); // It will always find itself minNeighbors += 1; // distance is Euclidean squared radius *= radius; for( int i = cloud.size()-1; i >= 0; i-- ) { search.findNearest(cloud.get(i),radius,minNeighbors,results); if( results.size < minNeighbors ) { cloud.remove(i); } } }
java
public static void prune(List<Point3D_F64> cloud , int minNeighbors , double radius ) { if( minNeighbors < 0 ) throw new IllegalArgumentException("minNeighbors must be >= 0"); NearestNeighbor<Point3D_F64> nn = FactoryNearestNeighbor.kdtree(new KdTreePoint3D_F64() ); NearestNeighbor.Search<Point3D_F64> search = nn.createSearch(); nn.setPoints(cloud,false); FastQueue<NnData<Point3D_F64>> results = new FastQueue(NnData.class,true); // It will always find itself minNeighbors += 1; // distance is Euclidean squared radius *= radius; for( int i = cloud.size()-1; i >= 0; i-- ) { search.findNearest(cloud.get(i),radius,minNeighbors,results); if( results.size < minNeighbors ) { cloud.remove(i); } } }
[ "public", "static", "void", "prune", "(", "List", "<", "Point3D_F64", ">", "cloud", ",", "int", "minNeighbors", ",", "double", "radius", ")", "{", "if", "(", "minNeighbors", "<", "0", ")", "throw", "new", "IllegalArgumentException", "(", "\"minNeighbors must b...
Prunes points from the point cloud if they have very few neighbors @param cloud Point cloud @param minNeighbors Minimum number of neighbors for it to not be pruned @param radius search distance for neighbors
[ "Prunes", "points", "from", "the", "point", "cloud", "if", "they", "have", "very", "few", "neighbors" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/cloud/PointCloudUtils.java#L96-L118
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/LowLevelMultiViewOps.java
LowLevelMultiViewOps.computeNormalizationLL
public static void computeNormalizationLL(List<List<Point2D_F64>> points, NormalizationPoint2D normalize ) { double meanX = 0; double meanY = 0; int count = 0; for (int i = 0; i < points.size(); i++) { List<Point2D_F64> l = points.get(i); for (int j = 0; j < l.size(); j++) { Point2D_F64 p = l.get(j); meanX += p.x; meanY += p.y; } count += l.size(); } meanX /= count; meanY /= count; double stdX = 0; double stdY = 0; for (int i = 0; i < points.size(); i++) { List<Point2D_F64> l = points.get(i); for (int j = 0; j < l.size(); j++) { Point2D_F64 p = l.get(j); double dx = p.x - meanX; double dy = p.y - meanY; stdX += dx*dx; stdY += dy*dy; } } normalize.meanX = meanX; normalize.meanY = meanY; normalize.stdX = Math.sqrt(stdX/count); normalize.stdY = Math.sqrt(stdY/count); }
java
public static void computeNormalizationLL(List<List<Point2D_F64>> points, NormalizationPoint2D normalize ) { double meanX = 0; double meanY = 0; int count = 0; for (int i = 0; i < points.size(); i++) { List<Point2D_F64> l = points.get(i); for (int j = 0; j < l.size(); j++) { Point2D_F64 p = l.get(j); meanX += p.x; meanY += p.y; } count += l.size(); } meanX /= count; meanY /= count; double stdX = 0; double stdY = 0; for (int i = 0; i < points.size(); i++) { List<Point2D_F64> l = points.get(i); for (int j = 0; j < l.size(); j++) { Point2D_F64 p = l.get(j); double dx = p.x - meanX; double dy = p.y - meanY; stdX += dx*dx; stdY += dy*dy; } } normalize.meanX = meanX; normalize.meanY = meanY; normalize.stdX = Math.sqrt(stdX/count); normalize.stdY = Math.sqrt(stdY/count); }
[ "public", "static", "void", "computeNormalizationLL", "(", "List", "<", "List", "<", "Point2D_F64", ">", ">", "points", ",", "NormalizationPoint2D", "normalize", ")", "{", "double", "meanX", "=", "0", ";", "double", "meanY", "=", "0", ";", "int", "count", ...
Computes normalization when points are contained in a list of lists @param points Input: List of observed points. Not modified. @param normalize Output: 3x3 normalization matrix for first set of points. Modified.
[ "Computes", "normalization", "when", "points", "are", "contained", "in", "a", "list", "of", "lists" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/LowLevelMultiViewOps.java#L82-L121
train
lessthanoptimal/BoofCV
main/autocode/src/main/java/boofcv/AutocodeConcurrentApp.java
AutocodeConcurrentApp.convertFile
public static void convertFile( File original ) throws IOException { File outputFile = determineClassName(original); String classNameOld = className(original); String classNameNew = className(outputFile); // Read the file and split it up into lines List<String> inputLines = FileUtils.readLines(original,"UTF-8"); List<String> outputLines = new ArrayList<>(); List<Macro> macros = new ArrayList<>(); // parse each line by line looking for instructions boolean foundClassDef = false; for (int i = 0; i < inputLines.size(); i++) { String line = inputLines.get(i); int where = line.indexOf(prefix); if( where < 0 ) { if( !foundClassDef && line.contains("class "+classNameOld)) { foundClassDef = true; line = line.replaceFirst("class "+classNameOld,"class "+classNameNew); } else { line = line.replace(classNameOld+"(",classNameNew+"("); } outputLines.add(line); continue; } String type = readType(line,where+prefix.length()); String whitespaces = line.substring(0,where); int frontLength =where+prefix.length()+type.length(); String message = line.length()>frontLength ? line.substring(frontLength+1) : ""; switch(type) { case "CLASS_NAME":continue; // ignore. already processed case "INLINE": outputLines.add(whitespaces+message); break; case "ABOVE": // remove the previous line outputLines.remove(outputLines.size()-1); outputLines.add(whitespaces+message); break; case "BELOW": outputLines.add(whitespaces+message); i += 1; // skip next line break; case "REMOVE_ABOVE": outputLines.remove(outputLines.size()-1); break; case "REMOVE_BELOW": i += 1; // skip next line break; case "MACRO": throw new RuntimeException("MACRO not handled yet"); default: throw new RuntimeException("Unknown: "+type); } } PrintStream out = new PrintStream(outputFile); for (int i = 0; i < outputLines.size(); i++) { out.println(outputLines.get(i)); } out.close(); createTestIfNotThere(outputFile); }
java
public static void convertFile( File original ) throws IOException { File outputFile = determineClassName(original); String classNameOld = className(original); String classNameNew = className(outputFile); // Read the file and split it up into lines List<String> inputLines = FileUtils.readLines(original,"UTF-8"); List<String> outputLines = new ArrayList<>(); List<Macro> macros = new ArrayList<>(); // parse each line by line looking for instructions boolean foundClassDef = false; for (int i = 0; i < inputLines.size(); i++) { String line = inputLines.get(i); int where = line.indexOf(prefix); if( where < 0 ) { if( !foundClassDef && line.contains("class "+classNameOld)) { foundClassDef = true; line = line.replaceFirst("class "+classNameOld,"class "+classNameNew); } else { line = line.replace(classNameOld+"(",classNameNew+"("); } outputLines.add(line); continue; } String type = readType(line,where+prefix.length()); String whitespaces = line.substring(0,where); int frontLength =where+prefix.length()+type.length(); String message = line.length()>frontLength ? line.substring(frontLength+1) : ""; switch(type) { case "CLASS_NAME":continue; // ignore. already processed case "INLINE": outputLines.add(whitespaces+message); break; case "ABOVE": // remove the previous line outputLines.remove(outputLines.size()-1); outputLines.add(whitespaces+message); break; case "BELOW": outputLines.add(whitespaces+message); i += 1; // skip next line break; case "REMOVE_ABOVE": outputLines.remove(outputLines.size()-1); break; case "REMOVE_BELOW": i += 1; // skip next line break; case "MACRO": throw new RuntimeException("MACRO not handled yet"); default: throw new RuntimeException("Unknown: "+type); } } PrintStream out = new PrintStream(outputFile); for (int i = 0; i < outputLines.size(); i++) { out.println(outputLines.get(i)); } out.close(); createTestIfNotThere(outputFile); }
[ "public", "static", "void", "convertFile", "(", "File", "original", ")", "throws", "IOException", "{", "File", "outputFile", "=", "determineClassName", "(", "original", ")", ";", "String", "classNameOld", "=", "className", "(", "original", ")", ";", "String", ...
Converts the file from single thread into concurrent implementation
[ "Converts", "the", "file", "from", "single", "thread", "into", "concurrent", "implementation" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/autocode/src/main/java/boofcv/AutocodeConcurrentApp.java#L54-L119
train
lessthanoptimal/BoofCV
main/autocode/src/main/java/boofcv/AutocodeConcurrentApp.java
AutocodeConcurrentApp.determineClassName
private static File determineClassName( File original ) throws IOException { String text = FileUtils.readFileToString(original, "UTF-8"); if(!text.contains("//CONCURRENT")) throw new IOException("Not a concurrent file"); String pattern = "//CONCURRENT_CLASS_NAME "; int where = text.indexOf(pattern); if( where < 0 ) { String name = className(original); return new File(original.getParent(),name+"_MT.java"); } String name = readUntilEndOfLine(text,where+pattern.length()); return new File(original.getParent(),name+".java"); }
java
private static File determineClassName( File original ) throws IOException { String text = FileUtils.readFileToString(original, "UTF-8"); if(!text.contains("//CONCURRENT")) throw new IOException("Not a concurrent file"); String pattern = "//CONCURRENT_CLASS_NAME "; int where = text.indexOf(pattern); if( where < 0 ) { String name = className(original); return new File(original.getParent(),name+"_MT.java"); } String name = readUntilEndOfLine(text,where+pattern.length()); return new File(original.getParent(),name+".java"); }
[ "private", "static", "File", "determineClassName", "(", "File", "original", ")", "throws", "IOException", "{", "String", "text", "=", "FileUtils", ".", "readFileToString", "(", "original", ",", "\"UTF-8\"", ")", ";", "if", "(", "!", "text", ".", "contains", ...
Searches the input file for an override. If none is found then _MT is added to the class name. @param original Input file @return Output file
[ "Searches", "the", "input", "file", "for", "an", "override", ".", "If", "none", "is", "found", "then", "_MT", "is", "added", "to", "the", "class", "name", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/autocode/src/main/java/boofcv/AutocodeConcurrentApp.java#L208-L223
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/pyramid/ImagePyramidBase.java
ImagePyramidBase.initialize
@Override public void initialize(int width, int height) { // see if it has already been initialized if( bottomWidth == width && bottomHeight == height ) return; this.bottomWidth = width; this.bottomHeight = height; layers = imageType.createArray(getNumLayers()); double scaleFactor = getScale(0); if (scaleFactor == 1) { if (!saveOriginalReference) { layers[0] = imageType.createImage(bottomWidth, bottomHeight); } } else { layers[0] = imageType.createImage((int)Math.ceil(bottomWidth / scaleFactor), (int)Math.ceil(bottomHeight / scaleFactor)); } for (int i = 1; i < layers.length; i++) { scaleFactor = getScale(i); layers[i] = imageType.createImage((int)Math.ceil(bottomWidth / scaleFactor), (int)Math.ceil(bottomHeight / scaleFactor)); } }
java
@Override public void initialize(int width, int height) { // see if it has already been initialized if( bottomWidth == width && bottomHeight == height ) return; this.bottomWidth = width; this.bottomHeight = height; layers = imageType.createArray(getNumLayers()); double scaleFactor = getScale(0); if (scaleFactor == 1) { if (!saveOriginalReference) { layers[0] = imageType.createImage(bottomWidth, bottomHeight); } } else { layers[0] = imageType.createImage((int)Math.ceil(bottomWidth / scaleFactor), (int)Math.ceil(bottomHeight / scaleFactor)); } for (int i = 1; i < layers.length; i++) { scaleFactor = getScale(i); layers[i] = imageType.createImage((int)Math.ceil(bottomWidth / scaleFactor), (int)Math.ceil(bottomHeight / scaleFactor)); } }
[ "@", "Override", "public", "void", "initialize", "(", "int", "width", ",", "int", "height", ")", "{", "// see if it has already been initialized", "if", "(", "bottomWidth", "==", "width", "&&", "bottomHeight", "==", "height", ")", "return", ";", "this", ".", "...
Initializes internal data structures based on the input image's size. Should be called each time a new image is processed. @param width Image width @param height Image height
[ "Initializes", "internal", "data", "structures", "based", "on", "the", "input", "image", "s", "size", ".", "Should", "be", "called", "each", "time", "a", "new", "image", "is", "processed", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/pyramid/ImagePyramidBase.java#L72-L95
train
lessthanoptimal/BoofCV
main/boofcv-types/src/main/java/boofcv/struct/pyramid/ImagePyramidBase.java
ImagePyramidBase.checkScales
protected void checkScales() { if( getScale(0) < 0 ) { throw new IllegalArgumentException("The first layer must be more than zero."); } double prevScale = 0; for( int i = 0; i < getNumLayers(); i++ ) { double s = getScale(i); if( s < prevScale ) throw new IllegalArgumentException("Higher layers must be the same size or larger than previous layers."); prevScale = s; } }
java
protected void checkScales() { if( getScale(0) < 0 ) { throw new IllegalArgumentException("The first layer must be more than zero."); } double prevScale = 0; for( int i = 0; i < getNumLayers(); i++ ) { double s = getScale(i); if( s < prevScale ) throw new IllegalArgumentException("Higher layers must be the same size or larger than previous layers."); prevScale = s; } }
[ "protected", "void", "checkScales", "(", ")", "{", "if", "(", "getScale", "(", "0", ")", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"The first layer must be more than zero.\"", ")", ";", "}", "double", "prevScale", "=", "0", ";", ...
Used to internally check that the provided scales are valid.
[ "Used", "to", "internally", "check", "that", "the", "provided", "scales", "are", "valid", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/pyramid/ImagePyramidBase.java#L100-L112
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoRegularGrid.java
EllipseClustersIntoRegularGrid.checkGridSize
static boolean checkGridSize(List<List<NodeInfo>> grid , int clusterSize ) { int total = 0; int expected = grid.get(0).size(); for (int i = 0; i < grid.size(); i++) { if( expected != grid.get(i).size() ) return false; total += grid.get(i).size(); } return total == clusterSize; }
java
static boolean checkGridSize(List<List<NodeInfo>> grid , int clusterSize ) { int total = 0; int expected = grid.get(0).size(); for (int i = 0; i < grid.size(); i++) { if( expected != grid.get(i).size() ) return false; total += grid.get(i).size(); } return total == clusterSize; }
[ "static", "boolean", "checkGridSize", "(", "List", "<", "List", "<", "NodeInfo", ">", ">", "grid", ",", "int", "clusterSize", ")", "{", "int", "total", "=", "0", ";", "int", "expected", "=", "grid", ".", "get", "(", "0", ")", ".", "size", "(", ")",...
Makes sure the found grid is the same size as the original cluster. If it's not then. not all the nodes were used. All lists must have he same size too.
[ "Makes", "sure", "the", "found", "grid", "is", "the", "same", "size", "as", "the", "original", "cluster", ".", "If", "it", "s", "not", "then", ".", "not", "all", "the", "nodes", "were", "used", ".", "All", "lists", "must", "have", "he", "same", "size...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/EllipseClustersIntoRegularGrid.java#L119-L130
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java
PixelDepthLinearMetric.depthNView
public double depthNView( List<Point2D_F64> obs , List<Se3_F64> motion ) { double top = 0, bottom = 0; Point2D_F64 a = obs.get(0); for( int i = 1; i < obs.size(); i++ ) { Se3_F64 se = motion.get(i-1); Point2D_F64 b = obs.get(i); GeometryMath_F64.multCrossA(b, se.getR(), temp0); GeometryMath_F64.mult(temp0,a,temp1); GeometryMath_F64.cross(b, se.getT(), temp2); top += temp2.x+temp2.y+temp2.z; bottom += temp1.x+temp1.y+temp1.z; } return -top/bottom; }
java
public double depthNView( List<Point2D_F64> obs , List<Se3_F64> motion ) { double top = 0, bottom = 0; Point2D_F64 a = obs.get(0); for( int i = 1; i < obs.size(); i++ ) { Se3_F64 se = motion.get(i-1); Point2D_F64 b = obs.get(i); GeometryMath_F64.multCrossA(b, se.getR(), temp0); GeometryMath_F64.mult(temp0,a,temp1); GeometryMath_F64.cross(b, se.getT(), temp2); top += temp2.x+temp2.y+temp2.z; bottom += temp1.x+temp1.y+temp1.z; } return -top/bottom; }
[ "public", "double", "depthNView", "(", "List", "<", "Point2D_F64", ">", "obs", ",", "List", "<", "Se3_F64", ">", "motion", ")", "{", "double", "top", "=", "0", ",", "bottom", "=", "0", ";", "Point2D_F64", "a", "=", "obs", ".", "get", "(", "0", ")",...
Computes the pixel depth from N views of the same object. Pixel depth in the first frame. @param obs List of observations on a single feature in normalized coordinates @param motion List of camera motions. Each index 'i' is the motion from view 0 to view i+1. @return depth of the pixels
[ "Computes", "the", "pixel", "depth", "from", "N", "views", "of", "the", "same", "object", ".", "Pixel", "depth", "in", "the", "first", "frame", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java#L70-L91
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java
PixelDepthLinearMetric.depth2View
public double depth2View( Point2D_F64 a , Point2D_F64 b , Se3_F64 fromAtoB ) { DMatrixRMaj R = fromAtoB.getR(); Vector3D_F64 T = fromAtoB.getT(); GeometryMath_F64.multCrossA(b, R, temp0); GeometryMath_F64.mult(temp0,a,temp1); GeometryMath_F64.cross(b, T, temp2); return -(temp2.x+temp2.y+temp2.z)/(temp1.x+temp1.y+temp1.z); }
java
public double depth2View( Point2D_F64 a , Point2D_F64 b , Se3_F64 fromAtoB ) { DMatrixRMaj R = fromAtoB.getR(); Vector3D_F64 T = fromAtoB.getT(); GeometryMath_F64.multCrossA(b, R, temp0); GeometryMath_F64.mult(temp0,a,temp1); GeometryMath_F64.cross(b, T, temp2); return -(temp2.x+temp2.y+temp2.z)/(temp1.x+temp1.y+temp1.z); }
[ "public", "double", "depth2View", "(", "Point2D_F64", "a", ",", "Point2D_F64", "b", ",", "Se3_F64", "fromAtoB", ")", "{", "DMatrixRMaj", "R", "=", "fromAtoB", ".", "getR", "(", ")", ";", "Vector3D_F64", "T", "=", "fromAtoB", ".", "getT", "(", ")", ";", ...
Computes pixel depth in image 'a' from two observations. @param a Observation in first frame. In calibrated coordinates. Not modified. @param b Observation in second frame. In calibrated coordinates. Not modified. @param fromAtoB Transform from frame a to frame b. @return Pixel depth in first frame. In same units as T inside of fromAtoB.
[ "Computes", "pixel", "depth", "in", "image", "a", "from", "two", "observations", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/PixelDepthLinearMetric.java#L101-L112
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java
ProjectiveStructureByFactorization.initialize
public void initialize( int numFeatures , int numViews ) { depths.reshape(numViews,numFeatures); pixels.reshape(numViews*2,numFeatures); pixelScale = 0; }
java
public void initialize( int numFeatures , int numViews ) { depths.reshape(numViews,numFeatures); pixels.reshape(numViews*2,numFeatures); pixelScale = 0; }
[ "public", "void", "initialize", "(", "int", "numFeatures", ",", "int", "numViews", ")", "{", "depths", ".", "reshape", "(", "numViews", ",", "numFeatures", ")", ";", "pixels", ".", "reshape", "(", "numViews", "*", "2", ",", "numFeatures", ")", ";", "pixe...
Initializes internal data structures. Must be called first @param numFeatures Number of features @param numViews Number of views
[ "Initializes", "internal", "data", "structures", ".", "Must", "be", "called", "first" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java#L98-L102
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java
ProjectiveStructureByFactorization.setPixels
public void setPixels(int view , List<Point2D_F64> pixelsInView ) { if( pixelsInView.size() != pixels.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int row = view*2; for (int i = 0; i < pixelsInView.size(); i++) { Point2D_F64 p = pixelsInView.get(i); pixels.set(row,i,p.x); pixels.set(row+1,i,p.y); pixelScale = Math.max(Math.abs(p.x),Math.abs(p.y)); } }
java
public void setPixels(int view , List<Point2D_F64> pixelsInView ) { if( pixelsInView.size() != pixels.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int row = view*2; for (int i = 0; i < pixelsInView.size(); i++) { Point2D_F64 p = pixelsInView.get(i); pixels.set(row,i,p.x); pixels.set(row+1,i,p.y); pixelScale = Math.max(Math.abs(p.x),Math.abs(p.y)); } }
[ "public", "void", "setPixels", "(", "int", "view", ",", "List", "<", "Point2D_F64", ">", "pixelsInView", ")", "{", "if", "(", "pixelsInView", ".", "size", "(", ")", "!=", "pixels", ".", "numCols", ")", "throw", "new", "IllegalArgumentException", "(", "\"Pi...
Sets pixel observations for a paricular view @param view the view @param pixelsInView list of 2D pixel observations
[ "Sets", "pixel", "observations", "for", "a", "paricular", "view" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java#L109-L120
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java
ProjectiveStructureByFactorization.setDepths
public void setDepths( int view , double featureDepths[] ) { if( featureDepths.length < depths.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int N = depths.numCols; for (int i = 0; i < N; i++) { depths.set(view,i, featureDepths[i]); } }
java
public void setDepths( int view , double featureDepths[] ) { if( featureDepths.length < depths.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int N = depths.numCols; for (int i = 0; i < N; i++) { depths.set(view,i, featureDepths[i]); } }
[ "public", "void", "setDepths", "(", "int", "view", ",", "double", "featureDepths", "[", "]", ")", "{", "if", "(", "featureDepths", ".", "length", "<", "depths", ".", "numCols", ")", "throw", "new", "IllegalArgumentException", "(", "\"Pixel count must be constant...
Sets depths for a particular value to the values in the passed in array @param view @param featureDepths
[ "Sets", "depths", "for", "a", "particular", "value", "to", "the", "values", "in", "the", "passed", "in", "array" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java#L135-L143
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java
ProjectiveStructureByFactorization.setDepthsFrom3D
public void setDepthsFrom3D(int view , List<Point3D_F64> locations ) { if( locations.size() != pixels.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int N = depths.numCols; for (int i = 0; i < N; i++) { depths.set(view,i, locations.get(i).z ); } }
java
public void setDepthsFrom3D(int view , List<Point3D_F64> locations ) { if( locations.size() != pixels.numCols ) throw new IllegalArgumentException("Pixel count must be constant and match "+pixels.numCols); int N = depths.numCols; for (int i = 0; i < N; i++) { depths.set(view,i, locations.get(i).z ); } }
[ "public", "void", "setDepthsFrom3D", "(", "int", "view", ",", "List", "<", "Point3D_F64", ">", "locations", ")", "{", "if", "(", "locations", ".", "size", "(", ")", "!=", "pixels", ".", "numCols", ")", "throw", "new", "IllegalArgumentException", "(", "\"Pi...
Assigns depth to the z value of all the features in the list. Features must be in the coordinate system of the view for this to be correct @param view which view is features are in @param locations Location of features in the view's reference frame
[ "Assigns", "depth", "to", "the", "z", "value", "of", "all", "the", "features", "in", "the", "list", ".", "Features", "must", "be", "in", "the", "coordinate", "system", "of", "the", "view", "for", "this", "to", "be", "correct" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java#L151-L159
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java
ProjectiveStructureByFactorization.process
public boolean process() { int numViews = depths.numRows; int numFeatures = depths.numCols; P.reshape(3*numViews,4); X.reshape(4,numFeatures); A.reshape(numViews*3,numFeatures); B.reshape(numViews*3,numFeatures); // Scale depths so that they are close to unity normalizeDepths(depths); // Compute the initial A matirx assignValuesToA(A); for (int iter = 0; iter < maxIterations; iter++) { if( !svd.decompose(A) ) return false; svd.getU(U,false); svd.getV(Vt,true); double sv[] = svd.getSingularValues(); SingularOps_DDRM.descendingOrder(U,false,sv,A.numCols,Vt,true); // This is equivalent to forcing the rank to be 4 CommonOps_DDRM.extract(U,0,0,P); CommonOps_DDRM.multCols(P,sv); CommonOps_DDRM.extract(Vt,0,0,X); // Compute the new value of A CommonOps_DDRM.mult(P,X,B); // See how much change there is double delta = SpecializedOps_DDRM.diffNormF(A,B)/(A.numCols*A.numRows); // swap arrays for the next iteration DMatrixRMaj tmp = A; A = B; B = tmp; // exit if converged if( delta <= minimumChangeTol ) break; } return true; }
java
public boolean process() { int numViews = depths.numRows; int numFeatures = depths.numCols; P.reshape(3*numViews,4); X.reshape(4,numFeatures); A.reshape(numViews*3,numFeatures); B.reshape(numViews*3,numFeatures); // Scale depths so that they are close to unity normalizeDepths(depths); // Compute the initial A matirx assignValuesToA(A); for (int iter = 0; iter < maxIterations; iter++) { if( !svd.decompose(A) ) return false; svd.getU(U,false); svd.getV(Vt,true); double sv[] = svd.getSingularValues(); SingularOps_DDRM.descendingOrder(U,false,sv,A.numCols,Vt,true); // This is equivalent to forcing the rank to be 4 CommonOps_DDRM.extract(U,0,0,P); CommonOps_DDRM.multCols(P,sv); CommonOps_DDRM.extract(Vt,0,0,X); // Compute the new value of A CommonOps_DDRM.mult(P,X,B); // See how much change there is double delta = SpecializedOps_DDRM.diffNormF(A,B)/(A.numCols*A.numRows); // swap arrays for the next iteration DMatrixRMaj tmp = A; A = B; B = tmp; // exit if converged if( delta <= minimumChangeTol ) break; } return true; }
[ "public", "boolean", "process", "(", ")", "{", "int", "numViews", "=", "depths", ".", "numRows", ";", "int", "numFeatures", "=", "depths", ".", "numCols", ";", "P", ".", "reshape", "(", "3", "*", "numViews", ",", "4", ")", ";", "X", ".", "reshape", ...
Performs iteration to find camera matrices and feature locations in world frame @return true if no exception was thrown. Does not mean it converged to a valid solution
[ "Performs", "iteration", "to", "find", "camera", "matrices", "and", "feature", "locations", "in", "world", "frame" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java#L165-L212
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java
ProjectiveStructureByFactorization.getCameraMatrix
public void getCameraMatrix(int view , DMatrixRMaj cameraMatrix ) { cameraMatrix.reshape(3,4); CommonOps_DDRM.extract(P,view*3,0,cameraMatrix); for (int col = 0; col < 4; col++) { cameraMatrix.data[cameraMatrix.getIndex(0,col)] *= pixelScale; cameraMatrix.data[cameraMatrix.getIndex(1,col)] *= pixelScale; } }
java
public void getCameraMatrix(int view , DMatrixRMaj cameraMatrix ) { cameraMatrix.reshape(3,4); CommonOps_DDRM.extract(P,view*3,0,cameraMatrix); for (int col = 0; col < 4; col++) { cameraMatrix.data[cameraMatrix.getIndex(0,col)] *= pixelScale; cameraMatrix.data[cameraMatrix.getIndex(1,col)] *= pixelScale; } }
[ "public", "void", "getCameraMatrix", "(", "int", "view", ",", "DMatrixRMaj", "cameraMatrix", ")", "{", "cameraMatrix", ".", "reshape", "(", "3", ",", "4", ")", ";", "CommonOps_DDRM", ".", "extract", "(", "P", ",", "view", "*", "3", ",", "0", ",", "came...
Used to get found camera matrix for a view @param view Which view @param cameraMatrix storage for 3x4 projective camera matrix
[ "Used", "to", "get", "found", "camera", "matrix", "for", "a", "view" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java#L219-L227
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java
ProjectiveStructureByFactorization.getFeature3D
public void getFeature3D( int feature , Point4D_F64 out ) { out.x = X.get(0,feature); out.y = X.get(1,feature); out.z = X.get(2,feature); out.w = X.get(3,feature); }
java
public void getFeature3D( int feature , Point4D_F64 out ) { out.x = X.get(0,feature); out.y = X.get(1,feature); out.z = X.get(2,feature); out.w = X.get(3,feature); }
[ "public", "void", "getFeature3D", "(", "int", "feature", ",", "Point4D_F64", "out", ")", "{", "out", ".", "x", "=", "X", ".", "get", "(", "0", ",", "feature", ")", ";", "out", ".", "y", "=", "X", ".", "get", "(", "1", ",", "feature", ")", ";", ...
Returns location of 3D feature for a view @param feature Index of feature to retrieve @param out (Output) Storage for 3D feature. homogenous coordinates
[ "Returns", "location", "of", "3D", "feature", "for", "a", "view" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/ProjectiveStructureByFactorization.java#L234-L239
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/ImplDisparityScoreSadRectFive_U8.java
ImplDisparityScoreSadRectFive_U8.computeScoreFive
protected void computeScoreFive( int top[] , int middle[] , int bottom[] , int score[] , int width ) { // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisparity; d < maxDisparity; d++ ) { // take in account the different in image border between the sub-regions and the effective region int indexSrc = (d-minDisparity)*width + (d-minDisparity) + radiusX; int indexDst = (d-minDisparity)*width + (d-minDisparity); int end = indexSrc + (width-d-4*radiusX); while( indexSrc < end ) { int s = 0; // sample four outer regions at the corners around the center region int val0 = top[indexSrc-radiusX]; int val1 = top[indexSrc+radiusX]; int val2 = bottom[indexSrc-radiusX]; int val3 = bottom[indexSrc+radiusX]; // select the two best scores from outer for regions if( val1 < val0 ) { int temp = val0; val0 = val1; val1 = temp; } if( val3 < val2 ) { int temp = val2; val2 = val3; val3 = temp; } if( val3 < val0 ) { s += val2; s += val3; } else if( val2 < val1 ) { s += val2; s += val0; } else { s += val0; s += val1; } score[indexDst++] = s + middle[indexSrc++]; } } }
java
protected void computeScoreFive( int top[] , int middle[] , int bottom[] , int score[] , int width ) { // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisparity; d < maxDisparity; d++ ) { // take in account the different in image border between the sub-regions and the effective region int indexSrc = (d-minDisparity)*width + (d-minDisparity) + radiusX; int indexDst = (d-minDisparity)*width + (d-minDisparity); int end = indexSrc + (width-d-4*radiusX); while( indexSrc < end ) { int s = 0; // sample four outer regions at the corners around the center region int val0 = top[indexSrc-radiusX]; int val1 = top[indexSrc+radiusX]; int val2 = bottom[indexSrc-radiusX]; int val3 = bottom[indexSrc+radiusX]; // select the two best scores from outer for regions if( val1 < val0 ) { int temp = val0; val0 = val1; val1 = temp; } if( val3 < val2 ) { int temp = val2; val2 = val3; val3 = temp; } if( val3 < val0 ) { s += val2; s += val3; } else if( val2 < val1 ) { s += val2; s += val0; } else { s += val0; s += val1; } score[indexDst++] = s + middle[indexSrc++]; } } }
[ "protected", "void", "computeScoreFive", "(", "int", "top", "[", "]", ",", "int", "middle", "[", "]", ",", "int", "bottom", "[", "]", ",", "int", "score", "[", "]", ",", "int", "width", ")", "{", "// disparity as the outer loop to maximize common elements in i...
Compute the final score by sampling the 5 regions. Four regions are sampled around the center region. Out of those four only the two with the smallest score are used.
[ "Compute", "the", "final", "score", "by", "sampling", "the", "5", "regions", ".", "Four", "regions", "are", "sampled", "around", "the", "center", "region", ".", "Out", "of", "those", "four", "only", "the", "two", "with", "the", "smallest", "score", "are", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/ImplDisparityScoreSadRectFive_U8.java#L149-L194
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalTransfer.java
TrifocalTransfer.setTrifocal
public void setTrifocal(TrifocalTensor tensor ) { this.tensor = tensor; extract.setTensor(tensor); extract.extractFundmental(F21,F31); }
java
public void setTrifocal(TrifocalTensor tensor ) { this.tensor = tensor; extract.setTensor(tensor); extract.extractFundmental(F21,F31); }
[ "public", "void", "setTrifocal", "(", "TrifocalTensor", "tensor", ")", "{", "this", ".", "tensor", "=", "tensor", ";", "extract", ".", "setTensor", "(", "tensor", ")", ";", "extract", ".", "extractFundmental", "(", "F21", ",", "F31", ")", ";", "}" ]
Specify the trifocaltensor @param tensor tensor
[ "Specify", "the", "trifocaltensor" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalTransfer.java#L59-L63
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalTransfer.java
TrifocalTransfer.transfer_1_to_3
public void transfer_1_to_3(double x1 , double y1 , double x2 , double y2 , Point3D_F64 p3) { // Adjust the observations so that they lie on the epipolar lines exactly adjuster.process(F21,x1,y1,x2,y2,pa,pb); GeometryMath_F64.mult(F21,pa,la); // line through pb and perpendicular to la l.x = la.y; l.y = -la.x; l.z = -pb.x*la.y + pb.y*la.x; MultiViewOps.transfer_1_to_3(tensor,pa,l,p3); }
java
public void transfer_1_to_3(double x1 , double y1 , double x2 , double y2 , Point3D_F64 p3) { // Adjust the observations so that they lie on the epipolar lines exactly adjuster.process(F21,x1,y1,x2,y2,pa,pb); GeometryMath_F64.mult(F21,pa,la); // line through pb and perpendicular to la l.x = la.y; l.y = -la.x; l.z = -pb.x*la.y + pb.y*la.x; MultiViewOps.transfer_1_to_3(tensor,pa,l,p3); }
[ "public", "void", "transfer_1_to_3", "(", "double", "x1", ",", "double", "y1", ",", "double", "x2", ",", "double", "y2", ",", "Point3D_F64", "p3", ")", "{", "// Adjust the observations so that they lie on the epipolar lines exactly", "adjuster", ".", "process", "(", ...
Transfer a point to third view give its observed location in view one and two. @param x1 (Input) Observation in view 1. pixels. @param y1 (Input) Observation in view 1. pixels. @param x2 (Input) Observation in view 2. pixels. @param y2 (Input) Observation in view 2. pixels. @param p3 (Output) Estimated location in view 3.
[ "Transfer", "a", "point", "to", "third", "view", "give", "its", "observed", "location", "in", "view", "one", "and", "two", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalTransfer.java#L74-L88
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalTransfer.java
TrifocalTransfer.transfer_1_to_2
public void transfer_1_to_2(double x1 , double y1 , double x3 , double y3 , Point3D_F64 p2) { // Adjust the observations so that they lie on the epipolar lines exactly adjuster.process(F31,x1,y1,x3,y3,pa,pb); GeometryMath_F64.multTran(F31,pa,la); // line through pb and perpendicular to la l.x = la.y; l.y = -la.x; l.z = -pb.x*la.y + pb.y*la.x; MultiViewOps.transfer_1_to_2(tensor,pa,l,p2); }
java
public void transfer_1_to_2(double x1 , double y1 , double x3 , double y3 , Point3D_F64 p2) { // Adjust the observations so that they lie on the epipolar lines exactly adjuster.process(F31,x1,y1,x3,y3,pa,pb); GeometryMath_F64.multTran(F31,pa,la); // line through pb and perpendicular to la l.x = la.y; l.y = -la.x; l.z = -pb.x*la.y + pb.y*la.x; MultiViewOps.transfer_1_to_2(tensor,pa,l,p2); }
[ "public", "void", "transfer_1_to_2", "(", "double", "x1", ",", "double", "y1", ",", "double", "x3", ",", "double", "y3", ",", "Point3D_F64", "p2", ")", "{", "// Adjust the observations so that they lie on the epipolar lines exactly", "adjuster", ".", "process", "(", ...
Transfer a point to third view give its observed location in view one and three. @param x1 (Input) Observation in view 1. pixels. @param y1 (Input) Observation in view 1. pixels. @param x3 (Input) Observation in view 3. pixels. @param y3 (Input) Observation in view 3. pixels. @param p2 (Output) Estimated location in view 2.
[ "Transfer", "a", "point", "to", "third", "view", "give", "its", "observed", "location", "in", "view", "one", "and", "three", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/trifocal/TrifocalTransfer.java#L99-L113
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/deepboof/BaseImageClassifier.java
BaseImageClassifier.classify
@Override public void classify(Planar<GrayF32> image) { DataManipulationOps.imageToTensor(preprocess(image),tensorInput,0); innerProcess(tensorInput); }
java
@Override public void classify(Planar<GrayF32> image) { DataManipulationOps.imageToTensor(preprocess(image),tensorInput,0); innerProcess(tensorInput); }
[ "@", "Override", "public", "void", "classify", "(", "Planar", "<", "GrayF32", ">", "image", ")", "{", "DataManipulationOps", ".", "imageToTensor", "(", "preprocess", "(", "image", ")", ",", "tensorInput", ",", "0", ")", ";", "innerProcess", "(", "tensorInput...
The original implementation takes in an image then crops it randomly. This is primarily for training but is replicated here to reduce the number of differences @param image Image being processed. Must be RGB image. Pixel values must have values from 0 to 255.
[ "The", "original", "implementation", "takes", "in", "an", "image", "then", "crops", "it", "randomly", ".", "This", "is", "primarily", "for", "training", "but", "is", "replicated", "here", "to", "reduce", "the", "number", "of", "differences" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/deepboof/BaseImageClassifier.java#L95-L99
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/UtilDisparityScore.java
UtilDisparityScore.computeScoreRow
public static void computeScoreRow(GrayU8 left, GrayU8 right, int row, int[] scores, int minDisparity , int maxDisparity , int regionWidth , int elementScore[] ) { // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisparity; d < maxDisparity; d++ ) { int dispFromMin = d - minDisparity; // number of individual columns the error is computed in final int colMax = left.width-d; // number of regions that a score/error is computed in final int scoreMax = colMax-regionWidth; // indexes that data is read to/from for different data structures int indexScore = left.width*dispFromMin + dispFromMin; int indexLeft = left.startIndex + left.stride*row + d; int indexRight = right.startIndex + right.stride*row; // Fill elementScore with scores for individual elements for this row at disparity d computeScoreRowSad(left, right, colMax, indexLeft, indexRight, elementScore); // score at the first column int score = 0; for( int i = 0; i < regionWidth; i++ ) score += elementScore[i]; scores[indexScore++] = score; // scores for the remaining columns for( int col = 0; col < scoreMax; col++ , indexScore++ ) { scores[indexScore] = score += elementScore[col+regionWidth] - elementScore[col]; } } }
java
public static void computeScoreRow(GrayU8 left, GrayU8 right, int row, int[] scores, int minDisparity , int maxDisparity , int regionWidth , int elementScore[] ) { // disparity as the outer loop to maximize common elements in inner loops, reducing redundant calculations for( int d = minDisparity; d < maxDisparity; d++ ) { int dispFromMin = d - minDisparity; // number of individual columns the error is computed in final int colMax = left.width-d; // number of regions that a score/error is computed in final int scoreMax = colMax-regionWidth; // indexes that data is read to/from for different data structures int indexScore = left.width*dispFromMin + dispFromMin; int indexLeft = left.startIndex + left.stride*row + d; int indexRight = right.startIndex + right.stride*row; // Fill elementScore with scores for individual elements for this row at disparity d computeScoreRowSad(left, right, colMax, indexLeft, indexRight, elementScore); // score at the first column int score = 0; for( int i = 0; i < regionWidth; i++ ) score += elementScore[i]; scores[indexScore++] = score; // scores for the remaining columns for( int col = 0; col < scoreMax; col++ , indexScore++ ) { scores[indexScore] = score += elementScore[col+regionWidth] - elementScore[col]; } } }
[ "public", "static", "void", "computeScoreRow", "(", "GrayU8", "left", ",", "GrayU8", "right", ",", "int", "row", ",", "int", "[", "]", "scores", ",", "int", "minDisparity", ",", "int", "maxDisparity", ",", "int", "regionWidth", ",", "int", "elementScore", ...
Computes disparity score for an entire row. For a given disparity, the score for each region on the left share many components in common. Because of this the scores are computed with disparity being the outer most loop @param left left image @param right Right image @param row Image row being examined @param scores Storage for disparity scores. @param minDisparity Minimum disparity to consider @param maxDisparity Maximum disparity to consider @param regionWidth Size of the sample region's width @param elementScore Storage for scores of individual pixels
[ "Computes", "disparity", "score", "for", "an", "entire", "row", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/UtilDisparityScore.java#L47-L80
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/UtilDisparityScore.java
UtilDisparityScore.computeScoreRowSad
public static void computeScoreRowSad(GrayF32 left, GrayF32 right, int elementMax, int indexLeft, int indexRight, float elementScore[]) { for( int rCol = 0; rCol < elementMax; rCol++ ) { float diff = (left.data[ indexLeft++ ]) - (right.data[ indexRight++ ]); elementScore[rCol] = Math.abs(diff); } }
java
public static void computeScoreRowSad(GrayF32 left, GrayF32 right, int elementMax, int indexLeft, int indexRight, float elementScore[]) { for( int rCol = 0; rCol < elementMax; rCol++ ) { float diff = (left.data[ indexLeft++ ]) - (right.data[ indexRight++ ]); elementScore[rCol] = Math.abs(diff); } }
[ "public", "static", "void", "computeScoreRowSad", "(", "GrayF32", "left", ",", "GrayF32", "right", ",", "int", "elementMax", ",", "int", "indexLeft", ",", "int", "indexRight", ",", "float", "elementScore", "[", "]", ")", "{", "for", "(", "int", "rCol", "="...
compute the score for each element all at once to encourage the JVM to optimize and encourage the JVM to optimize this section of code. Was original inline, but was actually slightly slower by about 3% consistently, It is in its own function so that it can be overridden and have different cost functions inserted easily.
[ "compute", "the", "score", "for", "each", "element", "all", "at", "once", "to", "encourage", "the", "JVM", "to", "optimize", "and", "encourage", "the", "JVM", "to", "optimize", "this", "section", "of", "code", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/UtilDisparityScore.java#L228-L237
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/sfm/ExamplePnP.java
ExamplePnP.estimateOutliers
public Se3_F64 estimateOutliers( List<Point2D3D> observations ) { // We can no longer trust that each point is a real observation. Let's use RANSAC to separate the points // You will need to tune the number of iterations and inlier threshold!!! ModelMatcherMultiview<Se3_F64,Point2D3D> ransac = FactoryMultiViewRobust.pnpRansac(new ConfigPnP(),new ConfigRansac(300,1.0)); ransac.setIntrinsic(0,intrinsic); // Observations must be in normalized image coordinates! See javadoc of pnpRansac if( !ransac.process(observations) ) throw new RuntimeException("Probably got bad input data with NaN inside of it"); System.out.println("Inlier size "+ransac.getMatchSet().size()); Se3_F64 worldToCamera = ransac.getModelParameters(); // You will most likely want to refine this solution too. Can make a difference with real world data RefinePnP refine = FactoryMultiView.pnpRefine(1e-8,200); Se3_F64 refinedWorldToCamera = new Se3_F64(); // notice that only the match set was passed in if( !refine.fitModel(ransac.getMatchSet(),worldToCamera,refinedWorldToCamera) ) throw new RuntimeException("Refined failed! Input probably bad..."); return refinedWorldToCamera; }
java
public Se3_F64 estimateOutliers( List<Point2D3D> observations ) { // We can no longer trust that each point is a real observation. Let's use RANSAC to separate the points // You will need to tune the number of iterations and inlier threshold!!! ModelMatcherMultiview<Se3_F64,Point2D3D> ransac = FactoryMultiViewRobust.pnpRansac(new ConfigPnP(),new ConfigRansac(300,1.0)); ransac.setIntrinsic(0,intrinsic); // Observations must be in normalized image coordinates! See javadoc of pnpRansac if( !ransac.process(observations) ) throw new RuntimeException("Probably got bad input data with NaN inside of it"); System.out.println("Inlier size "+ransac.getMatchSet().size()); Se3_F64 worldToCamera = ransac.getModelParameters(); // You will most likely want to refine this solution too. Can make a difference with real world data RefinePnP refine = FactoryMultiView.pnpRefine(1e-8,200); Se3_F64 refinedWorldToCamera = new Se3_F64(); // notice that only the match set was passed in if( !refine.fitModel(ransac.getMatchSet(),worldToCamera,refinedWorldToCamera) ) throw new RuntimeException("Refined failed! Input probably bad..."); return refinedWorldToCamera; }
[ "public", "Se3_F64", "estimateOutliers", "(", "List", "<", "Point2D3D", ">", "observations", ")", "{", "// We can no longer trust that each point is a real observation. Let's use RANSAC to separate the points", "// You will need to tune the number of iterations and inlier threshold!!!", "...
Uses robust techniques to remove outliers
[ "Uses", "robust", "techniques", "to", "remove", "outliers" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/sfm/ExamplePnP.java#L117-L141
train
lessthanoptimal/BoofCV
examples/src/main/java/boofcv/examples/sfm/ExamplePnP.java
ExamplePnP.addOutliers
public void addOutliers( List<Point2D3D> observations , int total ) { int size = observations.size(); for (int i = 0; i < total; i++) { // outliers will be created by adding lots of noise to real observations Point2D3D p = observations.get(rand.nextInt(size)); Point2D3D o = new Point2D3D(); o.observation.set(p.observation); o.location.x = p.location.x + rand.nextGaussian()*5; o.location.y = p.location.y + rand.nextGaussian()*5; o.location.z = p.location.z + rand.nextGaussian()*5; observations.add(o); } // randomize the order Collections.shuffle(observations,rand); }
java
public void addOutliers( List<Point2D3D> observations , int total ) { int size = observations.size(); for (int i = 0; i < total; i++) { // outliers will be created by adding lots of noise to real observations Point2D3D p = observations.get(rand.nextInt(size)); Point2D3D o = new Point2D3D(); o.observation.set(p.observation); o.location.x = p.location.x + rand.nextGaussian()*5; o.location.y = p.location.y + rand.nextGaussian()*5; o.location.z = p.location.z + rand.nextGaussian()*5; observations.add(o); } // randomize the order Collections.shuffle(observations,rand); }
[ "public", "void", "addOutliers", "(", "List", "<", "Point2D3D", ">", "observations", ",", "int", "total", ")", "{", "int", "size", "=", "observations", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "total", ";", "i", ...
Adds some really bad observations to the mix
[ "Adds", "some", "really", "bad", "observations", "to", "the", "mix" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/sfm/ExamplePnP.java#L192-L211
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java
SelectAlgorithmAndInputPanel.loadInputData
@Override public void loadInputData(String fileName) { Reader r = media.openFile(fileName); List<PathLabel> refs = new ArrayList<>(); try { BufferedReader reader = new BufferedReader(r); String line; while( (line = reader.readLine()) != null ) { String[]z = line.split(":"); String[] names = new String[z.length-1]; for( int i = 1; i < z.length; i++ ) { names[i-1] = baseDirectory+z[i]; } refs.add(new PathLabel(z[0],names)); } setInputList(refs); } catch (IOException e) { throw new RuntimeException(e); } }
java
@Override public void loadInputData(String fileName) { Reader r = media.openFile(fileName); List<PathLabel> refs = new ArrayList<>(); try { BufferedReader reader = new BufferedReader(r); String line; while( (line = reader.readLine()) != null ) { String[]z = line.split(":"); String[] names = new String[z.length-1]; for( int i = 1; i < z.length; i++ ) { names[i-1] = baseDirectory+z[i]; } refs.add(new PathLabel(z[0],names)); } setInputList(refs); } catch (IOException e) { throw new RuntimeException(e); } }
[ "@", "Override", "public", "void", "loadInputData", "(", "String", "fileName", ")", "{", "Reader", "r", "=", "media", ".", "openFile", "(", "fileName", ")", ";", "List", "<", "PathLabel", ">", "refs", "=", "new", "ArrayList", "<>", "(", ")", ";", "try"...
Loads a standardized file for input references @param fileName path to config file
[ "Loads", "a", "standardized", "file", "for", "input", "references" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java#L108-L133
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java
SelectAlgorithmAndInputPanel.addToToolbar
public void addToToolbar( JComponent comp ) { toolbar.add(comp,1+algBoxes.length); toolbar.revalidate(); addedComponents.add(comp); }
java
public void addToToolbar( JComponent comp ) { toolbar.add(comp,1+algBoxes.length); toolbar.revalidate(); addedComponents.add(comp); }
[ "public", "void", "addToToolbar", "(", "JComponent", "comp", ")", "{", "toolbar", ".", "add", "(", "comp", ",", "1", "+", "algBoxes", ".", "length", ")", ";", "toolbar", ".", "revalidate", "(", ")", ";", "addedComponents", ".", "add", "(", "comp", ")",...
Adds a new component into the toolbar. @param comp The component being added
[ "Adds", "a", "new", "component", "into", "the", "toolbar", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java#L147-L151
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java
SelectAlgorithmAndInputPanel.setMainGUI
public void setMainGUI( final Component gui ) { postAlgorithmEvents = true; this.gui = gui; SwingUtilities.invokeLater(new Runnable() { public void run() { add(gui,BorderLayout.CENTER); }}); }
java
public void setMainGUI( final Component gui ) { postAlgorithmEvents = true; this.gui = gui; SwingUtilities.invokeLater(new Runnable() { public void run() { add(gui,BorderLayout.CENTER); }}); }
[ "public", "void", "setMainGUI", "(", "final", "Component", "gui", ")", "{", "postAlgorithmEvents", "=", "true", ";", "this", ".", "gui", "=", "gui", ";", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", ...
Used to add the main GUI to this panel. Must use this function. Algorithm change events will not be posted until this function has been set. @param gui The main GUI being displayed.
[ "Used", "to", "add", "the", "main", "GUI", "to", "this", "panel", ".", "Must", "use", "this", "function", ".", "Algorithm", "change", "events", "will", "not", "be", "posted", "until", "this", "function", "has", "been", "set", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java#L165-L172
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java
SelectAlgorithmAndInputPanel.setInputImage
public void setInputImage( BufferedImage image ) { inputImage = image; SwingUtilities.invokeLater(new Runnable() { public void run() { if( inputImage == null ) { originalCheck.setEnabled(false); } else { originalCheck.setEnabled(true); origPanel.setImage(inputImage); origPanel.setPreferredSize(new Dimension(inputImage.getWidth(),inputImage.getHeight())); origPanel.repaint(); } }}); }
java
public void setInputImage( BufferedImage image ) { inputImage = image; SwingUtilities.invokeLater(new Runnable() { public void run() { if( inputImage == null ) { originalCheck.setEnabled(false); } else { originalCheck.setEnabled(true); origPanel.setImage(inputImage); origPanel.setPreferredSize(new Dimension(inputImage.getWidth(),inputImage.getHeight())); origPanel.repaint(); } }}); }
[ "public", "void", "setInputImage", "(", "BufferedImage", "image", ")", "{", "inputImage", "=", "image", ";", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "(", ")", "{", "if", "(", "inputImage", "==",...
Specifies an image which contains the original input image. After this has been called the view input image widget is activated and when selected this image will be displayed instead of the main GUI. This functionality is optional. @param image Original input image.
[ "Specifies", "an", "image", "which", "contains", "the", "original", "input", "image", ".", "After", "this", "has", "been", "called", "the", "view", "input", "image", "widget", "is", "activated", "and", "when", "selected", "this", "image", "will", "be", "disp...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java#L181-L194
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java
SelectAlgorithmAndInputPanel.setInputList
public void setInputList(final List<PathLabel> inputRefs) { this.inputRefs = inputRefs; SwingUtilities.invokeLater(new Runnable() { public void run() { for( int i = 0; i < inputRefs.size(); i++ ) { imageBox.addItem(inputRefs.get(i).getLabel()); } }}); }
java
public void setInputList(final List<PathLabel> inputRefs) { this.inputRefs = inputRefs; SwingUtilities.invokeLater(new Runnable() { public void run() { for( int i = 0; i < inputRefs.size(); i++ ) { imageBox.addItem(inputRefs.get(i).getLabel()); } }}); }
[ "public", "void", "setInputList", "(", "final", "List", "<", "PathLabel", ">", "inputRefs", ")", "{", "this", ".", "inputRefs", "=", "inputRefs", ";", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "public", "void", "run", "("...
Specifies a list of images to use as input and loads them @param inputRefs Name of input and where to get it
[ "Specifies", "a", "list", "of", "images", "to", "use", "as", "input", "and", "loads", "them" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java#L201-L210
train
lessthanoptimal/BoofCV
integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java
SelectAlgorithmAndInputPanel.getAlgorithmCookie
protected <T> T getAlgorithmCookie( int indexFamily ) { return (T)algCookies[indexFamily].get( algBoxes[indexFamily].getSelectedIndex() ); }
java
protected <T> T getAlgorithmCookie( int indexFamily ) { return (T)algCookies[indexFamily].get( algBoxes[indexFamily].getSelectedIndex() ); }
[ "protected", "<", "T", ">", "T", "getAlgorithmCookie", "(", "int", "indexFamily", ")", "{", "return", "(", "T", ")", "algCookies", "[", "indexFamily", "]", ".", "get", "(", "algBoxes", "[", "indexFamily", "]", ".", "getSelectedIndex", "(", ")", ")", ";",...
Returns the cookie associated with the specified algorithm family.
[ "Returns", "the", "cookie", "associated", "with", "the", "specified", "algorithm", "family", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/SelectAlgorithmAndInputPanel.java#L266-L268
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/BaseDetectFiducialSquare.java
BaseDetectFiducialSquare.checkSideSize
private boolean checkSideSize( Polygon2D_F64 p ) { double max=0,min=Double.MAX_VALUE; for (int i = 0; i < p.size(); i++) { double l = p.getSideLength(i); max = Math.max(max,l); min = Math.min(min,l); } // See if a side is too small to decode if( min < 10 ) return false; // see if it's under extreme perspective distortion and unlikely to be readable return !(min / max < thresholdSideRatio); }
java
private boolean checkSideSize( Polygon2D_F64 p ) { double max=0,min=Double.MAX_VALUE; for (int i = 0; i < p.size(); i++) { double l = p.getSideLength(i); max = Math.max(max,l); min = Math.min(min,l); } // See if a side is too small to decode if( min < 10 ) return false; // see if it's under extreme perspective distortion and unlikely to be readable return !(min / max < thresholdSideRatio); }
[ "private", "boolean", "checkSideSize", "(", "Polygon2D_F64", "p", ")", "{", "double", "max", "=", "0", ",", "min", "=", "Double", ".", "MAX_VALUE", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "p", ".", "size", "(", ")", ";", "i", "++", ...
Sanity check the polygon based on the size of its sides to see if it could be a fiducial that can be decoded
[ "Sanity", "check", "the", "polygon", "based", "on", "the", "size", "of", "its", "sides", "to", "see", "if", "it", "could", "be", "a", "fiducial", "that", "can", "be", "decoded" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/BaseDetectFiducialSquare.java#L325-L340
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/BaseDetectFiducialSquare.java
BaseDetectFiducialSquare.computeFractionBoundary
protected double computeFractionBoundary( float pixelThreshold ) { // TODO ignore outer pixels from this computation. Will require 8 regions (4 corners + top/bottom + left/right) final int w = square.width; int radius = (int) (w * borderWidthFraction); int innerWidth = w-2*radius; int total = w*w - innerWidth*innerWidth; int count = 0; for (int y = 0; y < radius; y++) { int indexTop = y*w; int indexBottom = (w - radius + y)*w; for (int x = 0; x < w; x++) { if( square.data[indexTop++] < pixelThreshold ) count++; if( square.data[indexBottom++] < pixelThreshold ) count++; } } for (int y = radius; y < w-radius; y++) { int indexLeft = y*w; int indexRight = y*w + w - radius; for (int x = 0; x < radius; x++) { if( square.data[indexLeft++] < pixelThreshold ) count++; if( square.data[indexRight++] < pixelThreshold ) count++; } } return count/(double)total; }
java
protected double computeFractionBoundary( float pixelThreshold ) { // TODO ignore outer pixels from this computation. Will require 8 regions (4 corners + top/bottom + left/right) final int w = square.width; int radius = (int) (w * borderWidthFraction); int innerWidth = w-2*radius; int total = w*w - innerWidth*innerWidth; int count = 0; for (int y = 0; y < radius; y++) { int indexTop = y*w; int indexBottom = (w - radius + y)*w; for (int x = 0; x < w; x++) { if( square.data[indexTop++] < pixelThreshold ) count++; if( square.data[indexBottom++] < pixelThreshold ) count++; } } for (int y = radius; y < w-radius; y++) { int indexLeft = y*w; int indexRight = y*w + w - radius; for (int x = 0; x < radius; x++) { if( square.data[indexLeft++] < pixelThreshold ) count++; if( square.data[indexRight++] < pixelThreshold ) count++; } } return count/(double)total; }
[ "protected", "double", "computeFractionBoundary", "(", "float", "pixelThreshold", ")", "{", "// TODO ignore outer pixels from this computation. Will require 8 regions (4 corners + top/bottom + left/right)", "final", "int", "w", "=", "square", ".", "width", ";", "int", "radius", ...
Computes the fraction of pixels inside the image border which are black @param pixelThreshold Pixel's less than this value are considered black @return fraction of border that's black
[ "Computes", "the", "fraction", "of", "pixels", "inside", "the", "image", "border", "which", "are", "black" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/BaseDetectFiducialSquare.java#L359-L392
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/BaseDetectFiducialSquare.java
BaseDetectFiducialSquare.prepareForOutput
private void prepareForOutput(Polygon2D_F64 imageShape, Result result) { // the rotation estimate, apply in counter clockwise direction // since result.rotation is a clockwise rotation in the visual sense, which // is CCW on the grid int rotationCCW = (4-result.rotation)%4; for (int j = 0; j < rotationCCW; j++) { UtilPolygons2D_F64.shiftUp(imageShape); } // save the results for output FoundFiducial f = found.grow(); f.id = result.which; for (int i = 0; i < 4; i++) { Point2D_F64 a = imageShape.get(i); undistToDist.compute(a.x, a.y, f.distortedPixels.get(i)); } }
java
private void prepareForOutput(Polygon2D_F64 imageShape, Result result) { // the rotation estimate, apply in counter clockwise direction // since result.rotation is a clockwise rotation in the visual sense, which // is CCW on the grid int rotationCCW = (4-result.rotation)%4; for (int j = 0; j < rotationCCW; j++) { UtilPolygons2D_F64.shiftUp(imageShape); } // save the results for output FoundFiducial f = found.grow(); f.id = result.which; for (int i = 0; i < 4; i++) { Point2D_F64 a = imageShape.get(i); undistToDist.compute(a.x, a.y, f.distortedPixels.get(i)); } }
[ "private", "void", "prepareForOutput", "(", "Polygon2D_F64", "imageShape", ",", "Result", "result", ")", "{", "// the rotation estimate, apply in counter clockwise direction", "// since result.rotation is a clockwise rotation in the visual sense, which", "// is CCW on the grid", "int", ...
Takes the found quadrilateral and the computed 3D information and prepares it for output
[ "Takes", "the", "found", "quadrilateral", "and", "the", "computed", "3D", "information", "and", "prepares", "it", "for", "output" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/square/BaseDetectFiducialSquare.java#L397-L414
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeRegionMeanShift.java
MergeRegionMeanShift.process
public void process( GrayS32 pixelToRegion , GrowQueue_I32 regionMemberCount, FastQueue<float[]> regionColor , FastQueue<Point2D_I32> modeLocation ) { stopRequested = false; initializeMerge(regionMemberCount.size); markMergeRegions(regionColor,modeLocation,pixelToRegion); if( stopRequested ) return; performMerge(pixelToRegion, regionMemberCount); }
java
public void process( GrayS32 pixelToRegion , GrowQueue_I32 regionMemberCount, FastQueue<float[]> regionColor , FastQueue<Point2D_I32> modeLocation ) { stopRequested = false; initializeMerge(regionMemberCount.size); markMergeRegions(regionColor,modeLocation,pixelToRegion); if( stopRequested ) return; performMerge(pixelToRegion, regionMemberCount); }
[ "public", "void", "process", "(", "GrayS32", "pixelToRegion", ",", "GrowQueue_I32", "regionMemberCount", ",", "FastQueue", "<", "float", "[", "]", ">", "regionColor", ",", "FastQueue", "<", "Point2D_I32", ">", "modeLocation", ")", "{", "stopRequested", "=", "fal...
Merges together similar regions which are in close proximity to each other. After merging most of the input data structures are modified to take in account the changes. @param pixelToRegion (Input/output) Image that specifies the segmentation. Modified. @param regionMemberCount (Input/output) Number of pixels in each region. Modified. @param regionColor (Input/output) Color of each region. Modified. @param modeLocation (Input) Location of each region's mode. Not modified.
[ "Merges", "together", "similar", "regions", "which", "are", "in", "close", "proximity", "to", "each", "other", ".", "After", "merging", "most", "of", "the", "input", "data", "structures", "are", "modified", "to", "take", "in", "account", "the", "changes", "....
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeRegionMeanShift.java#L65-L77
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeRegionMeanShift.java
MergeRegionMeanShift.markMergeRegions
protected void markMergeRegions(FastQueue<float[]> regionColor, FastQueue<Point2D_I32> modeLocation, GrayS32 pixelToRegion ) { for( int targetId = 0; targetId < modeLocation.size &&!stopRequested; targetId++ ) { float[] color = regionColor.get(targetId); Point2D_I32 location = modeLocation.get(targetId); int x0 = location.x-searchRadius; int x1 = location.x+searchRadius+1; int y0 = location.y-searchRadius; int y1 = location.y+searchRadius+1; // ensure that all pixels it examines are inside the image if( x0 < 0 ) x0 = 0; if( x1 > pixelToRegion.width ) x1 = pixelToRegion.width; if( y0 < 0 ) y0 = 0; if( y1 > pixelToRegion.height ) y1 = pixelToRegion.height; // look at the local neighborhood for( int y = y0; y < y1; y++ ) { for( int x = x0; x < x1; x++ ) { int candidateId = pixelToRegion.unsafe_get(x,y); // see if it is the same region if( candidateId == targetId ) continue; // see if the mode is near by Point2D_I32 p = modeLocation.get(candidateId); if( p.distance2(location) <= maxSpacialDistanceSq ) { // see if the color is similar float[] candidateColor = regionColor.get(candidateId); float colorDistance = SegmentMeanShiftSearch.distanceSq(color,candidateColor); if( colorDistance <= maxColorDistanceSq ) { // mark the two regions as merged markMerge(targetId, candidateId); } } } } } }
java
protected void markMergeRegions(FastQueue<float[]> regionColor, FastQueue<Point2D_I32> modeLocation, GrayS32 pixelToRegion ) { for( int targetId = 0; targetId < modeLocation.size &&!stopRequested; targetId++ ) { float[] color = regionColor.get(targetId); Point2D_I32 location = modeLocation.get(targetId); int x0 = location.x-searchRadius; int x1 = location.x+searchRadius+1; int y0 = location.y-searchRadius; int y1 = location.y+searchRadius+1; // ensure that all pixels it examines are inside the image if( x0 < 0 ) x0 = 0; if( x1 > pixelToRegion.width ) x1 = pixelToRegion.width; if( y0 < 0 ) y0 = 0; if( y1 > pixelToRegion.height ) y1 = pixelToRegion.height; // look at the local neighborhood for( int y = y0; y < y1; y++ ) { for( int x = x0; x < x1; x++ ) { int candidateId = pixelToRegion.unsafe_get(x,y); // see if it is the same region if( candidateId == targetId ) continue; // see if the mode is near by Point2D_I32 p = modeLocation.get(candidateId); if( p.distance2(location) <= maxSpacialDistanceSq ) { // see if the color is similar float[] candidateColor = regionColor.get(candidateId); float colorDistance = SegmentMeanShiftSearch.distanceSq(color,candidateColor); if( colorDistance <= maxColorDistanceSq ) { // mark the two regions as merged markMerge(targetId, candidateId); } } } } } }
[ "protected", "void", "markMergeRegions", "(", "FastQueue", "<", "float", "[", "]", ">", "regionColor", ",", "FastQueue", "<", "Point2D_I32", ">", "modeLocation", ",", "GrayS32", "pixelToRegion", ")", "{", "for", "(", "int", "targetId", "=", "0", ";", "target...
Takes the mode of a region and searches the local area around it for other regions. If the region's mode is also within the local area its color is checked to see if it's similar enough. If the color is similar enough then the two regions are marked for merger.
[ "Takes", "the", "mode", "of", "a", "region", "and", "searches", "the", "local", "area", "around", "it", "for", "other", "regions", ".", "If", "the", "region", "s", "mode", "is", "also", "within", "the", "local", "area", "its", "color", "is", "checked", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/MergeRegionMeanShift.java#L84-L129
train
lessthanoptimal/BoofCV
integration/boofcv-jcodec/src/main/java/boofcv/io/jcodec/UtilJCodec.java
UtilJCodec.convertToBoof
public static void convertToBoof(Picture input, ImageBase output) { if( input.getColor() == ColorSpace.RGB ) { ImplConvertJCodecPicture.RGB_to_PLU8(input, (Planar) output); } else if( input.getColor() == ColorSpace.YUV420 ) { if( output instanceof Planar) { Planar ms = (Planar)output; if( ms.getImageType().getDataType() == ImageDataType.U8 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_U8(input, ms); } else if( ms.getImageType().getDataType() == ImageDataType.F32 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_F32(input, ms); } } else if( output instanceof GrayU8) { ImplConvertJCodecPicture.yuv420_to_U8(input, (GrayU8) output); } else if( output instanceof GrayF32) { ImplConvertJCodecPicture.yuv420_to_F32(input, (GrayF32) output); } else { throw new RuntimeException("Unexpected output image type"); } } }
java
public static void convertToBoof(Picture input, ImageBase output) { if( input.getColor() == ColorSpace.RGB ) { ImplConvertJCodecPicture.RGB_to_PLU8(input, (Planar) output); } else if( input.getColor() == ColorSpace.YUV420 ) { if( output instanceof Planar) { Planar ms = (Planar)output; if( ms.getImageType().getDataType() == ImageDataType.U8 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_U8(input, ms); } else if( ms.getImageType().getDataType() == ImageDataType.F32 ) { ImplConvertJCodecPicture.yuv420_to_PlRgb_F32(input, ms); } } else if( output instanceof GrayU8) { ImplConvertJCodecPicture.yuv420_to_U8(input, (GrayU8) output); } else if( output instanceof GrayF32) { ImplConvertJCodecPicture.yuv420_to_F32(input, (GrayF32) output); } else { throw new RuntimeException("Unexpected output image type"); } } }
[ "public", "static", "void", "convertToBoof", "(", "Picture", "input", ",", "ImageBase", "output", ")", "{", "if", "(", "input", ".", "getColor", "(", ")", "==", "ColorSpace", ".", "RGB", ")", "{", "ImplConvertJCodecPicture", ".", "RGB_to_PLU8", "(", "input",...
Converts an image in JCodec format into one in BoofCV format. @param input JCodec image @param output BoofCV image
[ "Converts", "an", "image", "in", "JCodec", "format", "into", "one", "in", "BoofCV", "format", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-jcodec/src/main/java/boofcv/io/jcodec/UtilJCodec.java#L34-L53
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/PositionFromPairLinear2.java
PositionFromPairLinear2.process
public boolean process( DMatrixRMaj R , List<Point3D_F64> worldPts , List<Point2D_F64> observed ) { if( worldPts.size() != observed.size() ) throw new IllegalArgumentException("Number of worldPts and observed must be the same"); if( worldPts.size() < 2 ) throw new IllegalArgumentException("A minimum of two points are required"); int N = worldPts.size(); A.reshape(3*N,3); b.reshape(A.numRows, 1); for( int i = 0; i < N; i++ ) { Point3D_F64 X = worldPts.get(i); Point2D_F64 o = observed.get(i); int indexA = i*3*3; int indexB = i*3; A.data[indexA+1] = -1; A.data[indexA+2] = o.y; A.data[indexA+3] = 1; A.data[indexA+5] = -o.x; A.data[indexA+6] = -o.y; A.data[indexA+7] = o.x; GeometryMath_F64.mult(R,X,RX); b.data[indexB++] = 1*RX.y - o.y*RX.z; b.data[indexB++] = -1*RX.x + o.x*RX.z; b.data[indexB ] = o.y*RX.x - o.x*RX.y; } if( !solver.setA(A) ) return false; solver.solve(b,x); T.x = x.data[0]; T.y = x.data[1]; T.z = x.data[2]; return true; }
java
public boolean process( DMatrixRMaj R , List<Point3D_F64> worldPts , List<Point2D_F64> observed ) { if( worldPts.size() != observed.size() ) throw new IllegalArgumentException("Number of worldPts and observed must be the same"); if( worldPts.size() < 2 ) throw new IllegalArgumentException("A minimum of two points are required"); int N = worldPts.size(); A.reshape(3*N,3); b.reshape(A.numRows, 1); for( int i = 0; i < N; i++ ) { Point3D_F64 X = worldPts.get(i); Point2D_F64 o = observed.get(i); int indexA = i*3*3; int indexB = i*3; A.data[indexA+1] = -1; A.data[indexA+2] = o.y; A.data[indexA+3] = 1; A.data[indexA+5] = -o.x; A.data[indexA+6] = -o.y; A.data[indexA+7] = o.x; GeometryMath_F64.mult(R,X,RX); b.data[indexB++] = 1*RX.y - o.y*RX.z; b.data[indexB++] = -1*RX.x + o.x*RX.z; b.data[indexB ] = o.y*RX.x - o.x*RX.y; } if( !solver.setA(A) ) return false; solver.solve(b,x); T.x = x.data[0]; T.y = x.data[1]; T.z = x.data[2]; return true; }
[ "public", "boolean", "process", "(", "DMatrixRMaj", "R", ",", "List", "<", "Point3D_F64", ">", "worldPts", ",", "List", "<", "Point2D_F64", ">", "observed", ")", "{", "if", "(", "worldPts", ".", "size", "(", ")", "!=", "observed", ".", "size", "(", ")"...
Computes the translation given two or more feature observations and the known rotation @param R Rotation matrix. World to view. @param worldPts Location of features in world coordinates. @param observed Observations of point in current view. Normalized coordinates. @return true if it succeeded.
[ "Computes", "the", "translation", "given", "two", "or", "more", "feature", "observations", "and", "the", "known", "rotation" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/pose/PositionFromPairLinear2.java#L78-L121
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java
BinaryEllipseDetectorPixel.process
public void process( GrayU8 binary ) { found.reset(); labeled.reshape(binary.width, binary.height); contourFinder.process(binary, labeled); List<ContourPacked> blobs = contourFinder.getContours(); for (int i = 0; i < blobs.size(); i++) { ContourPacked c = blobs.get(i); contourFinder.loadContour(c.externalIndex,contourTmp); proccessContour(contourTmp.toList()); if(internalContour) { for( int j = 0; j < c.internalIndexes.size(); j++ ) { contourFinder.loadContour(c.internalIndexes.get(j),contourTmp); proccessContour(contourTmp.toList()); } } } }
java
public void process( GrayU8 binary ) { found.reset(); labeled.reshape(binary.width, binary.height); contourFinder.process(binary, labeled); List<ContourPacked> blobs = contourFinder.getContours(); for (int i = 0; i < blobs.size(); i++) { ContourPacked c = blobs.get(i); contourFinder.loadContour(c.externalIndex,contourTmp); proccessContour(contourTmp.toList()); if(internalContour) { for( int j = 0; j < c.internalIndexes.size(); j++ ) { contourFinder.loadContour(c.internalIndexes.get(j),contourTmp); proccessContour(contourTmp.toList()); } } } }
[ "public", "void", "process", "(", "GrayU8", "binary", ")", "{", "found", ".", "reset", "(", ")", ";", "labeled", ".", "reshape", "(", "binary", ".", "width", ",", "binary", ".", "height", ")", ";", "contourFinder", ".", "process", "(", "binary", ",", ...
Finds all valid ellipses in the binary image @param binary binary image
[ "Finds", "all", "valid", "ellipses", "in", "the", "binary", "image" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java#L132-L152
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java
BinaryEllipseDetectorPixel.adjustElipseForBinaryBias
protected void adjustElipseForBinaryBias( EllipseRotated_F64 ellipse ) { ellipse.center.x += 0.5; ellipse.center.y += 0.5; ellipse.a += 0.5; ellipse.b += 0.5; }
java
protected void adjustElipseForBinaryBias( EllipseRotated_F64 ellipse ) { ellipse.center.x += 0.5; ellipse.center.y += 0.5; ellipse.a += 0.5; ellipse.b += 0.5; }
[ "protected", "void", "adjustElipseForBinaryBias", "(", "EllipseRotated_F64", "ellipse", ")", "{", "ellipse", ".", "center", ".", "x", "+=", "0.5", ";", "ellipse", ".", "center", ".", "y", "+=", "0.5", ";", "ellipse", ".", "a", "+=", "0.5", ";", "ellipse", ...
In a binary image the contour on the right and bottom is off by one pixel. This is because the block region extends the entire pixel not just the lower extent which is where it is indexed from.
[ "In", "a", "binary", "image", "the", "contour", "on", "the", "right", "and", "bottom", "is", "off", "by", "one", "pixel", ".", "This", "is", "because", "the", "block", "region", "extends", "the", "entire", "pixel", "not", "just", "the", "lower", "extent"...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java#L210-L216
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java
BinaryEllipseDetectorPixel.undistortContour
void undistortContour(List<Point2D_I32> external, FastQueue<Point2D_F64> pointsF ) { for (int j = 0; j < external.size(); j++) { Point2D_I32 p = external.get(j); if( distToUndist != null ) { distToUndist.compute(p.x,p.y,distortedPoint); pointsF.grow().set( distortedPoint.x , distortedPoint.y ); } else { pointsF.grow().set(p.x, p.y); } } }
java
void undistortContour(List<Point2D_I32> external, FastQueue<Point2D_F64> pointsF ) { for (int j = 0; j < external.size(); j++) { Point2D_I32 p = external.get(j); if( distToUndist != null ) { distToUndist.compute(p.x,p.y,distortedPoint); pointsF.grow().set( distortedPoint.x , distortedPoint.y ); } else { pointsF.grow().set(p.x, p.y); } } }
[ "void", "undistortContour", "(", "List", "<", "Point2D_I32", ">", "external", ",", "FastQueue", "<", "Point2D_F64", ">", "pointsF", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "external", ".", "size", "(", ")", ";", "j", "++", ")", "...
Undistort the contour points and convert into a floating point format for the fitting operation @param external The external contour @param pointsF Output of converted points
[ "Undistort", "the", "contour", "points", "and", "convert", "into", "a", "floating", "point", "format", "for", "the", "fitting", "operation" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java#L239-L250
train
lessthanoptimal/BoofCV
main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java
BinaryEllipseDetectorPixel.isApproximatelyElliptical
boolean isApproximatelyElliptical(EllipseRotated_F64 ellipse , List<Point2D_F64> points , int maxSamples ) { closestPoint.setEllipse(ellipse); double maxDistance2 = maxDistanceFromEllipse*maxDistanceFromEllipse; if( points.size() <= maxSamples ) { for( int i = 0; i < points.size(); i++ ) { Point2D_F64 p = points.get(i); closestPoint.process(p); double d = closestPoint.getClosest().distance2(p); if( d > maxDistance2 ) { return false; } } } else { for (int i = 0; i < maxSamples; i++) { Point2D_F64 p = points.get( i*points.size()/maxSamples ); closestPoint.process(p); double d = closestPoint.getClosest().distance2(p); if( d > maxDistance2 ) { return false; } } } return true; }
java
boolean isApproximatelyElliptical(EllipseRotated_F64 ellipse , List<Point2D_F64> points , int maxSamples ) { closestPoint.setEllipse(ellipse); double maxDistance2 = maxDistanceFromEllipse*maxDistanceFromEllipse; if( points.size() <= maxSamples ) { for( int i = 0; i < points.size(); i++ ) { Point2D_F64 p = points.get(i); closestPoint.process(p); double d = closestPoint.getClosest().distance2(p); if( d > maxDistance2 ) { return false; } } } else { for (int i = 0; i < maxSamples; i++) { Point2D_F64 p = points.get( i*points.size()/maxSamples ); closestPoint.process(p); double d = closestPoint.getClosest().distance2(p); if( d > maxDistance2 ) { return false; } } } return true; }
[ "boolean", "isApproximatelyElliptical", "(", "EllipseRotated_F64", "ellipse", ",", "List", "<", "Point2D_F64", ">", "points", ",", "int", "maxSamples", ")", "{", "closestPoint", ".", "setEllipse", "(", "ellipse", ")", ";", "double", "maxDistance2", "=", "maxDistan...
Look at the maximum distance contour points are from the ellipse and see if they exceed a maximum threshold
[ "Look", "at", "the", "maximum", "distance", "contour", "points", "are", "from", "the", "ellipse", "and", "see", "if", "they", "exceed", "a", "maximum", "threshold" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/ellipse/BinaryEllipseDetectorPixel.java#L255-L283
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardPolygonHelper.java
ChessboardPolygonHelper.filterPixelPolygon
@Override public boolean filterPixelPolygon(Polygon2D_F64 undistorted , Polygon2D_F64 distorted, GrowQueue_B touches, boolean touchesBorder) { if( touchesBorder ) { if( distorted.size() < 3) return false; int totalRegular = distorted.size(); for (int i = 0; i < distorted.size(); i++) { if( touches.get(i) ) totalRegular--; } return totalRegular > 0; // Would be 3 if it was filled in, but local binary can cause external contour to be concave } else { return distorted.size() == 4; } }
java
@Override public boolean filterPixelPolygon(Polygon2D_F64 undistorted , Polygon2D_F64 distorted, GrowQueue_B touches, boolean touchesBorder) { if( touchesBorder ) { if( distorted.size() < 3) return false; int totalRegular = distorted.size(); for (int i = 0; i < distorted.size(); i++) { if( touches.get(i) ) totalRegular--; } return totalRegular > 0; // Would be 3 if it was filled in, but local binary can cause external contour to be concave } else { return distorted.size() == 4; } }
[ "@", "Override", "public", "boolean", "filterPixelPolygon", "(", "Polygon2D_F64", "undistorted", ",", "Polygon2D_F64", "distorted", ",", "GrowQueue_B", "touches", ",", "boolean", "touchesBorder", ")", "{", "if", "(", "touchesBorder", ")", "{", "if", "(", "distorte...
If not touching the border then the number of corners must be 4. If touching the border there must be at least 3 corners not touching the border. 7 corners at most. If there were 8 then all sides of a square would be touching the border. No more than 3 corners since that's the most number of non-border corners a square can have.
[ "If", "not", "touching", "the", "border", "then", "the", "number", "of", "corners", "must", "be", "4", ".", "If", "touching", "the", "border", "there", "must", "be", "at", "least", "3", "corners", "not", "touching", "the", "border", ".", "7", "corners", ...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/ChessboardPolygonHelper.java#L57-L74
train
lessthanoptimal/BoofCV
integration/boofcv-ffmpeg/src/main/java/org/bytedeco/copiedstuff/Java2DFrameConverter.java
Java2DFrameConverter.getFrame
public Frame getFrame(BufferedImage image, double gamma, boolean flipChannels) { if (image == null) { return null; } SampleModel sm = image.getSampleModel(); int depth = 0, numChannels = sm.getNumBands(); switch (image.getType()) { case BufferedImage.TYPE_INT_RGB: case BufferedImage.TYPE_INT_ARGB: case BufferedImage.TYPE_INT_ARGB_PRE: case BufferedImage.TYPE_INT_BGR: depth = Frame.DEPTH_UBYTE; numChannels = 4; break; } if (depth == 0 || numChannels == 0) { switch (sm.getDataType()) { case DataBuffer.TYPE_BYTE: depth = Frame.DEPTH_UBYTE; break; case DataBuffer.TYPE_USHORT: depth = Frame.DEPTH_USHORT; break; case DataBuffer.TYPE_SHORT: depth = Frame.DEPTH_SHORT; break; case DataBuffer.TYPE_INT: depth = Frame.DEPTH_INT; break; case DataBuffer.TYPE_FLOAT: depth = Frame.DEPTH_FLOAT; break; case DataBuffer.TYPE_DOUBLE: depth = Frame.DEPTH_DOUBLE; break; default: assert false; } } if (frame == null || frame.imageWidth != image.getWidth() || frame.imageHeight != image.getHeight() || frame.imageDepth != depth || frame.imageChannels != numChannels) { frame = new Frame(image.getWidth(), image.getHeight(), depth, numChannels); } copy(image, frame, gamma, flipChannels, null); return frame; }
java
public Frame getFrame(BufferedImage image, double gamma, boolean flipChannels) { if (image == null) { return null; } SampleModel sm = image.getSampleModel(); int depth = 0, numChannels = sm.getNumBands(); switch (image.getType()) { case BufferedImage.TYPE_INT_RGB: case BufferedImage.TYPE_INT_ARGB: case BufferedImage.TYPE_INT_ARGB_PRE: case BufferedImage.TYPE_INT_BGR: depth = Frame.DEPTH_UBYTE; numChannels = 4; break; } if (depth == 0 || numChannels == 0) { switch (sm.getDataType()) { case DataBuffer.TYPE_BYTE: depth = Frame.DEPTH_UBYTE; break; case DataBuffer.TYPE_USHORT: depth = Frame.DEPTH_USHORT; break; case DataBuffer.TYPE_SHORT: depth = Frame.DEPTH_SHORT; break; case DataBuffer.TYPE_INT: depth = Frame.DEPTH_INT; break; case DataBuffer.TYPE_FLOAT: depth = Frame.DEPTH_FLOAT; break; case DataBuffer.TYPE_DOUBLE: depth = Frame.DEPTH_DOUBLE; break; default: assert false; } } if (frame == null || frame.imageWidth != image.getWidth() || frame.imageHeight != image.getHeight() || frame.imageDepth != depth || frame.imageChannels != numChannels) { frame = new Frame(image.getWidth(), image.getHeight(), depth, numChannels); } copy(image, frame, gamma, flipChannels, null); return frame; }
[ "public", "Frame", "getFrame", "(", "BufferedImage", "image", ",", "double", "gamma", ",", "boolean", "flipChannels", ")", "{", "if", "(", "image", "==", "null", ")", "{", "return", "null", ";", "}", "SampleModel", "sm", "=", "image", ".", "getSampleModel"...
Returns a Frame based on a BufferedImage, given gamma, and inverted channels flag.
[ "Returns", "a", "Frame", "based", "on", "a", "BufferedImage", "given", "gamma", "and", "inverted", "channels", "flag", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-ffmpeg/src/main/java/org/bytedeco/copiedstuff/Java2DFrameConverter.java#L680-L712
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldOps.java
GaliosFieldOps.multiply
public static int multiply( int x , int y , int primitive , int domain ) { int r = 0; while( y > 0 ) { if( (y&1) != 0 ) { r = r ^ x; } y = y >> 1; x = x << 1; if( x >= domain) { x ^= primitive; } } return r; }
java
public static int multiply( int x , int y , int primitive , int domain ) { int r = 0; while( y > 0 ) { if( (y&1) != 0 ) { r = r ^ x; } y = y >> 1; x = x << 1; if( x >= domain) { x ^= primitive; } } return r; }
[ "public", "static", "int", "multiply", "(", "int", "x", ",", "int", "y", ",", "int", "primitive", ",", "int", "domain", ")", "{", "int", "r", "=", "0", ";", "while", "(", "y", ">", "0", ")", "{", "if", "(", "(", "y", "&", "1", ")", "!=", "0...
Implementation of multiplication with a primitive polynomial. The result will be a member of the same field as the inputs, provided primitive is an appropriate irreducible polynomial for that field. Uses 'Russian Peasant Multiplication' that should be a faster algorithm. @param x polynomial @param y polynomial @param primitive Primitive polynomial which is irreducible. @param domain Value of a the largest possible value plus 1. E.g. GF(2**8) would be 256 @return result polynomial
[ "Implementation", "of", "multiplication", "with", "a", "primitive", "polynomial", ".", "The", "result", "will", "be", "a", "member", "of", "the", "same", "field", "as", "the", "inputs", "provided", "primitive", "is", "an", "appropriate", "irreducible", "polynomi...
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/GaliosFieldOps.java#L76-L90
train
lessthanoptimal/BoofCV
main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleHexagonalGrid.java
DetectCircleHexagonalGrid.isClockWise
private static boolean isClockWise( Grid g ) { EllipseRotated_F64 v00 = g.get(0,0); EllipseRotated_F64 v02 = g.columns<3?g.get(1,1):g.get(0,2); EllipseRotated_F64 v20 = g.rows<3?g.get(1,1):g.get(2,0); double a_x = v02.center.x - v00.center.x; double a_y = v02.center.y - v00.center.y; double b_x = v20.center.x - v00.center.x; double b_y = v20.center.y - v00.center.y; return a_x * b_y - a_y * b_x < 0; }
java
private static boolean isClockWise( Grid g ) { EllipseRotated_F64 v00 = g.get(0,0); EllipseRotated_F64 v02 = g.columns<3?g.get(1,1):g.get(0,2); EllipseRotated_F64 v20 = g.rows<3?g.get(1,1):g.get(2,0); double a_x = v02.center.x - v00.center.x; double a_y = v02.center.y - v00.center.y; double b_x = v20.center.x - v00.center.x; double b_y = v20.center.y - v00.center.y; return a_x * b_y - a_y * b_x < 0; }
[ "private", "static", "boolean", "isClockWise", "(", "Grid", "g", ")", "{", "EllipseRotated_F64", "v00", "=", "g", ".", "get", "(", "0", ",", "0", ")", ";", "EllipseRotated_F64", "v02", "=", "g", ".", "columns", "<", "3", "?", "g", ".", "get", "(", ...
Uses the cross product to determine if the grid is in clockwise order
[ "Uses", "the", "cross", "product", "to", "determine", "if", "the", "grid", "is", "in", "clockwise", "order" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleHexagonalGrid.java#L136-L148
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.init
public FDistort init(ImageBase input, ImageBase output) { this.input = input; this.output = output; inputType = input.getImageType(); interp(InterpolationType.BILINEAR); border(0); cached = false; distorter = null; outputToInput = null; return this; }
java
public FDistort init(ImageBase input, ImageBase output) { this.input = input; this.output = output; inputType = input.getImageType(); interp(InterpolationType.BILINEAR); border(0); cached = false; distorter = null; outputToInput = null; return this; }
[ "public", "FDistort", "init", "(", "ImageBase", "input", ",", "ImageBase", "output", ")", "{", "this", ".", "input", "=", "input", ";", "this", ".", "output", "=", "output", ";", "inputType", "=", "input", ".", "getImageType", "(", ")", ";", "interp", ...
Specifies the input and output image and sets interpolation to BILINEAR, black image border, cache is off.
[ "Specifies", "the", "input", "and", "output", "image", "and", "sets", "interpolation", "to", "BILINEAR", "black", "image", "border", "cache", "is", "off", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L97-L110
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.setRefs
public FDistort setRefs( ImageBase input, ImageBase output ) { this.input = input; this.output = output; inputType = input.getImageType(); return this; }
java
public FDistort setRefs( ImageBase input, ImageBase output ) { this.input = input; this.output = output; inputType = input.getImageType(); return this; }
[ "public", "FDistort", "setRefs", "(", "ImageBase", "input", ",", "ImageBase", "output", ")", "{", "this", ".", "input", "=", "input", ";", "this", ".", "output", "=", "output", ";", "inputType", "=", "input", ".", "getImageType", "(", ")", ";", "return",...
All this does is set the references to the images. Nothing else is changed and its up to the user to correctly update everything else. If called the first time you need to do the following <pre> 1) specify the interpolation method 2) specify the transform 3) specify the border </pre> If called again and the image shape has changed you need to do the following: <pre> 1) Update the transform </pre>
[ "All", "this", "does", "is", "set", "the", "references", "to", "the", "images", ".", "Nothing", "else", "is", "changed", "and", "its", "up", "to", "the", "user", "to", "correctly", "update", "everything", "else", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L128-L134
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.input
public FDistort input( ImageBase input ) { if( this.input == null || this.input.width != input.width || this.input.height != input.height ) { distorter = null; } this.input = input; inputType = input.getImageType(); return this; }
java
public FDistort input( ImageBase input ) { if( this.input == null || this.input.width != input.width || this.input.height != input.height ) { distorter = null; } this.input = input; inputType = input.getImageType(); return this; }
[ "public", "FDistort", "input", "(", "ImageBase", "input", ")", "{", "if", "(", "this", ".", "input", "==", "null", "||", "this", ".", "input", ".", "width", "!=", "input", ".", "width", "||", "this", ".", "input", ".", "height", "!=", "input", ".", ...
Changes the input image. The previous distortion is thrown away only if the input image has a different shape
[ "Changes", "the", "input", "image", ".", "The", "previous", "distortion", "is", "thrown", "away", "only", "if", "the", "input", "image", "has", "a", "different", "shape" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L140-L147
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.output
public FDistort output( ImageBase output ) { if( this.output == null || this.output.width != output.width || this.output.height != output.height ) { distorter = null; } this.output = output; return this; }
java
public FDistort output( ImageBase output ) { if( this.output == null || this.output.width != output.width || this.output.height != output.height ) { distorter = null; } this.output = output; return this; }
[ "public", "FDistort", "output", "(", "ImageBase", "output", ")", "{", "if", "(", "this", ".", "output", "==", "null", "||", "this", ".", "output", ".", "width", "!=", "output", ".", "width", "||", "this", ".", "output", ".", "height", "!=", "output", ...
Changes the output image. The previous distortion is thrown away only if the output image has a different shape
[ "Changes", "the", "output", "image", ".", "The", "previous", "distortion", "is", "thrown", "away", "only", "if", "the", "output", "image", "has", "a", "different", "shape" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L153-L159
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.border
public FDistort border( BorderType type ) { if( borderType == type ) return this; borderType = type; return border(FactoryImageBorder.generic(type, inputType)); }
java
public FDistort border( BorderType type ) { if( borderType == type ) return this; borderType = type; return border(FactoryImageBorder.generic(type, inputType)); }
[ "public", "FDistort", "border", "(", "BorderType", "type", ")", "{", "if", "(", "borderType", "==", "type", ")", "return", "this", ";", "borderType", "=", "type", ";", "return", "border", "(", "FactoryImageBorder", ".", "generic", "(", "type", ",", "inputT...
Sets the border by type.
[ "Sets", "the", "border", "by", "type", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L172-L177
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.border
public FDistort border( double value ) { // to recycle here the value also needs to be saved // if( borderType == BorderType.VALUE ) // return this; borderType = BorderType.ZERO; return border(FactoryImageBorder.genericValue(value, inputType)); }
java
public FDistort border( double value ) { // to recycle here the value also needs to be saved // if( borderType == BorderType.VALUE ) // return this; borderType = BorderType.ZERO; return border(FactoryImageBorder.genericValue(value, inputType)); }
[ "public", "FDistort", "border", "(", "double", "value", ")", "{", "// to recycle here the value also needs to be saved", "//\t\tif( borderType == BorderType.VALUE )", "//\t\t\treturn this;", "borderType", "=", "BorderType", ".", "ZERO", ";", "return", "border", "(", "FactoryI...
Sets the border to a fixed gray-scale value
[ "Sets", "the", "border", "to", "a", "fixed", "gray", "-", "scale", "value" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L182-L188
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.interp
public FDistort interp(InterpolationType type) { distorter = null; this.interp = FactoryInterpolation.createPixel(0, 255, type, BorderType.EXTENDED, inputType); return this; }
java
public FDistort interp(InterpolationType type) { distorter = null; this.interp = FactoryInterpolation.createPixel(0, 255, type, BorderType.EXTENDED, inputType); return this; }
[ "public", "FDistort", "interp", "(", "InterpolationType", "type", ")", "{", "distorter", "=", "null", ";", "this", ".", "interp", "=", "FactoryInterpolation", ".", "createPixel", "(", "0", ",", "255", ",", "type", ",", "BorderType", ".", "EXTENDED", ",", "...
Specifies the interpolation used by type.
[ "Specifies", "the", "interpolation", "used", "by", "type", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L215-L220
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.affine
public FDistort affine(double a11, double a12, double a21, double a22, double dx, double dy) { PixelTransformAffine_F32 transform; if( outputToInput != null && outputToInput instanceof PixelTransformAffine_F32 ) { transform = (PixelTransformAffine_F32)outputToInput; } else { transform = new PixelTransformAffine_F32(); } Affine2D_F32 m = new Affine2D_F32(); m.a11 = (float)a11; m.a12 = (float)a12; m.a21 = (float)a21; m.a22 = (float)a22; m.tx = (float)dx; m.ty = (float)dy; m.invert(transform.getModel()); return transform(transform); }
java
public FDistort affine(double a11, double a12, double a21, double a22, double dx, double dy) { PixelTransformAffine_F32 transform; if( outputToInput != null && outputToInput instanceof PixelTransformAffine_F32 ) { transform = (PixelTransformAffine_F32)outputToInput; } else { transform = new PixelTransformAffine_F32(); } Affine2D_F32 m = new Affine2D_F32(); m.a11 = (float)a11; m.a12 = (float)a12; m.a21 = (float)a21; m.a22 = (float)a22; m.tx = (float)dx; m.ty = (float)dy; m.invert(transform.getModel()); return transform(transform); }
[ "public", "FDistort", "affine", "(", "double", "a11", ",", "double", "a12", ",", "double", "a21", ",", "double", "a22", ",", "double", "dx", ",", "double", "dy", ")", "{", "PixelTransformAffine_F32", "transform", ";", "if", "(", "outputToInput", "!=", "nul...
Affine transform from input to output
[ "Affine", "transform", "from", "input", "to", "output" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L256-L279
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.rotate
public FDistort rotate( double angleInputToOutput ) { PixelTransform<Point2D_F32> outputToInput = DistortSupport.transformRotate(input.width/2,input.height/2, output.width/2,output.height/2,(float)angleInputToOutput); return transform(outputToInput); }
java
public FDistort rotate( double angleInputToOutput ) { PixelTransform<Point2D_F32> outputToInput = DistortSupport.transformRotate(input.width/2,input.height/2, output.width/2,output.height/2,(float)angleInputToOutput); return transform(outputToInput); }
[ "public", "FDistort", "rotate", "(", "double", "angleInputToOutput", ")", "{", "PixelTransform", "<", "Point2D_F32", ">", "outputToInput", "=", "DistortSupport", ".", "transformRotate", "(", "input", ".", "width", "/", "2", ",", "input", ".", "height", "/", "2...
Applies a distortion which will rotate the input image by the specified amount.
[ "Applies", "a", "distortion", "which", "will", "rotate", "the", "input", "image", "by", "the", "specified", "amount", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L316-L321
train
lessthanoptimal/BoofCV
main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java
FDistort.apply
public void apply() { // see if the distortion class needs to be created again if( distorter == null ) { Class typeOut = output.getImageType().getImageClass(); switch( input.getImageType().getFamily() ) { case GRAY: distorter = FactoryDistort.distortSB(cached, (InterpolatePixelS)interp, typeOut); break; case PLANAR: distorter = FactoryDistort.distortPL(cached, (InterpolatePixelS)interp, typeOut); break; case INTERLEAVED: distorter = FactoryDistort.distortIL(cached, (InterpolatePixelMB) interp, output.getImageType()); break; default: throw new IllegalArgumentException("Unsupported image type"); } } distorter.setModel(outputToInput); distorter.apply(input,output); }
java
public void apply() { // see if the distortion class needs to be created again if( distorter == null ) { Class typeOut = output.getImageType().getImageClass(); switch( input.getImageType().getFamily() ) { case GRAY: distorter = FactoryDistort.distortSB(cached, (InterpolatePixelS)interp, typeOut); break; case PLANAR: distorter = FactoryDistort.distortPL(cached, (InterpolatePixelS)interp, typeOut); break; case INTERLEAVED: distorter = FactoryDistort.distortIL(cached, (InterpolatePixelMB) interp, output.getImageType()); break; default: throw new IllegalArgumentException("Unsupported image type"); } } distorter.setModel(outputToInput); distorter.apply(input,output); }
[ "public", "void", "apply", "(", ")", "{", "// see if the distortion class needs to be created again", "if", "(", "distorter", "==", "null", ")", "{", "Class", "typeOut", "=", "output", ".", "getImageType", "(", ")", ".", "getImageClass", "(", ")", ";", "switch",...
Applies the distortion.
[ "Applies", "the", "distortion", "." ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/distort/FDistort.java#L326-L350
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/impl/ProjectiveToIdentity.java
ProjectiveToIdentity.process
public boolean process( DMatrixRMaj P ) { if( !svd.decompose(P) ) return false; svd.getU(Ut,true); svd.getV(V,false); double sv[] = svd.getSingularValues(); SingularOps_DDRM.descendingOrder(Ut,true,sv,3,V,false); // compute W+, which is transposed and non-negative inverted for (int i = 0; i < 3; i++) { Wt.unsafe_set(i,i, 1.0/sv[i]); } // get the pseudo inverse // A+ = V*(W+)*U' CommonOps_DDRM.mult(V,Wt,tmp); CommonOps_DDRM.mult(tmp, Ut,PA); // Vector U, which is P*U = 0 SpecializedOps_DDRM.subvector(V,0,3,V.numRows,false,0,ns); return true; }
java
public boolean process( DMatrixRMaj P ) { if( !svd.decompose(P) ) return false; svd.getU(Ut,true); svd.getV(V,false); double sv[] = svd.getSingularValues(); SingularOps_DDRM.descendingOrder(Ut,true,sv,3,V,false); // compute W+, which is transposed and non-negative inverted for (int i = 0; i < 3; i++) { Wt.unsafe_set(i,i, 1.0/sv[i]); } // get the pseudo inverse // A+ = V*(W+)*U' CommonOps_DDRM.mult(V,Wt,tmp); CommonOps_DDRM.mult(tmp, Ut,PA); // Vector U, which is P*U = 0 SpecializedOps_DDRM.subvector(V,0,3,V.numRows,false,0,ns); return true; }
[ "public", "boolean", "process", "(", "DMatrixRMaj", "P", ")", "{", "if", "(", "!", "svd", ".", "decompose", "(", "P", ")", ")", "return", "false", ";", "svd", ".", "getU", "(", "Ut", ",", "true", ")", ";", "svd", ".", "getV", "(", "V", ",", "fa...
Compute projective transform that converts P into identity @param P (Input) 3x4 camera matrix @return true if no errors
[ "Compute", "projective", "transform", "that", "converts", "P", "into", "identity" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/impl/ProjectiveToIdentity.java#L52-L76
train
lessthanoptimal/BoofCV
main/boofcv-geo/src/main/java/boofcv/alg/geo/impl/ProjectiveToIdentity.java
ProjectiveToIdentity.computeH
public void computeH( DMatrixRMaj H ) { H.reshape(4,4); CommonOps_DDRM.insert(PA,H,0,0); for (int i = 0; i < 4; i++) { H.unsafe_set(i,3,ns.data[i]); } }
java
public void computeH( DMatrixRMaj H ) { H.reshape(4,4); CommonOps_DDRM.insert(PA,H,0,0); for (int i = 0; i < 4; i++) { H.unsafe_set(i,3,ns.data[i]); } }
[ "public", "void", "computeH", "(", "DMatrixRMaj", "H", ")", "{", "H", ".", "reshape", "(", "4", ",", "4", ")", ";", "CommonOps_DDRM", ".", "insert", "(", "PA", ",", "H", ",", "0", ",", "0", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i"...
Retrieve projective transform H
[ "Retrieve", "projective", "transform", "H" ]
f01c0243da0ec086285ee722183804d5923bc3ac
https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/impl/ProjectiveToIdentity.java#L81-L90
train