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 | integration/boofcv-android/examples/video/app/src/main/java/org/boofcv/video/MainActivity.java | MainActivity.requestCameraPermission | private void requestCameraPermission() {
int permissionCheck = ContextCompat.checkSelfPermission(this,
Manifest.permission.CAMERA);
if( permissionCheck != android.content.pm.PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA},
0);
// a dialog should open and this dialog will resume when a decision has been made
}
} | java | private void requestCameraPermission() {
int permissionCheck = ContextCompat.checkSelfPermission(this,
Manifest.permission.CAMERA);
if( permissionCheck != android.content.pm.PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.CAMERA},
0);
// a dialog should open and this dialog will resume when a decision has been made
}
} | [
"private",
"void",
"requestCameraPermission",
"(",
")",
"{",
"int",
"permissionCheck",
"=",
"ContextCompat",
".",
"checkSelfPermission",
"(",
"this",
",",
"Manifest",
".",
"permission",
".",
"CAMERA",
")",
";",
"if",
"(",
"permissionCheck",
"!=",
"android",
".",... | Newer versions of Android require explicit permission from the user | [
"Newer",
"versions",
"of",
"Android",
"require",
"explicit",
"permission",
"from",
"the",
"user"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/examples/video/app/src/main/java/org/boofcv/video/MainActivity.java#L66-L76 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java | ConvertBitmap.bitmapToGray | public static <T extends ImageGray<T>>
T bitmapToGray( Bitmap input , T output , Class<T> imageType , byte[] storage) {
if( imageType == GrayF32.class )
return (T)bitmapToGray(input,(GrayF32)output,storage);
else if( imageType == GrayU8.class )
return (T)bitmapToGray(input,(GrayU8)output,storage);
else
throw new IllegalArgumentException("Unsupported BoofCV Image Type");
} | java | public static <T extends ImageGray<T>>
T bitmapToGray( Bitmap input , T output , Class<T> imageType , byte[] storage) {
if( imageType == GrayF32.class )
return (T)bitmapToGray(input,(GrayF32)output,storage);
else if( imageType == GrayU8.class )
return (T)bitmapToGray(input,(GrayU8)output,storage);
else
throw new IllegalArgumentException("Unsupported BoofCV Image Type");
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"T",
"bitmapToGray",
"(",
"Bitmap",
"input",
",",
"T",
"output",
",",
"Class",
"<",
"T",
">",
"imageType",
",",
"byte",
"[",
"]",
"storage",
")",
"{",
"if",
"(",
"imageType",
... | Converts Bitmap image into a single band image of arbitrary type.
@see #declareStorage(android.graphics.Bitmap, byte[])
@param input Input Bitmap image.
@param output Output single band image. If null a new one will be declared.
@param imageType Type of single band image.
@param storage Byte array used for internal storage. If null it will be declared internally.
@return The converted gray scale image. | [
"Converts",
"Bitmap",
"image",
"into",
"a",
"single",
"band",
"image",
"of",
"arbitrary",
"type",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L98-L107 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java | ConvertBitmap.bitmapToGray | public static GrayU8 bitmapToGray( Bitmap input , GrayU8 output , byte[] storage ) {
if( output == null ) {
output = new GrayU8( input.getWidth() , input.getHeight() );
} else {
output.reshape(input.getWidth(), input.getHeight());
}
if( storage == null )
storage = declareStorage(input,null);
input.copyPixelsToBuffer(ByteBuffer.wrap(storage));
ImplConvertBitmap.arrayToGray(storage, input.getConfig(), output);
return output;
} | java | public static GrayU8 bitmapToGray( Bitmap input , GrayU8 output , byte[] storage ) {
if( output == null ) {
output = new GrayU8( input.getWidth() , input.getHeight() );
} else {
output.reshape(input.getWidth(), input.getHeight());
}
if( storage == null )
storage = declareStorage(input,null);
input.copyPixelsToBuffer(ByteBuffer.wrap(storage));
ImplConvertBitmap.arrayToGray(storage, input.getConfig(), output);
return output;
} | [
"public",
"static",
"GrayU8",
"bitmapToGray",
"(",
"Bitmap",
"input",
",",
"GrayU8",
"output",
",",
"byte",
"[",
"]",
"storage",
")",
"{",
"if",
"(",
"output",
"==",
"null",
")",
"{",
"output",
"=",
"new",
"GrayU8",
"(",
"input",
".",
"getWidth",
"(",
... | Converts Bitmap image into GrayU8.
@param input Input Bitmap image.
@param output Output image. If null a new one will be declared.
@param storage Byte array used for internal storage. If null it will be declared internally.
@return The converted gray scale image. | [
"Converts",
"Bitmap",
"image",
"into",
"GrayU8",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L117-L132 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java | ConvertBitmap.bitmapToPlanar | public static <T extends ImageGray<T>>
Planar<T> bitmapToPlanar(Bitmap input , Planar<T> output , Class<T> type , byte[] storage ) {
if( output == null ) {
output = new Planar<>(type, input.getWidth(), input.getHeight(), 3);
} else {
int numBands = Math.min(4,Math.max(3,output.getNumBands()));
output.reshape(input.getWidth(), input.getHeight(),numBands);
}
if( storage == null )
storage = declareStorage(input,null);
input.copyPixelsToBuffer(ByteBuffer.wrap(storage));
if( type == GrayU8.class )
ImplConvertBitmap.arrayToPlanar_U8(storage, input.getConfig(), (Planar)output);
else if( type == GrayF32.class )
ImplConvertBitmap.arrayToPlanar_F32(storage, input.getConfig(), (Planar)output);
else
throw new IllegalArgumentException("Unsupported BoofCV Type");
return output;
} | java | public static <T extends ImageGray<T>>
Planar<T> bitmapToPlanar(Bitmap input , Planar<T> output , Class<T> type , byte[] storage ) {
if( output == null ) {
output = new Planar<>(type, input.getWidth(), input.getHeight(), 3);
} else {
int numBands = Math.min(4,Math.max(3,output.getNumBands()));
output.reshape(input.getWidth(), input.getHeight(),numBands);
}
if( storage == null )
storage = declareStorage(input,null);
input.copyPixelsToBuffer(ByteBuffer.wrap(storage));
if( type == GrayU8.class )
ImplConvertBitmap.arrayToPlanar_U8(storage, input.getConfig(), (Planar)output);
else if( type == GrayF32.class )
ImplConvertBitmap.arrayToPlanar_F32(storage, input.getConfig(), (Planar)output);
else
throw new IllegalArgumentException("Unsupported BoofCV Type");
return output;
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"Planar",
"<",
"T",
">",
"bitmapToPlanar",
"(",
"Bitmap",
"input",
",",
"Planar",
"<",
"T",
">",
"output",
",",
"Class",
"<",
"T",
">",
"type",
",",
"byte",
"[",
"]",
"storag... | Converts Bitmap image into Planar image of the appropriate type.
@see #declareStorage(android.graphics.Bitmap, byte[])
@param input Input Bitmap image.
@param output Output image. If null a new one will be declared.
@param type The type of internal single band image used in the Planar image.
@param storage Byte array used for internal storage. If null it will be declared internally.
@return The converted Planar image. | [
"Converts",
"Bitmap",
"image",
"into",
"Planar",
"image",
"of",
"the",
"appropriate",
"type",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L171-L192 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java | ConvertBitmap.boofToBitmap | public static void boofToBitmap( ImageBase input , Bitmap output , byte[] storage) {
if( BOverrideConvertAndroid.invokeBoofToBitmap(ColorFormat.RGB,input,output,storage))
return;
if( input instanceof Planar ) {
planarToBitmap((Planar)input,output,storage);
} else if( input instanceof ImageGray ) {
grayToBitmap((ImageGray)input,output,storage);
} else if( input instanceof ImageInterleaved ) {
interleavedToBitmap((ImageInterleaved) input, output, storage);
} else {
throw new IllegalArgumentException("Unsupported input image type");
}
} | java | public static void boofToBitmap( ImageBase input , Bitmap output , byte[] storage) {
if( BOverrideConvertAndroid.invokeBoofToBitmap(ColorFormat.RGB,input,output,storage))
return;
if( input instanceof Planar ) {
planarToBitmap((Planar)input,output,storage);
} else if( input instanceof ImageGray ) {
grayToBitmap((ImageGray)input,output,storage);
} else if( input instanceof ImageInterleaved ) {
interleavedToBitmap((ImageInterleaved) input, output, storage);
} else {
throw new IllegalArgumentException("Unsupported input image type");
}
} | [
"public",
"static",
"void",
"boofToBitmap",
"(",
"ImageBase",
"input",
",",
"Bitmap",
"output",
",",
"byte",
"[",
"]",
"storage",
")",
"{",
"if",
"(",
"BOverrideConvertAndroid",
".",
"invokeBoofToBitmap",
"(",
"ColorFormat",
".",
"RGB",
",",
"input",
",",
"o... | Converts many BoofCV image types into a Bitmap.
@see #declareStorage(android.graphics.Bitmap, byte[])
@param input Input BoofCV image.
@param output Output Bitmap image.
@param storage Byte array used for internal storage. If null it will be declared internally. | [
"Converts",
"many",
"BoofCV",
"image",
"types",
"into",
"a",
"Bitmap",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L203-L216 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java | ConvertBitmap.planarToBitmap | public static <T extends ImageGray<T>>
void planarToBitmap(Planar<T> input , Bitmap output , byte[] storage ) {
if( output.getWidth() != input.getWidth() || output.getHeight() != input.getHeight() ) {
throw new IllegalArgumentException("Image shapes are not the same");
}
if( storage == null )
storage = declareStorage(output,null);
if( input.getBandType() == GrayU8.class )
ImplConvertBitmap.planarToArray_U8((Planar)input, storage,output.getConfig());
else if( input.getBandType() == GrayF32.class )
ImplConvertBitmap.planarToArray_F32((Planar)input, storage,output.getConfig());
else
throw new IllegalArgumentException("Unsupported BoofCV Type");
output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
} | java | public static <T extends ImageGray<T>>
void planarToBitmap(Planar<T> input , Bitmap output , byte[] storage ) {
if( output.getWidth() != input.getWidth() || output.getHeight() != input.getHeight() ) {
throw new IllegalArgumentException("Image shapes are not the same");
}
if( storage == null )
storage = declareStorage(output,null);
if( input.getBandType() == GrayU8.class )
ImplConvertBitmap.planarToArray_U8((Planar)input, storage,output.getConfig());
else if( input.getBandType() == GrayF32.class )
ImplConvertBitmap.planarToArray_F32((Planar)input, storage,output.getConfig());
else
throw new IllegalArgumentException("Unsupported BoofCV Type");
output.copyPixelsFromBuffer(ByteBuffer.wrap(storage));
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"void",
"planarToBitmap",
"(",
"Planar",
"<",
"T",
">",
"input",
",",
"Bitmap",
"output",
",",
"byte",
"[",
"]",
"storage",
")",
"{",
"if",
"(",
"output",
".",
"getWidth",
"(",... | Converts Planar image into Bitmap.
@see #declareStorage(android.graphics.Bitmap, byte[])
@param input Input Planar image.
@param output Output Bitmap image.
@param storage Byte array used for internal storage. If null it will be declared internally. | [
"Converts",
"Planar",
"image",
"into",
"Bitmap",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L311-L327 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java | ConvertBitmap.grayToBitmap | public static Bitmap grayToBitmap( GrayU8 input , Bitmap.Config config ) {
Bitmap output = Bitmap.createBitmap(input.width, input.height, config);
grayToBitmap(input,output,null);
return output;
} | java | public static Bitmap grayToBitmap( GrayU8 input , Bitmap.Config config ) {
Bitmap output = Bitmap.createBitmap(input.width, input.height, config);
grayToBitmap(input,output,null);
return output;
} | [
"public",
"static",
"Bitmap",
"grayToBitmap",
"(",
"GrayU8",
"input",
",",
"Bitmap",
".",
"Config",
"config",
")",
"{",
"Bitmap",
"output",
"=",
"Bitmap",
".",
"createBitmap",
"(",
"input",
".",
"width",
",",
"input",
".",
"height",
",",
"config",
")",
"... | Converts GrayU8 into a new Bitmap.
@param input Input gray scale image.
@param config Type of Bitmap image to create. | [
"Converts",
"GrayU8",
"into",
"a",
"new",
"Bitmap",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/ConvertBitmap.java#L386-L392 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateUniqueByScoreAlg.java | AssociateUniqueByScoreAlg.process | public void process( FastQueue<AssociatedIndex> matches , int numSource , int numDestination ) {
if( checkSource ) {
if( checkDestination ) {
processSource(matches, numSource, firstPass);
processDestination(firstPass,numDestination,pruned);
} else {
processSource(matches, numSource, pruned);
}
} else if( checkDestination ) {
processDestination(matches,numDestination,pruned);
} else {
// well this was pointless, just return the input set
pruned = matches;
}
} | java | public void process( FastQueue<AssociatedIndex> matches , int numSource , int numDestination ) {
if( checkSource ) {
if( checkDestination ) {
processSource(matches, numSource, firstPass);
processDestination(firstPass,numDestination,pruned);
} else {
processSource(matches, numSource, pruned);
}
} else if( checkDestination ) {
processDestination(matches,numDestination,pruned);
} else {
// well this was pointless, just return the input set
pruned = matches;
}
} | [
"public",
"void",
"process",
"(",
"FastQueue",
"<",
"AssociatedIndex",
">",
"matches",
",",
"int",
"numSource",
",",
"int",
"numDestination",
")",
"{",
"if",
"(",
"checkSource",
")",
"{",
"if",
"(",
"checkDestination",
")",
"{",
"processSource",
"(",
"matche... | Given a set of matches, enforce the uniqueness rules it was configured to.
@param matches Set of matching features
@param numSource Number of source features
@param numDestination Number of destination features | [
"Given",
"a",
"set",
"of",
"matches",
"enforce",
"the",
"uniqueness",
"rules",
"it",
"was",
"configured",
"to",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateUniqueByScoreAlg.java#L74-L89 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateUniqueByScoreAlg.java | AssociateUniqueByScoreAlg.processSource | private void processSource(FastQueue<AssociatedIndex> matches, int numSource,
FastQueue<AssociatedIndex> output ) {
//set up data structures
scores.resize(numSource);
solutions.resize(numSource);
for( int i =0; i < numSource; i++ ) {
solutions.data[i] = -1;
}
// select best matches
for( int i = 0; i < matches.size(); i++ ) {
AssociatedIndex a = matches.get(i);
int found = solutions.data[a.src];
if( found != -1 ) {
if( found == -2 ) {
// the best solution is invalid because two or more had the same score, see if this is better
double bestScore = scores.data[a.src];
int result = type.compareTo(bestScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.src] = i;
scores.data[a.src] = a.fitScore;
}
} else {
// see if this new score is better than the current best
AssociatedIndex currentBest = matches.get( found );
int result = type.compareTo(currentBest.fitScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.src] = i;
scores.data[a.src] = a.fitScore;
} else if( result == 0 ) {
// two solutions have the same score
solutions.data[a.src] = -2;
}
}
} else {
// no previous match found
solutions.data[a.src] = i;
scores.data[a.src] = a.fitScore;
}
}
output.reset();
for( int i =0; i < numSource; i++ ) {
int index = solutions.data[i];
if( index >= 0 ) {
output.add( matches.get(index) );
}
}
} | java | private void processSource(FastQueue<AssociatedIndex> matches, int numSource,
FastQueue<AssociatedIndex> output ) {
//set up data structures
scores.resize(numSource);
solutions.resize(numSource);
for( int i =0; i < numSource; i++ ) {
solutions.data[i] = -1;
}
// select best matches
for( int i = 0; i < matches.size(); i++ ) {
AssociatedIndex a = matches.get(i);
int found = solutions.data[a.src];
if( found != -1 ) {
if( found == -2 ) {
// the best solution is invalid because two or more had the same score, see if this is better
double bestScore = scores.data[a.src];
int result = type.compareTo(bestScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.src] = i;
scores.data[a.src] = a.fitScore;
}
} else {
// see if this new score is better than the current best
AssociatedIndex currentBest = matches.get( found );
int result = type.compareTo(currentBest.fitScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.src] = i;
scores.data[a.src] = a.fitScore;
} else if( result == 0 ) {
// two solutions have the same score
solutions.data[a.src] = -2;
}
}
} else {
// no previous match found
solutions.data[a.src] = i;
scores.data[a.src] = a.fitScore;
}
}
output.reset();
for( int i =0; i < numSource; i++ ) {
int index = solutions.data[i];
if( index >= 0 ) {
output.add( matches.get(index) );
}
}
} | [
"private",
"void",
"processSource",
"(",
"FastQueue",
"<",
"AssociatedIndex",
">",
"matches",
",",
"int",
"numSource",
",",
"FastQueue",
"<",
"AssociatedIndex",
">",
"output",
")",
"{",
"//set up data structures",
"scores",
".",
"resize",
"(",
"numSource",
")",
... | Selects a subset of matches that have at most one association for each source feature. | [
"Selects",
"a",
"subset",
"of",
"matches",
"that",
"have",
"at",
"most",
"one",
"association",
"for",
"each",
"source",
"feature",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateUniqueByScoreAlg.java#L94-L144 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateUniqueByScoreAlg.java | AssociateUniqueByScoreAlg.processDestination | private void processDestination(FastQueue<AssociatedIndex> matches, int numDestination,
FastQueue<AssociatedIndex> output ) {
//set up data structures
scores.resize(numDestination);
solutions.resize(numDestination);
for( int i =0; i < numDestination; i++ ) {
solutions.data[i] = -1;
}
// select best matches
for( int i = 0; i < matches.size(); i++ ) {
AssociatedIndex a = matches.get(i);
int found = solutions.data[a.dst];
if( found != -1 ) {
if( found == -2 ) {
// the best solution is invalid because two or more had the same score, see if this is better
double bestScore = scores.data[a.dst];
int result = type.compareTo(bestScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.dst] = i;
scores.data[a.dst] = a.fitScore;
}
} else {
// see if this new score is better than the current best
AssociatedIndex currentBest = matches.get( found );
int result = type.compareTo(currentBest.fitScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.dst] = i;
scores.data[a.dst] = a.fitScore;
} else if( result == 0 ) {
// two solutions have the same score
solutions.data[a.dst] = -2;
}
}
} else {
// no previous match found
solutions.data[a.dst] = i;
scores.data[a.dst] = i;
}
}
output.reset();
for( int i =0; i < numDestination; i++ ) {
int index = solutions.data[i];
if( index >= 0 ) {
output.add( matches.get(index) );
}
}
} | java | private void processDestination(FastQueue<AssociatedIndex> matches, int numDestination,
FastQueue<AssociatedIndex> output ) {
//set up data structures
scores.resize(numDestination);
solutions.resize(numDestination);
for( int i =0; i < numDestination; i++ ) {
solutions.data[i] = -1;
}
// select best matches
for( int i = 0; i < matches.size(); i++ ) {
AssociatedIndex a = matches.get(i);
int found = solutions.data[a.dst];
if( found != -1 ) {
if( found == -2 ) {
// the best solution is invalid because two or more had the same score, see if this is better
double bestScore = scores.data[a.dst];
int result = type.compareTo(bestScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.dst] = i;
scores.data[a.dst] = a.fitScore;
}
} else {
// see if this new score is better than the current best
AssociatedIndex currentBest = matches.get( found );
int result = type.compareTo(currentBest.fitScore,a.fitScore);
if( result < 0 ) {
// found a better one, use this now
solutions.data[a.dst] = i;
scores.data[a.dst] = a.fitScore;
} else if( result == 0 ) {
// two solutions have the same score
solutions.data[a.dst] = -2;
}
}
} else {
// no previous match found
solutions.data[a.dst] = i;
scores.data[a.dst] = i;
}
}
output.reset();
for( int i =0; i < numDestination; i++ ) {
int index = solutions.data[i];
if( index >= 0 ) {
output.add( matches.get(index) );
}
}
} | [
"private",
"void",
"processDestination",
"(",
"FastQueue",
"<",
"AssociatedIndex",
">",
"matches",
",",
"int",
"numDestination",
",",
"FastQueue",
"<",
"AssociatedIndex",
">",
"output",
")",
"{",
"//set up data structures",
"scores",
".",
"resize",
"(",
"numDestinat... | Selects a subset of matches that have at most one association for each destination feature. | [
"Selects",
"a",
"subset",
"of",
"matches",
"that",
"have",
"at",
"most",
"one",
"association",
"for",
"each",
"destination",
"feature",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/associate/AssociateUniqueByScoreAlg.java#L149-L199 | train |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/d3/PointCloudViewerPanelSwing.java | PointCloudViewerPanelSwing.applyFog | private int applyFog( int rgb , float fraction ) {
// avoid floating point math
int adjustment = (int)(1000*fraction);
int r = (rgb >> 16)&0xFF;
int g = (rgb >> 8)&0xFF;
int b = rgb & 0xFF;
r = (r * adjustment + ((backgroundColor>>16)&0xFF)*(1000-adjustment)) / 1000;
g = (g * adjustment + ((backgroundColor>>8)&0xFF)*(1000-adjustment)) / 1000;
b = (b * adjustment + (backgroundColor&0xFF)*(1000-adjustment)) / 1000;
return (r << 16) | (g << 8) | b;
} | java | private int applyFog( int rgb , float fraction ) {
// avoid floating point math
int adjustment = (int)(1000*fraction);
int r = (rgb >> 16)&0xFF;
int g = (rgb >> 8)&0xFF;
int b = rgb & 0xFF;
r = (r * adjustment + ((backgroundColor>>16)&0xFF)*(1000-adjustment)) / 1000;
g = (g * adjustment + ((backgroundColor>>8)&0xFF)*(1000-adjustment)) / 1000;
b = (b * adjustment + (backgroundColor&0xFF)*(1000-adjustment)) / 1000;
return (r << 16) | (g << 8) | b;
} | [
"private",
"int",
"applyFog",
"(",
"int",
"rgb",
",",
"float",
"fraction",
")",
"{",
"// avoid floating point math",
"int",
"adjustment",
"=",
"(",
"int",
")",
"(",
"1000",
"*",
"fraction",
")",
";",
"int",
"r",
"=",
"(",
"rgb",
">>",
"16",
")",
"&",
... | Fades color into background as a function of distance | [
"Fades",
"color",
"into",
"background",
"as",
"a",
"function",
"of",
"distance"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/d3/PointCloudViewerPanelSwing.java#L246-L259 | train |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/d3/PointCloudViewerPanelSwing.java | PointCloudViewerPanelSwing.renderDot | private void renderDot( int cx , int cy , float Z , int rgb ) {
for (int i = -dotRadius; i <= dotRadius; i++) {
int y = cy+i;
if( y < 0 || y >= imageRgb.height )
continue;
for (int j = -dotRadius; j <= dotRadius; j++) {
int x = cx+j;
if( x < 0 || x >= imageRgb.width )
continue;
int pixelIndex = imageDepth.getIndex(x,y);
float depth = imageDepth.data[pixelIndex];
if( depth > Z ) {
imageDepth.data[pixelIndex] = Z;
imageRgb.data[pixelIndex] = rgb;
}
}
}
} | java | private void renderDot( int cx , int cy , float Z , int rgb ) {
for (int i = -dotRadius; i <= dotRadius; i++) {
int y = cy+i;
if( y < 0 || y >= imageRgb.height )
continue;
for (int j = -dotRadius; j <= dotRadius; j++) {
int x = cx+j;
if( x < 0 || x >= imageRgb.width )
continue;
int pixelIndex = imageDepth.getIndex(x,y);
float depth = imageDepth.data[pixelIndex];
if( depth > Z ) {
imageDepth.data[pixelIndex] = Z;
imageRgb.data[pixelIndex] = rgb;
}
}
}
} | [
"private",
"void",
"renderDot",
"(",
"int",
"cx",
",",
"int",
"cy",
",",
"float",
"Z",
",",
"int",
"rgb",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"-",
"dotRadius",
";",
"i",
"<=",
"dotRadius",
";",
"i",
"++",
")",
"{",
"int",
"y",
"=",
"cy",
"... | Renders a dot as a square sprite with the specified color | [
"Renders",
"a",
"dot",
"as",
"a",
"square",
"sprite",
"with",
"the",
"specified",
"color"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/d3/PointCloudViewerPanelSwing.java#L264-L282 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/camera/VideoRenderProcessing.java | VideoRenderProcessing.imageToOutput | protected void imageToOutput( double x , double y , Point2D_F64 pt ) {
pt.x = x/scale - tranX/scale;
pt.y = y/scale - tranY/scale;
} | java | protected void imageToOutput( double x , double y , Point2D_F64 pt ) {
pt.x = x/scale - tranX/scale;
pt.y = y/scale - tranY/scale;
} | [
"protected",
"void",
"imageToOutput",
"(",
"double",
"x",
",",
"double",
"y",
",",
"Point2D_F64",
"pt",
")",
"{",
"pt",
".",
"x",
"=",
"x",
"/",
"scale",
"-",
"tranX",
"/",
"scale",
";",
"pt",
".",
"y",
"=",
"y",
"/",
"scale",
"-",
"tranY",
"/",
... | Converts a coordinate from pixel to the output image coordinates | [
"Converts",
"a",
"coordinate",
"from",
"pixel",
"to",
"the",
"output",
"image",
"coordinates"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera/VideoRenderProcessing.java#L139-L142 | train |
lessthanoptimal/BoofCV | integration/boofcv-android/src/main/java/boofcv/android/camera/VideoRenderProcessing.java | VideoRenderProcessing.outputToImage | protected void outputToImage( double x , double y , Point2D_F64 pt ) {
pt.x = x*scale + tranX;
pt.y = y*scale + tranY;
} | java | protected void outputToImage( double x , double y , Point2D_F64 pt ) {
pt.x = x*scale + tranX;
pt.y = y*scale + tranY;
} | [
"protected",
"void",
"outputToImage",
"(",
"double",
"x",
",",
"double",
"y",
",",
"Point2D_F64",
"pt",
")",
"{",
"pt",
".",
"x",
"=",
"x",
"*",
"scale",
"+",
"tranX",
";",
"pt",
".",
"y",
"=",
"y",
"*",
"scale",
"+",
"tranY",
";",
"}"
] | Converts a coordinate from output image coordinates to input image | [
"Converts",
"a",
"coordinate",
"from",
"output",
"image",
"coordinates",
"to",
"input",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-android/src/main/java/boofcv/android/camera/VideoRenderProcessing.java#L147-L150 | train |
lessthanoptimal/BoofCV | integration/boofcv-jcodec/src/main/java/boofcv/io/jcodec/ImplConvertJCodecPicture.java | ImplConvertJCodecPicture.RGB_to_PLU8 | public static void RGB_to_PLU8(Picture input, Planar<GrayU8> output) {
if( input.getColor() != ColorSpace.RGB )
throw new RuntimeException("Unexpected input color space!");
if( output.getNumBands() != 3 )
throw new RuntimeException("Unexpected number of bands in output image!");
output.reshape(input.getWidth(),input.getHeight());
int dataIn[] = input.getData()[0];
GrayU8 out0 = output.getBand(0);
GrayU8 out1 = output.getBand(1);
GrayU8 out2 = output.getBand(2);
int indexIn = 0;
int indexOut = 0;
for (int i = 0; i < output.height; i++) {
for (int j = 0; j < output.width; j++, indexOut++ ) {
int r = dataIn[indexIn++];
int g = dataIn[indexIn++];
int b = dataIn[indexIn++];
out2.data[indexOut] = (byte)r;
out1.data[indexOut] = (byte)g;
out0.data[indexOut] = (byte)b;
}
}
} | java | public static void RGB_to_PLU8(Picture input, Planar<GrayU8> output) {
if( input.getColor() != ColorSpace.RGB )
throw new RuntimeException("Unexpected input color space!");
if( output.getNumBands() != 3 )
throw new RuntimeException("Unexpected number of bands in output image!");
output.reshape(input.getWidth(),input.getHeight());
int dataIn[] = input.getData()[0];
GrayU8 out0 = output.getBand(0);
GrayU8 out1 = output.getBand(1);
GrayU8 out2 = output.getBand(2);
int indexIn = 0;
int indexOut = 0;
for (int i = 0; i < output.height; i++) {
for (int j = 0; j < output.width; j++, indexOut++ ) {
int r = dataIn[indexIn++];
int g = dataIn[indexIn++];
int b = dataIn[indexIn++];
out2.data[indexOut] = (byte)r;
out1.data[indexOut] = (byte)g;
out0.data[indexOut] = (byte)b;
}
}
} | [
"public",
"static",
"void",
"RGB_to_PLU8",
"(",
"Picture",
"input",
",",
"Planar",
"<",
"GrayU8",
">",
"output",
")",
"{",
"if",
"(",
"input",
".",
"getColor",
"(",
")",
"!=",
"ColorSpace",
".",
"RGB",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Une... | Converts a picture in JCodec RGB into RGB BoofCV | [
"Converts",
"a",
"picture",
"in",
"JCodec",
"RGB",
"into",
"RGB",
"BoofCV"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-jcodec/src/main/java/boofcv/io/jcodec/ImplConvertJCodecPicture.java#L34-L61 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyTotalLeastSquares.java | HomographyTotalLeastSquares.backsubstitution0134 | static void backsubstitution0134(DMatrixRMaj P_plus, DMatrixRMaj P , DMatrixRMaj X ,
double H[] ) {
final int N = P.numRows;
DMatrixRMaj tmp = new DMatrixRMaj(N*2, 1);
double H6 = H[6];
double H7 = H[7];
double H8 = H[8];
for (int i = 0, index = 0; i < N; i++) {
double x = -X.data[index],y = -X.data[index+1];
double sum = P.data[index++] * H6 + P.data[index++] * H7 + H8;
tmp.data[i] = x * sum;
tmp.data[i+N] = y * sum;
}
double h0=0,h1=0,h3=0,h4=0;
for (int i = 0; i < N; i++) {
double P_pls_0 = P_plus.data[i];
double P_pls_1 = P_plus.data[i+N];
double tmp_i = tmp.data[i];
double tmp_j = tmp.data[i+N];
h0 += P_pls_0*tmp_i;
h1 += P_pls_1*tmp_i;
h3 += P_pls_0*tmp_j;
h4 += P_pls_1*tmp_j;
}
H[0] = -h0;
H[1] = -h1;
H[3] = -h3;
H[4] = -h4;
} | java | static void backsubstitution0134(DMatrixRMaj P_plus, DMatrixRMaj P , DMatrixRMaj X ,
double H[] ) {
final int N = P.numRows;
DMatrixRMaj tmp = new DMatrixRMaj(N*2, 1);
double H6 = H[6];
double H7 = H[7];
double H8 = H[8];
for (int i = 0, index = 0; i < N; i++) {
double x = -X.data[index],y = -X.data[index+1];
double sum = P.data[index++] * H6 + P.data[index++] * H7 + H8;
tmp.data[i] = x * sum;
tmp.data[i+N] = y * sum;
}
double h0=0,h1=0,h3=0,h4=0;
for (int i = 0; i < N; i++) {
double P_pls_0 = P_plus.data[i];
double P_pls_1 = P_plus.data[i+N];
double tmp_i = tmp.data[i];
double tmp_j = tmp.data[i+N];
h0 += P_pls_0*tmp_i;
h1 += P_pls_1*tmp_i;
h3 += P_pls_0*tmp_j;
h4 += P_pls_1*tmp_j;
}
H[0] = -h0;
H[1] = -h1;
H[3] = -h3;
H[4] = -h4;
} | [
"static",
"void",
"backsubstitution0134",
"(",
"DMatrixRMaj",
"P_plus",
",",
"DMatrixRMaj",
"P",
",",
"DMatrixRMaj",
"X",
",",
"double",
"H",
"[",
"]",
")",
"{",
"final",
"int",
"N",
"=",
"P",
".",
"numRows",
";",
"DMatrixRMaj",
"tmp",
"=",
"new",
"DMatr... | Backsubstitution for solving for 0,1 and 3,4 using solution for 6,7,8 | [
"Backsubstitution",
"for",
"solving",
"for",
"0",
"1",
"and",
"3",
"4",
"using",
"solution",
"for",
"6",
"7",
"8"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyTotalLeastSquares.java#L114-L148 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyTotalLeastSquares.java | HomographyTotalLeastSquares.constructA678 | void constructA678() {
final int N = X1.numRows;
// Pseudo-inverse of hat(p)
computePseudo(X1,P_plus);
DMatrixRMaj PPpXP = new DMatrixRMaj(1,1);
DMatrixRMaj PPpYP = new DMatrixRMaj(1,1);
computePPXP(X1,P_plus,X2,0,PPpXP);
computePPXP(X1,P_plus,X2,1,PPpYP);
DMatrixRMaj PPpX = new DMatrixRMaj(1,1);
DMatrixRMaj PPpY = new DMatrixRMaj(1,1);
computePPpX(X1,P_plus,X2,0,PPpX);
computePPpX(X1,P_plus,X2,1,PPpY);
//============ Equations 20
computeEq20(X2,X1,XP_bar);
//============ Equation 21
A.reshape(N *2,3);
double XP_bar_x = XP_bar[0];
double XP_bar_y = XP_bar[1];
double YP_bar_x = XP_bar[2];
double YP_bar_y = XP_bar[3];
// Compute the top half of A
for (int i = 0, index = 0, indexA = 0; i < N; i++, index+=2) {
double x = -X2.data[i*2]; // X'
double P_hat_x = X1.data[index]; // hat{P}[0]
double P_hat_y = X1.data[index+1]; // hat{P}[1]
// x'*hat{p} - bar{X*P} - PPpXP
A.data[indexA++] = x*P_hat_x - XP_bar_x - PPpXP.data[index];
A.data[indexA++] = x*P_hat_y - XP_bar_y - PPpXP.data[index+1];
// X'*1 - PPx1
A.data[indexA++] = x - PPpX.data[i];
}
// Compute the bottom half of A
for (int i = 0, index = 0, indexA = N*3; i < N; i++, index+=2) {
double x = -X2.data[i*2+1];
double P_hat_x = X1.data[index];
double P_hat_y = X1.data[index+1];
// x'*hat{p} - bar{X*P} - PPpXP
A.data[indexA++] = x*P_hat_x - YP_bar_x - PPpYP.data[index];
A.data[indexA++] = x*P_hat_y - YP_bar_y - PPpYP.data[index+1];
// X'*1 - PPx1
A.data[indexA++] = x - PPpY.data[i];
}
} | java | void constructA678() {
final int N = X1.numRows;
// Pseudo-inverse of hat(p)
computePseudo(X1,P_plus);
DMatrixRMaj PPpXP = new DMatrixRMaj(1,1);
DMatrixRMaj PPpYP = new DMatrixRMaj(1,1);
computePPXP(X1,P_plus,X2,0,PPpXP);
computePPXP(X1,P_plus,X2,1,PPpYP);
DMatrixRMaj PPpX = new DMatrixRMaj(1,1);
DMatrixRMaj PPpY = new DMatrixRMaj(1,1);
computePPpX(X1,P_plus,X2,0,PPpX);
computePPpX(X1,P_plus,X2,1,PPpY);
//============ Equations 20
computeEq20(X2,X1,XP_bar);
//============ Equation 21
A.reshape(N *2,3);
double XP_bar_x = XP_bar[0];
double XP_bar_y = XP_bar[1];
double YP_bar_x = XP_bar[2];
double YP_bar_y = XP_bar[3];
// Compute the top half of A
for (int i = 0, index = 0, indexA = 0; i < N; i++, index+=2) {
double x = -X2.data[i*2]; // X'
double P_hat_x = X1.data[index]; // hat{P}[0]
double P_hat_y = X1.data[index+1]; // hat{P}[1]
// x'*hat{p} - bar{X*P} - PPpXP
A.data[indexA++] = x*P_hat_x - XP_bar_x - PPpXP.data[index];
A.data[indexA++] = x*P_hat_y - XP_bar_y - PPpXP.data[index+1];
// X'*1 - PPx1
A.data[indexA++] = x - PPpX.data[i];
}
// Compute the bottom half of A
for (int i = 0, index = 0, indexA = N*3; i < N; i++, index+=2) {
double x = -X2.data[i*2+1];
double P_hat_x = X1.data[index];
double P_hat_y = X1.data[index+1];
// x'*hat{p} - bar{X*P} - PPpXP
A.data[indexA++] = x*P_hat_x - YP_bar_x - PPpYP.data[index];
A.data[indexA++] = x*P_hat_y - YP_bar_y - PPpYP.data[index+1];
// X'*1 - PPx1
A.data[indexA++] = x - PPpY.data[i];
}
} | [
"void",
"constructA678",
"(",
")",
"{",
"final",
"int",
"N",
"=",
"X1",
".",
"numRows",
";",
"// Pseudo-inverse of hat(p)",
"computePseudo",
"(",
"X1",
",",
"P_plus",
")",
";",
"DMatrixRMaj",
"PPpXP",
"=",
"new",
"DMatrixRMaj",
"(",
"1",
",",
"1",
")",
"... | Constructs equation for elements 6 to 8 in H | [
"Constructs",
"equation",
"for",
"elements",
"6",
"to",
"8",
"in",
"H"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyTotalLeastSquares.java#L153-L205 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/MetricSceneGraph.java | MetricSceneGraph.sanityCheck | public void sanityCheck() {
for( View v : nodes ) {
for( Motion m : v.connections ) {
if( m.viewDst != v && m.viewSrc != v )
throw new RuntimeException("Not member of connection");
}
}
for( Motion m : edges ) {
if( m.viewDst != m.destination(m.viewSrc) )
throw new RuntimeException("Unexpected result");
}
} | java | public void sanityCheck() {
for( View v : nodes ) {
for( Motion m : v.connections ) {
if( m.viewDst != v && m.viewSrc != v )
throw new RuntimeException("Not member of connection");
}
}
for( Motion m : edges ) {
if( m.viewDst != m.destination(m.viewSrc) )
throw new RuntimeException("Unexpected result");
}
} | [
"public",
"void",
"sanityCheck",
"(",
")",
"{",
"for",
"(",
"View",
"v",
":",
"nodes",
")",
"{",
"for",
"(",
"Motion",
"m",
":",
"v",
".",
"connections",
")",
"{",
"if",
"(",
"m",
".",
"viewDst",
"!=",
"v",
"&&",
"m",
".",
"viewSrc",
"!=",
"v",... | Performs simple checks to see if the data structure is avlid | [
"Performs",
"simple",
"checks",
"to",
"see",
"if",
"the",
"data",
"structure",
"is",
"avlid"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/structure/MetricSceneGraph.java#L98-L110 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldAdjustRegion.java | TldAdjustRegion.process | public boolean process( FastQueue<AssociatedPair> pairs , Rectangle2D_F64 targetRectangle ) {
// estimate how the rectangle has changed and update it
if( !estimateMotion.process(pairs.toList()) )
return false;
ScaleTranslate2D motion = estimateMotion.getModelParameters();
adjustRectangle(targetRectangle,motion);
if( targetRectangle.p0.x < 0 || targetRectangle.p0.y < 0 )
return false;
if( targetRectangle.p1.x >= imageWidth || targetRectangle.p1.y >= imageHeight )
return false;
return true;
} | java | public boolean process( FastQueue<AssociatedPair> pairs , Rectangle2D_F64 targetRectangle ) {
// estimate how the rectangle has changed and update it
if( !estimateMotion.process(pairs.toList()) )
return false;
ScaleTranslate2D motion = estimateMotion.getModelParameters();
adjustRectangle(targetRectangle,motion);
if( targetRectangle.p0.x < 0 || targetRectangle.p0.y < 0 )
return false;
if( targetRectangle.p1.x >= imageWidth || targetRectangle.p1.y >= imageHeight )
return false;
return true;
} | [
"public",
"boolean",
"process",
"(",
"FastQueue",
"<",
"AssociatedPair",
">",
"pairs",
",",
"Rectangle2D_F64",
"targetRectangle",
")",
"{",
"// estimate how the rectangle has changed and update it",
"if",
"(",
"!",
"estimateMotion",
".",
"process",
"(",
"pairs",
".",
... | Adjusts target rectangle using track information
@param pairs List of feature location in previous and current frame.
@param targetRectangle (Input) current location of rectangle. (output) adjusted location
@return true if successful | [
"Adjusts",
"target",
"rectangle",
"using",
"track",
"information"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldAdjustRegion.java#L72-L88 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldAdjustRegion.java | TldAdjustRegion.adjustRectangle | protected void adjustRectangle( Rectangle2D_F64 rect , ScaleTranslate2D motion ) {
rect.p0.x = rect.p0.x*motion.scale + motion.transX;
rect.p0.y = rect.p0.y*motion.scale + motion.transY;
rect.p1.x = rect.p1.x*motion.scale + motion.transX;
rect.p1.y = rect.p1.y*motion.scale + motion.transY;
} | java | protected void adjustRectangle( Rectangle2D_F64 rect , ScaleTranslate2D motion ) {
rect.p0.x = rect.p0.x*motion.scale + motion.transX;
rect.p0.y = rect.p0.y*motion.scale + motion.transY;
rect.p1.x = rect.p1.x*motion.scale + motion.transX;
rect.p1.y = rect.p1.y*motion.scale + motion.transY;
} | [
"protected",
"void",
"adjustRectangle",
"(",
"Rectangle2D_F64",
"rect",
",",
"ScaleTranslate2D",
"motion",
")",
"{",
"rect",
".",
"p0",
".",
"x",
"=",
"rect",
".",
"p0",
".",
"x",
"*",
"motion",
".",
"scale",
"+",
"motion",
".",
"transX",
";",
"rect",
... | Estimate motion of points inside the rectangle and updates the rectangle using the found motion. | [
"Estimate",
"motion",
"of",
"points",
"inside",
"the",
"rectangle",
"and",
"updates",
"the",
"rectangle",
"using",
"the",
"found",
"motion",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldAdjustRegion.java#L93-L98 | train |
lessthanoptimal/BoofCV | examples/src/main/java/boofcv/examples/features/ExampleAssociatePoints.java | ExampleAssociatePoints.associate | public void associate( BufferedImage imageA , BufferedImage imageB )
{
T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType);
T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType);
// stores the location of detected interest points
pointsA = new ArrayList<>();
pointsB = new ArrayList<>();
// stores the description of detected interest points
FastQueue<TD> descA = UtilFeature.createQueue(detDesc,100);
FastQueue<TD> descB = UtilFeature.createQueue(detDesc,100);
// describe each image using interest points
describeImage(inputA,pointsA,descA);
describeImage(inputB,pointsB,descB);
// Associate features between the two images
associate.setSource(descA);
associate.setDestination(descB);
associate.associate();
// display the results
AssociationPanel panel = new AssociationPanel(20);
panel.setAssociation(pointsA,pointsB,associate.getMatches());
panel.setImages(imageA,imageB);
ShowImages.showWindow(panel,"Associated Features",true);
} | java | public void associate( BufferedImage imageA , BufferedImage imageB )
{
T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType);
T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType);
// stores the location of detected interest points
pointsA = new ArrayList<>();
pointsB = new ArrayList<>();
// stores the description of detected interest points
FastQueue<TD> descA = UtilFeature.createQueue(detDesc,100);
FastQueue<TD> descB = UtilFeature.createQueue(detDesc,100);
// describe each image using interest points
describeImage(inputA,pointsA,descA);
describeImage(inputB,pointsB,descB);
// Associate features between the two images
associate.setSource(descA);
associate.setDestination(descB);
associate.associate();
// display the results
AssociationPanel panel = new AssociationPanel(20);
panel.setAssociation(pointsA,pointsB,associate.getMatches());
panel.setImages(imageA,imageB);
ShowImages.showWindow(panel,"Associated Features",true);
} | [
"public",
"void",
"associate",
"(",
"BufferedImage",
"imageA",
",",
"BufferedImage",
"imageB",
")",
"{",
"T",
"inputA",
"=",
"ConvertBufferedImage",
".",
"convertFromSingle",
"(",
"imageA",
",",
"null",
",",
"imageType",
")",
";",
"T",
"inputB",
"=",
"ConvertB... | Detect and associate point features in the two images. Display the results. | [
"Detect",
"and",
"associate",
"point",
"features",
"in",
"the",
"two",
"images",
".",
"Display",
"the",
"results",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleAssociatePoints.java#L76-L104 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/abst/denoise/FactoryImageDenoise.java | FactoryImageDenoise.waveletVisu | public static <T extends ImageGray<T>> WaveletDenoiseFilter<T>
waveletVisu( Class<T> imageType , int numLevels , double minPixelValue , double maxPixelValue )
{
ImageDataType info = ImageDataType.classToType(imageType);
WaveletTransform descTran = createDefaultShrinkTransform(info, numLevels,minPixelValue,maxPixelValue);
DenoiseWavelet denoiser = FactoryDenoiseWaveletAlg.visu(imageType);
return new WaveletDenoiseFilter<>(descTran, denoiser);
} | java | public static <T extends ImageGray<T>> WaveletDenoiseFilter<T>
waveletVisu( Class<T> imageType , int numLevels , double minPixelValue , double maxPixelValue )
{
ImageDataType info = ImageDataType.classToType(imageType);
WaveletTransform descTran = createDefaultShrinkTransform(info, numLevels,minPixelValue,maxPixelValue);
DenoiseWavelet denoiser = FactoryDenoiseWaveletAlg.visu(imageType);
return new WaveletDenoiseFilter<>(descTran, denoiser);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"WaveletDenoiseFilter",
"<",
"T",
">",
"waveletVisu",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"int",
"numLevels",
",",
"double",
"minPixelValue",
",",
"double",
"maxPixelValue",... | Denoises an image using VISU Shrink wavelet denoiser.
@param imageType The type of image being transform.
@param numLevels Number of levels in the wavelet transform. If not sure, try using 3.
@param minPixelValue Minimum allowed pixel intensity value
@param maxPixelValue Maximum allowed pixel intensity value
@return filter for image noise removal. | [
"Denoises",
"an",
"image",
"using",
"VISU",
"Shrink",
"wavelet",
"denoiser",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/denoise/FactoryImageDenoise.java#L55-L63 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/abst/denoise/FactoryImageDenoise.java | FactoryImageDenoise.waveletBayes | public static <T extends ImageGray<T>> WaveletDenoiseFilter<T>
waveletBayes( Class<T> imageType , int numLevels , double minPixelValue , double maxPixelValue )
{
ImageDataType info = ImageDataType.classToType(imageType);
WaveletTransform descTran = createDefaultShrinkTransform(info, numLevels,minPixelValue,maxPixelValue);
DenoiseWavelet denoiser = FactoryDenoiseWaveletAlg.bayes(null, imageType);
return new WaveletDenoiseFilter<>(descTran, denoiser);
} | java | public static <T extends ImageGray<T>> WaveletDenoiseFilter<T>
waveletBayes( Class<T> imageType , int numLevels , double minPixelValue , double maxPixelValue )
{
ImageDataType info = ImageDataType.classToType(imageType);
WaveletTransform descTran = createDefaultShrinkTransform(info, numLevels,minPixelValue,maxPixelValue);
DenoiseWavelet denoiser = FactoryDenoiseWaveletAlg.bayes(null, imageType);
return new WaveletDenoiseFilter<>(descTran, denoiser);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"WaveletDenoiseFilter",
"<",
"T",
">",
"waveletBayes",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"int",
"numLevels",
",",
"double",
"minPixelValue",
",",
"double",
"maxPixelValue"... | Denoises an image using BayesShrink wavelet denoiser.
@param imageType The type of image being transform.
@param numLevels Number of levels in the wavelet transform. If not sure, try using 3.
@param minPixelValue Minimum allowed pixel intensity value
@param maxPixelValue Maximum allowed pixel intensity value
@return filter for image noise removal. | [
"Denoises",
"an",
"image",
"using",
"BayesShrink",
"wavelet",
"denoiser",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/denoise/FactoryImageDenoise.java#L74-L82 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/abst/denoise/FactoryImageDenoise.java | FactoryImageDenoise.createDefaultShrinkTransform | private static WaveletTransform createDefaultShrinkTransform(ImageDataType imageType, int numLevels,
double minPixelValue , double maxPixelValue ) {
WaveletTransform descTran;
if( !imageType.isInteger()) {
WaveletDescription<WlCoef_F32> waveletDesc_F32 = FactoryWaveletDaub.daubJ_F32(4);
descTran = FactoryWaveletTransform.create_F32(waveletDesc_F32,numLevels,
(float)minPixelValue,(float)maxPixelValue);
} else {
WaveletDescription<WlCoef_I32> waveletDesc_I32 = FactoryWaveletDaub.biorthogonal_I32(5, BorderType.REFLECT);
descTran = FactoryWaveletTransform.create_I(waveletDesc_I32,numLevels,
(int)minPixelValue,(int)maxPixelValue,
ImageType.getImageClass(ImageType.Family.GRAY, imageType));
}
return descTran;
} | java | private static WaveletTransform createDefaultShrinkTransform(ImageDataType imageType, int numLevels,
double minPixelValue , double maxPixelValue ) {
WaveletTransform descTran;
if( !imageType.isInteger()) {
WaveletDescription<WlCoef_F32> waveletDesc_F32 = FactoryWaveletDaub.daubJ_F32(4);
descTran = FactoryWaveletTransform.create_F32(waveletDesc_F32,numLevels,
(float)minPixelValue,(float)maxPixelValue);
} else {
WaveletDescription<WlCoef_I32> waveletDesc_I32 = FactoryWaveletDaub.biorthogonal_I32(5, BorderType.REFLECT);
descTran = FactoryWaveletTransform.create_I(waveletDesc_I32,numLevels,
(int)minPixelValue,(int)maxPixelValue,
ImageType.getImageClass(ImageType.Family.GRAY, imageType));
}
return descTran;
} | [
"private",
"static",
"WaveletTransform",
"createDefaultShrinkTransform",
"(",
"ImageDataType",
"imageType",
",",
"int",
"numLevels",
",",
"double",
"minPixelValue",
",",
"double",
"maxPixelValue",
")",
"{",
"WaveletTransform",
"descTran",
";",
"if",
"(",
"!",
"imageTy... | Default wavelet transform used for denoising images. | [
"Default",
"wavelet",
"transform",
"used",
"for",
"denoising",
"images",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/abst/denoise/FactoryImageDenoise.java#L106-L122 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java | CircularIndex.minusPOffset | public static int minusPOffset(int index, int offset, int size) {
index -= offset;
if( index < 0 ) {
return size + index;
} else {
return index;
}
} | java | public static int minusPOffset(int index, int offset, int size) {
index -= offset;
if( index < 0 ) {
return size + index;
} else {
return index;
}
} | [
"public",
"static",
"int",
"minusPOffset",
"(",
"int",
"index",
",",
"int",
"offset",
",",
"int",
"size",
")",
"{",
"index",
"-=",
"offset",
";",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"size",
"+",
"index",
";",
"}",
"else",
"{",
"return... | Subtracts a positive offset to index in a circular buffer.
@param index element in circular buffer
@param offset integer which is positive and less than size
@param size size of the circular buffer
@return new index | [
"Subtracts",
"a",
"positive",
"offset",
"to",
"index",
"in",
"a",
"circular",
"buffer",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java#L47-L54 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java | CircularIndex.distanceP | public static int distanceP(int index0, int index1, int size) {
int difference = index1-index0;
if( difference < 0 ) {
difference = size+difference;
}
return difference;
} | java | public static int distanceP(int index0, int index1, int size) {
int difference = index1-index0;
if( difference < 0 ) {
difference = size+difference;
}
return difference;
} | [
"public",
"static",
"int",
"distanceP",
"(",
"int",
"index0",
",",
"int",
"index1",
",",
"int",
"size",
")",
"{",
"int",
"difference",
"=",
"index1",
"-",
"index0",
";",
"if",
"(",
"difference",
"<",
"0",
")",
"{",
"difference",
"=",
"size",
"+",
"di... | Returns how many elements away in the positive direction you need to travel to get from
index0 to index1.
@param index0 element in circular buffer
@param index1 element in circular buffer
@param size size of the circular buffer
@return positive distance | [
"Returns",
"how",
"many",
"elements",
"away",
"in",
"the",
"positive",
"direction",
"you",
"need",
"to",
"travel",
"to",
"get",
"from",
"index0",
"to",
"index1",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java#L82-L88 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java | CircularIndex.subtract | public static int subtract(int index0, int index1, int size) {
int distance = distanceP(index0, index1, size);
if( distance >= size/2+size%2 ) {
return distance-size;
} else {
return distance;
}
} | java | public static int subtract(int index0, int index1, int size) {
int distance = distanceP(index0, index1, size);
if( distance >= size/2+size%2 ) {
return distance-size;
} else {
return distance;
}
} | [
"public",
"static",
"int",
"subtract",
"(",
"int",
"index0",
",",
"int",
"index1",
",",
"int",
"size",
")",
"{",
"int",
"distance",
"=",
"distanceP",
"(",
"index0",
",",
"index1",
",",
"size",
")",
";",
"if",
"(",
"distance",
">=",
"size",
"/",
"2",
... | Subtracts index1 from index0. positive number if its closer in the positive
direction or negative if closer in the negative direction. if equal distance then
it will return a negative number.
@param index0 element in circular buffer
@param index1 element in circular buffer
@param size size of the circular buffer
@return new index | [
"Subtracts",
"index1",
"from",
"index0",
".",
"positive",
"number",
"if",
"its",
"closer",
"in",
"the",
"positive",
"direction",
"or",
"negative",
"if",
"closer",
"in",
"the",
"negative",
"direction",
".",
"if",
"equal",
"distance",
"then",
"it",
"will",
"re... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/misc/CircularIndex.java#L122-L129 | train |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/StandardAlgConfigPanel.java | StandardAlgConfigPanel.removeChildInsidePanel | protected static void removeChildInsidePanel( JComponent root , JComponent target ) {
int N = root.getComponentCount();
for (int i = 0; i < N; i++) {
try {
JPanel p = (JPanel)root.getComponent(i);
Component[] children = p.getComponents();
for (int j = 0; j < children.length; j++) {
if( children[j] == target ) {
root.remove(i);
return;
}
}
}catch( ClassCastException ignore){}
}
} | java | protected static void removeChildInsidePanel( JComponent root , JComponent target ) {
int N = root.getComponentCount();
for (int i = 0; i < N; i++) {
try {
JPanel p = (JPanel)root.getComponent(i);
Component[] children = p.getComponents();
for (int j = 0; j < children.length; j++) {
if( children[j] == target ) {
root.remove(i);
return;
}
}
}catch( ClassCastException ignore){}
}
} | [
"protected",
"static",
"void",
"removeChildInsidePanel",
"(",
"JComponent",
"root",
",",
"JComponent",
"target",
")",
"{",
"int",
"N",
"=",
"root",
".",
"getComponentCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",... | Searches inside the children of "root" for a component that's a JPanel. Then inside the JPanel it
looks for the target. If the target is inside the JPanel the JPanel is removed from root. | [
"Searches",
"inside",
"the",
"children",
"of",
"root",
"for",
"a",
"component",
"that",
"s",
"a",
"JPanel",
".",
"Then",
"inside",
"the",
"JPanel",
"it",
"looks",
"for",
"the",
"target",
".",
"If",
"the",
"target",
"is",
"inside",
"the",
"JPanel",
"the",... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/StandardAlgConfigPanel.java#L263-L278 | train |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/StandardAlgConfigPanel.java | StandardAlgConfigPanel.removeChildAndPrevious | protected static void removeChildAndPrevious( JComponent root , JComponent target ) {
int N = root.getComponentCount();
for (int i = 0; i < N; i++) {
if( root.getComponent(i) == target ) {
root.remove(i);
root.remove(i-1);
return;
}
}
throw new RuntimeException("Can't find component");
} | java | protected static void removeChildAndPrevious( JComponent root , JComponent target ) {
int N = root.getComponentCount();
for (int i = 0; i < N; i++) {
if( root.getComponent(i) == target ) {
root.remove(i);
root.remove(i-1);
return;
}
}
throw new RuntimeException("Can't find component");
} | [
"protected",
"static",
"void",
"removeChildAndPrevious",
"(",
"JComponent",
"root",
",",
"JComponent",
"target",
")",
"{",
"int",
"N",
"=",
"root",
".",
"getComponentCount",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",... | Searches inside the children of "root" for 'target'. If found it is removed and the
previous component. | [
"Searches",
"inside",
"the",
"children",
"of",
"root",
"for",
"target",
".",
"If",
"found",
"it",
"is",
"removed",
"and",
"the",
"previous",
"component",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/StandardAlgConfigPanel.java#L284-L295 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/SegmentMeanShiftSearch.java | SegmentMeanShiftSearch.distanceSq | public static float distanceSq( float[] a , float[]b ) {
float ret = 0;
for( int i = 0; i < a.length; i++ ) {
float d = a[i] - b[i];
ret += d*d;
}
return ret;
} | java | public static float distanceSq( float[] a , float[]b ) {
float ret = 0;
for( int i = 0; i < a.length; i++ ) {
float d = a[i] - b[i];
ret += d*d;
}
return ret;
} | [
"public",
"static",
"float",
"distanceSq",
"(",
"float",
"[",
"]",
"a",
",",
"float",
"[",
"]",
"b",
")",
"{",
"float",
"ret",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"a",
".",
"length",
";",
"i",
"++",
")",
"{",
"fl... | Returns the Euclidean distance squared between the two vectors | [
"Returns",
"the",
"Euclidean",
"distance",
"squared",
"between",
"the",
"two",
"vectors"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/SegmentMeanShiftSearch.java#L173-L180 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/SegmentMeanShiftSearch.java | SegmentMeanShiftSearch.weight | protected float weight( float distance ) {
float findex = distance*100f;
int index = (int)findex;
if( index >= 99 )
return weightTable[99];
float sample0 = weightTable[index];
float sample1 = weightTable[index+1];
float w = findex-index;
return sample0*(1f-w) + sample1*w;
} | java | protected float weight( float distance ) {
float findex = distance*100f;
int index = (int)findex;
if( index >= 99 )
return weightTable[99];
float sample0 = weightTable[index];
float sample1 = weightTable[index+1];
float w = findex-index;
return sample0*(1f-w) + sample1*w;
} | [
"protected",
"float",
"weight",
"(",
"float",
"distance",
")",
"{",
"float",
"findex",
"=",
"distance",
"*",
"100f",
";",
"int",
"index",
"=",
"(",
"int",
")",
"findex",
";",
"if",
"(",
"index",
">=",
"99",
")",
"return",
"weightTable",
"[",
"99",
"]... | Returns the weight given the normalized distance. Instead of computing the kernel distance every time
a lookup table with linear interpolation is used. The distance has a domain from 0 to 1, inclusive
@param distance Normalized Euclidean distance squared. From 0 to 1.
@return Weight. | [
"Returns",
"the",
"weight",
"given",
"the",
"normalized",
"distance",
".",
"Instead",
"of",
"computing",
"the",
"kernel",
"distance",
"every",
"time",
"a",
"lookup",
"table",
"with",
"linear",
"interpolation",
"is",
"used",
".",
"The",
"distance",
"has",
"a",
... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/SegmentMeanShiftSearch.java#L189-L201 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/scene/FeatureToWordHistogram_F64.java | FeatureToWordHistogram_F64.process | @Override
public void process() {
processed = true;
for (int i = 0; i < histogram.length; i++) {
histogram[i] /= total;
}
} | java | @Override
public void process() {
processed = true;
for (int i = 0; i < histogram.length; i++) {
histogram[i] /= total;
}
} | [
"@",
"Override",
"public",
"void",
"process",
"(",
")",
"{",
"processed",
"=",
"true",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"histogram",
".",
"length",
";",
"i",
"++",
")",
"{",
"histogram",
"[",
"i",
"]",
"/=",
"total",
";",
"... | No more features are being added. Normalized the computed histogram. | [
"No",
"more",
"features",
"are",
"being",
"added",
".",
"Normalized",
"the",
"computed",
"histogram",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/scene/FeatureToWordHistogram_F64.java#L97-L103 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLinePolar.java | HoughTransformLinePolar.transform | public void transform( GrayU8 binary )
{
ImageMiscOps.fill(transform, 0);
originX = binary.width/2;
originY = binary.height/2;
r_max = Math.sqrt(originX*originX+originY*originY);
for( int y = 0; y < binary.height; y++ ) {
int start = binary.startIndex + y*binary.stride;
int stop = start + binary.width;
for( int index = start; index < stop; index++ ) {
if( binary.data[index] != 0 ) {
parameterize(index-start,y);
}
}
}
} | java | public void transform( GrayU8 binary )
{
ImageMiscOps.fill(transform, 0);
originX = binary.width/2;
originY = binary.height/2;
r_max = Math.sqrt(originX*originX+originY*originY);
for( int y = 0; y < binary.height; y++ ) {
int start = binary.startIndex + y*binary.stride;
int stop = start + binary.width;
for( int index = start; index < stop; index++ ) {
if( binary.data[index] != 0 ) {
parameterize(index-start,y);
}
}
}
} | [
"public",
"void",
"transform",
"(",
"GrayU8",
"binary",
")",
"{",
"ImageMiscOps",
".",
"fill",
"(",
"transform",
",",
"0",
")",
";",
"originX",
"=",
"binary",
".",
"width",
"/",
"2",
";",
"originY",
"=",
"binary",
".",
"height",
"/",
"2",
";",
"r_max... | Computes the Hough transform of the image.
@param binary Binary image that indicates which pixels lie on edges. | [
"Computes",
"the",
"Hough",
"transform",
"of",
"the",
"image",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLinePolar.java#L114-L132 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLinePolar.java | HoughTransformLinePolar.lineToCoordinate | public void lineToCoordinate(LineParametric2D_F32 line , Point2D_F64 coordinate ) {
line = line.copy();
line.p.x -= originX;
line.p.y -= originY;
LinePolar2D_F32 polar = new LinePolar2D_F32();
UtilLine2D_F32.convert(line,polar);
if( polar.angle < 0 ) {
polar.distance = -polar.distance;
polar.angle = UtilAngle.toHalfCircle(polar.angle);
}
int w2 = transform.width/2;
coordinate.x = (int)Math.floor(polar.distance*w2/r_max) + w2;
coordinate.y = polar.angle*transform.height/Math.PI;
} | java | public void lineToCoordinate(LineParametric2D_F32 line , Point2D_F64 coordinate ) {
line = line.copy();
line.p.x -= originX;
line.p.y -= originY;
LinePolar2D_F32 polar = new LinePolar2D_F32();
UtilLine2D_F32.convert(line,polar);
if( polar.angle < 0 ) {
polar.distance = -polar.distance;
polar.angle = UtilAngle.toHalfCircle(polar.angle);
}
int w2 = transform.width/2;
coordinate.x = (int)Math.floor(polar.distance*w2/r_max) + w2;
coordinate.y = polar.angle*transform.height/Math.PI;
} | [
"public",
"void",
"lineToCoordinate",
"(",
"LineParametric2D_F32",
"line",
",",
"Point2D_F64",
"coordinate",
")",
"{",
"line",
"=",
"line",
".",
"copy",
"(",
")",
";",
"line",
".",
"p",
".",
"x",
"-=",
"originX",
";",
"line",
".",
"p",
".",
"y",
"-=",
... | Compute the parameterized coordinate for the line | [
"Compute",
"the",
"parameterized",
"coordinate",
"for",
"the",
"line"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLinePolar.java#L173-L189 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLinePolar.java | HoughTransformLinePolar.parameterize | public void parameterize( int x , int y )
{
// put the point in a new coordinate system centered at the image's origin
x -= originX;
y -= originY;
int w2 = transform.width/2;
// The line's slope is encoded using the tangent angle. Those bins are along the image's y-axis
for( int i = 0; i < transform.height; i++ ) {
// distance of closest point on line from a line defined by the point (x,y) and
// the tangent theta=PI*i/height
double p = x*tableTrig.c[i] + y*tableTrig.s[i];
int col = (int)Math.floor(p * w2 / r_max) + w2;
int index = transform.startIndex + i*transform.stride + col;
transform.data[index]++;
}
} | java | public void parameterize( int x , int y )
{
// put the point in a new coordinate system centered at the image's origin
x -= originX;
y -= originY;
int w2 = transform.width/2;
// The line's slope is encoded using the tangent angle. Those bins are along the image's y-axis
for( int i = 0; i < transform.height; i++ ) {
// distance of closest point on line from a line defined by the point (x,y) and
// the tangent theta=PI*i/height
double p = x*tableTrig.c[i] + y*tableTrig.s[i];
int col = (int)Math.floor(p * w2 / r_max) + w2;
int index = transform.startIndex + i*transform.stride + col;
transform.data[index]++;
}
} | [
"public",
"void",
"parameterize",
"(",
"int",
"x",
",",
"int",
"y",
")",
"{",
"// put the point in a new coordinate system centered at the image's origin",
"x",
"-=",
"originX",
";",
"y",
"-=",
"originY",
";",
"int",
"w2",
"=",
"transform",
".",
"width",
"/",
"2... | Converts the pixel coordinate into a line in parameter space | [
"Converts",
"the",
"pixel",
"coordinate",
"into",
"a",
"line",
"in",
"parameter",
"space"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/line/HoughTransformLinePolar.java#L194-L212 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/struct/geo/PairLineNorm.java | PairLineNorm.set | public void set( Vector3D_F64 l1 , Vector3D_F64 l2 ) {
this.l1.set(l1);
this.l2.set(l2);
} | java | public void set( Vector3D_F64 l1 , Vector3D_F64 l2 ) {
this.l1.set(l1);
this.l2.set(l2);
} | [
"public",
"void",
"set",
"(",
"Vector3D_F64",
"l1",
",",
"Vector3D_F64",
"l2",
")",
"{",
"this",
".",
"l1",
".",
"set",
"(",
"l1",
")",
";",
"this",
".",
"l2",
".",
"set",
"(",
"l2",
")",
";",
"}"
] | Sets the value of p1 and p2 to be equal to the values of the passed in objects | [
"Sets",
"the",
"value",
"of",
"p1",
"and",
"p2",
"to",
"be",
"equal",
"to",
"the",
"values",
"of",
"the",
"passed",
"in",
"objects"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/struct/geo/PairLineNorm.java#L87-L90 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/scene/ClassifierKNearestNeighborsBow.java | ClassifierKNearestNeighborsBow.setClassificationData | public void setClassificationData(List<HistogramScene> memory , int numScenes ) {
nn.setPoints(memory, false);
scenes = new double[ numScenes ];
} | java | public void setClassificationData(List<HistogramScene> memory , int numScenes ) {
nn.setPoints(memory, false);
scenes = new double[ numScenes ];
} | [
"public",
"void",
"setClassificationData",
"(",
"List",
"<",
"HistogramScene",
">",
"memory",
",",
"int",
"numScenes",
")",
"{",
"nn",
".",
"setPoints",
"(",
"memory",
",",
"false",
")",
";",
"scenes",
"=",
"new",
"double",
"[",
"numScenes",
"]",
";",
"}... | Provides a set of labeled word histograms to use to classify a new image
@param memory labeled histograms | [
"Provides",
"a",
"set",
"of",
"labeled",
"word",
"histograms",
"to",
"use",
"to",
"classify",
"a",
"new",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/scene/ClassifierKNearestNeighborsBow.java#L98-L103 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/scene/ClassifierKNearestNeighborsBow.java | ClassifierKNearestNeighborsBow.classify | public int classify(T image) {
if( numNeighbors == 0 )
throw new IllegalArgumentException("Must specify number of neighbors!");
// compute all the features inside the image
describe.process(image);
// find which word the feature matches and construct a frequency histogram
featureToHistogram.reset();
List<Desc> imageFeatures = describe.getDescriptions();
for (int i = 0; i < imageFeatures.size(); i++) {
Desc d = imageFeatures.get(i);
featureToHistogram.addFeature(d);
}
featureToHistogram.process();
temp.histogram = featureToHistogram.getHistogram();
// Find the N most similar image histograms
resultsNN.reset();
search.findNearest(temp,-1,numNeighbors,resultsNN);
// Find the most common scene among those neighbors
Arrays.fill(scenes,0);
for (int i = 0; i < resultsNN.size; i++) {
NnData<HistogramScene> data = resultsNN.get(i);
HistogramScene n = data.point;
// scenes[n.type]++;
scenes[n.type] += 1.0/(data.distance+0.005); // todo
// scenes[n.type] += 1.0/(Math.sqrt(data.distance)+0.005); // todo
}
// pick the scene with the highest frequency
int bestIndex = 0;
double bestCount = 0;
for (int i = 0; i < scenes.length; i++) {
if( scenes[i] > bestCount ) {
bestCount = scenes[i];
bestIndex = i;
}
}
return bestIndex;
} | java | public int classify(T image) {
if( numNeighbors == 0 )
throw new IllegalArgumentException("Must specify number of neighbors!");
// compute all the features inside the image
describe.process(image);
// find which word the feature matches and construct a frequency histogram
featureToHistogram.reset();
List<Desc> imageFeatures = describe.getDescriptions();
for (int i = 0; i < imageFeatures.size(); i++) {
Desc d = imageFeatures.get(i);
featureToHistogram.addFeature(d);
}
featureToHistogram.process();
temp.histogram = featureToHistogram.getHistogram();
// Find the N most similar image histograms
resultsNN.reset();
search.findNearest(temp,-1,numNeighbors,resultsNN);
// Find the most common scene among those neighbors
Arrays.fill(scenes,0);
for (int i = 0; i < resultsNN.size; i++) {
NnData<HistogramScene> data = resultsNN.get(i);
HistogramScene n = data.point;
// scenes[n.type]++;
scenes[n.type] += 1.0/(data.distance+0.005); // todo
// scenes[n.type] += 1.0/(Math.sqrt(data.distance)+0.005); // todo
}
// pick the scene with the highest frequency
int bestIndex = 0;
double bestCount = 0;
for (int i = 0; i < scenes.length; i++) {
if( scenes[i] > bestCount ) {
bestCount = scenes[i];
bestIndex = i;
}
}
return bestIndex;
} | [
"public",
"int",
"classify",
"(",
"T",
"image",
")",
"{",
"if",
"(",
"numNeighbors",
"==",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Must specify number of neighbors!\"",
")",
";",
"// compute all the features inside the image",
"describe",
".",
"p... | Finds the scene which most resembles the provided image
@param image Image that's to be classified
@return The index of the scene it most resembles | [
"Finds",
"the",
"scene",
"which",
"most",
"resembles",
"the",
"provided",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/scene/ClassifierKNearestNeighborsBow.java#L110-L154 | train |
lessthanoptimal/BoofCV | examples/src/main/java/boofcv/examples/imageprocessing/ExamplePyramidDiscrete.java | ExamplePyramidDiscrete.unusual | public void unusual() {
// Note that the first level does not have to be one
pyramid = FactoryPyramid.discreteGaussian(new int[]{2,6},-1,2,true, ImageType.single(imageType));
// Other kernels can also be used besides Gaussian
Kernel1D kernel;
if(GeneralizedImageOps.isFloatingPoint(imageType) ) {
kernel = FactoryKernel.table1D_F32(2,true);
} else {
kernel = FactoryKernel.table1D_I32(2);
}
} | java | public void unusual() {
// Note that the first level does not have to be one
pyramid = FactoryPyramid.discreteGaussian(new int[]{2,6},-1,2,true, ImageType.single(imageType));
// Other kernels can also be used besides Gaussian
Kernel1D kernel;
if(GeneralizedImageOps.isFloatingPoint(imageType) ) {
kernel = FactoryKernel.table1D_F32(2,true);
} else {
kernel = FactoryKernel.table1D_I32(2);
}
} | [
"public",
"void",
"unusual",
"(",
")",
"{",
"// Note that the first level does not have to be one",
"pyramid",
"=",
"FactoryPyramid",
".",
"discreteGaussian",
"(",
"new",
"int",
"[",
"]",
"{",
"2",
",",
"6",
"}",
",",
"-",
"1",
",",
"2",
",",
"true",
",",
... | Creates a more unusual pyramid and updater. | [
"Creates",
"a",
"more",
"unusual",
"pyramid",
"and",
"updater",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/imageprocessing/ExamplePyramidDiscrete.java#L66-L77 | train |
lessthanoptimal/BoofCV | examples/src/main/java/boofcv/examples/imageprocessing/ExamplePyramidDiscrete.java | ExamplePyramidDiscrete.process | public void process( BufferedImage image ) {
T input = ConvertBufferedImage.convertFromSingle(image, null, imageType);
pyramid.process(input);
DiscretePyramidPanel gui = new DiscretePyramidPanel();
gui.setPyramid(pyramid);
gui.render();
ShowImages.showWindow(gui,"Image Pyramid");
// To get an image at any of the scales simply call this get function
T imageAtScale = pyramid.getLayer(1);
ShowImages.showWindow(ConvertBufferedImage.convertTo(imageAtScale,null,true),"Image at layer 1");
} | java | public void process( BufferedImage image ) {
T input = ConvertBufferedImage.convertFromSingle(image, null, imageType);
pyramid.process(input);
DiscretePyramidPanel gui = new DiscretePyramidPanel();
gui.setPyramid(pyramid);
gui.render();
ShowImages.showWindow(gui,"Image Pyramid");
// To get an image at any of the scales simply call this get function
T imageAtScale = pyramid.getLayer(1);
ShowImages.showWindow(ConvertBufferedImage.convertTo(imageAtScale,null,true),"Image at layer 1");
} | [
"public",
"void",
"process",
"(",
"BufferedImage",
"image",
")",
"{",
"T",
"input",
"=",
"ConvertBufferedImage",
".",
"convertFromSingle",
"(",
"image",
",",
"null",
",",
"imageType",
")",
";",
"pyramid",
".",
"process",
"(",
"input",
")",
";",
"DiscretePyra... | Updates and displays the pyramid. | [
"Updates",
"and",
"displays",
"the",
"pyramid",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/imageprocessing/ExamplePyramidDiscrete.java#L82-L96 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java | FactoryDerivativeSparse.createLaplacian | public static <T extends ImageGray<T>>
ImageFunctionSparse<T> createLaplacian( Class<T> imageType , ImageBorder<T> border )
{
if( border == null ) {
border = FactoryImageBorder.single(imageType, BorderType.EXTENDED);
}
if( GeneralizedImageOps.isFloatingPoint(imageType)) {
ImageConvolveSparse<GrayF32, Kernel2D_F32> r = FactoryConvolveSparse.convolve2D(GrayF32.class, DerivativeLaplacian.kernel_F32);
r.setImageBorder((ImageBorder_F32)border);
return (ImageFunctionSparse<T>)r;
} else {
ImageConvolveSparse r = FactoryConvolveSparse.convolve2D(GrayI.class, DerivativeLaplacian.kernel_I32);
r.setImageBorder(border);
return (ImageFunctionSparse<T>)r;
}
} | java | public static <T extends ImageGray<T>>
ImageFunctionSparse<T> createLaplacian( Class<T> imageType , ImageBorder<T> border )
{
if( border == null ) {
border = FactoryImageBorder.single(imageType, BorderType.EXTENDED);
}
if( GeneralizedImageOps.isFloatingPoint(imageType)) {
ImageConvolveSparse<GrayF32, Kernel2D_F32> r = FactoryConvolveSparse.convolve2D(GrayF32.class, DerivativeLaplacian.kernel_F32);
r.setImageBorder((ImageBorder_F32)border);
return (ImageFunctionSparse<T>)r;
} else {
ImageConvolveSparse r = FactoryConvolveSparse.convolve2D(GrayI.class, DerivativeLaplacian.kernel_I32);
r.setImageBorder(border);
return (ImageFunctionSparse<T>)r;
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"ImageFunctionSparse",
"<",
"T",
">",
"createLaplacian",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"ImageBorder",
"<",
"T",
">",
"border",
")",
"{",
"if",
"(",
"border",
"==... | Creates a sparse Laplacian filter.
@see DerivativeLaplacian
@param imageType The type of image which is to be processed.
@param border How the border should be handled. If null {@link BorderType#EXTENDED} will be used.
@return Filter for performing a sparse laplacian. | [
"Creates",
"a",
"sparse",
"Laplacian",
"filter",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java#L58-L78 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java | FactoryDerivativeSparse.createSobel | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createSobel( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseSobel_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseSobel_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | java | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createSobel( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseSobel_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseSobel_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"G",
"extends",
"GradientValue",
">",
"SparseImageGradient",
"<",
"T",
",",
"G",
">",
"createSobel",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"ImageBorder",
"<",
"T",
">",
... | Creates a sparse sobel gradient operator.
@see GradientSobel
@param imageType The type of image which is to be processed.
@param border How the border should be handled. If null then the borders can't be processed.
@return Sparse gradient | [
"Creates",
"a",
"sparse",
"sobel",
"gradient",
"operator",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java#L89-L99 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java | FactoryDerivativeSparse.createPrewitt | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createPrewitt( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparsePrewitt_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparsePrewitt_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | java | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createPrewitt( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparsePrewitt_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparsePrewitt_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"G",
"extends",
"GradientValue",
">",
"SparseImageGradient",
"<",
"T",
",",
"G",
">",
"createPrewitt",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"ImageBorder",
"<",
"T",
">",
... | Creates a sparse prewitt gradient operator.
@see boofcv.alg.filter.derivative.GradientPrewitt
@param imageType The type of image which is to be processed.
@param border How the border should be handled. If null then the borders can't be processed.
@return Sparse gradient. | [
"Creates",
"a",
"sparse",
"prewitt",
"gradient",
"operator",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java#L110-L120 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java | FactoryDerivativeSparse.createThree | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createThree( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseThree_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseThree_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | java | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createThree( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseThree_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseThree_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"G",
"extends",
"GradientValue",
">",
"SparseImageGradient",
"<",
"T",
",",
"G",
">",
"createThree",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"ImageBorder",
"<",
"T",
">",
... | Creates a sparse three gradient operator.
@see boofcv.alg.filter.derivative.GradientThree
@param imageType The type of image which is to be processed.
@param border How the border should be handled. If null then the borders can't be processed.
@return Sparse gradient. | [
"Creates",
"a",
"sparse",
"three",
"gradient",
"operator",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java#L131-L141 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java | FactoryDerivativeSparse.createTwo0 | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createTwo0( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseTwo0_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseTwo0_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | java | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createTwo0( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseTwo0_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseTwo0_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"G",
"extends",
"GradientValue",
">",
"SparseImageGradient",
"<",
"T",
",",
"G",
">",
"createTwo0",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"ImageBorder",
"<",
"T",
">",
"... | Creates a sparse two-0 gradient operator.
@see boofcv.alg.filter.derivative.GradientTwo0
@param imageType The type of image which is to be processed.
@param border How the border should be handled. If null then the borders can't be processed.
@return Sparse gradient. | [
"Creates",
"a",
"sparse",
"two",
"-",
"0",
"gradient",
"operator",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java#L152-L162 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java | FactoryDerivativeSparse.createTwo1 | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createTwo1( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseTwo1_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseTwo1_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | java | public static <T extends ImageGray<T>, G extends GradientValue>
SparseImageGradient<T,G> createTwo1( Class<T> imageType , ImageBorder<T> border )
{
if( imageType == GrayF32.class) {
return (SparseImageGradient)new GradientSparseTwo1_F32((ImageBorder_F32)border);
} else if( imageType == GrayU8.class ){
return (SparseImageGradient)new GradientSparseTwo1_U8((ImageBorder_S32)border);
} else {
throw new IllegalArgumentException("Unsupported image type "+imageType.getSimpleName());
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
",",
"G",
"extends",
"GradientValue",
">",
"SparseImageGradient",
"<",
"T",
",",
"G",
">",
"createTwo1",
"(",
"Class",
"<",
"T",
">",
"imageType",
",",
"ImageBorder",
"<",
"T",
">",
"... | Creates a sparse two-1 gradient operator.
@see boofcv.alg.filter.derivative.GradientTwo1
@param imageType The type of image which is to be processed.
@param border How the border should be handled. If null then the borders can't be processed.
@return Sparse gradient. | [
"Creates",
"a",
"sparse",
"two",
"-",
"1",
"gradient",
"operator",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/derivative/FactoryDerivativeSparse.java#L173-L183 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/flow/DenseFlowPyramidBase.java | DenseFlowPyramidBase.process | public void process( T image1 , T image2 )
{
// declare image data structures
if( pyr1 == null || pyr1.getInputWidth() != image1.width || pyr1.getInputHeight() != image1.height ) {
pyr1 = UtilDenseOpticalFlow.standardPyramid(image1.width, image1.height, scale, sigma, 5, maxLayers, GrayF32.class);
pyr2 = UtilDenseOpticalFlow.standardPyramid(image1.width, image1.height, scale, sigma, 5, maxLayers, GrayF32.class);
pyr1.initialize(image1.width,image1.height);
pyr2.initialize(image1.width,image1.height);
}
norm1.reshape(image1.width, image1.height);
norm2.reshape(image1.width, image1.height);
// normalize input image to make sure alpha is image independent
imageNormalization(image1, image2, norm1, norm2);
// create image pyramid
pyr1.process(norm1);
pyr2.process(norm2);
// compute flow from pyramid
process(pyr1, pyr2);
} | java | public void process( T image1 , T image2 )
{
// declare image data structures
if( pyr1 == null || pyr1.getInputWidth() != image1.width || pyr1.getInputHeight() != image1.height ) {
pyr1 = UtilDenseOpticalFlow.standardPyramid(image1.width, image1.height, scale, sigma, 5, maxLayers, GrayF32.class);
pyr2 = UtilDenseOpticalFlow.standardPyramid(image1.width, image1.height, scale, sigma, 5, maxLayers, GrayF32.class);
pyr1.initialize(image1.width,image1.height);
pyr2.initialize(image1.width,image1.height);
}
norm1.reshape(image1.width, image1.height);
norm2.reshape(image1.width, image1.height);
// normalize input image to make sure alpha is image independent
imageNormalization(image1, image2, norm1, norm2);
// create image pyramid
pyr1.process(norm1);
pyr2.process(norm2);
// compute flow from pyramid
process(pyr1, pyr2);
} | [
"public",
"void",
"process",
"(",
"T",
"image1",
",",
"T",
"image2",
")",
"{",
"// declare image data structures",
"if",
"(",
"pyr1",
"==",
"null",
"||",
"pyr1",
".",
"getInputWidth",
"(",
")",
"!=",
"image1",
".",
"width",
"||",
"pyr1",
".",
"getInputHeig... | Processes the raw input images. Normalizes them and creates image pyramids from them. | [
"Processes",
"the",
"raw",
"input",
"images",
".",
"Normalizes",
"them",
"and",
"creates",
"image",
"pyramids",
"from",
"them",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/flow/DenseFlowPyramidBase.java#L67-L90 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/flow/DenseFlowPyramidBase.java | DenseFlowPyramidBase.imageNormalization | protected static<T extends ImageGray<T>>
void imageNormalization(T image1, T image2, GrayF32 normalized1, GrayF32 normalized2 )
{
// find the max and min of both images
float max1 = (float)GImageStatistics.max(image1);
float max2 = (float)GImageStatistics.max(image2);
float min1 = (float)GImageStatistics.min(image1);
float min2 = (float)GImageStatistics.min(image2);
// obtain the absolute max and min
float max = max1 > max2 ? max1 : max2;
float min = min1 < min2 ? min1 : min2;
float range = max - min;
if(range > 0) {
// normalize both images
int indexN = 0;
for (int y = 0; y < image1.height; y++) {
for (int x = 0; x < image1.width; x++,indexN++) {
// this is a slow way to convert the image type into a float, but everything else is much
// more expensive
float pv1 = (float)GeneralizedImageOps.get(image1, x, y);
float pv2 = (float)GeneralizedImageOps.get(image2,x,y);
normalized1.data[indexN] = (pv1 - min) / range;
normalized2.data[indexN] = (pv2 - min) / range;
}
}
} else {
GConvertImage.convert(image1, normalized1);
GConvertImage.convert(image2, normalized2);
}
} | java | protected static<T extends ImageGray<T>>
void imageNormalization(T image1, T image2, GrayF32 normalized1, GrayF32 normalized2 )
{
// find the max and min of both images
float max1 = (float)GImageStatistics.max(image1);
float max2 = (float)GImageStatistics.max(image2);
float min1 = (float)GImageStatistics.min(image1);
float min2 = (float)GImageStatistics.min(image2);
// obtain the absolute max and min
float max = max1 > max2 ? max1 : max2;
float min = min1 < min2 ? min1 : min2;
float range = max - min;
if(range > 0) {
// normalize both images
int indexN = 0;
for (int y = 0; y < image1.height; y++) {
for (int x = 0; x < image1.width; x++,indexN++) {
// this is a slow way to convert the image type into a float, but everything else is much
// more expensive
float pv1 = (float)GeneralizedImageOps.get(image1, x, y);
float pv2 = (float)GeneralizedImageOps.get(image2,x,y);
normalized1.data[indexN] = (pv1 - min) / range;
normalized2.data[indexN] = (pv2 - min) / range;
}
}
} else {
GConvertImage.convert(image1, normalized1);
GConvertImage.convert(image2, normalized2);
}
} | [
"protected",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"void",
"imageNormalization",
"(",
"T",
"image1",
",",
"T",
"image2",
",",
"GrayF32",
"normalized1",
",",
"GrayF32",
"normalized2",
")",
"{",
"// find the max and min of both images",
"... | Function to normalize the images between 0 and 255. | [
"Function",
"to",
"normalize",
"the",
"images",
"between",
"0",
"and",
"255",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/flow/DenseFlowPyramidBase.java#L152-L184 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyInducedStereo3Pts.java | HomographyInducedStereo3Pts.process | public boolean process(AssociatedPair p1, AssociatedPair p2, AssociatedPair p3) {
// Fill rows of M with observations from image 1
fillM(p1.p1,p2.p1,p3.p1);
// Compute 'b' vector
b.x = computeB(p1.p2);
b.y = computeB(p2.p2);
b.z = computeB(p3.p2);
// A_inv_b = inv(A)*b
if( !solver.setA(M) )
return false;
GeometryMath_F64.toMatrix(b,temp0);
solver.solve(temp0,temp1);
GeometryMath_F64.toTuple3D(temp1, A_inv_b);
GeometryMath_F64.addOuterProd(A, -1, e2, A_inv_b, H);
// pick a good scale and sign for H
adjust.adjust(H, p1);
return true;
} | java | public boolean process(AssociatedPair p1, AssociatedPair p2, AssociatedPair p3) {
// Fill rows of M with observations from image 1
fillM(p1.p1,p2.p1,p3.p1);
// Compute 'b' vector
b.x = computeB(p1.p2);
b.y = computeB(p2.p2);
b.z = computeB(p3.p2);
// A_inv_b = inv(A)*b
if( !solver.setA(M) )
return false;
GeometryMath_F64.toMatrix(b,temp0);
solver.solve(temp0,temp1);
GeometryMath_F64.toTuple3D(temp1, A_inv_b);
GeometryMath_F64.addOuterProd(A, -1, e2, A_inv_b, H);
// pick a good scale and sign for H
adjust.adjust(H, p1);
return true;
} | [
"public",
"boolean",
"process",
"(",
"AssociatedPair",
"p1",
",",
"AssociatedPair",
"p2",
",",
"AssociatedPair",
"p3",
")",
"{",
"// Fill rows of M with observations from image 1",
"fillM",
"(",
"p1",
".",
"p1",
",",
"p2",
".",
"p1",
",",
"p3",
".",
"p1",
")",... | Estimates the homography from view 1 to view 2 induced by a plane from 3 point associations.
Each pair must pass the epipolar constraint. This can fail if the points are colinear.
@param p1 Associated point observation
@param p2 Associated point observation
@param p3 Associated point observation
@return True if successful or false if it failed | [
"Estimates",
"the",
"homography",
"from",
"view",
"1",
"to",
"view",
"2",
"induced",
"by",
"a",
"plane",
"from",
"3",
"point",
"associations",
".",
"Each",
"pair",
"must",
"pass",
"the",
"epipolar",
"constraint",
".",
"This",
"can",
"fail",
"if",
"the",
... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyInducedStereo3Pts.java#L104-L128 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyInducedStereo3Pts.java | HomographyInducedStereo3Pts.fillM | private void fillM( Point2D_F64 x1 , Point2D_F64 x2 , Point2D_F64 x3 ) {
M.data[0] = x1.x; M.data[1] = x1.y; M.data[2] = 1;
M.data[3] = x2.x; M.data[4] = x2.y; M.data[5] = 1;
M.data[6] = x3.x; M.data[7] = x3.y; M.data[8] = 1;
} | java | private void fillM( Point2D_F64 x1 , Point2D_F64 x2 , Point2D_F64 x3 ) {
M.data[0] = x1.x; M.data[1] = x1.y; M.data[2] = 1;
M.data[3] = x2.x; M.data[4] = x2.y; M.data[5] = 1;
M.data[6] = x3.x; M.data[7] = x3.y; M.data[8] = 1;
} | [
"private",
"void",
"fillM",
"(",
"Point2D_F64",
"x1",
",",
"Point2D_F64",
"x2",
",",
"Point2D_F64",
"x3",
")",
"{",
"M",
".",
"data",
"[",
"0",
"]",
"=",
"x1",
".",
"x",
";",
"M",
".",
"data",
"[",
"1",
"]",
"=",
"x1",
".",
"y",
";",
"M",
"."... | Fill rows of M with observations from image 1 | [
"Fill",
"rows",
"of",
"M",
"with",
"observations",
"from",
"image",
"1"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/h/HomographyInducedStereo3Pts.java#L133-L137 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/DecomposeAbsoluteDualQuadratic.java | DecomposeAbsoluteDualQuadratic.decompose | public boolean decompose( DMatrix4x4 Q ) {
// scale Q so that Q(3,3) = 1 to provide a uniform scaling
CommonOps_DDF4.scale(1.0/Q.a33,Q);
// TODO consider using eigen decomposition like it was suggested
// Directly extract from the definition of Q
// Q = [w -w*p;-p'*w p'*w*p]
// w = k*k'
k.a11 = Q.a11;k.a12 = Q.a12;k.a13 = Q.a13;
k.a21 = Q.a21;k.a22 = Q.a22;k.a23 = Q.a23;
k.a31 = Q.a31;k.a32 = Q.a32;k.a33 = Q.a33;
if( !CommonOps_DDF3.invert(k,w_inv) )
return false;
// force it to be positive definite. Solution will be of dubious value if this condition is triggered, but it
// seems to help much more often than it hurts
// I'm not sure if I flip these variables if others along the same row/col should be flipped too or not
k.set(w_inv);
k.a11 = Math.abs(k.a11);
k.a22 = Math.abs(k.a22);
k.a33 = Math.abs(k.a33);
if( !CommonOps_DDF3.cholU(k) )
return false;
if( !CommonOps_DDF3.invert(k,k) )
return false;
CommonOps_DDF3.divide(k,k.a33);
t.a1 = Q.a14; t.a2 = Q.a24; t.a3 = Q.a34;
CommonOps_DDF3.mult(w_inv, t, p);
CommonOps_DDF3.scale(-1,p);
CommonOps_DDF3.multTransB(k,k,w);
return true;
} | java | public boolean decompose( DMatrix4x4 Q ) {
// scale Q so that Q(3,3) = 1 to provide a uniform scaling
CommonOps_DDF4.scale(1.0/Q.a33,Q);
// TODO consider using eigen decomposition like it was suggested
// Directly extract from the definition of Q
// Q = [w -w*p;-p'*w p'*w*p]
// w = k*k'
k.a11 = Q.a11;k.a12 = Q.a12;k.a13 = Q.a13;
k.a21 = Q.a21;k.a22 = Q.a22;k.a23 = Q.a23;
k.a31 = Q.a31;k.a32 = Q.a32;k.a33 = Q.a33;
if( !CommonOps_DDF3.invert(k,w_inv) )
return false;
// force it to be positive definite. Solution will be of dubious value if this condition is triggered, but it
// seems to help much more often than it hurts
// I'm not sure if I flip these variables if others along the same row/col should be flipped too or not
k.set(w_inv);
k.a11 = Math.abs(k.a11);
k.a22 = Math.abs(k.a22);
k.a33 = Math.abs(k.a33);
if( !CommonOps_DDF3.cholU(k) )
return false;
if( !CommonOps_DDF3.invert(k,k) )
return false;
CommonOps_DDF3.divide(k,k.a33);
t.a1 = Q.a14; t.a2 = Q.a24; t.a3 = Q.a34;
CommonOps_DDF3.mult(w_inv, t, p);
CommonOps_DDF3.scale(-1,p);
CommonOps_DDF3.multTransB(k,k,w);
return true;
} | [
"public",
"boolean",
"decompose",
"(",
"DMatrix4x4",
"Q",
")",
"{",
"// scale Q so that Q(3,3) = 1 to provide a uniform scaling",
"CommonOps_DDF4",
".",
"scale",
"(",
"1.0",
"/",
"Q",
".",
"a33",
",",
"Q",
")",
";",
"// TODO consider using eigen decomposition like it was ... | Decomposes the passed in absolute quadratic
@param Q Absolute quadratic
@return true if successful or false if it failed | [
"Decomposes",
"the",
"passed",
"in",
"absolute",
"quadratic"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/DecomposeAbsoluteDualQuadratic.java#L54-L92 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/DecomposeAbsoluteDualQuadratic.java | DecomposeAbsoluteDualQuadratic.recomputeQ | public void recomputeQ( DMatrix4x4 Q ) {
CommonOps_DDF3.multTransB(k,k,w);
Q.a11 = w.a11;Q.a12 = w.a12;Q.a13 = w.a13;
Q.a21 = w.a21;Q.a22 = w.a22;Q.a23 = w.a23;
Q.a31 = w.a31;Q.a32 = w.a32;Q.a33 = w.a33;
CommonOps_DDF3.mult(w,p,t);
CommonOps_DDF3.scale(-1,t);
Q.a14 = t.a1;Q.a24 = t.a2;Q.a34 = t.a3;
Q.a41 = t.a1;Q.a42 = t.a2;Q.a43 = t.a3;
Q.a44 = -CommonOps_DDF3.dot(t,p);
} | java | public void recomputeQ( DMatrix4x4 Q ) {
CommonOps_DDF3.multTransB(k,k,w);
Q.a11 = w.a11;Q.a12 = w.a12;Q.a13 = w.a13;
Q.a21 = w.a21;Q.a22 = w.a22;Q.a23 = w.a23;
Q.a31 = w.a31;Q.a32 = w.a32;Q.a33 = w.a33;
CommonOps_DDF3.mult(w,p,t);
CommonOps_DDF3.scale(-1,t);
Q.a14 = t.a1;Q.a24 = t.a2;Q.a34 = t.a3;
Q.a41 = t.a1;Q.a42 = t.a2;Q.a43 = t.a3;
Q.a44 = -CommonOps_DDF3.dot(t,p);
} | [
"public",
"void",
"recomputeQ",
"(",
"DMatrix4x4",
"Q",
")",
"{",
"CommonOps_DDF3",
".",
"multTransB",
"(",
"k",
",",
"k",
",",
"w",
")",
";",
"Q",
".",
"a11",
"=",
"w",
".",
"a11",
";",
"Q",
".",
"a12",
"=",
"w",
".",
"a12",
";",
"Q",
".",
"... | Recomputes Q from w and p.
@param Q Storage for the recomputed Q | [
"Recomputes",
"Q",
"from",
"w",
"and",
"p",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/DecomposeAbsoluteDualQuadratic.java#L99-L113 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/DecomposeAbsoluteDualQuadratic.java | DecomposeAbsoluteDualQuadratic.computeRectifyingHomography | public boolean computeRectifyingHomography( DMatrixRMaj H ) {
H.reshape(4,4);
// insert the results into H
// H = [K 0;-p'*K 1 ]
H.zero();
for (int i = 0; i < 3; i++) {
for (int j = i; j < 3; j++) {
H.set(i,j,k.get(i,j));
}
}
// p and k have different scales, fix that
H.set(3,0, -(p.a1*k.a11 + p.a2*k.a21 + p.a3*k.a31));
H.set(3,1, -(p.a1*k.a12 + p.a2*k.a22 + p.a3*k.a32));
H.set(3,2, -(p.a1*k.a13 + p.a2*k.a23 + p.a3*k.a33));
H.set(3,3,1);
return true;
} | java | public boolean computeRectifyingHomography( DMatrixRMaj H ) {
H.reshape(4,4);
// insert the results into H
// H = [K 0;-p'*K 1 ]
H.zero();
for (int i = 0; i < 3; i++) {
for (int j = i; j < 3; j++) {
H.set(i,j,k.get(i,j));
}
}
// p and k have different scales, fix that
H.set(3,0, -(p.a1*k.a11 + p.a2*k.a21 + p.a3*k.a31));
H.set(3,1, -(p.a1*k.a12 + p.a2*k.a22 + p.a3*k.a32));
H.set(3,2, -(p.a1*k.a13 + p.a2*k.a23 + p.a3*k.a33));
H.set(3,3,1);
return true;
} | [
"public",
"boolean",
"computeRectifyingHomography",
"(",
"DMatrixRMaj",
"H",
")",
"{",
"H",
".",
"reshape",
"(",
"4",
",",
"4",
")",
";",
"// insert the results into H",
"// H = [K 0;-p'*K 1 ]",
"H",
".",
"zero",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
... | Computes the rectifying homography from the decomposed Q
H = [K 0; -p'*K 1] see Pg 460 | [
"Computes",
"the",
"rectifying",
"homography",
"from",
"the",
"decomposed",
"Q"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/structure/DecomposeAbsoluteDualQuadratic.java#L120-L138 | train |
lessthanoptimal/BoofCV | integration/boofcv-WebcamCapture/examples/boofcv/examples/ExampleWebcamObjectTracking.java | ExampleWebcamObjectTracking.process | public void process() {
Webcam webcam = UtilWebcamCapture.openDefault(desiredWidth,desiredHeight);
// adjust the window size and let the GUI know it has changed
Dimension actualSize = webcam.getViewSize();
setPreferredSize(actualSize);
setMinimumSize(actualSize);
window.setMinimumSize(actualSize);
window.setPreferredSize(actualSize);
window.setVisible(true);
// create
T input = tracker.getImageType().createImage(actualSize.width,actualSize.height);
workImage = new BufferedImage(input.getWidth(),input.getHeight(),BufferedImage.TYPE_INT_RGB);
while( true ) {
BufferedImage buffered = webcam.getImage();
if( buffered == null ) break;
ConvertBufferedImage.convertFrom(webcam.getImage(),input,true);
// mode is read/written to by the GUI also
int mode = this.mode;
boolean success = false;
if( mode == 2 ) {
Rectangle2D_F64 rect = new Rectangle2D_F64();
rect.set(point0.x, point0.y, point1.x, point1.y);
UtilPolygons2D_F64.convert(rect, target);
success = tracker.initialize(input,target);
this.mode = success ? 3 : 0;
} else if( mode == 3 ) {
success = tracker.process(input,target);
}
synchronized( workImage ) {
// copy the latest image into the work buffered
Graphics2D g2 = workImage.createGraphics();
g2.drawImage(buffered,0,0,null);
// visualize the current results
if (mode == 1) {
drawSelected(g2);
} else if (mode == 3) {
if( success ) {
drawTrack(g2);
}
}
}
repaint();
}
} | java | public void process() {
Webcam webcam = UtilWebcamCapture.openDefault(desiredWidth,desiredHeight);
// adjust the window size and let the GUI know it has changed
Dimension actualSize = webcam.getViewSize();
setPreferredSize(actualSize);
setMinimumSize(actualSize);
window.setMinimumSize(actualSize);
window.setPreferredSize(actualSize);
window.setVisible(true);
// create
T input = tracker.getImageType().createImage(actualSize.width,actualSize.height);
workImage = new BufferedImage(input.getWidth(),input.getHeight(),BufferedImage.TYPE_INT_RGB);
while( true ) {
BufferedImage buffered = webcam.getImage();
if( buffered == null ) break;
ConvertBufferedImage.convertFrom(webcam.getImage(),input,true);
// mode is read/written to by the GUI also
int mode = this.mode;
boolean success = false;
if( mode == 2 ) {
Rectangle2D_F64 rect = new Rectangle2D_F64();
rect.set(point0.x, point0.y, point1.x, point1.y);
UtilPolygons2D_F64.convert(rect, target);
success = tracker.initialize(input,target);
this.mode = success ? 3 : 0;
} else if( mode == 3 ) {
success = tracker.process(input,target);
}
synchronized( workImage ) {
// copy the latest image into the work buffered
Graphics2D g2 = workImage.createGraphics();
g2.drawImage(buffered,0,0,null);
// visualize the current results
if (mode == 1) {
drawSelected(g2);
} else if (mode == 3) {
if( success ) {
drawTrack(g2);
}
}
}
repaint();
}
} | [
"public",
"void",
"process",
"(",
")",
"{",
"Webcam",
"webcam",
"=",
"UtilWebcamCapture",
".",
"openDefault",
"(",
"desiredWidth",
",",
"desiredHeight",
")",
";",
"// adjust the window size and let the GUI know it has changed",
"Dimension",
"actualSize",
"=",
"webcam",
... | Invoke to start the main processing loop. | [
"Invoke",
"to",
"start",
"the",
"main",
"processing",
"loop",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-WebcamCapture/examples/boofcv/examples/ExampleWebcamObjectTracking.java#L92-L144 | train |
lessthanoptimal/BoofCV | examples/src/main/java/boofcv/examples/features/ExampleFeatureSurf.java | ExampleFeatureSurf.easy | public static void easy( GrayF32 image ) {
// create the detector and descriptors
DetectDescribePoint<GrayF32,BrightFeature> surf = FactoryDetectDescribe.
surfStable(new ConfigFastHessian(0, 2, 200, 2, 9, 4, 4), null, null,GrayF32.class);
// specify the image to process
surf.detect(image);
System.out.println("Found Features: "+surf.getNumberOfFeatures());
System.out.println("First descriptor's first value: "+surf.getDescription(0).value[0]);
} | java | public static void easy( GrayF32 image ) {
// create the detector and descriptors
DetectDescribePoint<GrayF32,BrightFeature> surf = FactoryDetectDescribe.
surfStable(new ConfigFastHessian(0, 2, 200, 2, 9, 4, 4), null, null,GrayF32.class);
// specify the image to process
surf.detect(image);
System.out.println("Found Features: "+surf.getNumberOfFeatures());
System.out.println("First descriptor's first value: "+surf.getDescription(0).value[0]);
} | [
"public",
"static",
"void",
"easy",
"(",
"GrayF32",
"image",
")",
"{",
"// create the detector and descriptors",
"DetectDescribePoint",
"<",
"GrayF32",
",",
"BrightFeature",
">",
"surf",
"=",
"FactoryDetectDescribe",
".",
"surfStable",
"(",
"new",
"ConfigFastHessian",
... | Use generalized interfaces for working with SURF. This removes much of the drudgery, but also reduces flexibility
and slightly increases memory and computational requirements.
@param image Input image type. DOES NOT NEED TO BE GrayF32, GrayU8 works too | [
"Use",
"generalized",
"interfaces",
"for",
"working",
"with",
"SURF",
".",
"This",
"removes",
"much",
"of",
"the",
"drudgery",
"but",
"also",
"reduces",
"flexibility",
"and",
"slightly",
"increases",
"memory",
"and",
"computational",
"requirements",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleFeatureSurf.java#L59-L69 | train |
lessthanoptimal/BoofCV | examples/src/main/java/boofcv/examples/features/ExampleFeatureSurf.java | ExampleFeatureSurf.harder | public static <II extends ImageGray<II>> void harder(GrayF32 image ) {
// SURF works off of integral images
Class<II> integralType = GIntegralImageOps.getIntegralType(GrayF32.class);
// define the feature detection algorithm
NonMaxSuppression extractor =
FactoryFeatureExtractor.nonmax(new ConfigExtract(2, 0, 5, true));
FastHessianFeatureDetector<II> detector =
new FastHessianFeatureDetector<>(extractor, 200, 2, 9, 4, 4, 6);
// estimate orientation
OrientationIntegral<II> orientation =
FactoryOrientationAlgs.sliding_ii(null, integralType);
DescribePointSurf<II> descriptor = FactoryDescribePointAlgs.<II>surfStability(null,integralType);
// compute the integral image of 'image'
II integral = GeneralizedImageOps.createSingleBand(integralType,image.width,image.height);
GIntegralImageOps.transform(image, integral);
// detect fast hessian features
detector.detect(integral);
// tell algorithms which image to process
orientation.setImage(integral);
descriptor.setImage(integral);
List<ScalePoint> points = detector.getFoundPoints();
List<BrightFeature> descriptions = new ArrayList<>();
for( ScalePoint p : points ) {
// estimate orientation
orientation.setObjectRadius( p.scale*BoofDefaults.SURF_SCALE_TO_RADIUS);
double angle = orientation.compute(p.x,p.y);
// extract the SURF description for this region
BrightFeature desc = descriptor.createDescription();
descriptor.describe(p.x,p.y,angle,p.scale,desc);
// save everything for processing later on
descriptions.add(desc);
}
System.out.println("Found Features: "+points.size());
System.out.println("First descriptor's first value: "+descriptions.get(0).value[0]);
} | java | public static <II extends ImageGray<II>> void harder(GrayF32 image ) {
// SURF works off of integral images
Class<II> integralType = GIntegralImageOps.getIntegralType(GrayF32.class);
// define the feature detection algorithm
NonMaxSuppression extractor =
FactoryFeatureExtractor.nonmax(new ConfigExtract(2, 0, 5, true));
FastHessianFeatureDetector<II> detector =
new FastHessianFeatureDetector<>(extractor, 200, 2, 9, 4, 4, 6);
// estimate orientation
OrientationIntegral<II> orientation =
FactoryOrientationAlgs.sliding_ii(null, integralType);
DescribePointSurf<II> descriptor = FactoryDescribePointAlgs.<II>surfStability(null,integralType);
// compute the integral image of 'image'
II integral = GeneralizedImageOps.createSingleBand(integralType,image.width,image.height);
GIntegralImageOps.transform(image, integral);
// detect fast hessian features
detector.detect(integral);
// tell algorithms which image to process
orientation.setImage(integral);
descriptor.setImage(integral);
List<ScalePoint> points = detector.getFoundPoints();
List<BrightFeature> descriptions = new ArrayList<>();
for( ScalePoint p : points ) {
// estimate orientation
orientation.setObjectRadius( p.scale*BoofDefaults.SURF_SCALE_TO_RADIUS);
double angle = orientation.compute(p.x,p.y);
// extract the SURF description for this region
BrightFeature desc = descriptor.createDescription();
descriptor.describe(p.x,p.y,angle,p.scale,desc);
// save everything for processing later on
descriptions.add(desc);
}
System.out.println("Found Features: "+points.size());
System.out.println("First descriptor's first value: "+descriptions.get(0).value[0]);
} | [
"public",
"static",
"<",
"II",
"extends",
"ImageGray",
"<",
"II",
">",
">",
"void",
"harder",
"(",
"GrayF32",
"image",
")",
"{",
"// SURF works off of integral images",
"Class",
"<",
"II",
">",
"integralType",
"=",
"GIntegralImageOps",
".",
"getIntegralType",
"(... | Configured exactly the same as the easy example above, but require a lot more code and a more in depth
understanding of how SURF works and is configured. Instead of TupleDesc_F64, SurfFeature are computed in
this case. They are almost the same as TupleDesc_F64, but contain the Laplacian's sign which can be used
to speed up association. That is an example of how using less generalized interfaces can improve performance.
@param image Input image type. DOES NOT NEED TO BE GrayF32, GrayU8 works too | [
"Configured",
"exactly",
"the",
"same",
"as",
"the",
"easy",
"example",
"above",
"but",
"require",
"a",
"lot",
"more",
"code",
"and",
"a",
"more",
"in",
"depth",
"understanding",
"of",
"how",
"SURF",
"works",
"and",
"is",
"configured",
".",
"Instead",
"of"... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/examples/src/main/java/boofcv/examples/features/ExampleFeatureSurf.java#L79-L124 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundModelMoving.java | BackgroundModelMoving.updateBackground | public void updateBackground(MotionModel homeToCurrent, T frame) {
worldToHome.concat(homeToCurrent, worldToCurrent);
worldToCurrent.invert(currentToWorld);
// find the distorted polygon of the current image in the "home" background reference frame
transform.setModel(currentToWorld);
transform.compute(0, 0, corners[0]);
transform.compute(frame.width-1,0,corners[1]);
transform.compute(frame.width-1,frame.height-1,corners[2]);
transform.compute(0, frame.height-1, corners[3]);
// find the bounding box
int x0 = Integer.MAX_VALUE;
int y0 = Integer.MAX_VALUE;
int x1 = -Integer.MAX_VALUE;
int y1 = -Integer.MAX_VALUE;
for (int i = 0; i < 4; i++) {
Point2D_F32 p = corners[i];
int x = (int)p.x;
int y = (int)p.y;
if( x0 > x ) x0 = x;
if( y0 > y ) y0 = y;
if( x1 < x ) x1 = x;
if( y1 < y ) y1 = y;
}
x1++;y1++;
if( x0 < 0 ) x0 = 0;
if( x1 > backgroundWidth ) x1 = backgroundWidth;
if( y0 < 0 ) y0 = 0;
if( y1 > backgroundHeight ) y1 = backgroundHeight;
updateBackground(x0,y0,x1,y1,frame);
} | java | public void updateBackground(MotionModel homeToCurrent, T frame) {
worldToHome.concat(homeToCurrent, worldToCurrent);
worldToCurrent.invert(currentToWorld);
// find the distorted polygon of the current image in the "home" background reference frame
transform.setModel(currentToWorld);
transform.compute(0, 0, corners[0]);
transform.compute(frame.width-1,0,corners[1]);
transform.compute(frame.width-1,frame.height-1,corners[2]);
transform.compute(0, frame.height-1, corners[3]);
// find the bounding box
int x0 = Integer.MAX_VALUE;
int y0 = Integer.MAX_VALUE;
int x1 = -Integer.MAX_VALUE;
int y1 = -Integer.MAX_VALUE;
for (int i = 0; i < 4; i++) {
Point2D_F32 p = corners[i];
int x = (int)p.x;
int y = (int)p.y;
if( x0 > x ) x0 = x;
if( y0 > y ) y0 = y;
if( x1 < x ) x1 = x;
if( y1 < y ) y1 = y;
}
x1++;y1++;
if( x0 < 0 ) x0 = 0;
if( x1 > backgroundWidth ) x1 = backgroundWidth;
if( y0 < 0 ) y0 = 0;
if( y1 > backgroundHeight ) y1 = backgroundHeight;
updateBackground(x0,y0,x1,y1,frame);
} | [
"public",
"void",
"updateBackground",
"(",
"MotionModel",
"homeToCurrent",
",",
"T",
"frame",
")",
"{",
"worldToHome",
".",
"concat",
"(",
"homeToCurrent",
",",
"worldToCurrent",
")",
";",
"worldToCurrent",
".",
"invert",
"(",
"currentToWorld",
")",
";",
"// fin... | Updates the background with new image information.
@param homeToCurrent Transform from home image to the current image
@param frame The current image in the sequence | [
"Updates",
"the",
"background",
"with",
"new",
"image",
"information",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundModelMoving.java#L115-L150 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundModelMoving.java | BackgroundModelMoving.segment | public void segment( MotionModel homeToCurrent , T frame , GrayU8 segmented ) {
InputSanityCheck.checkSameShape(frame,segmented);
worldToHome.concat(homeToCurrent, worldToCurrent);
worldToCurrent.invert(currentToWorld);
_segment(currentToWorld,frame,segmented);
} | java | public void segment( MotionModel homeToCurrent , T frame , GrayU8 segmented ) {
InputSanityCheck.checkSameShape(frame,segmented);
worldToHome.concat(homeToCurrent, worldToCurrent);
worldToCurrent.invert(currentToWorld);
_segment(currentToWorld,frame,segmented);
} | [
"public",
"void",
"segment",
"(",
"MotionModel",
"homeToCurrent",
",",
"T",
"frame",
",",
"GrayU8",
"segmented",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"frame",
",",
"segmented",
")",
";",
"worldToHome",
".",
"concat",
"(",
"homeToCurrent",
... | Invoke to use the background image to segment the current frame into background and foreground pixels
@param homeToCurrent Transform from home image to the current image
@param frame current image
@param segmented Segmented image. 0 = background, 1 = foreground/moving | [
"Invoke",
"to",
"use",
"the",
"background",
"image",
"to",
"segment",
"the",
"current",
"frame",
"into",
"background",
"and",
"foreground",
"pixels"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundModelMoving.java#L165-L172 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/AdjustPolygonForThresholdBias.java | AdjustPolygonForThresholdBias.process | public void process( Polygon2D_F64 polygon, boolean clockwise) {
int N = polygon.size();
segments.resize(N);
// Apply the adjustment independently to each side
for (int i = N - 1, j = 0; j < N; i = j, j++) {
int ii,jj;
if( clockwise ) {
ii = i; jj = j;
} else {
ii = j; jj = i;
}
Point2D_F64 a = polygon.get(ii), b = polygon.get(jj);
double dx = b.x - a.x;
double dy = b.y - a.y;
double l = Math.sqrt(dx * dx + dy * dy);
if( l == 0) {
throw new RuntimeException("Two identical corners!");
}
// only needs to be shifted in two directions
if( dx < 0 )
dx = 0;
if( dy > 0 )
dy = 0;
LineSegment2D_F64 s = segments.get(ii);
s.a.x = a.x - dy/l;
s.a.y = a.y + dx/l;
s.b.x = b.x - dy/l;
s.b.y = b.y + dx/l;
}
// Find the intersection between the adjusted lines to convert it back into polygon format
for (int i = N - 1, j = 0; j < N; i = j, j++) {
int ii,jj;
if( clockwise ) {
ii = i; jj = j;
} else {
ii = j; jj = i;
}
UtilLine2D_F64.convert(segments.get(ii),ga);
UtilLine2D_F64.convert(segments.get(jj),gb);
if( null != Intersection2D_F64.intersection(ga,gb,intersection)) {
// very acute angles can cause a large delta. This is conservative and prevents that
if( intersection.distance2(polygon.get(jj)) < 20 ) {
polygon.get(jj).set(intersection);
}
}
}
// if two corners have a distance of 1 there are some conditions which exist where the corners can be shifted
// such that two points will now be equal. Avoiding the shift isn't a good idea shift the shift should happen
// there might be a more elegant solution to this problem but this is probably the simplest
UtilPolygons2D_F64.removeAdjacentDuplicates(polygon,1e-8);
} | java | public void process( Polygon2D_F64 polygon, boolean clockwise) {
int N = polygon.size();
segments.resize(N);
// Apply the adjustment independently to each side
for (int i = N - 1, j = 0; j < N; i = j, j++) {
int ii,jj;
if( clockwise ) {
ii = i; jj = j;
} else {
ii = j; jj = i;
}
Point2D_F64 a = polygon.get(ii), b = polygon.get(jj);
double dx = b.x - a.x;
double dy = b.y - a.y;
double l = Math.sqrt(dx * dx + dy * dy);
if( l == 0) {
throw new RuntimeException("Two identical corners!");
}
// only needs to be shifted in two directions
if( dx < 0 )
dx = 0;
if( dy > 0 )
dy = 0;
LineSegment2D_F64 s = segments.get(ii);
s.a.x = a.x - dy/l;
s.a.y = a.y + dx/l;
s.b.x = b.x - dy/l;
s.b.y = b.y + dx/l;
}
// Find the intersection between the adjusted lines to convert it back into polygon format
for (int i = N - 1, j = 0; j < N; i = j, j++) {
int ii,jj;
if( clockwise ) {
ii = i; jj = j;
} else {
ii = j; jj = i;
}
UtilLine2D_F64.convert(segments.get(ii),ga);
UtilLine2D_F64.convert(segments.get(jj),gb);
if( null != Intersection2D_F64.intersection(ga,gb,intersection)) {
// very acute angles can cause a large delta. This is conservative and prevents that
if( intersection.distance2(polygon.get(jj)) < 20 ) {
polygon.get(jj).set(intersection);
}
}
}
// if two corners have a distance of 1 there are some conditions which exist where the corners can be shifted
// such that two points will now be equal. Avoiding the shift isn't a good idea shift the shift should happen
// there might be a more elegant solution to this problem but this is probably the simplest
UtilPolygons2D_F64.removeAdjacentDuplicates(polygon,1e-8);
} | [
"public",
"void",
"process",
"(",
"Polygon2D_F64",
"polygon",
",",
"boolean",
"clockwise",
")",
"{",
"int",
"N",
"=",
"polygon",
".",
"size",
"(",
")",
";",
"segments",
".",
"resize",
"(",
"N",
")",
";",
"// Apply the adjustment independently to each side",
"f... | Processes and adjusts the polygon. If after adjustment a corner needs to be removed because two sides are
parallel then the size of the polygon can be changed.
@param polygon The polygon that is to be adjusted. Modified.
@param clockwise Is the polygon in a lockwise orientation? | [
"Processes",
"and",
"adjusts",
"the",
"polygon",
".",
"If",
"after",
"adjustment",
"a",
"corner",
"needs",
"to",
"be",
"removed",
"because",
"two",
"sides",
"are",
"parallel",
"then",
"the",
"size",
"of",
"the",
"polygon",
"can",
"be",
"changed",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/shapes/polygon/AdjustPolygonForThresholdBias.java#L51-L111 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java | DetectCircleGrid.closestCorner4 | static int closestCorner4(Grid g ) {
double bestDistance = g.get(0,0).center.normSq();
int bestIdx = 0;
double d = g.get(0,g.columns-1).center.normSq();
if( d < bestDistance ) {
bestDistance = d;
bestIdx = 3;
}
d = g.get(g.rows-1,g.columns-1).center.normSq();
if( d < bestDistance ) {
bestDistance = d;
bestIdx = 2;
}
d = g.get(g.rows-1,0).center.normSq();
if( d < bestDistance ) {
bestIdx = 1;
}
return bestIdx;
} | java | static int closestCorner4(Grid g ) {
double bestDistance = g.get(0,0).center.normSq();
int bestIdx = 0;
double d = g.get(0,g.columns-1).center.normSq();
if( d < bestDistance ) {
bestDistance = d;
bestIdx = 3;
}
d = g.get(g.rows-1,g.columns-1).center.normSq();
if( d < bestDistance ) {
bestDistance = d;
bestIdx = 2;
}
d = g.get(g.rows-1,0).center.normSq();
if( d < bestDistance ) {
bestIdx = 1;
}
return bestIdx;
} | [
"static",
"int",
"closestCorner4",
"(",
"Grid",
"g",
")",
"{",
"double",
"bestDistance",
"=",
"g",
".",
"get",
"(",
"0",
",",
"0",
")",
".",
"center",
".",
"normSq",
"(",
")",
";",
"int",
"bestIdx",
"=",
"0",
";",
"double",
"d",
"=",
"g",
".",
... | Number of CCW rotations to put selected corner into the canonical location. Only works
when there are 4 possible solutions
@param g The grid
@return number of rotations | [
"Number",
"of",
"CCW",
"rotations",
"to",
"put",
"selected",
"corner",
"into",
"the",
"canonical",
"location",
".",
"Only",
"works",
"when",
"there",
"are",
"4",
"possible",
"solutions"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java#L159-L179 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java | DetectCircleGrid.rotateGridCCW | void rotateGridCCW( Grid g ) {
work.clear();
for (int i = 0; i < g.rows * g.columns; i++) {
work.add(null);
}
for (int row = 0; row < g.rows; row++) {
for (int col = 0; col < g.columns; col++) {
work.set(col*g.rows + row, g.get(g.rows - row - 1,col));
}
}
g.ellipses.clear();
g.ellipses.addAll(work);
int tmp = g.columns;
g.columns = g.rows;
g.rows = tmp;
} | java | void rotateGridCCW( Grid g ) {
work.clear();
for (int i = 0; i < g.rows * g.columns; i++) {
work.add(null);
}
for (int row = 0; row < g.rows; row++) {
for (int col = 0; col < g.columns; col++) {
work.set(col*g.rows + row, g.get(g.rows - row - 1,col));
}
}
g.ellipses.clear();
g.ellipses.addAll(work);
int tmp = g.columns;
g.columns = g.rows;
g.rows = tmp;
} | [
"void",
"rotateGridCCW",
"(",
"Grid",
"g",
")",
"{",
"work",
".",
"clear",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"g",
".",
"rows",
"*",
"g",
".",
"columns",
";",
"i",
"++",
")",
"{",
"work",
".",
"add",
"(",
"null"... | performs a counter-clockwise rotation | [
"performs",
"a",
"counter",
"-",
"clockwise",
"rotation"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java#L184-L202 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java | DetectCircleGrid.reverse | void reverse( Grid g ) {
work.clear();
int N = g.rows*g.columns;
for (int i = 0; i < N; i++) {
work.add( g.ellipses.get(N-i-1));
}
g.ellipses.clear();
g.ellipses.addAll(work);
} | java | void reverse( Grid g ) {
work.clear();
int N = g.rows*g.columns;
for (int i = 0; i < N; i++) {
work.add( g.ellipses.get(N-i-1));
}
g.ellipses.clear();
g.ellipses.addAll(work);
} | [
"void",
"reverse",
"(",
"Grid",
"g",
")",
"{",
"work",
".",
"clear",
"(",
")",
";",
"int",
"N",
"=",
"g",
".",
"rows",
"*",
"g",
".",
"columns",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
"++",
")",
"{",
"work",
... | Reverse the order of elements inside the grid | [
"Reverse",
"the",
"order",
"of",
"elements",
"inside",
"the",
"grid"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java#L207-L216 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java | DetectCircleGrid.pruneIncorrectShape | static void pruneIncorrectShape(FastQueue<Grid> grids , int numRows, int numCols ) {
// prune clusters which can't be a member calibration target
for (int i = grids.size()-1; i >= 0; i--) {
Grid g = grids.get(i);
if ((g.rows != numRows || g.columns != numCols) && (g.rows != numCols || g.columns != numRows)) {
grids.remove(i);
}
}
} | java | static void pruneIncorrectShape(FastQueue<Grid> grids , int numRows, int numCols ) {
// prune clusters which can't be a member calibration target
for (int i = grids.size()-1; i >= 0; i--) {
Grid g = grids.get(i);
if ((g.rows != numRows || g.columns != numCols) && (g.rows != numCols || g.columns != numRows)) {
grids.remove(i);
}
}
} | [
"static",
"void",
"pruneIncorrectShape",
"(",
"FastQueue",
"<",
"Grid",
">",
"grids",
",",
"int",
"numRows",
",",
"int",
"numCols",
")",
"{",
"// prune clusters which can't be a member calibration target",
"for",
"(",
"int",
"i",
"=",
"grids",
".",
"size",
"(",
... | Remove grids which cannot possible match the expected shape | [
"Remove",
"grids",
"which",
"cannot",
"possible",
"match",
"the",
"expected",
"shape"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java#L247-L255 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java | DetectCircleGrid.pruneIncorrectSize | static void pruneIncorrectSize(List<List<EllipsesIntoClusters.Node>> clusters, int N) {
// prune clusters which can't be a member calibration target
for (int i = clusters.size()-1; i >= 0; i--) {
if( clusters.get(i).size() != N ) {
clusters.remove(i);
}
}
} | java | static void pruneIncorrectSize(List<List<EllipsesIntoClusters.Node>> clusters, int N) {
// prune clusters which can't be a member calibration target
for (int i = clusters.size()-1; i >= 0; i--) {
if( clusters.get(i).size() != N ) {
clusters.remove(i);
}
}
} | [
"static",
"void",
"pruneIncorrectSize",
"(",
"List",
"<",
"List",
"<",
"EllipsesIntoClusters",
".",
"Node",
">",
">",
"clusters",
",",
"int",
"N",
")",
"{",
"// prune clusters which can't be a member calibration target",
"for",
"(",
"int",
"i",
"=",
"clusters",
".... | Prune clusters which do not have the expected number of elements | [
"Prune",
"clusters",
"which",
"do",
"not",
"have",
"the",
"expected",
"number",
"of",
"elements"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/circle/DetectCircleGrid.java#L260-L267 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardSquarePoints.java | DetectChessboardSquarePoints.process | public boolean process( T input , GrayU8 binary ) {
double maxCornerDistancePixels = maxCornerDistance.computeI(Math.min(input.width,input.height));
s2c.setMaxCornerDistance(maxCornerDistancePixels);
configureContourDetector(input);
boundPolygon.vertexes.reset();
detectorSquare.process(input, binary);
detectorSquare.refineAll();
List<DetectPolygonFromContour.Info> found = detectorSquare.getPolygonInfo();
clusters = s2c.process(found);
c2g.process(clusters);
List<SquareGrid> grids = c2g.getGrids().toList();
for (int i = 0; i < grids.size(); i++) {
SquareGrid grid = grids.get(i);
if( grid.rows == numCols && grid.columns == numRows ) {
tools.transpose(grid);
}
if( grid.rows == numRows && grid.columns == numCols ) {
// this detector requires that the (0,0) grid cell has a square inside of it
if( grid.get(0,0) == null ){
if( grid.get(0,-1) != null ) {
tools.flipColumns(grid);
} else if( grid.get(-1,0) != null ) {
tools.flipRows(grid);
} else {
continue;
}
}
// make sure its in the expected orientation
if( !ensureCCW(grid) )
continue;
// If symmetric, ensure that the (0,0) is closest to top-left image corner
putIntoCanonical(grid);
// now extract the calibration points
return computeCalibrationPoints(grid);
}
}
return false;
} | java | public boolean process( T input , GrayU8 binary ) {
double maxCornerDistancePixels = maxCornerDistance.computeI(Math.min(input.width,input.height));
s2c.setMaxCornerDistance(maxCornerDistancePixels);
configureContourDetector(input);
boundPolygon.vertexes.reset();
detectorSquare.process(input, binary);
detectorSquare.refineAll();
List<DetectPolygonFromContour.Info> found = detectorSquare.getPolygonInfo();
clusters = s2c.process(found);
c2g.process(clusters);
List<SquareGrid> grids = c2g.getGrids().toList();
for (int i = 0; i < grids.size(); i++) {
SquareGrid grid = grids.get(i);
if( grid.rows == numCols && grid.columns == numRows ) {
tools.transpose(grid);
}
if( grid.rows == numRows && grid.columns == numCols ) {
// this detector requires that the (0,0) grid cell has a square inside of it
if( grid.get(0,0) == null ){
if( grid.get(0,-1) != null ) {
tools.flipColumns(grid);
} else if( grid.get(-1,0) != null ) {
tools.flipRows(grid);
} else {
continue;
}
}
// make sure its in the expected orientation
if( !ensureCCW(grid) )
continue;
// If symmetric, ensure that the (0,0) is closest to top-left image corner
putIntoCanonical(grid);
// now extract the calibration points
return computeCalibrationPoints(grid);
}
}
return false;
} | [
"public",
"boolean",
"process",
"(",
"T",
"input",
",",
"GrayU8",
"binary",
")",
"{",
"double",
"maxCornerDistancePixels",
"=",
"maxCornerDistance",
".",
"computeI",
"(",
"Math",
".",
"min",
"(",
"input",
".",
"width",
",",
"input",
".",
"height",
")",
")"... | Detects chessboard in the binary image. Square corners must be disconnected.
Returns true if a chessboard was found, false otherwise.
@param input Original input image.
@param binary Binary image of chessboard
@return True if successful. | [
"Detects",
"chessboard",
"in",
"the",
"binary",
"image",
".",
"Square",
"corners",
"must",
"be",
"disconnected",
".",
"Returns",
"true",
"if",
"a",
"chessboard",
"was",
"found",
"false",
"otherwise",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardSquarePoints.java#L110-L157 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardSquarePoints.java | DetectChessboardSquarePoints.adjustBeforeOptimize | public void adjustBeforeOptimize(Polygon2D_F64 polygon, GrowQueue_B touchesBorder, boolean clockwise) {
int N = polygon.size();
work.vertexes.resize(N);
for (int i = 0; i < N; i++) {
work.get(i).set(0, 0);
}
for (int i = N - 1, j = 0; j < N; i = j, j++) {
int ii,jj,kk,mm;
if( clockwise ) {
mm = CircularIndex.addOffset(-1,i,N);
ii=i;jj=j;
kk = CircularIndex.addOffset(1,j,N);
} else {
mm = CircularIndex.addOffset(1,j,N);
ii=j;jj=i;
kk = CircularIndex.addOffset(-1,i,N);
}
Point2D_F64 a = polygon.get(ii), b = polygon.get(jj);
double dx = b.x - a.x;
double dy = b.y - a.y;
double l = Math.sqrt(dx * dx + dy * dy);
// The input polygon has two identical corners. This is bad. We will just skip over the first corner
if( l == 0 ) {
throw new RuntimeException("Input polygon has two identical corners. You need to fix that.");
}
dx *= 1.5 / l;
dy *= 1.5 / l;
Point2D_F64 _a = work.get(ii);
Point2D_F64 _b = work.get(jj);
// move the point away from the line
if( touchesBorder.size>0 && touchesBorder.get(ii) ) {
if(!touchesBorder.get(mm)) {
_a.x -= dx;
_a.y -= dy;
}
} else {
_a.x += -dy;
_a.y += dx;
}
if( touchesBorder.size>0 && touchesBorder.get(jj) ) {
if( !touchesBorder.get(kk) ) {
_b.x += dx;
_b.y += dy;
}
} else {
_b.x += -dy;
_b.y += dx;
}
}
for (int i = 0; i < N; i++) {
Point2D_F64 a = polygon.get(i);
Point2D_F64 b = work.get(i);
a.x += b.x;
a.y += b.y;
}
} | java | public void adjustBeforeOptimize(Polygon2D_F64 polygon, GrowQueue_B touchesBorder, boolean clockwise) {
int N = polygon.size();
work.vertexes.resize(N);
for (int i = 0; i < N; i++) {
work.get(i).set(0, 0);
}
for (int i = N - 1, j = 0; j < N; i = j, j++) {
int ii,jj,kk,mm;
if( clockwise ) {
mm = CircularIndex.addOffset(-1,i,N);
ii=i;jj=j;
kk = CircularIndex.addOffset(1,j,N);
} else {
mm = CircularIndex.addOffset(1,j,N);
ii=j;jj=i;
kk = CircularIndex.addOffset(-1,i,N);
}
Point2D_F64 a = polygon.get(ii), b = polygon.get(jj);
double dx = b.x - a.x;
double dy = b.y - a.y;
double l = Math.sqrt(dx * dx + dy * dy);
// The input polygon has two identical corners. This is bad. We will just skip over the first corner
if( l == 0 ) {
throw new RuntimeException("Input polygon has two identical corners. You need to fix that.");
}
dx *= 1.5 / l;
dy *= 1.5 / l;
Point2D_F64 _a = work.get(ii);
Point2D_F64 _b = work.get(jj);
// move the point away from the line
if( touchesBorder.size>0 && touchesBorder.get(ii) ) {
if(!touchesBorder.get(mm)) {
_a.x -= dx;
_a.y -= dy;
}
} else {
_a.x += -dy;
_a.y += dx;
}
if( touchesBorder.size>0 && touchesBorder.get(jj) ) {
if( !touchesBorder.get(kk) ) {
_b.x += dx;
_b.y += dy;
}
} else {
_b.x += -dy;
_b.y += dx;
}
}
for (int i = 0; i < N; i++) {
Point2D_F64 a = polygon.get(i);
Point2D_F64 b = work.get(i);
a.x += b.x;
a.y += b.y;
}
} | [
"public",
"void",
"adjustBeforeOptimize",
"(",
"Polygon2D_F64",
"polygon",
",",
"GrowQueue_B",
"touchesBorder",
",",
"boolean",
"clockwise",
")",
"{",
"int",
"N",
"=",
"polygon",
".",
"size",
"(",
")",
";",
"work",
".",
"vertexes",
".",
"resize",
"(",
"N",
... | The polygon detected from the contour is too small because the binary image was eroded. This expand the size
of the polygon so that it fits the image edge better | [
"The",
"polygon",
"detected",
"from",
"the",
"contour",
"is",
"too",
"small",
"because",
"the",
"binary",
"image",
"was",
"eroded",
".",
"This",
"expand",
"the",
"size",
"of",
"the",
"polygon",
"so",
"that",
"it",
"fits",
"the",
"image",
"edge",
"better"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardSquarePoints.java#L176-L240 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardSquarePoints.java | DetectChessboardSquarePoints.computeCalibrationPoints | boolean computeCalibrationPoints(SquareGrid grid) {
calibrationPoints.reset();
for (int row = 0; row < grid.rows-1; row++) {
int offset = row%2;
for (int col = offset; col < grid.columns; col += 2) {
SquareNode a = grid.get(row,col);
if( col > 0 ) {
SquareNode b = grid.get(row+1,col-1);
if( !setIntersection(a,b,calibrationPoints.grow()))
return false;
}
if( col < grid.columns-1) {
SquareNode b = grid.get(row+1,col+1);
if( !setIntersection(a,b,calibrationPoints.grow()))
return false;
}
}
}
return true;
} | java | boolean computeCalibrationPoints(SquareGrid grid) {
calibrationPoints.reset();
for (int row = 0; row < grid.rows-1; row++) {
int offset = row%2;
for (int col = offset; col < grid.columns; col += 2) {
SquareNode a = grid.get(row,col);
if( col > 0 ) {
SquareNode b = grid.get(row+1,col-1);
if( !setIntersection(a,b,calibrationPoints.grow()))
return false;
}
if( col < grid.columns-1) {
SquareNode b = grid.get(row+1,col+1);
if( !setIntersection(a,b,calibrationPoints.grow()))
return false;
}
}
}
return true;
} | [
"boolean",
"computeCalibrationPoints",
"(",
"SquareGrid",
"grid",
")",
"{",
"calibrationPoints",
".",
"reset",
"(",
")",
";",
"for",
"(",
"int",
"row",
"=",
"0",
";",
"row",
"<",
"grid",
".",
"rows",
"-",
"1",
";",
"row",
"++",
")",
"{",
"int",
"offs... | Find inner corner points across the grid. Start from the "top" row and work its way down. Corners
are found by finding the average point between two adjacent corners on adjacent squares. | [
"Find",
"inner",
"corner",
"points",
"across",
"the",
"grid",
".",
"Start",
"from",
"the",
"top",
"row",
"and",
"work",
"its",
"way",
"down",
".",
"Corners",
"are",
"found",
"by",
"finding",
"the",
"average",
"point",
"between",
"two",
"adjacent",
"corners... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/calib/chess/DetectChessboardSquarePoints.java#L327-L350 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/filter/blur/impl/ImplMedianSortNaive.java | ImplMedianSortNaive.process | public static void process(GrayI input, GrayI output, int radius , int[] storage ) {
int w = 2*radius+1;
if( storage == null ) {
storage = new int[ w*w ];
} else if( storage.length < w*w ) {
throw new IllegalArgumentException("'storage' must be at least of length "+(w*w));
}
for( int y = 0; y < input.height; y++ ) {
int minI = y - radius;
int maxI = y + radius+1;
// bound the y-axius inside the image
if( minI < 0 ) minI = 0;
if( maxI > input.height ) maxI = input.height;
for( int x = 0; x < input.width; x++ ) {
int minJ = x - radius;
int maxJ = x + radius+1;
// bound the x-axis to be inside the image
if( minJ < 0 ) minJ = 0;
if( maxJ > input.width ) maxJ = input.width;
int index = 0;
for( int i = minI; i < maxI; i++ ) {
for( int j = minJ; j < maxJ; j++ ) {
storage[index++] = input.get(j,i);
}
}
// use quick select to avoid sorting the whole list
int median = QuickSelect.select(storage, index / 2, index);
output.set(x,y, median );
}
}
} | java | public static void process(GrayI input, GrayI output, int radius , int[] storage ) {
int w = 2*radius+1;
if( storage == null ) {
storage = new int[ w*w ];
} else if( storage.length < w*w ) {
throw new IllegalArgumentException("'storage' must be at least of length "+(w*w));
}
for( int y = 0; y < input.height; y++ ) {
int minI = y - radius;
int maxI = y + radius+1;
// bound the y-axius inside the image
if( minI < 0 ) minI = 0;
if( maxI > input.height ) maxI = input.height;
for( int x = 0; x < input.width; x++ ) {
int minJ = x - radius;
int maxJ = x + radius+1;
// bound the x-axis to be inside the image
if( minJ < 0 ) minJ = 0;
if( maxJ > input.width ) maxJ = input.width;
int index = 0;
for( int i = minI; i < maxI; i++ ) {
for( int j = minJ; j < maxJ; j++ ) {
storage[index++] = input.get(j,i);
}
}
// use quick select to avoid sorting the whole list
int median = QuickSelect.select(storage, index / 2, index);
output.set(x,y, median );
}
}
} | [
"public",
"static",
"void",
"process",
"(",
"GrayI",
"input",
",",
"GrayI",
"output",
",",
"int",
"radius",
",",
"int",
"[",
"]",
"storage",
")",
"{",
"int",
"w",
"=",
"2",
"*",
"radius",
"+",
"1",
";",
"if",
"(",
"storage",
"==",
"null",
")",
"{... | Performs a median filter.
@param input Raw input image.
@param output Filtered image.
@param radius Size of the filter's region.
@param storage Array used for storage. If null a new array is declared internally. | [
"Performs",
"a",
"median",
"filter",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/blur/impl/ImplMedianSortNaive.java#L49-L87 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java | FactoryPointTracker.dda_ST_BRIEF | public static <I extends ImageGray<I>, D extends ImageGray<D>>
PointTracker<I> dda_ST_BRIEF(int maxAssociationError,
ConfigGeneralDetector configExtract,
Class<I> imageType, Class<D> derivType)
{
if( derivType == null )
derivType = GImageDerivativeOps.getDerivativeType(imageType);
DescribePointBrief<I> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512),
FactoryBlurFilter.gaussian(ImageType.single(imageType), 0, 4));
GeneralFeatureDetector<I, D> detectPoint = createShiTomasi(configExtract, derivType);
EasyGeneralFeatureDetector<I,D> easy = new EasyGeneralFeatureDetector<>(detectPoint, imageType, derivType);
ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
AssociateDescription2D<TupleDesc_B> association =
new AssociateDescTo2D<>(FactoryAssociation.greedy(score, maxAssociationError, true));
DdaManagerGeneralPoint<I,D,TupleDesc_B> manager =
new DdaManagerGeneralPoint<>(easy, new WrapDescribeBrief<>(brief, imageType), 1.0);
return new DetectDescribeAssociate<>(manager, association, new ConfigTrackerDda());
} | java | public static <I extends ImageGray<I>, D extends ImageGray<D>>
PointTracker<I> dda_ST_BRIEF(int maxAssociationError,
ConfigGeneralDetector configExtract,
Class<I> imageType, Class<D> derivType)
{
if( derivType == null )
derivType = GImageDerivativeOps.getDerivativeType(imageType);
DescribePointBrief<I> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512),
FactoryBlurFilter.gaussian(ImageType.single(imageType), 0, 4));
GeneralFeatureDetector<I, D> detectPoint = createShiTomasi(configExtract, derivType);
EasyGeneralFeatureDetector<I,D> easy = new EasyGeneralFeatureDetector<>(detectPoint, imageType, derivType);
ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
AssociateDescription2D<TupleDesc_B> association =
new AssociateDescTo2D<>(FactoryAssociation.greedy(score, maxAssociationError, true));
DdaManagerGeneralPoint<I,D,TupleDesc_B> manager =
new DdaManagerGeneralPoint<>(easy, new WrapDescribeBrief<>(brief, imageType), 1.0);
return new DetectDescribeAssociate<>(manager, association, new ConfigTrackerDda());
} | [
"public",
"static",
"<",
"I",
"extends",
"ImageGray",
"<",
"I",
">",
",",
"D",
"extends",
"ImageGray",
"<",
"D",
">",
">",
"PointTracker",
"<",
"I",
">",
"dda_ST_BRIEF",
"(",
"int",
"maxAssociationError",
",",
"ConfigGeneralDetector",
"configExtract",
",",
"... | Creates a tracker which detects Shi-Tomasi corner features and describes them with BRIEF.
@see ShiTomasiCornerIntensity
@see DescribePointBrief
@see boofcv.abst.feature.tracker.DdaManagerDetectDescribePoint
@param maxAssociationError Maximum allowed association error. Try 200.
@param configExtract Configuration for extracting features
@param imageType Type of image being processed.
@param derivType Type of image used to store the image derivative. null == use default | [
"Creates",
"a",
"tracker",
"which",
"detects",
"Shi",
"-",
"Tomasi",
"corner",
"features",
"and",
"describes",
"them",
"with",
"BRIEF",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java#L229-L252 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java | FactoryPointTracker.dda_FAST_BRIEF | public static <I extends ImageGray<I>, D extends ImageGray<D>>
PointTracker<I> dda_FAST_BRIEF(ConfigFastCorner configFast,
ConfigGeneralDetector configExtract,
int maxAssociationError,
Class<I> imageType )
{
DescribePointBrief<I> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512),
FactoryBlurFilter.gaussian(ImageType.single(imageType), 0, 4));
GeneralFeatureDetector<I,D> corner = FactoryDetectPoint.createFast(configFast, configExtract, imageType);
EasyGeneralFeatureDetector<I,D> easy = new EasyGeneralFeatureDetector<>(corner, imageType, null);
ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
AssociateDescription2D<TupleDesc_B> association =
new AssociateDescTo2D<>(
FactoryAssociation.greedy(score, maxAssociationError, true));
DdaManagerGeneralPoint<I,D,TupleDesc_B> manager =
new DdaManagerGeneralPoint<>(easy, new WrapDescribeBrief<>(brief, imageType), 1.0);
return new DetectDescribeAssociate<>(manager, association, new ConfigTrackerDda());
} | java | public static <I extends ImageGray<I>, D extends ImageGray<D>>
PointTracker<I> dda_FAST_BRIEF(ConfigFastCorner configFast,
ConfigGeneralDetector configExtract,
int maxAssociationError,
Class<I> imageType )
{
DescribePointBrief<I> brief = FactoryDescribePointAlgs.brief(FactoryBriefDefinition.gaussian2(new Random(123), 16, 512),
FactoryBlurFilter.gaussian(ImageType.single(imageType), 0, 4));
GeneralFeatureDetector<I,D> corner = FactoryDetectPoint.createFast(configFast, configExtract, imageType);
EasyGeneralFeatureDetector<I,D> easy = new EasyGeneralFeatureDetector<>(corner, imageType, null);
ScoreAssociateHamming_B score = new ScoreAssociateHamming_B();
AssociateDescription2D<TupleDesc_B> association =
new AssociateDescTo2D<>(
FactoryAssociation.greedy(score, maxAssociationError, true));
DdaManagerGeneralPoint<I,D,TupleDesc_B> manager =
new DdaManagerGeneralPoint<>(easy, new WrapDescribeBrief<>(brief, imageType), 1.0);
return new DetectDescribeAssociate<>(manager, association, new ConfigTrackerDda());
} | [
"public",
"static",
"<",
"I",
"extends",
"ImageGray",
"<",
"I",
">",
",",
"D",
"extends",
"ImageGray",
"<",
"D",
">",
">",
"PointTracker",
"<",
"I",
">",
"dda_FAST_BRIEF",
"(",
"ConfigFastCorner",
"configFast",
",",
"ConfigGeneralDetector",
"configExtract",
",... | Creates a tracker which detects FAST corner features and describes them with BRIEF.
@see FastCornerDetector
@see DescribePointBrief
@see boofcv.abst.feature.tracker.DdaManagerDetectDescribePoint
@param configFast Configuration for FAST detector
@param configExtract Configuration for extracting features
@param maxAssociationError Maximum allowed association error. Try 200.
@param imageType Type of image being processed. | [
"Creates",
"a",
"tracker",
"which",
"detects",
"FAST",
"corner",
"features",
"and",
"describes",
"them",
"with",
"BRIEF",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java#L266-L288 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java | FactoryPointTracker.dda | public static <I extends ImageGray<I>, Desc extends TupleDesc>
DetectDescribeAssociate<I,Desc> dda(InterestPointDetector<I> detector,
OrientationImage<I> orientation ,
DescribeRegionPoint<I, Desc> describe,
AssociateDescription2D<Desc> associate ,
ConfigTrackerDda config ) {
DetectDescribeFusion<I,Desc> fused =
new DetectDescribeFusion<>(detector, orientation, describe);
DdaManagerDetectDescribePoint<I,Desc> manager =
new DdaManagerDetectDescribePoint<>(fused);
DetectDescribeAssociate<I,Desc> dat =
new DetectDescribeAssociate<>(manager, associate, config);
return dat;
} | java | public static <I extends ImageGray<I>, Desc extends TupleDesc>
DetectDescribeAssociate<I,Desc> dda(InterestPointDetector<I> detector,
OrientationImage<I> orientation ,
DescribeRegionPoint<I, Desc> describe,
AssociateDescription2D<Desc> associate ,
ConfigTrackerDda config ) {
DetectDescribeFusion<I,Desc> fused =
new DetectDescribeFusion<>(detector, orientation, describe);
DdaManagerDetectDescribePoint<I,Desc> manager =
new DdaManagerDetectDescribePoint<>(fused);
DetectDescribeAssociate<I,Desc> dat =
new DetectDescribeAssociate<>(manager, associate, config);
return dat;
} | [
"public",
"static",
"<",
"I",
"extends",
"ImageGray",
"<",
"I",
">",
",",
"Desc",
"extends",
"TupleDesc",
">",
"DetectDescribeAssociate",
"<",
"I",
",",
"Desc",
">",
"dda",
"(",
"InterestPointDetector",
"<",
"I",
">",
"detector",
",",
"OrientationImage",
"<"... | Creates a tracker which uses the detect, describe, associate architecture.
@param detector Interest point detector.
@param orientation Optional orientation estimation algorithm. Can be null.
@param describe Region description.
@param associate Description association.
@param config Configuration
@param <I> Type of input image.
@param <Desc> Type of region description
@return tracker | [
"Creates",
"a",
"tracker",
"which",
"uses",
"the",
"detect",
"describe",
"associate",
"architecture",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java#L339-L356 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java | FactoryPointTracker.combined_FH_SURF_KLT | public static <I extends ImageGray<I>>
PointTracker<I> combined_FH_SURF_KLT( PkltConfig kltConfig ,
int reactivateThreshold ,
ConfigFastHessian configDetector ,
ConfigSurfDescribe.Stability configDescribe ,
ConfigSlidingIntegral configOrientation ,
Class<I> imageType) {
ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
AssociateSurfBasic assoc = new AssociateSurfBasic(FactoryAssociation.greedy(score, 100000, true));
AssociateDescription<BrightFeature> generalAssoc = new WrapAssociateSurfBasic(assoc);
DetectDescribePoint<I,BrightFeature> fused =
FactoryDetectDescribe.surfStable(configDetector, configDescribe, configOrientation,imageType);
return combined(fused,generalAssoc, kltConfig,reactivateThreshold, imageType);
} | java | public static <I extends ImageGray<I>>
PointTracker<I> combined_FH_SURF_KLT( PkltConfig kltConfig ,
int reactivateThreshold ,
ConfigFastHessian configDetector ,
ConfigSurfDescribe.Stability configDescribe ,
ConfigSlidingIntegral configOrientation ,
Class<I> imageType) {
ScoreAssociation<TupleDesc_F64> score = FactoryAssociation.defaultScore(TupleDesc_F64.class);
AssociateSurfBasic assoc = new AssociateSurfBasic(FactoryAssociation.greedy(score, 100000, true));
AssociateDescription<BrightFeature> generalAssoc = new WrapAssociateSurfBasic(assoc);
DetectDescribePoint<I,BrightFeature> fused =
FactoryDetectDescribe.surfStable(configDetector, configDescribe, configOrientation,imageType);
return combined(fused,generalAssoc, kltConfig,reactivateThreshold, imageType);
} | [
"public",
"static",
"<",
"I",
"extends",
"ImageGray",
"<",
"I",
">",
">",
"PointTracker",
"<",
"I",
">",
"combined_FH_SURF_KLT",
"(",
"PkltConfig",
"kltConfig",
",",
"int",
"reactivateThreshold",
",",
"ConfigFastHessian",
"configDetector",
",",
"ConfigSurfDescribe",... | Creates a tracker which detects Fast-Hessian features, describes them with SURF, nominally tracks them using KLT.
@see DescribePointSurf
@see boofcv.abst.feature.tracker.DdaManagerDetectDescribePoint
@param kltConfig Configuration for KLT tracker
@param reactivateThreshold Tracks are reactivated after this many have been dropped. Try 10% of maxMatches
@param configDetector Configuration for SURF detector
@param configDescribe Configuration for SURF descriptor
@param configOrientation Configuration for region orientation
@param imageType Type of image the input is.
@param <I> Input image type.
@return SURF based tracker. | [
"Creates",
"a",
"tracker",
"which",
"detects",
"Fast",
"-",
"Hessian",
"features",
"describes",
"them",
"with",
"SURF",
"nominally",
"tracks",
"them",
"using",
"KLT",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java#L387-L404 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java | FactoryPointTracker.createShiTomasi | public static <I extends ImageGray<I>, D extends ImageGray<D>>
GeneralFeatureDetector<I, D> createShiTomasi(ConfigGeneralDetector config ,
Class<D> derivType)
{
GradientCornerIntensity<D> cornerIntensity = FactoryIntensityPointAlg.shiTomasi(1, false, derivType);
return FactoryDetectPoint.createGeneral(cornerIntensity, config );
} | java | public static <I extends ImageGray<I>, D extends ImageGray<D>>
GeneralFeatureDetector<I, D> createShiTomasi(ConfigGeneralDetector config ,
Class<D> derivType)
{
GradientCornerIntensity<D> cornerIntensity = FactoryIntensityPointAlg.shiTomasi(1, false, derivType);
return FactoryDetectPoint.createGeneral(cornerIntensity, config );
} | [
"public",
"static",
"<",
"I",
"extends",
"ImageGray",
"<",
"I",
">",
",",
"D",
"extends",
"ImageGray",
"<",
"D",
">",
">",
"GeneralFeatureDetector",
"<",
"I",
",",
"D",
">",
"createShiTomasi",
"(",
"ConfigGeneralDetector",
"config",
",",
"Class",
"<",
"D",... | Creates a Shi-Tomasi corner detector specifically designed for SFM. Smaller feature radius work better.
Variable detectRadius to control the number of features. When larger features are used weighting should
be set to true, but because this is so small, it is set to false | [
"Creates",
"a",
"Shi",
"-",
"Tomasi",
"corner",
"detector",
"specifically",
"designed",
"for",
"SFM",
".",
"Smaller",
"feature",
"radius",
"work",
"better",
".",
"Variable",
"detectRadius",
"to",
"control",
"the",
"number",
"of",
"features",
".",
"When",
"larg... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/feature/tracker/FactoryPointTracker.java#L534-L541 | train |
lessthanoptimal/BoofCV | applications/src/main/java/boofcv/app/CameraCalibration.java | CameraCalibration.handleWebcam | public void handleWebcam() {
final Webcam webcam = openSelectedCamera();
if( desiredWidth > 0 && desiredHeight > 0 )
UtilWebcamCapture.adjustResolution(webcam, desiredWidth, desiredHeight);
webcam.open();
// close the webcam gracefully on exit
Runtime.getRuntime().addShutdownHook(new Thread(){public void run(){
if(webcam.isOpen()){System.out.println("Closing webcam");webcam.close();}}});
ComputeGeometryScore quality = new ComputeGeometryScore(zeroSkew,detector.getLayout());
AssistedCalibrationGui gui = new AssistedCalibrationGui(webcam.getViewSize());
JFrame frame = ShowImages.showWindow(gui, "Webcam Calibration", true);
GrayF32 gray = new GrayF32(webcam.getViewSize().width,webcam.getViewSize().height);
if( desiredWidth > 0 && desiredHeight > 0 ) {
if (gray.width != desiredWidth || gray.height != desiredHeight )
System.err.println("Actual camera resolution does not match desired. Actual: "+gray.width+" "+gray.height+
" Desired: "+desiredWidth+" "+desiredHeight);
}
AssistedCalibration assisted = new AssistedCalibration(detector,quality,gui,OUTPUT_DIRECTORY, IMAGE_DIRECTORY);
assisted.init(gray.width,gray.height);
BufferedImage image;
while( (image = webcam.getImage()) != null && !assisted.isFinished()) {
ConvertBufferedImage.convertFrom(image, gray);
try {
assisted.process(gray,image);
} catch( RuntimeException e ) {
System.err.println("BUG!!! saving image to crash_image.png");
UtilImageIO.saveImage(image, "crash_image.png");
throw e;
}
}
webcam.close();
if( assisted.isFinished() ) {
frame.setVisible(false);
inputDirectory = new File(OUTPUT_DIRECTORY, IMAGE_DIRECTORY).getPath();
outputFileName = new File(OUTPUT_DIRECTORY, "intrinsic.yaml").getPath();
handleDirectory();
}
} | java | public void handleWebcam() {
final Webcam webcam = openSelectedCamera();
if( desiredWidth > 0 && desiredHeight > 0 )
UtilWebcamCapture.adjustResolution(webcam, desiredWidth, desiredHeight);
webcam.open();
// close the webcam gracefully on exit
Runtime.getRuntime().addShutdownHook(new Thread(){public void run(){
if(webcam.isOpen()){System.out.println("Closing webcam");webcam.close();}}});
ComputeGeometryScore quality = new ComputeGeometryScore(zeroSkew,detector.getLayout());
AssistedCalibrationGui gui = new AssistedCalibrationGui(webcam.getViewSize());
JFrame frame = ShowImages.showWindow(gui, "Webcam Calibration", true);
GrayF32 gray = new GrayF32(webcam.getViewSize().width,webcam.getViewSize().height);
if( desiredWidth > 0 && desiredHeight > 0 ) {
if (gray.width != desiredWidth || gray.height != desiredHeight )
System.err.println("Actual camera resolution does not match desired. Actual: "+gray.width+" "+gray.height+
" Desired: "+desiredWidth+" "+desiredHeight);
}
AssistedCalibration assisted = new AssistedCalibration(detector,quality,gui,OUTPUT_DIRECTORY, IMAGE_DIRECTORY);
assisted.init(gray.width,gray.height);
BufferedImage image;
while( (image = webcam.getImage()) != null && !assisted.isFinished()) {
ConvertBufferedImage.convertFrom(image, gray);
try {
assisted.process(gray,image);
} catch( RuntimeException e ) {
System.err.println("BUG!!! saving image to crash_image.png");
UtilImageIO.saveImage(image, "crash_image.png");
throw e;
}
}
webcam.close();
if( assisted.isFinished() ) {
frame.setVisible(false);
inputDirectory = new File(OUTPUT_DIRECTORY, IMAGE_DIRECTORY).getPath();
outputFileName = new File(OUTPUT_DIRECTORY, "intrinsic.yaml").getPath();
handleDirectory();
}
} | [
"public",
"void",
"handleWebcam",
"(",
")",
"{",
"final",
"Webcam",
"webcam",
"=",
"openSelectedCamera",
"(",
")",
";",
"if",
"(",
"desiredWidth",
">",
"0",
"&&",
"desiredHeight",
">",
"0",
")",
"UtilWebcamCapture",
".",
"adjustResolution",
"(",
"webcam",
",... | Captures calibration data live using a webcam and a GUI to assist the user | [
"Captures",
"calibration",
"data",
"live",
"using",
"a",
"webcam",
"and",
"a",
"GUI",
"to",
"assist",
"the",
"user"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/CameraCalibration.java#L535-L581 | train |
lessthanoptimal/BoofCV | applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java | ImageSelectorAndSaver.setTemplate | public void setTemplate(GrayF32 image, List<Point2D_F64> sides) {
if( sides.size() != 4 )
throw new IllegalArgumentException("Expected 4 sidesCollision");
removePerspective.apply(image,sides.get(0),sides.get(1),sides.get(2),sides.get(3));
templateOriginal.setTo(removePerspective.getOutput());
// blur the image a bit so it doesn't have to be a perfect match
GrayF32 blurred = new GrayF32(LENGTH,LENGTH);
BlurImageOps.gaussian(templateOriginal,blurred,-1,2,null);
// place greater importance on pixels which are around edges
GrayF32 derivX = new GrayF32(LENGTH, LENGTH);
GrayF32 derivY = new GrayF32(LENGTH, LENGTH);
GImageDerivativeOps.gradient(DerivativeType.SOBEL,blurred,derivX,derivY, BorderType.EXTENDED);
GGradientToEdgeFeatures.intensityE(derivX,derivY,weights);
float max = ImageStatistics.max(weights);
PixelMath.divide(weights,max,weights);
totalWeight = ImageStatistics.sum(weights);
// compute a normalized template for later use. Divide by the mean to add some lighting invariance
template.setTo(removePerspective.getOutput());
float mean = (float)ImageStatistics.mean(template);
PixelMath.divide(template,mean,template);
} | java | public void setTemplate(GrayF32 image, List<Point2D_F64> sides) {
if( sides.size() != 4 )
throw new IllegalArgumentException("Expected 4 sidesCollision");
removePerspective.apply(image,sides.get(0),sides.get(1),sides.get(2),sides.get(3));
templateOriginal.setTo(removePerspective.getOutput());
// blur the image a bit so it doesn't have to be a perfect match
GrayF32 blurred = new GrayF32(LENGTH,LENGTH);
BlurImageOps.gaussian(templateOriginal,blurred,-1,2,null);
// place greater importance on pixels which are around edges
GrayF32 derivX = new GrayF32(LENGTH, LENGTH);
GrayF32 derivY = new GrayF32(LENGTH, LENGTH);
GImageDerivativeOps.gradient(DerivativeType.SOBEL,blurred,derivX,derivY, BorderType.EXTENDED);
GGradientToEdgeFeatures.intensityE(derivX,derivY,weights);
float max = ImageStatistics.max(weights);
PixelMath.divide(weights,max,weights);
totalWeight = ImageStatistics.sum(weights);
// compute a normalized template for later use. Divide by the mean to add some lighting invariance
template.setTo(removePerspective.getOutput());
float mean = (float)ImageStatistics.mean(template);
PixelMath.divide(template,mean,template);
} | [
"public",
"void",
"setTemplate",
"(",
"GrayF32",
"image",
",",
"List",
"<",
"Point2D_F64",
">",
"sides",
")",
"{",
"if",
"(",
"sides",
".",
"size",
"(",
")",
"!=",
"4",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected 4 sidesCollision\"",
")... | Creates a template of the fiducial and this is then used to determine how blurred the image is | [
"Creates",
"a",
"template",
"of",
"the",
"fiducial",
"and",
"this",
"is",
"then",
"used",
"to",
"determine",
"how",
"blurred",
"the",
"image",
"is"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java#L82-L110 | train |
lessthanoptimal/BoofCV | applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java | ImageSelectorAndSaver.process | public synchronized void process(GrayF32 image, List<Point2D_F64> sides) {
if( sides.size() != 4 )
throw new IllegalArgumentException("Expected 4 sidesCollision");
updateScore(image,sides);
if( currentScore < bestScore ) {
bestScore = currentScore;
if( bestImage == null ) {
bestImage = new BufferedImage(image.getWidth(), image.getHeight(),BufferedImage.TYPE_INT_RGB);
}
ConvertBufferedImage.convertTo(image,bestImage);
}
} | java | public synchronized void process(GrayF32 image, List<Point2D_F64> sides) {
if( sides.size() != 4 )
throw new IllegalArgumentException("Expected 4 sidesCollision");
updateScore(image,sides);
if( currentScore < bestScore ) {
bestScore = currentScore;
if( bestImage == null ) {
bestImage = new BufferedImage(image.getWidth(), image.getHeight(),BufferedImage.TYPE_INT_RGB);
}
ConvertBufferedImage.convertTo(image,bestImage);
}
} | [
"public",
"synchronized",
"void",
"process",
"(",
"GrayF32",
"image",
",",
"List",
"<",
"Point2D_F64",
">",
"sides",
")",
"{",
"if",
"(",
"sides",
".",
"size",
"(",
")",
"!=",
"4",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expected 4 sidesColl... | Computes the sharpness score for the current image, if better than the current best image it's then saved.
@param image Gray scale input image for detector
@param sides Location of 4 corners on fiducial | [
"Computes",
"the",
"sharpness",
"score",
"for",
"the",
"current",
"image",
"if",
"better",
"than",
"the",
"current",
"best",
"image",
"it",
"s",
"then",
"saved",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java#L125-L138 | train |
lessthanoptimal/BoofCV | applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java | ImageSelectorAndSaver.updateScore | public synchronized void updateScore(GrayF32 image, List<Point2D_F64> sides) {
removePerspective.apply(image,sides.get(0),sides.get(1),sides.get(2),sides.get(3));
GrayF32 current = removePerspective.getOutput();
float mean = (float)ImageStatistics.mean(current);
PixelMath.divide(current,mean,tempImage);
PixelMath.diffAbs(tempImage,template,difference);
PixelMath.multiply(difference,weights,difference);
// compute score as a weighted average of the difference
currentScore = ImageStatistics.sum(difference)/totalWeight;
} | java | public synchronized void updateScore(GrayF32 image, List<Point2D_F64> sides) {
removePerspective.apply(image,sides.get(0),sides.get(1),sides.get(2),sides.get(3));
GrayF32 current = removePerspective.getOutput();
float mean = (float)ImageStatistics.mean(current);
PixelMath.divide(current,mean,tempImage);
PixelMath.diffAbs(tempImage,template,difference);
PixelMath.multiply(difference,weights,difference);
// compute score as a weighted average of the difference
currentScore = ImageStatistics.sum(difference)/totalWeight;
} | [
"public",
"synchronized",
"void",
"updateScore",
"(",
"GrayF32",
"image",
",",
"List",
"<",
"Point2D_F64",
">",
"sides",
")",
"{",
"removePerspective",
".",
"apply",
"(",
"image",
",",
"sides",
".",
"get",
"(",
"0",
")",
",",
"sides",
".",
"get",
"(",
... | Used when you just want to update the score for visualization purposes but not update the best image. | [
"Used",
"when",
"you",
"just",
"want",
"to",
"update",
"the",
"score",
"for",
"visualization",
"purposes",
"but",
"not",
"update",
"the",
"best",
"image",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java#L143-L155 | train |
lessthanoptimal/BoofCV | applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java | ImageSelectorAndSaver.save | public synchronized void save() {
if( bestImage != null ) {
File path = new File(outputDirectory, String.format("image%04d.png",imageNumber));
UtilImageIO.saveImage(bestImage,path.getAbsolutePath());
imageNumber++;
}
clearHistory();
} | java | public synchronized void save() {
if( bestImage != null ) {
File path = new File(outputDirectory, String.format("image%04d.png",imageNumber));
UtilImageIO.saveImage(bestImage,path.getAbsolutePath());
imageNumber++;
}
clearHistory();
} | [
"public",
"synchronized",
"void",
"save",
"(",
")",
"{",
"if",
"(",
"bestImage",
"!=",
"null",
")",
"{",
"File",
"path",
"=",
"new",
"File",
"(",
"outputDirectory",
",",
"String",
".",
"format",
"(",
"\"image%04d.png\"",
",",
"imageNumber",
")",
")",
";"... | Saves the image to a file | [
"Saves",
"the",
"image",
"to",
"a",
"file"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/calib/ImageSelectorAndSaver.java#L160-L167 | train |
lessthanoptimal/BoofCV | integration/boofcv-swing/src/main/java/boofcv/gui/image/ImagePanel.java | ImagePanel.setImageRepaint | public void setImageRepaint(BufferedImage image) {
// if image is larger before than the new image then you need to make sure you repaint
// the entire image otherwise a ghost will be left
ScaleOffset workspace;
if( SwingUtilities.isEventDispatchThread() ) {
workspace = adjustmentGUI;
} else {
workspace = new ScaleOffset();
}
repaintJustImage(img,workspace);
this.img = image;
if( image != null ) {
repaintJustImage(img, workspace);
} else {
repaint();
}
} | java | public void setImageRepaint(BufferedImage image) {
// if image is larger before than the new image then you need to make sure you repaint
// the entire image otherwise a ghost will be left
ScaleOffset workspace;
if( SwingUtilities.isEventDispatchThread() ) {
workspace = adjustmentGUI;
} else {
workspace = new ScaleOffset();
}
repaintJustImage(img,workspace);
this.img = image;
if( image != null ) {
repaintJustImage(img, workspace);
} else {
repaint();
}
} | [
"public",
"void",
"setImageRepaint",
"(",
"BufferedImage",
"image",
")",
"{",
"// if image is larger before than the new image then you need to make sure you repaint",
"// the entire image otherwise a ghost will be left",
"ScaleOffset",
"workspace",
";",
"if",
"(",
"SwingUtilities",
... | Changes the buffered image and calls repaint. Does not need to be called in the UI thread. | [
"Changes",
"the",
"buffered",
"image",
"and",
"calls",
"repaint",
".",
"Does",
"not",
"need",
"to",
"be",
"called",
"in",
"the",
"UI",
"thread",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-swing/src/main/java/boofcv/gui/image/ImagePanel.java#L166-L182 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/ImageMotionPtkSmartRespawn.java | ImageMotionPtkSmartRespawn.computeContainment | private void computeContainment( int imageArea ) {
// mark that the track is in the inlier set and compute the containment rectangle
contRect.x0 = contRect.y0 = Double.MAX_VALUE;
contRect.x1 = contRect.y1 = -Double.MAX_VALUE;
for( AssociatedPair p : motion.getModelMatcher().getMatchSet() ) {
Point2D_F64 t = p.p2;
if( t.x > contRect.x1 )
contRect.x1 = t.x;
if( t.y > contRect.y1 )
contRect.y1 = t.y;
if( t.x < contRect.x0 )
contRect.x0 = t.x;
if( t.y < contRect.y0 )
contRect.y0 = t.y;
}
containment = contRect.area()/imageArea;
} | java | private void computeContainment( int imageArea ) {
// mark that the track is in the inlier set and compute the containment rectangle
contRect.x0 = contRect.y0 = Double.MAX_VALUE;
contRect.x1 = contRect.y1 = -Double.MAX_VALUE;
for( AssociatedPair p : motion.getModelMatcher().getMatchSet() ) {
Point2D_F64 t = p.p2;
if( t.x > contRect.x1 )
contRect.x1 = t.x;
if( t.y > contRect.y1 )
contRect.y1 = t.y;
if( t.x < contRect.x0 )
contRect.x0 = t.x;
if( t.y < contRect.y0 )
contRect.y0 = t.y;
}
containment = contRect.area()/imageArea;
} | [
"private",
"void",
"computeContainment",
"(",
"int",
"imageArea",
")",
"{",
"// mark that the track is in the inlier set and compute the containment rectangle",
"contRect",
".",
"x0",
"=",
"contRect",
".",
"y0",
"=",
"Double",
".",
"MAX_VALUE",
";",
"contRect",
".",
"x1... | Computes an axis-aligned rectangle that contains all the inliers. It then computes the area contained in
that rectangle to the total area of the image
@param imageArea width*height | [
"Computes",
"an",
"axis",
"-",
"aligned",
"rectangle",
"that",
"contains",
"all",
"the",
"inliers",
".",
"It",
"then",
"computes",
"the",
"area",
"contained",
"in",
"that",
"rectangle",
"to",
"the",
"total",
"area",
"of",
"the",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/ImageMotionPtkSmartRespawn.java#L149-L165 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/PruneStructureFromSceneProjective.java | PruneStructureFromSceneProjective.pruneViews | public boolean pruneViews(int count) {
List<SceneStructureProjective.View> remainingS = new ArrayList<>();
List<SceneObservations.View> remainingO = new ArrayList<>();
// count number of observations in each view
int counts[] = new int[structure.views.length];
for (int pointIdx = 0; pointIdx < structure.points.length; pointIdx++) {
GrowQueue_I32 viewsIn = structure.points[pointIdx].views;
for (int i = 0; i < viewsIn.size; i++) {
counts[viewsIn.get(i)]++;
}
}
// TODO Add a list of points to each view reducing number of iterations through all the points
// mark views with too few points for removal
for (int viewIdx = 0; viewIdx < structure.views.length; viewIdx++) {
if( counts[viewIdx] > count) {
remainingS.add(structure.views[viewIdx]);
remainingO.add(observations.views[viewIdx]);
} else {
structure.views[viewIdx].width = -2;
}
}
// remove the view from points
for (int pointIdx = 0; pointIdx < structure.points.length; pointIdx++) {
GrowQueue_I32 viewsIn = structure.points[pointIdx].views;
for (int i = viewsIn.size-1; i >= 0; i--) {
SceneStructureProjective.View v = structure.views[viewsIn.get(i)];
if( v.width == -2 ) {
viewsIn.remove(i);
}
}
}
if( structure.views.length == remainingS.size() ) {
return false;
}
// Create new arrays with the views that were not pruned
structure.views = new SceneStructureProjective.View[remainingS.size()];
observations.views = new SceneObservations.View[remainingO.size()];
for (int i = 0; i < structure.views.length; i++) {
structure.views[i] = remainingS.get(i);
observations.views[i] = remainingO.get(i);
}
return true;
} | java | public boolean pruneViews(int count) {
List<SceneStructureProjective.View> remainingS = new ArrayList<>();
List<SceneObservations.View> remainingO = new ArrayList<>();
// count number of observations in each view
int counts[] = new int[structure.views.length];
for (int pointIdx = 0; pointIdx < structure.points.length; pointIdx++) {
GrowQueue_I32 viewsIn = structure.points[pointIdx].views;
for (int i = 0; i < viewsIn.size; i++) {
counts[viewsIn.get(i)]++;
}
}
// TODO Add a list of points to each view reducing number of iterations through all the points
// mark views with too few points for removal
for (int viewIdx = 0; viewIdx < structure.views.length; viewIdx++) {
if( counts[viewIdx] > count) {
remainingS.add(structure.views[viewIdx]);
remainingO.add(observations.views[viewIdx]);
} else {
structure.views[viewIdx].width = -2;
}
}
// remove the view from points
for (int pointIdx = 0; pointIdx < structure.points.length; pointIdx++) {
GrowQueue_I32 viewsIn = structure.points[pointIdx].views;
for (int i = viewsIn.size-1; i >= 0; i--) {
SceneStructureProjective.View v = structure.views[viewsIn.get(i)];
if( v.width == -2 ) {
viewsIn.remove(i);
}
}
}
if( structure.views.length == remainingS.size() ) {
return false;
}
// Create new arrays with the views that were not pruned
structure.views = new SceneStructureProjective.View[remainingS.size()];
observations.views = new SceneObservations.View[remainingO.size()];
for (int i = 0; i < structure.views.length; i++) {
structure.views[i] = remainingS.get(i);
observations.views[i] = remainingO.get(i);
}
return true;
} | [
"public",
"boolean",
"pruneViews",
"(",
"int",
"count",
")",
"{",
"List",
"<",
"SceneStructureProjective",
".",
"View",
">",
"remainingS",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"List",
"<",
"SceneObservations",
".",
"View",
">",
"remainingO",
"=",
... | Removes views with less than 'count' features visible. Observations of features in removed views are also
removed. Features are not automatically removed even if there are zero observations of them.
@param count Prune if it has this number of views or less
@return true if views were pruned or false if not | [
"Removes",
"views",
"with",
"less",
"than",
"count",
"features",
"visible",
".",
"Observations",
"of",
"features",
"in",
"removed",
"views",
"are",
"also",
"removed",
".",
"Features",
"are",
"not",
"automatically",
"removed",
"even",
"if",
"there",
"are",
"zer... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/geo/bundle/PruneStructureFromSceneProjective.java#L166-L214 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/DisparityScoreRowFormat.java | DisparityScoreRowFormat.process | public void process( Input left , Input right , Disparity disparity ) {
// initialize data structures
InputSanityCheck.checkSameShape(left, right, disparity);
if( maxDisparity > left.width-2*radiusX )
throw new RuntimeException(
"The maximum disparity is too large for this image size: max size "+(left.width-2*radiusX));
lengthHorizontal = left.width*rangeDisparity;
_process(left,right,disparity);
} | java | public void process( Input left , Input right , Disparity disparity ) {
// initialize data structures
InputSanityCheck.checkSameShape(left, right, disparity);
if( maxDisparity > left.width-2*radiusX )
throw new RuntimeException(
"The maximum disparity is too large for this image size: max size "+(left.width-2*radiusX));
lengthHorizontal = left.width*rangeDisparity;
_process(left,right,disparity);
} | [
"public",
"void",
"process",
"(",
"Input",
"left",
",",
"Input",
"right",
",",
"Disparity",
"disparity",
")",
"{",
"// initialize data structures",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"left",
",",
"right",
",",
"disparity",
")",
";",
"if",
"(",
"ma... | Computes disparity between two stereo images
@param left Left rectified stereo image. Input
@param right Right rectified stereo image. Input
@param disparity Disparity between the two images. Output | [
"Computes",
"disparity",
"between",
"two",
"stereo",
"images"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/DisparityScoreRowFormat.java#L92-L103 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java | SelfCalibrationLinearDualQuadratic.solve | public GeometricResult solve() {
if( cameras.size < minimumProjectives )
throw new IllegalArgumentException("You need at least "+minimumProjectives+" motions");
int N = cameras.size;
DMatrixRMaj L = new DMatrixRMaj(N*eqs,10);
// Convert constraints into a (N*eqs) by 10 matrix. Null space is Q
constructMatrix(L);
// Compute the SVD for its null space
if( !svd.decompose(L)) {
return GeometricResult.SOLVE_FAILED;
}
// Examine the null space to find the values of Q
extractSolutionForQ(Q);
// determine if the solution is good by looking at two smallest singular values
// If there isn't a steep drop it either isn't singular or more there is more than 1 singular value
double sv[] = svd.getSingularValues();
Arrays.sort(sv);
if( singularThreshold*sv[1] <= sv[0] ) {
// System.out.println("ratio = "+(sv[0]/sv[1]));
return GeometricResult.GEOMETRY_POOR;
}
// Enforce constraints and solve for each view
if( !MultiViewOps.enforceAbsoluteQuadraticConstraints(Q,true,zeroSkew) ) {
return GeometricResult.SOLVE_FAILED;
}
computeSolutions(Q);
if( solutions.size() != N ) {
return GeometricResult.SOLUTION_NAN;
} else {
return GeometricResult.SUCCESS;
}
} | java | public GeometricResult solve() {
if( cameras.size < minimumProjectives )
throw new IllegalArgumentException("You need at least "+minimumProjectives+" motions");
int N = cameras.size;
DMatrixRMaj L = new DMatrixRMaj(N*eqs,10);
// Convert constraints into a (N*eqs) by 10 matrix. Null space is Q
constructMatrix(L);
// Compute the SVD for its null space
if( !svd.decompose(L)) {
return GeometricResult.SOLVE_FAILED;
}
// Examine the null space to find the values of Q
extractSolutionForQ(Q);
// determine if the solution is good by looking at two smallest singular values
// If there isn't a steep drop it either isn't singular or more there is more than 1 singular value
double sv[] = svd.getSingularValues();
Arrays.sort(sv);
if( singularThreshold*sv[1] <= sv[0] ) {
// System.out.println("ratio = "+(sv[0]/sv[1]));
return GeometricResult.GEOMETRY_POOR;
}
// Enforce constraints and solve for each view
if( !MultiViewOps.enforceAbsoluteQuadraticConstraints(Q,true,zeroSkew) ) {
return GeometricResult.SOLVE_FAILED;
}
computeSolutions(Q);
if( solutions.size() != N ) {
return GeometricResult.SOLUTION_NAN;
} else {
return GeometricResult.SUCCESS;
}
} | [
"public",
"GeometricResult",
"solve",
"(",
")",
"{",
"if",
"(",
"cameras",
".",
"size",
"<",
"minimumProjectives",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"You need at least \"",
"+",
"minimumProjectives",
"+",
"\" motions\"",
")",
";",
"int",
"N",... | Solve for camera calibration. A sanity check is performed to ensure that a valid calibration is found.
All values must be countable numbers and the focal lengths must be positive numbers.
@return Indicates if it was successful or not. If it fails it says why | [
"Solve",
"for",
"camera",
"calibration",
".",
"A",
"sanity",
"check",
"is",
"performed",
"to",
"ensure",
"that",
"a",
"valid",
"calibration",
"is",
"found",
".",
"All",
"values",
"must",
"be",
"countable",
"numbers",
"and",
"the",
"focal",
"lengths",
"must",... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java#L124-L162 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java | SelfCalibrationLinearDualQuadratic.extractSolutionForQ | private void extractSolutionForQ( DMatrix4x4 Q ) {
DMatrixRMaj nv = new DMatrixRMaj(10,1);
SingularOps_DDRM.nullVector(svd,true,nv);
// Convert the solution into a fixed sized matrix because it's easier to read
encodeQ(Q,nv.data);
// diagonal elements must be positive because Q = [K*K' .. ; ... ]
// If they are a mix of positive and negative that's bad and can't be fixed
// All 3 are checked because technically they could be zero. Not a physically useful solution but...
if( Q.a11 < 0 || Q.a22 < 0 || Q.a33 < 0 ){
CommonOps_DDF4.scale(-1,Q);
}
} | java | private void extractSolutionForQ( DMatrix4x4 Q ) {
DMatrixRMaj nv = new DMatrixRMaj(10,1);
SingularOps_DDRM.nullVector(svd,true,nv);
// Convert the solution into a fixed sized matrix because it's easier to read
encodeQ(Q,nv.data);
// diagonal elements must be positive because Q = [K*K' .. ; ... ]
// If they are a mix of positive and negative that's bad and can't be fixed
// All 3 are checked because technically they could be zero. Not a physically useful solution but...
if( Q.a11 < 0 || Q.a22 < 0 || Q.a33 < 0 ){
CommonOps_DDF4.scale(-1,Q);
}
} | [
"private",
"void",
"extractSolutionForQ",
"(",
"DMatrix4x4",
"Q",
")",
"{",
"DMatrixRMaj",
"nv",
"=",
"new",
"DMatrixRMaj",
"(",
"10",
",",
"1",
")",
";",
"SingularOps_DDRM",
".",
"nullVector",
"(",
"svd",
",",
"true",
",",
"nv",
")",
";",
"// Convert the ... | Extracts the null space and converts it into the Q matrix | [
"Extracts",
"the",
"null",
"space",
"and",
"converts",
"it",
"into",
"the",
"Q",
"matrix"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java#L167-L180 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java | SelfCalibrationLinearDualQuadratic.computeSolutions | private void computeSolutions(DMatrix4x4 Q) {
DMatrixRMaj w_i = new DMatrixRMaj(3,3);
for (int i = 0; i < cameras.size; i++) {
computeW(cameras.get(i),Q,w_i);
Intrinsic calib = solveForCalibration(w_i);
if( sanityCheck(calib)) {
solutions.add(calib);
}
}
} | java | private void computeSolutions(DMatrix4x4 Q) {
DMatrixRMaj w_i = new DMatrixRMaj(3,3);
for (int i = 0; i < cameras.size; i++) {
computeW(cameras.get(i),Q,w_i);
Intrinsic calib = solveForCalibration(w_i);
if( sanityCheck(calib)) {
solutions.add(calib);
}
}
} | [
"private",
"void",
"computeSolutions",
"(",
"DMatrix4x4",
"Q",
")",
"{",
"DMatrixRMaj",
"w_i",
"=",
"new",
"DMatrixRMaj",
"(",
"3",
",",
"3",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"cameras",
".",
"size",
";",
"i",
"++",
")",
... | Computes the calibration for each view.. | [
"Computes",
"the",
"calibration",
"for",
"each",
"view",
".."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java#L185-L195 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java | SelfCalibrationLinearDualQuadratic.solveForCalibration | private Intrinsic solveForCalibration(DMatrixRMaj w) {
Intrinsic calib = new Intrinsic();
// CholeskyDecomposition_F64<DMatrixRMaj> chol = DecompositionFactory_DDRM.chol(false);
//
// chol.decompose(w.copy());
// DMatrixRMaj R = chol.getT(w);
// R.print();
if( zeroSkew ) {
calib.skew = 0;
calib.fy = Math.sqrt(w.get(1,1));
if( knownAspect ) {
calib.fx = calib.fy/aspectRatio;
} else {
calib.fx = Math.sqrt(w.get(0,0));
}
} else if( knownAspect ) {
calib.fy = Math.sqrt(w.get(1,1));
calib.fx = calib.fy/aspectRatio;
calib.skew = w.get(0,1)/calib.fy;
} else {
calib.fy = Math.sqrt(w.get(1,1));
calib.skew = w.get(0,1)/calib.fy;
calib.fx = Math.sqrt(w.get(0,0) - calib.skew*calib.skew);
}
return calib;
} | java | private Intrinsic solveForCalibration(DMatrixRMaj w) {
Intrinsic calib = new Intrinsic();
// CholeskyDecomposition_F64<DMatrixRMaj> chol = DecompositionFactory_DDRM.chol(false);
//
// chol.decompose(w.copy());
// DMatrixRMaj R = chol.getT(w);
// R.print();
if( zeroSkew ) {
calib.skew = 0;
calib.fy = Math.sqrt(w.get(1,1));
if( knownAspect ) {
calib.fx = calib.fy/aspectRatio;
} else {
calib.fx = Math.sqrt(w.get(0,0));
}
} else if( knownAspect ) {
calib.fy = Math.sqrt(w.get(1,1));
calib.fx = calib.fy/aspectRatio;
calib.skew = w.get(0,1)/calib.fy;
} else {
calib.fy = Math.sqrt(w.get(1,1));
calib.skew = w.get(0,1)/calib.fy;
calib.fx = Math.sqrt(w.get(0,0) - calib.skew*calib.skew);
}
return calib;
} | [
"private",
"Intrinsic",
"solveForCalibration",
"(",
"DMatrixRMaj",
"w",
")",
"{",
"Intrinsic",
"calib",
"=",
"new",
"Intrinsic",
"(",
")",
";",
"//\t\tCholeskyDecomposition_F64<DMatrixRMaj> chol = DecompositionFactory_DDRM.chol(false);",
"//",
"//\t\tchol.decompose(w.copy());",
... | Given the solution for w and the constraints solve for the remaining parameters | [
"Given",
"the",
"solution",
"for",
"w",
"and",
"the",
"constraints",
"solve",
"for",
"the",
"remaining",
"parameters"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java#L200-L228 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java | SelfCalibrationLinearDualQuadratic.sanityCheck | boolean sanityCheck(Intrinsic calib ) {
if(UtilEjml.isUncountable(calib.fx))
return false;
if(UtilEjml.isUncountable(calib.fy))
return false;
if(UtilEjml.isUncountable(calib.skew))
return false;
if( calib.fx < 0 )
return false;
if( calib.fy < 0 )
return false;
return true;
} | java | boolean sanityCheck(Intrinsic calib ) {
if(UtilEjml.isUncountable(calib.fx))
return false;
if(UtilEjml.isUncountable(calib.fy))
return false;
if(UtilEjml.isUncountable(calib.skew))
return false;
if( calib.fx < 0 )
return false;
if( calib.fy < 0 )
return false;
return true;
} | [
"boolean",
"sanityCheck",
"(",
"Intrinsic",
"calib",
")",
"{",
"if",
"(",
"UtilEjml",
".",
"isUncountable",
"(",
"calib",
".",
"fx",
")",
")",
"return",
"false",
";",
"if",
"(",
"UtilEjml",
".",
"isUncountable",
"(",
"calib",
".",
"fy",
")",
")",
"retu... | Makes sure that the found solution is valid and physically possible
@return true if valid | [
"Makes",
"sure",
"that",
"the",
"found",
"solution",
"is",
"valid",
"and",
"physically",
"possible"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearDualQuadratic.java#L234-L248 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/ImplSelectRectStandardBase_S32.java | ImplSelectRectStandardBase_S32.selectRightToLeft | private int selectRightToLeft( int col , int[] scores ) {
// see how far it can search
int localMax = Math.min(imageWidth-regionWidth,col+maxDisparity)-col-minDisparity;
int indexBest = 0;
int indexScore = col;
int scoreBest = scores[col];
indexScore += imageWidth+1;
for( int i = 1; i < localMax; i++ ,indexScore += imageWidth+1) {
int s = scores[indexScore];
if( s < scoreBest ) {
scoreBest = s;
indexBest = i;
}
}
return indexBest;
} | java | private int selectRightToLeft( int col , int[] scores ) {
// see how far it can search
int localMax = Math.min(imageWidth-regionWidth,col+maxDisparity)-col-minDisparity;
int indexBest = 0;
int indexScore = col;
int scoreBest = scores[col];
indexScore += imageWidth+1;
for( int i = 1; i < localMax; i++ ,indexScore += imageWidth+1) {
int s = scores[indexScore];
if( s < scoreBest ) {
scoreBest = s;
indexBest = i;
}
}
return indexBest;
} | [
"private",
"int",
"selectRightToLeft",
"(",
"int",
"col",
",",
"int",
"[",
"]",
"scores",
")",
"{",
"// see how far it can search",
"int",
"localMax",
"=",
"Math",
".",
"min",
"(",
"imageWidth",
"-",
"regionWidth",
",",
"col",
"+",
"maxDisparity",
")",
"-",
... | Finds the best disparity going from right to left image. | [
"Finds",
"the",
"best",
"disparity",
"going",
"from",
"right",
"to",
"left",
"image",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/disparity/impl/ImplSelectRectStandardBase_S32.java#L135-L154 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldNonMaximalSuppression.java | TldNonMaximalSuppression.process | public void process( FastQueue<TldRegion> regions , FastQueue<TldRegion> output ) {
final int N = regions.size;
// set all connections to be a local maximum initially
conn.growArray(N);
for( int i = 0; i < N; i++ ) {
conn.data[i].reset();
}
// Create the graph of connected regions and mark which regions are local maximums
for( int i = 0; i < N; i++ ) {
TldRegion ra = regions.get(i);
Connections ca = conn.data[i];
for( int j = i+1; j < N; j++ ) {
TldRegion rb = regions.get(j);
Connections cb = conn.data[j];
// see if they are connected
double overlap = helper.computeOverlap(ra.rect,rb.rect);
if( overlap < connectionThreshold ) {
continue;
}
// connect the two and check for strict maximums
ca.maximum &= ra.confidence > rb.confidence;
cb.maximum &= rb.confidence > ra.confidence;
ra.connections++;
rb.connections++;
}
}
// Compute the output from local maximums.
for( int i = 0; i < N; i++ ) {
TldRegion ra = regions.get(i);
Connections ca = conn.data[i];
if( ca.maximum ) {
TldRegion o = output.grow();
o.connections = ra.connections;
o.confidence = ra.confidence;
o.rect.set(ra.rect);
} else if( ra.connections == 0 ) {
System.out.println("Not a maximum but has zero connections?");
}
}
} | java | public void process( FastQueue<TldRegion> regions , FastQueue<TldRegion> output ) {
final int N = regions.size;
// set all connections to be a local maximum initially
conn.growArray(N);
for( int i = 0; i < N; i++ ) {
conn.data[i].reset();
}
// Create the graph of connected regions and mark which regions are local maximums
for( int i = 0; i < N; i++ ) {
TldRegion ra = regions.get(i);
Connections ca = conn.data[i];
for( int j = i+1; j < N; j++ ) {
TldRegion rb = regions.get(j);
Connections cb = conn.data[j];
// see if they are connected
double overlap = helper.computeOverlap(ra.rect,rb.rect);
if( overlap < connectionThreshold ) {
continue;
}
// connect the two and check for strict maximums
ca.maximum &= ra.confidence > rb.confidence;
cb.maximum &= rb.confidence > ra.confidence;
ra.connections++;
rb.connections++;
}
}
// Compute the output from local maximums.
for( int i = 0; i < N; i++ ) {
TldRegion ra = regions.get(i);
Connections ca = conn.data[i];
if( ca.maximum ) {
TldRegion o = output.grow();
o.connections = ra.connections;
o.confidence = ra.confidence;
o.rect.set(ra.rect);
} else if( ra.connections == 0 ) {
System.out.println("Not a maximum but has zero connections?");
}
}
} | [
"public",
"void",
"process",
"(",
"FastQueue",
"<",
"TldRegion",
">",
"regions",
",",
"FastQueue",
"<",
"TldRegion",
">",
"output",
")",
"{",
"final",
"int",
"N",
"=",
"regions",
".",
"size",
";",
"// set all connections to be a local maximum initially",
"conn",
... | Finds local maximums from the set of provided regions
@param regions Set of high confidence regions for target
@param output Output after non-maximum suppression | [
"Finds",
"local",
"maximums",
"from",
"the",
"set",
"of",
"provided",
"regions"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldNonMaximalSuppression.java#L61-L108 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java | ImageType.createImage | public T createImage( int width , int height ) {
switch( family ) {
case GRAY:
return (T)GeneralizedImageOps.createSingleBand(getImageClass(),width,height);
case INTERLEAVED:
return (T)GeneralizedImageOps.createInterleaved(getImageClass(), width, height, numBands);
case PLANAR:
return (T)new Planar(getImageClass(),width,height,numBands);
default:
throw new IllegalArgumentException("Type not yet supported");
}
} | java | public T createImage( int width , int height ) {
switch( family ) {
case GRAY:
return (T)GeneralizedImageOps.createSingleBand(getImageClass(),width,height);
case INTERLEAVED:
return (T)GeneralizedImageOps.createInterleaved(getImageClass(), width, height, numBands);
case PLANAR:
return (T)new Planar(getImageClass(),width,height,numBands);
default:
throw new IllegalArgumentException("Type not yet supported");
}
} | [
"public",
"T",
"createImage",
"(",
"int",
"width",
",",
"int",
"height",
")",
"{",
"switch",
"(",
"family",
")",
"{",
"case",
"GRAY",
":",
"return",
"(",
"T",
")",
"GeneralizedImageOps",
".",
"createSingleBand",
"(",
"getImageClass",
"(",
")",
",",
"widt... | Creates a new image.
@param width Number of columns in the image.
@param height Number of rows in the image.
@return New instance of the image. | [
"Creates",
"a",
"new",
"image",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java#L87-L101 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java | ImageType.createArray | public T[] createArray( int length ) {
switch( family ) {
case GRAY:
case INTERLEAVED:
return (T[])Array.newInstance(getImageClass(),length);
case PLANAR:
return (T[])new Planar[ length ];
default:
throw new IllegalArgumentException("Type not yet supported");
}
} | java | public T[] createArray( int length ) {
switch( family ) {
case GRAY:
case INTERLEAVED:
return (T[])Array.newInstance(getImageClass(),length);
case PLANAR:
return (T[])new Planar[ length ];
default:
throw new IllegalArgumentException("Type not yet supported");
}
} | [
"public",
"T",
"[",
"]",
"createArray",
"(",
"int",
"length",
")",
"{",
"switch",
"(",
"family",
")",
"{",
"case",
"GRAY",
":",
"case",
"INTERLEAVED",
":",
"return",
"(",
"T",
"[",
"]",
")",
"Array",
".",
"newInstance",
"(",
"getImageClass",
"(",
")"... | Creates an array of the specified iamge type
@param length Number of elements in the array
@return array of image type | [
"Creates",
"an",
"array",
"of",
"the",
"specified",
"iamge",
"type"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java#L108-L120 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java | ImageType.isSameType | public boolean isSameType( ImageType o ) {
if( family != o.family )
return false;
if( dataType != o.dataType)
return false;
if( numBands != o.numBands )
return false;
return true;
} | java | public boolean isSameType( ImageType o ) {
if( family != o.family )
return false;
if( dataType != o.dataType)
return false;
if( numBands != o.numBands )
return false;
return true;
} | [
"public",
"boolean",
"isSameType",
"(",
"ImageType",
"o",
")",
"{",
"if",
"(",
"family",
"!=",
"o",
".",
"family",
")",
"return",
"false",
";",
"if",
"(",
"dataType",
"!=",
"o",
".",
"dataType",
")",
"return",
"false",
";",
"if",
"(",
"numBands",
"!=... | Returns true if the passed in ImageType is the same as this image type | [
"Returns",
"true",
"if",
"the",
"passed",
"in",
"ImageType",
"is",
"the",
"same",
"as",
"this",
"image",
"type"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java#L178-L186 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java | ImageType.setTo | public void setTo( ImageType o ) {
this.family = o.family;
this.dataType = o.dataType;
this.numBands = o.numBands;
} | java | public void setTo( ImageType o ) {
this.family = o.family;
this.dataType = o.dataType;
this.numBands = o.numBands;
} | [
"public",
"void",
"setTo",
"(",
"ImageType",
"o",
")",
"{",
"this",
".",
"family",
"=",
"o",
".",
"family",
";",
"this",
".",
"dataType",
"=",
"o",
".",
"dataType",
";",
"this",
".",
"numBands",
"=",
"o",
".",
"numBands",
";",
"}"
] | Sets 'this' to be identical to 'o'
@param o What is to be copied. | [
"Sets",
"this",
"to",
"be",
"identical",
"to",
"o"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/struct/image/ImageType.java#L192-L196 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogFastAlg.java | DescribeDenseHogFastAlg.growCellArray | void growCellArray(int imageWidth, int imageHeight) {
cellCols = imageWidth/ pixelsPerCell;
cellRows = imageHeight/ pixelsPerCell;
if( cellRows*cellCols > cells.length ) {
Cell[] a = new Cell[cellCols*cellRows];
System.arraycopy(cells,0,a,0,cells.length);
for (int i = cells.length; i < a.length; i++) {
a[i] = new Cell();
a[i].histogram = new float[ orientationBins ];
}
cells = a;
}
} | java | void growCellArray(int imageWidth, int imageHeight) {
cellCols = imageWidth/ pixelsPerCell;
cellRows = imageHeight/ pixelsPerCell;
if( cellRows*cellCols > cells.length ) {
Cell[] a = new Cell[cellCols*cellRows];
System.arraycopy(cells,0,a,0,cells.length);
for (int i = cells.length; i < a.length; i++) {
a[i] = new Cell();
a[i].histogram = new float[ orientationBins ];
}
cells = a;
}
} | [
"void",
"growCellArray",
"(",
"int",
"imageWidth",
",",
"int",
"imageHeight",
")",
"{",
"cellCols",
"=",
"imageWidth",
"/",
"pixelsPerCell",
";",
"cellRows",
"=",
"imageHeight",
"/",
"pixelsPerCell",
";",
"if",
"(",
"cellRows",
"*",
"cellCols",
">",
"cells",
... | Determines if the cell array needs to grow. If it does a new array is declared. Old data is recycled when
possible | [
"Determines",
"if",
"the",
"cell",
"array",
"needs",
"to",
"grow",
".",
"If",
"it",
"does",
"a",
"new",
"array",
"is",
"declared",
".",
"Old",
"data",
"is",
"recycled",
"when",
"possible"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogFastAlg.java#L104-L118 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogFastAlg.java | DescribeDenseHogFastAlg.getDescriptorsInRegion | public void getDescriptorsInRegion(int pixelX0 , int pixelY0 , int pixelX1 , int pixelY1 ,
List<TupleDesc_F64> output ) {
int gridX0 = (int)Math.ceil(pixelX0/(double) pixelsPerCell);
int gridY0 = (int)Math.ceil(pixelY0/(double) pixelsPerCell);
int gridX1 = pixelX1/ pixelsPerCell - cellsPerBlockX;
int gridY1 = pixelY1/ pixelsPerCell - cellsPerBlockY;
for (int y = gridY0; y <= gridY1; y++) {
int index = y*cellCols + gridX0;
for (int x = gridX0; x <= gridX1; x++ ) {
output.add( descriptions.get(index++) );
}
}
} | java | public void getDescriptorsInRegion(int pixelX0 , int pixelY0 , int pixelX1 , int pixelY1 ,
List<TupleDesc_F64> output ) {
int gridX0 = (int)Math.ceil(pixelX0/(double) pixelsPerCell);
int gridY0 = (int)Math.ceil(pixelY0/(double) pixelsPerCell);
int gridX1 = pixelX1/ pixelsPerCell - cellsPerBlockX;
int gridY1 = pixelY1/ pixelsPerCell - cellsPerBlockY;
for (int y = gridY0; y <= gridY1; y++) {
int index = y*cellCols + gridX0;
for (int x = gridX0; x <= gridX1; x++ ) {
output.add( descriptions.get(index++) );
}
}
} | [
"public",
"void",
"getDescriptorsInRegion",
"(",
"int",
"pixelX0",
",",
"int",
"pixelY0",
",",
"int",
"pixelX1",
",",
"int",
"pixelY1",
",",
"List",
"<",
"TupleDesc_F64",
">",
"output",
")",
"{",
"int",
"gridX0",
"=",
"(",
"int",
")",
"Math",
".",
"ceil"... | Convenience function which returns a list of all the descriptors computed inside the specified region in the image
@param pixelX0 Pixel coordinate X-axis lower extent
@param pixelY0 Pixel coordinate Y-axis lower extent
@param pixelX1 Pixel coordinate X-axis upper extent
@param pixelY1 Pixel coordinate Y-axis upper extent
@param output List of descriptions | [
"Convenience",
"function",
"which",
"returns",
"a",
"list",
"of",
"all",
"the",
"descriptors",
"computed",
"inside",
"the",
"specified",
"region",
"in",
"the",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogFastAlg.java#L129-L143 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogFastAlg.java | DescribeDenseHogFastAlg.computeCellHistograms | void computeCellHistograms() {
int width = cellCols* pixelsPerCell;
int height = cellRows* pixelsPerCell;
float angleBinSize = GrlConstants.F_PI/orientationBins;
int indexCell = 0;
for (int i = 0; i < height; i += pixelsPerCell) {
for (int j = 0; j < width; j += pixelsPerCell, indexCell++ ) {
Cell c = cells[indexCell];
c.reset();
for (int k = 0; k < pixelsPerCell; k++) {
int indexPixel = (i+k)*derivX.width+j;
for (int l = 0; l < pixelsPerCell; l++, indexPixel++ ) {
float pixelDX = this.derivX.data[indexPixel];
float pixelDY = this.derivY.data[indexPixel];
// angle from 0 to pi radians
float angle = UtilAngle.atanSafe(pixelDY,pixelDX) + GrlConstants.F_PId2;
// gradient magnitude
float magnitude = (float)Math.sqrt(pixelDX*pixelDX + pixelDY*pixelDY);
// Add the weighted gradient using bilinear interpolation
float findex0 = angle/angleBinSize;
int index0 = (int)findex0;
float weight1 = findex0-index0;
index0 %= orientationBins;
int index1 = (index0+1)%orientationBins;
c.histogram[index0] += magnitude*(1.0f-weight1);
c.histogram[index1] += magnitude*weight1;
}
}
}
}
} | java | void computeCellHistograms() {
int width = cellCols* pixelsPerCell;
int height = cellRows* pixelsPerCell;
float angleBinSize = GrlConstants.F_PI/orientationBins;
int indexCell = 0;
for (int i = 0; i < height; i += pixelsPerCell) {
for (int j = 0; j < width; j += pixelsPerCell, indexCell++ ) {
Cell c = cells[indexCell];
c.reset();
for (int k = 0; k < pixelsPerCell; k++) {
int indexPixel = (i+k)*derivX.width+j;
for (int l = 0; l < pixelsPerCell; l++, indexPixel++ ) {
float pixelDX = this.derivX.data[indexPixel];
float pixelDY = this.derivY.data[indexPixel];
// angle from 0 to pi radians
float angle = UtilAngle.atanSafe(pixelDY,pixelDX) + GrlConstants.F_PId2;
// gradient magnitude
float magnitude = (float)Math.sqrt(pixelDX*pixelDX + pixelDY*pixelDY);
// Add the weighted gradient using bilinear interpolation
float findex0 = angle/angleBinSize;
int index0 = (int)findex0;
float weight1 = findex0-index0;
index0 %= orientationBins;
int index1 = (index0+1)%orientationBins;
c.histogram[index0] += magnitude*(1.0f-weight1);
c.histogram[index1] += magnitude*weight1;
}
}
}
}
} | [
"void",
"computeCellHistograms",
"(",
")",
"{",
"int",
"width",
"=",
"cellCols",
"*",
"pixelsPerCell",
";",
"int",
"height",
"=",
"cellRows",
"*",
"pixelsPerCell",
";",
"float",
"angleBinSize",
"=",
"GrlConstants",
".",
"F_PI",
"/",
"orientationBins",
";",
"in... | Compute histograms for all the cells inside the image using precomputed derivative. | [
"Compute",
"histograms",
"for",
"all",
"the",
"cells",
"inside",
"the",
"image",
"using",
"precomputed",
"derivative",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseHogFastAlg.java#L175-L215 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detdesc/DetectDescribeSurfPlanar.java | DetectDescribeSurfPlanar.detect | public void detect( II grayII , Planar<II> colorII ) {
descriptions.reset();
featureAngles.reset();
// detect features
detector.detect(grayII);
// describe the found interest points
foundPoints = detector.getFoundPoints();
descriptions.resize(foundPoints.size());
featureAngles.resize(foundPoints.size());
describe(grayII, colorII);
} | java | public void detect( II grayII , Planar<II> colorII ) {
descriptions.reset();
featureAngles.reset();
// detect features
detector.detect(grayII);
// describe the found interest points
foundPoints = detector.getFoundPoints();
descriptions.resize(foundPoints.size());
featureAngles.resize(foundPoints.size());
describe(grayII, colorII);
} | [
"public",
"void",
"detect",
"(",
"II",
"grayII",
",",
"Planar",
"<",
"II",
">",
"colorII",
")",
"{",
"descriptions",
".",
"reset",
"(",
")",
";",
"featureAngles",
".",
"reset",
"(",
")",
";",
"// detect features",
"detector",
".",
"detect",
"(",
"grayII"... | Detects and describes features inside provide images. All images are integral images.
@param grayII Gray-scale integral image
@param colorII Color integral image | [
"Detects",
"and",
"describes",
"features",
"inside",
"provide",
"images",
".",
"All",
"images",
"are",
"integral",
"images",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detdesc/DetectDescribeSurfPlanar.java#L87-L102 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrPose3DUtils.java | QrPose3DUtils.getLandmark3D | public List<Point3D_F64> getLandmark3D( int version ) {
int N = QrCode.totalModules(version);
set3D( 0,0,N,point3D.get(0));
set3D( 0,7,N,point3D.get(1));
set3D( 7,7,N,point3D.get(2));
set3D( 7,0,N,point3D.get(3));
set3D( 0,N-7,N,point3D.get(4));
set3D( 0,N,N,point3D.get(5));
set3D( 7,N,N,point3D.get(6));
set3D( 7,N-7,N,point3D.get(7));
set3D( N-7,0,N,point3D.get(8));
set3D( N-7,7,N,point3D.get(9));
set3D( N,7,N,point3D.get(10));
set3D( N,0,N,point3D.get(11));
return point3D;
} | java | public List<Point3D_F64> getLandmark3D( int version ) {
int N = QrCode.totalModules(version);
set3D( 0,0,N,point3D.get(0));
set3D( 0,7,N,point3D.get(1));
set3D( 7,7,N,point3D.get(2));
set3D( 7,0,N,point3D.get(3));
set3D( 0,N-7,N,point3D.get(4));
set3D( 0,N,N,point3D.get(5));
set3D( 7,N,N,point3D.get(6));
set3D( 7,N-7,N,point3D.get(7));
set3D( N-7,0,N,point3D.get(8));
set3D( N-7,7,N,point3D.get(9));
set3D( N,7,N,point3D.get(10));
set3D( N,0,N,point3D.get(11));
return point3D;
} | [
"public",
"List",
"<",
"Point3D_F64",
">",
"getLandmark3D",
"(",
"int",
"version",
")",
"{",
"int",
"N",
"=",
"QrCode",
".",
"totalModules",
"(",
"version",
")",
";",
"set3D",
"(",
"0",
",",
"0",
",",
"N",
",",
"point3D",
".",
"get",
"(",
"0",
")",... | Location of each corner in the QR Code's reference frame in 3D
@param version QR Code's version
@return List. Recycled on each call | [
"Location",
"of",
"each",
"corner",
"in",
"the",
"QR",
"Code",
"s",
"reference",
"frame",
"in",
"3D"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrPose3DUtils.java#L119-L138 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrPose3DUtils.java | QrPose3DUtils.setPair | private void setPair(int which, int row, int col, int N , Point2D_F64 pixel ) {
set3D(row,col,N,point23.get(which).location);
pixelToNorm.compute(pixel.x,pixel.y,point23.get(which).observation);
} | java | private void setPair(int which, int row, int col, int N , Point2D_F64 pixel ) {
set3D(row,col,N,point23.get(which).location);
pixelToNorm.compute(pixel.x,pixel.y,point23.get(which).observation);
} | [
"private",
"void",
"setPair",
"(",
"int",
"which",
",",
"int",
"row",
",",
"int",
"col",
",",
"int",
"N",
",",
"Point2D_F64",
"pixel",
")",
"{",
"set3D",
"(",
"row",
",",
"col",
",",
"N",
",",
"point23",
".",
"get",
"(",
"which",
")",
".",
"locat... | Specifies PNP parameters for a single feature
@param which Landmark's index
@param row row in the QR code's grid coordinate system
@param col column in the QR code's grid coordinate system
@param N width of grid
@param pixel observed pixel coordinate of feature | [
"Specifies",
"PNP",
"parameters",
"for",
"a",
"single",
"feature"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrPose3DUtils.java#L149-L152 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrPose3DUtils.java | QrPose3DUtils.set3D | private void set3D(int row, int col, int N , Point3D_F64 location ) {
double _N = N;
double gridX = 2.0*(col/_N-0.5);
double gridY = 2.0*(0.5-row/_N);
location.set(gridX,gridY,0);
} | java | private void set3D(int row, int col, int N , Point3D_F64 location ) {
double _N = N;
double gridX = 2.0*(col/_N-0.5);
double gridY = 2.0*(0.5-row/_N);
location.set(gridX,gridY,0);
} | [
"private",
"void",
"set3D",
"(",
"int",
"row",
",",
"int",
"col",
",",
"int",
"N",
",",
"Point3D_F64",
"location",
")",
"{",
"double",
"_N",
"=",
"N",
";",
"double",
"gridX",
"=",
"2.0",
"*",
"(",
"col",
"/",
"_N",
"-",
"0.5",
")",
";",
"double",... | Specifies 3D location of landmark in marker coordinate system
@param row row in the QR code's grid coordinate system
@param col column in the QR code's grid coordinate system
@param N width of grid
@param location (Output) location of feature in marker reference frame | [
"Specifies",
"3D",
"location",
"of",
"landmark",
"in",
"marker",
"coordinate",
"system"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrPose3DUtils.java#L161-L167 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.