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-openkinect/src/main/java/boofcv/openkinect/StreamOpenKinectRgbDepth.java | StreamOpenKinectRgbDepth.start | public void start( Device device , Resolution resolution , Listener listener )
{
if( resolution != Resolution.MEDIUM ) {
throw new IllegalArgumentException("Depth image is always at medium resolution. Possible bug in kinect driver");
}
this.device = device;
this.listener = listener;
// Configure the kinect
device.setDepthFormat(DepthFormat.REGISTERED,resolution);
device.setVideoFormat(VideoFormat.RGB, resolution);
// declare data structures
int w = UtilOpenKinect.getWidth(resolution);
int h = UtilOpenKinect.getHeight(resolution);
dataDepth = new byte[ w*h*2 ];
dataRgb = new byte[ w*h*3 ];
depth.reshape(w,h);
rgb.reshape(w,h);
thread = new CombineThread();
thread.start();
// make sure the thread is running before moving on
while(!thread.running)
Thread.yield();
// start the streaming
device.startDepth(new DepthHandler() {
@Override
public void onFrameReceived(FrameMode mode, ByteBuffer frame, int timestamp) {
processDepth(frame,timestamp);
}
});
device.startVideo(new VideoHandler() {
@Override
public void onFrameReceived(FrameMode mode, ByteBuffer frame, int timestamp) {
processRgb(frame,timestamp);
}
});
} | java | public void start( Device device , Resolution resolution , Listener listener )
{
if( resolution != Resolution.MEDIUM ) {
throw new IllegalArgumentException("Depth image is always at medium resolution. Possible bug in kinect driver");
}
this.device = device;
this.listener = listener;
// Configure the kinect
device.setDepthFormat(DepthFormat.REGISTERED,resolution);
device.setVideoFormat(VideoFormat.RGB, resolution);
// declare data structures
int w = UtilOpenKinect.getWidth(resolution);
int h = UtilOpenKinect.getHeight(resolution);
dataDepth = new byte[ w*h*2 ];
dataRgb = new byte[ w*h*3 ];
depth.reshape(w,h);
rgb.reshape(w,h);
thread = new CombineThread();
thread.start();
// make sure the thread is running before moving on
while(!thread.running)
Thread.yield();
// start the streaming
device.startDepth(new DepthHandler() {
@Override
public void onFrameReceived(FrameMode mode, ByteBuffer frame, int timestamp) {
processDepth(frame,timestamp);
}
});
device.startVideo(new VideoHandler() {
@Override
public void onFrameReceived(FrameMode mode, ByteBuffer frame, int timestamp) {
processRgb(frame,timestamp);
}
});
} | [
"public",
"void",
"start",
"(",
"Device",
"device",
",",
"Resolution",
"resolution",
",",
"Listener",
"listener",
")",
"{",
"if",
"(",
"resolution",
"!=",
"Resolution",
".",
"MEDIUM",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Depth image is a... | Adds listeners to the device and sets its resolutions.
@param device Kinect device
@param resolution Resolution that images are being processed at. Must be medium for now
@param listener Listener for data | [
"Adds",
"listeners",
"to",
"the",
"device",
"and",
"sets",
"its",
"resolutions",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-openkinect/src/main/java/boofcv/openkinect/StreamOpenKinectRgbDepth.java#L66-L108 | train |
lessthanoptimal/BoofCV | integration/boofcv-openkinect/src/main/java/boofcv/openkinect/StreamOpenKinectRgbDepth.java | StreamOpenKinectRgbDepth.stop | public void stop() {
thread.requestStop = true;
long start = System.currentTimeMillis()+timeout;
while( start > System.currentTimeMillis() && thread.running )
Thread.yield();
device.stopDepth();
device.stopVideo();
device.close();
} | java | public void stop() {
thread.requestStop = true;
long start = System.currentTimeMillis()+timeout;
while( start > System.currentTimeMillis() && thread.running )
Thread.yield();
device.stopDepth();
device.stopVideo();
device.close();
} | [
"public",
"void",
"stop",
"(",
")",
"{",
"thread",
".",
"requestStop",
"=",
"true",
";",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"+",
"timeout",
";",
"while",
"(",
"start",
">",
"System",
".",
"currentTimeMillis",
"(",
")",
... | Stops all the threads from running and closes the video channels and video device | [
"Stops",
"all",
"the",
"threads",
"from",
"running",
"and",
"closes",
"the",
"video",
"channels",
"and",
"video",
"device"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/integration/boofcv-openkinect/src/main/java/boofcv/openkinect/StreamOpenKinectRgbDepth.java#L113-L122 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/RefineDualQuadraticAlgebra.java | RefineDualQuadraticAlgebra.refine | public boolean refine(List<CameraPinhole> calibration , DMatrix4x4 Q ) {
if( calibration.size() != cameras.size )
throw new RuntimeException("Calibration and cameras do not match");
computeNumberOfCalibrationParameters();
func = new ResidualK();
if( func.getNumOfInputsN() > 6*calibration.size() )
throw new IllegalArgumentException("Need more views to refine. eqs="+(3*calibration.size()+" unknowns="+func.getNumOfInputsN()));
// Declared new each time to ensure all variables are properly zeroed
// plane at infinity to the null space of Q
ConvertDMatrixStruct.convert(Q,_Q);
nullspace.process(_Q,1,p);
CommonOps_DDRM.divide(p,p.get(3));
p.numRows=3;
// Convert input objects into an array which can be understood by optimization
encode(calibration,p,param);
// Configure optimization
// optimizer.setVerbose(System.out,0);
optimizer.setFunction(func,null); // Compute using a numerical Jacobian
optimizer.initialize(param.data,converge.ftol,converge.gtol);
// Tell it to run for at most 100 iterations
if( !UtilOptimize.process(optimizer,converge.maxIterations) )
return false;
// extract solution
decode(optimizer.getParameters(),calibration,p);
recomputeQ(p,Q);
return true;
} | java | public boolean refine(List<CameraPinhole> calibration , DMatrix4x4 Q ) {
if( calibration.size() != cameras.size )
throw new RuntimeException("Calibration and cameras do not match");
computeNumberOfCalibrationParameters();
func = new ResidualK();
if( func.getNumOfInputsN() > 6*calibration.size() )
throw new IllegalArgumentException("Need more views to refine. eqs="+(3*calibration.size()+" unknowns="+func.getNumOfInputsN()));
// Declared new each time to ensure all variables are properly zeroed
// plane at infinity to the null space of Q
ConvertDMatrixStruct.convert(Q,_Q);
nullspace.process(_Q,1,p);
CommonOps_DDRM.divide(p,p.get(3));
p.numRows=3;
// Convert input objects into an array which can be understood by optimization
encode(calibration,p,param);
// Configure optimization
// optimizer.setVerbose(System.out,0);
optimizer.setFunction(func,null); // Compute using a numerical Jacobian
optimizer.initialize(param.data,converge.ftol,converge.gtol);
// Tell it to run for at most 100 iterations
if( !UtilOptimize.process(optimizer,converge.maxIterations) )
return false;
// extract solution
decode(optimizer.getParameters(),calibration,p);
recomputeQ(p,Q);
return true;
} | [
"public",
"boolean",
"refine",
"(",
"List",
"<",
"CameraPinhole",
">",
"calibration",
",",
"DMatrix4x4",
"Q",
")",
"{",
"if",
"(",
"calibration",
".",
"size",
"(",
")",
"!=",
"cameras",
".",
"size",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Calibrat... | Refine calibration matrix K given the dual absolute quadratic Q.
@param calibration (Input) Initial estimates of K. (Output) Refined estimate.
@param Q (Input) Initial estimate of absolute quadratic (Output) refined estimate. | [
"Refine",
"calibration",
"matrix",
"K",
"given",
"the",
"dual",
"absolute",
"quadratic",
"Q",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/RefineDualQuadraticAlgebra.java#L99-L135 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/RefineDualQuadraticAlgebra.java | RefineDualQuadraticAlgebra.recomputeQ | void recomputeQ( DMatrixRMaj p , DMatrix4x4 Q ) {
Equation eq = new Equation();
DMatrix3x3 K = new DMatrix3x3();
encodeK(K,0,3,param.data);
eq.alias(p,"p",K,"K");
eq.process("w=K*K'");
eq.process("Q=[w , -w*p;-p'*w , p'*w*p]");
DMatrixRMaj _Q = eq.lookupDDRM("Q");
CommonOps_DDRM.divide(_Q, NormOps_DDRM.normF(_Q));
ConvertDMatrixStruct.convert(_Q,Q);
} | java | void recomputeQ( DMatrixRMaj p , DMatrix4x4 Q ) {
Equation eq = new Equation();
DMatrix3x3 K = new DMatrix3x3();
encodeK(K,0,3,param.data);
eq.alias(p,"p",K,"K");
eq.process("w=K*K'");
eq.process("Q=[w , -w*p;-p'*w , p'*w*p]");
DMatrixRMaj _Q = eq.lookupDDRM("Q");
CommonOps_DDRM.divide(_Q, NormOps_DDRM.normF(_Q));
ConvertDMatrixStruct.convert(_Q,Q);
} | [
"void",
"recomputeQ",
"(",
"DMatrixRMaj",
"p",
",",
"DMatrix4x4",
"Q",
")",
"{",
"Equation",
"eq",
"=",
"new",
"Equation",
"(",
")",
";",
"DMatrix3x3",
"K",
"=",
"new",
"DMatrix3x3",
"(",
")",
";",
"encodeK",
"(",
"K",
",",
"0",
",",
"3",
",",
"par... | Compuets the absolute dual quadratic from the first camera parameters and
plane at infinity
@param p plane at infinity
@param Q (Output) ABQ | [
"Compuets",
"the",
"absolute",
"dual",
"quadratic",
"from",
"the",
"first",
"camera",
"parameters",
"and",
"plane",
"at",
"infinity"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/RefineDualQuadraticAlgebra.java#L155-L165 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/RefineDualQuadraticAlgebra.java | RefineDualQuadraticAlgebra.encodeK | public int encodeK( DMatrix3x3 K , int which, int offset, double params[] ) {
if( fixedAspectRatio ) {
K.a11 = params[offset++];
K.a22 = aspect.data[which]*K.a11;
} else {
K.a11 = params[offset++];
K.a22 = params[offset++];
}
if( !zeroSkew ) {
K.a12 = params[offset++];
}
if( !zeroPrinciplePoint ) {
K.a13 = params[offset++];
K.a23 = params[offset++];
}
K.a33 = 1;
return offset;
} | java | public int encodeK( DMatrix3x3 K , int which, int offset, double params[] ) {
if( fixedAspectRatio ) {
K.a11 = params[offset++];
K.a22 = aspect.data[which]*K.a11;
} else {
K.a11 = params[offset++];
K.a22 = params[offset++];
}
if( !zeroSkew ) {
K.a12 = params[offset++];
}
if( !zeroPrinciplePoint ) {
K.a13 = params[offset++];
K.a23 = params[offset++];
}
K.a33 = 1;
return offset;
} | [
"public",
"int",
"encodeK",
"(",
"DMatrix3x3",
"K",
",",
"int",
"which",
",",
"int",
"offset",
",",
"double",
"params",
"[",
"]",
")",
"{",
"if",
"(",
"fixedAspectRatio",
")",
"{",
"K",
".",
"a11",
"=",
"params",
"[",
"offset",
"++",
"]",
";",
"K",... | Encode the calibration as a 3x3 matrix. K is assumed to zero initially or at
least all non-zero elements will align with values that are written to. | [
"Encode",
"the",
"calibration",
"as",
"a",
"3x3",
"matrix",
".",
"K",
"is",
"assumed",
"to",
"zero",
"initially",
"or",
"at",
"least",
"all",
"non",
"-",
"zero",
"elements",
"will",
"align",
"with",
"values",
"that",
"are",
"written",
"to",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/RefineDualQuadraticAlgebra.java#L230-L250 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java | RegionMergeTree.initializeMerge | public void initializeMerge(int numRegions) {
mergeList.resize(numRegions);
for( int i = 0; i < numRegions; i++ )
mergeList.data[i] = i;
} | java | public void initializeMerge(int numRegions) {
mergeList.resize(numRegions);
for( int i = 0; i < numRegions; i++ )
mergeList.data[i] = i;
} | [
"public",
"void",
"initializeMerge",
"(",
"int",
"numRegions",
")",
"{",
"mergeList",
".",
"resize",
"(",
"numRegions",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numRegions",
";",
"i",
"++",
")",
"mergeList",
".",
"data",
"[",
"i",
... | Must call before any other functions.
@param numRegions Total number of regions. | [
"Must",
"call",
"before",
"any",
"other",
"functions",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java#L57-L61 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java | RegionMergeTree.performMerge | public void performMerge( GrayS32 pixelToRegion ,
GrowQueue_I32 regionMemberCount ) {
// update member counts
flowIntoRootNode(regionMemberCount);
// re-assign the number of the root node and trim excessive nodes from the lists
setToRootNodeNewID(regionMemberCount);
// change the labels in the pixelToRegion image
BinaryImageOps.relabel(pixelToRegion, mergeList.data);
} | java | public void performMerge( GrayS32 pixelToRegion ,
GrowQueue_I32 regionMemberCount ) {
// update member counts
flowIntoRootNode(regionMemberCount);
// re-assign the number of the root node and trim excessive nodes from the lists
setToRootNodeNewID(regionMemberCount);
// change the labels in the pixelToRegion image
BinaryImageOps.relabel(pixelToRegion, mergeList.data);
} | [
"public",
"void",
"performMerge",
"(",
"GrayS32",
"pixelToRegion",
",",
"GrowQueue_I32",
"regionMemberCount",
")",
"{",
"// update member counts",
"flowIntoRootNode",
"(",
"regionMemberCount",
")",
";",
"// re-assign the number of the root node and trim excessive nodes from the lis... | Merges regions together and updates the provided data structures for said changes.
@param pixelToRegion (Input/Output) Image used to convert pixel location in region ID. Modified.
@param regionMemberCount (Input/Output) List containing how many pixels belong to each region. Modified. | [
"Merges",
"regions",
"together",
"and",
"updates",
"the",
"provided",
"data",
"structures",
"for",
"said",
"changes",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java#L69-L79 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java | RegionMergeTree.flowIntoRootNode | protected void flowIntoRootNode(GrowQueue_I32 regionMemberCount) {
rootID.resize(regionMemberCount.size);
int count = 0;
for( int i = 0; i < mergeList.size; i++ ) {
int p = mergeList.data[i];
// see if it is a root note
if( p == i ) {
// mark the root nodes new ID
rootID.data[i] = count++;
continue;
}
// traverse down until it finds the root note
int gp = mergeList.data[p];
while( gp != p ) {
p = gp;
gp = mergeList.data[p];
}
// update the count and change this node into the root node
regionMemberCount.data[p] += regionMemberCount.data[i];
mergeList.data[i] = p;
}
} | java | protected void flowIntoRootNode(GrowQueue_I32 regionMemberCount) {
rootID.resize(regionMemberCount.size);
int count = 0;
for( int i = 0; i < mergeList.size; i++ ) {
int p = mergeList.data[i];
// see if it is a root note
if( p == i ) {
// mark the root nodes new ID
rootID.data[i] = count++;
continue;
}
// traverse down until it finds the root note
int gp = mergeList.data[p];
while( gp != p ) {
p = gp;
gp = mergeList.data[p];
}
// update the count and change this node into the root node
regionMemberCount.data[p] += regionMemberCount.data[i];
mergeList.data[i] = p;
}
} | [
"protected",
"void",
"flowIntoRootNode",
"(",
"GrowQueue_I32",
"regionMemberCount",
")",
"{",
"rootID",
".",
"resize",
"(",
"regionMemberCount",
".",
"size",
")",
";",
"int",
"count",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"merge... | For each region in the merge list which is not a root node, find its root node and add to the root node
its member count and set the index in mergeList to the root node. If a node is a root node just note
what its new ID will be after all the other segments are removed. | [
"For",
"each",
"region",
"in",
"the",
"merge",
"list",
"which",
"is",
"not",
"a",
"root",
"node",
"find",
"its",
"root",
"node",
"and",
"add",
"to",
"the",
"root",
"node",
"its",
"member",
"count",
"and",
"set",
"the",
"index",
"in",
"mergeList",
"to",... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java#L86-L111 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java | RegionMergeTree.setToRootNodeNewID | protected void setToRootNodeNewID( GrowQueue_I32 regionMemberCount ) {
tmpMemberCount.reset();
for( int i = 0; i < mergeList.size; i++ ) {
int p = mergeList.data[i];
if( p == i ) {
mergeList.data[i] = rootID.data[i];
tmpMemberCount.add( regionMemberCount.data[i] );
} else {
mergeList.data[i] = rootID.data[mergeList.data[i]];
}
}
regionMemberCount.reset();
regionMemberCount.addAll(tmpMemberCount);
} | java | protected void setToRootNodeNewID( GrowQueue_I32 regionMemberCount ) {
tmpMemberCount.reset();
for( int i = 0; i < mergeList.size; i++ ) {
int p = mergeList.data[i];
if( p == i ) {
mergeList.data[i] = rootID.data[i];
tmpMemberCount.add( regionMemberCount.data[i] );
} else {
mergeList.data[i] = rootID.data[mergeList.data[i]];
}
}
regionMemberCount.reset();
regionMemberCount.addAll(tmpMemberCount);
} | [
"protected",
"void",
"setToRootNodeNewID",
"(",
"GrowQueue_I32",
"regionMemberCount",
")",
"{",
"tmpMemberCount",
".",
"reset",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mergeList",
".",
"size",
";",
"i",
"++",
")",
"{",
"int",
"... | Does much of the work needed to remove the redundant segments that are being merged into their root node.
The list of member count is updated. mergeList is updated with the new segment IDs. | [
"Does",
"much",
"of",
"the",
"work",
"needed",
"to",
"remove",
"the",
"redundant",
"segments",
"that",
"are",
"being",
"merged",
"into",
"their",
"root",
"node",
".",
"The",
"list",
"of",
"member",
"count",
"is",
"updated",
".",
"mergeList",
"is",
"updated... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/ms/RegionMergeTree.java#L117-L134 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java | FactoryMultiView.homographyRefine | public static RefineEpipolar homographyRefine(double tol , int maxIterations , EpipolarError type ) {
ModelObservationResidualN residuals;
switch( type ) {
case SIMPLE:
residuals = new HomographyResidualTransfer();
break;
case SAMPSON:
residuals = new HomographyResidualSampson();
break;
default:
throw new IllegalArgumentException("Type not supported: "+type);
}
return new LeastSquaresHomography(tol,maxIterations,residuals);
} | java | public static RefineEpipolar homographyRefine(double tol , int maxIterations , EpipolarError type ) {
ModelObservationResidualN residuals;
switch( type ) {
case SIMPLE:
residuals = new HomographyResidualTransfer();
break;
case SAMPSON:
residuals = new HomographyResidualSampson();
break;
default:
throw new IllegalArgumentException("Type not supported: "+type);
}
return new LeastSquaresHomography(tol,maxIterations,residuals);
} | [
"public",
"static",
"RefineEpipolar",
"homographyRefine",
"(",
"double",
"tol",
",",
"int",
"maxIterations",
",",
"EpipolarError",
"type",
")",
"{",
"ModelObservationResidualN",
"residuals",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"SIMPLE",
":",
"residuals",... | Creates a non-linear optimizer for refining estimates of homography matrices.
@see HomographyResidualSampson
@see HomographyResidualTransfer
@param tol Tolerance for convergence. Try 1e-8
@param maxIterations Maximum number of iterations it will perform. Try 100 or more.
@return Homography refinement | [
"Creates",
"a",
"non",
"-",
"linear",
"optimizer",
"for",
"refining",
"estimates",
"of",
"homography",
"matrices",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java#L211-L227 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java | FactoryMultiView.fundamentalRefine | public static RefineEpipolar fundamentalRefine(double tol , int maxIterations , EpipolarError type )
{
switch( type ) {
case SAMPSON:
return new LeastSquaresFundamental(tol,maxIterations,true);
case SIMPLE:
return new LeastSquaresFundamental(tol,maxIterations,false);
}
throw new IllegalArgumentException("Type not supported: "+type);
} | java | public static RefineEpipolar fundamentalRefine(double tol , int maxIterations , EpipolarError type )
{
switch( type ) {
case SAMPSON:
return new LeastSquaresFundamental(tol,maxIterations,true);
case SIMPLE:
return new LeastSquaresFundamental(tol,maxIterations,false);
}
throw new IllegalArgumentException("Type not supported: "+type);
} | [
"public",
"static",
"RefineEpipolar",
"fundamentalRefine",
"(",
"double",
"tol",
",",
"int",
"maxIterations",
",",
"EpipolarError",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"SAMPSON",
":",
"return",
"new",
"LeastSquaresFundamental",
"(",
"tol",... | Creates a non-linear optimizer for refining estimates of fundamental or essential matrices.
@see boofcv.alg.geo.f.FundamentalResidualSampson
@see boofcv.alg.geo.f.FundamentalResidualSimple
@param tol Tolerance for convergence. Try 1e-8
@param maxIterations Maximum number of iterations it will perform. Try 100 or more.
@return RefineEpipolar | [
"Creates",
"a",
"non",
"-",
"linear",
"optimizer",
"for",
"refining",
"estimates",
"of",
"fundamental",
"or",
"essential",
"matrices",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java#L370-L380 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java | FactoryMultiView.pnp_N | public static EstimateNofPnP pnp_N(EnumPNP which , int numIterations ) {
MotionTransformPoint<Se3_F64, Point3D_F64> motionFit = FitSpecialEuclideanOps_F64.fitPoints3D();
switch( which ) {
case P3P_GRUNERT:
P3PGrunert grunert = new P3PGrunert(PolynomialOps.createRootFinder(5, RootFinderType.STURM));
return new WrapP3PLineDistance(grunert,motionFit);
case P3P_FINSTERWALDER:
P3PFinsterwalder finster = new P3PFinsterwalder(PolynomialOps.createRootFinder(4,RootFinderType.STURM));
return new WrapP3PLineDistance(finster,motionFit);
case EPNP:
Estimate1ofPnP epnp = pnp_1(which,numIterations,0);
return new Estimate1toNofPnP(epnp);
case IPPE:
Estimate1ofEpipolar H = FactoryMultiView.homographyTLS();
return new Estimate1toNofPnP(new IPPE_to_EstimatePnP(H));
}
throw new IllegalArgumentException("Type "+which+" not known");
} | java | public static EstimateNofPnP pnp_N(EnumPNP which , int numIterations ) {
MotionTransformPoint<Se3_F64, Point3D_F64> motionFit = FitSpecialEuclideanOps_F64.fitPoints3D();
switch( which ) {
case P3P_GRUNERT:
P3PGrunert grunert = new P3PGrunert(PolynomialOps.createRootFinder(5, RootFinderType.STURM));
return new WrapP3PLineDistance(grunert,motionFit);
case P3P_FINSTERWALDER:
P3PFinsterwalder finster = new P3PFinsterwalder(PolynomialOps.createRootFinder(4,RootFinderType.STURM));
return new WrapP3PLineDistance(finster,motionFit);
case EPNP:
Estimate1ofPnP epnp = pnp_1(which,numIterations,0);
return new Estimate1toNofPnP(epnp);
case IPPE:
Estimate1ofEpipolar H = FactoryMultiView.homographyTLS();
return new Estimate1toNofPnP(new IPPE_to_EstimatePnP(H));
}
throw new IllegalArgumentException("Type "+which+" not known");
} | [
"public",
"static",
"EstimateNofPnP",
"pnp_N",
"(",
"EnumPNP",
"which",
",",
"int",
"numIterations",
")",
"{",
"MotionTransformPoint",
"<",
"Se3_F64",
",",
"Point3D_F64",
">",
"motionFit",
"=",
"FitSpecialEuclideanOps_F64",
".",
"fitPoints3D",
"(",
")",
";",
"swit... | Creates an estimator for the PnP problem that uses only three observations, which is the minimal case
and known as P3P.
<p>NOTE: Observations are in normalized image coordinates NOT pixels.</p>
@param which The algorithm which is to be returned.
@param numIterations Number of iterations. Only used by some algorithms and recommended number varies
significantly by algorithm.
@return An estimator which can return multiple estimates. | [
"Creates",
"an",
"estimator",
"for",
"the",
"PnP",
"problem",
"that",
"uses",
"only",
"three",
"observations",
"which",
"is",
"the",
"minimal",
"case",
"and",
"known",
"as",
"P3P",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java#L440-L463 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java | FactoryMultiView.pnp_1 | public static Estimate1ofPnP pnp_1(EnumPNP which, int numIterations , int numTest) {
if( which == EnumPNP.EPNP ) {
PnPLepetitEPnP alg = new PnPLepetitEPnP(0.1);
alg.setNumIterations(numIterations);
return new WrapPnPLepetitEPnP(alg);
} else if( which == EnumPNP.IPPE ) {
Estimate1ofEpipolar H = FactoryMultiView.homographyTLS();
return new IPPE_to_EstimatePnP(H);
}
FastQueue<Se3_F64> solutions = new FastQueue<>(4, Se3_F64.class, true);
return new EstimateNto1ofPnP(pnp_N(which,-1),solutions,numTest);
} | java | public static Estimate1ofPnP pnp_1(EnumPNP which, int numIterations , int numTest) {
if( which == EnumPNP.EPNP ) {
PnPLepetitEPnP alg = new PnPLepetitEPnP(0.1);
alg.setNumIterations(numIterations);
return new WrapPnPLepetitEPnP(alg);
} else if( which == EnumPNP.IPPE ) {
Estimate1ofEpipolar H = FactoryMultiView.homographyTLS();
return new IPPE_to_EstimatePnP(H);
}
FastQueue<Se3_F64> solutions = new FastQueue<>(4, Se3_F64.class, true);
return new EstimateNto1ofPnP(pnp_N(which,-1),solutions,numTest);
} | [
"public",
"static",
"Estimate1ofPnP",
"pnp_1",
"(",
"EnumPNP",
"which",
",",
"int",
"numIterations",
",",
"int",
"numTest",
")",
"{",
"if",
"(",
"which",
"==",
"EnumPNP",
".",
"EPNP",
")",
"{",
"PnPLepetitEPnP",
"alg",
"=",
"new",
"PnPLepetitEPnP",
"(",
"0... | Created an estimator for the P3P problem that selects a single solution by considering additional
observations.
<p>NOTE: Observations are in normalized image coordinates NOT pixels.</p>
<p>
NOTE: EPnP has several tuning parameters and the defaults here might not be the best for your situation.
Use {@link #computePnPwithEPnP} if you wish to have access to all parameters.
</p>
@param which The algorithm which is to be returned.
@param numIterations Number of iterations. Only used by some algorithms and recommended number varies
significantly by algorithm.
@param numTest How many additional sample points are used to remove ambiguity in the solutions. Not used
if only a single solution is found.
@return An estimator which returns a single estimate. | [
"Created",
"an",
"estimator",
"for",
"the",
"P3P",
"problem",
"that",
"selects",
"a",
"single",
"solution",
"by",
"considering",
"additional",
"observations",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java#L483-L497 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java | FactoryMultiView.computePnPwithEPnP | public static Estimate1ofPnP computePnPwithEPnP(int numIterations, double magicNumber) {
PnPLepetitEPnP alg = new PnPLepetitEPnP(magicNumber);
alg.setNumIterations(numIterations);
return new WrapPnPLepetitEPnP(alg);
} | java | public static Estimate1ofPnP computePnPwithEPnP(int numIterations, double magicNumber) {
PnPLepetitEPnP alg = new PnPLepetitEPnP(magicNumber);
alg.setNumIterations(numIterations);
return new WrapPnPLepetitEPnP(alg);
} | [
"public",
"static",
"Estimate1ofPnP",
"computePnPwithEPnP",
"(",
"int",
"numIterations",
",",
"double",
"magicNumber",
")",
"{",
"PnPLepetitEPnP",
"alg",
"=",
"new",
"PnPLepetitEPnP",
"(",
"magicNumber",
")",
";",
"alg",
".",
"setNumIterations",
"(",
"numIterations"... | Returns a solution to the PnP problem for 4 or more points using EPnP. Fast and fairly
accurate algorithm. Can handle general and planar scenario automatically.
<p>NOTE: Observations are in normalized image coordinates NOT pixels.</p>
@see PnPLepetitEPnP
@param numIterations If more then zero then non-linear optimization is done. More is not always better. Try 10
@param magicNumber Affects how the problem is linearized. See comments in {@link PnPLepetitEPnP}. Try 0.1
@return Estimate1ofPnP | [
"Returns",
"a",
"solution",
"to",
"the",
"PnP",
"problem",
"for",
"4",
"or",
"more",
"points",
"using",
"EPnP",
".",
"Fast",
"and",
"fairly",
"accurate",
"algorithm",
".",
"Can",
"handle",
"general",
"and",
"planar",
"scenario",
"automatically",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/factory/geo/FactoryMultiView.java#L511-L515 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/kernel/FactorySteerable.java | FactorySteerable.gaussian | public static <K extends Kernel2D> SteerableKernel<K> gaussian(Class<K> kernelType, int orderX, int orderY, double sigma, int radius) {
if( orderX < 0 || orderX > 4 )
throw new IllegalArgumentException("derivX must be from 0 to 4 inclusive.");
if( orderY < 0 || orderY > 4 )
throw new IllegalArgumentException("derivT must be from 0 to 4 inclusive.");
int order = orderX + orderY;
if( order > 4 ) {
throw new IllegalArgumentException("The total order of x and y can't be greater than 4");
}
int maxOrder = Math.max(orderX,orderY);
if( sigma <= 0 )
sigma = (float)FactoryKernelGaussian.sigmaForRadius(radius,maxOrder);
else if( radius <= 0 )
radius = FactoryKernelGaussian.radiusForSigma(sigma,maxOrder);
Class kernel1DType = FactoryKernel.get1DType(kernelType);
Kernel1D kerX = FactoryKernelGaussian.derivativeK(kernel1DType,orderX,sigma,radius);
Kernel1D kerY = FactoryKernelGaussian.derivativeK(kernel1DType,orderY,sigma,radius);
Kernel2D kernel = GKernelMath.convolve(kerY,kerX);
Kernel2D []basis = new Kernel2D[order+1];
// convert it into an image which can be rotated
ImageGray image = GKernelMath.convertToImage(kernel);
ImageGray imageRotated = (ImageGray)image.createNew(image.width,image.height);
basis[0] = kernel;
// form the basis by created rotated versions of the kernel
double angleStep = Math.PI/basis.length;
for( int index = 1; index <= order; index++ ) {
float angle = (float)(angleStep*index);
GImageMiscOps.fill(imageRotated, 0);
new FDistort(image,imageRotated).rotate(angle).apply();
basis[index] = GKernelMath.convertToKernel(imageRotated);
}
SteerableKernel<K> ret;
if( kernelType == Kernel2D_F32.class )
ret = (SteerableKernel<K>)new SteerableKernel_F32();
else
ret = (SteerableKernel<K>)new SteerableKernel_I32();
ret.setBasis(FactorySteerCoefficients.polynomial(order),basis);
return ret;
} | java | public static <K extends Kernel2D> SteerableKernel<K> gaussian(Class<K> kernelType, int orderX, int orderY, double sigma, int radius) {
if( orderX < 0 || orderX > 4 )
throw new IllegalArgumentException("derivX must be from 0 to 4 inclusive.");
if( orderY < 0 || orderY > 4 )
throw new IllegalArgumentException("derivT must be from 0 to 4 inclusive.");
int order = orderX + orderY;
if( order > 4 ) {
throw new IllegalArgumentException("The total order of x and y can't be greater than 4");
}
int maxOrder = Math.max(orderX,orderY);
if( sigma <= 0 )
sigma = (float)FactoryKernelGaussian.sigmaForRadius(radius,maxOrder);
else if( radius <= 0 )
radius = FactoryKernelGaussian.radiusForSigma(sigma,maxOrder);
Class kernel1DType = FactoryKernel.get1DType(kernelType);
Kernel1D kerX = FactoryKernelGaussian.derivativeK(kernel1DType,orderX,sigma,radius);
Kernel1D kerY = FactoryKernelGaussian.derivativeK(kernel1DType,orderY,sigma,radius);
Kernel2D kernel = GKernelMath.convolve(kerY,kerX);
Kernel2D []basis = new Kernel2D[order+1];
// convert it into an image which can be rotated
ImageGray image = GKernelMath.convertToImage(kernel);
ImageGray imageRotated = (ImageGray)image.createNew(image.width,image.height);
basis[0] = kernel;
// form the basis by created rotated versions of the kernel
double angleStep = Math.PI/basis.length;
for( int index = 1; index <= order; index++ ) {
float angle = (float)(angleStep*index);
GImageMiscOps.fill(imageRotated, 0);
new FDistort(image,imageRotated).rotate(angle).apply();
basis[index] = GKernelMath.convertToKernel(imageRotated);
}
SteerableKernel<K> ret;
if( kernelType == Kernel2D_F32.class )
ret = (SteerableKernel<K>)new SteerableKernel_F32();
else
ret = (SteerableKernel<K>)new SteerableKernel_I32();
ret.setBasis(FactorySteerCoefficients.polynomial(order),basis);
return ret;
} | [
"public",
"static",
"<",
"K",
"extends",
"Kernel2D",
">",
"SteerableKernel",
"<",
"K",
">",
"gaussian",
"(",
"Class",
"<",
"K",
">",
"kernelType",
",",
"int",
"orderX",
",",
"int",
"orderY",
",",
"double",
"sigma",
",",
"int",
"radius",
")",
"{",
"if",... | Steerable filter for 2D Gaussian derivatives. The basis is composed of a set of rotated kernels.
@param kernelType Specifies which type of 2D kernel should be generated.
@param orderX Order of the derivative in the x-axis.
@param orderY Order of the derivative in the y-axis.
@param sigma
@param radius Radius of the kernel. @return Steerable kernel generator for the specified gaussian derivative. | [
"Steerable",
"filter",
"for",
"2D",
"Gaussian",
"derivatives",
".",
"The",
"basis",
"is",
"composed",
"of",
"a",
"set",
"of",
"rotated",
"kernels",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/kernel/FactorySteerable.java#L54-L107 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/watershed/WatershedVincentSoille1991.java | WatershedVincentSoille1991.process | public void process( GrayU8 input ) {
// input = im_0
removedWatersheds = false;
output.reshape(input.width+2,input.height+2);
distance.reshape(input.width+2,input.height+2);
ImageMiscOps.fill(output, INIT);
ImageMiscOps.fill(distance, 0);
fifo.reset();
// sort pixels
sortPixels(input);
currentLabel = 0;
for( int i = 0; i < histogram.length; i++ ) {
GrowQueue_I32 level = histogram[i];
if( level.size == 0 )
continue;
// Go through each pixel at this level and mark them according to their neighbors
for( int j = 0; j < level.size; j++ ) {
int index = level.data[j];
output.data[index] = MASK;
// see if its neighbors has been labeled, if so set its distance and add to queue
assignNewToNeighbors(index);
}
currentDistance = 1;
fifo.add(MARKER_PIXEL);
while( true ) {
int p = fifo.popHead();
// end of a cycle. Exit the loop if it is done or increase the distance and continue processing
if( p == MARKER_PIXEL) {
if( fifo.isEmpty() )
break;
else {
fifo.add(MARKER_PIXEL);
currentDistance++;
p = fifo.popHead();
}
}
// look at its neighbors and see if they have been labeled or belong to a watershed
// and update its distance
checkNeighborsAssign(p);
}
// see if new minima have been discovered
for( int j = 0; j < level.size; j++ ) {
int index = level.get(j);
// distance associated with p is reset to 0
distance.data[index] = 0;
if( output.data[index] == MASK ) {
currentLabel++;
fifo.add(index);
output.data[index] = currentLabel;
// grow the new region into the surrounding connected pixels
while( !fifo.isEmpty() ) {
checkNeighborsMasks(fifo.popHead());
}
}
}
}
} | java | public void process( GrayU8 input ) {
// input = im_0
removedWatersheds = false;
output.reshape(input.width+2,input.height+2);
distance.reshape(input.width+2,input.height+2);
ImageMiscOps.fill(output, INIT);
ImageMiscOps.fill(distance, 0);
fifo.reset();
// sort pixels
sortPixels(input);
currentLabel = 0;
for( int i = 0; i < histogram.length; i++ ) {
GrowQueue_I32 level = histogram[i];
if( level.size == 0 )
continue;
// Go through each pixel at this level and mark them according to their neighbors
for( int j = 0; j < level.size; j++ ) {
int index = level.data[j];
output.data[index] = MASK;
// see if its neighbors has been labeled, if so set its distance and add to queue
assignNewToNeighbors(index);
}
currentDistance = 1;
fifo.add(MARKER_PIXEL);
while( true ) {
int p = fifo.popHead();
// end of a cycle. Exit the loop if it is done or increase the distance and continue processing
if( p == MARKER_PIXEL) {
if( fifo.isEmpty() )
break;
else {
fifo.add(MARKER_PIXEL);
currentDistance++;
p = fifo.popHead();
}
}
// look at its neighbors and see if they have been labeled or belong to a watershed
// and update its distance
checkNeighborsAssign(p);
}
// see if new minima have been discovered
for( int j = 0; j < level.size; j++ ) {
int index = level.get(j);
// distance associated with p is reset to 0
distance.data[index] = 0;
if( output.data[index] == MASK ) {
currentLabel++;
fifo.add(index);
output.data[index] = currentLabel;
// grow the new region into the surrounding connected pixels
while( !fifo.isEmpty() ) {
checkNeighborsMasks(fifo.popHead());
}
}
}
}
} | [
"public",
"void",
"process",
"(",
"GrayU8",
"input",
")",
"{",
"// input = im_0",
"removedWatersheds",
"=",
"false",
";",
"output",
".",
"reshape",
"(",
"input",
".",
"width",
"+",
"2",
",",
"input",
".",
"height",
"+",
"2",
")",
";",
"distance",
".",
... | Perform watershed segmentation on the provided input image. New basins are created at each local minima.
@param input Input gray-scale image. | [
"Perform",
"watershed",
"segmentation",
"on",
"the",
"provided",
"input",
"image",
".",
"New",
"basins",
"are",
"created",
"at",
"each",
"local",
"minima",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/watershed/WatershedVincentSoille1991.java#L119-L189 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/segmentation/watershed/WatershedVincentSoille1991.java | WatershedVincentSoille1991.sortPixels | protected void sortPixels(GrayU8 input) {
// initialize histogram
for( int i = 0; i < histogram.length; i++ ) {
histogram[i].reset();
}
// sort by creating a histogram
for( int y = 0; y < input.height; y++ ) {
int index = input.startIndex + y*input.stride;
int indexOut = (y+1)*output.stride + 1;
for (int x = 0; x < input.width; x++ , index++ , indexOut++) {
int value = input.data[index] & 0xFF;
histogram[value].add(indexOut);
}
}
} | java | protected void sortPixels(GrayU8 input) {
// initialize histogram
for( int i = 0; i < histogram.length; i++ ) {
histogram[i].reset();
}
// sort by creating a histogram
for( int y = 0; y < input.height; y++ ) {
int index = input.startIndex + y*input.stride;
int indexOut = (y+1)*output.stride + 1;
for (int x = 0; x < input.width; x++ , index++ , indexOut++) {
int value = input.data[index] & 0xFF;
histogram[value].add(indexOut);
}
}
} | [
"protected",
"void",
"sortPixels",
"(",
"GrayU8",
"input",
")",
"{",
"// initialize histogram",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"histogram",
".",
"length",
";",
"i",
"++",
")",
"{",
"histogram",
"[",
"i",
"]",
".",
"reset",
"(",
")",... | Very fast histogram based sorting. Index of each pixel is placed inside a list for its intensity level. | [
"Very",
"fast",
"histogram",
"based",
"sorting",
".",
"Index",
"of",
"each",
"pixel",
"is",
"placed",
"inside",
"a",
"list",
"for",
"its",
"intensity",
"level",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/segmentation/watershed/WatershedVincentSoille1991.java#L341-L355 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java | BoofMiscOps.numDigits | public static int numDigits(int number) {
if( number == 0 )
return 1;
int adjustment = 0;
if( number < 0 ) {
adjustment = 1;
number = -number;
}
return adjustment + (int)Math.log10(number)+1;
} | java | public static int numDigits(int number) {
if( number == 0 )
return 1;
int adjustment = 0;
if( number < 0 ) {
adjustment = 1;
number = -number;
}
return adjustment + (int)Math.log10(number)+1;
} | [
"public",
"static",
"int",
"numDigits",
"(",
"int",
"number",
")",
"{",
"if",
"(",
"number",
"==",
"0",
")",
"return",
"1",
";",
"int",
"adjustment",
"=",
"0",
";",
"if",
"(",
"number",
"<",
"0",
")",
"{",
"adjustment",
"=",
"1",
";",
"number",
"... | Returns the number of digits in a number. E.g. 345 = 3, -345 = 4, 0 = 1 | [
"Returns",
"the",
"number",
"of",
"digits",
"in",
"a",
"number",
".",
"E",
".",
"g",
".",
"345",
"=",
"3",
"-",
"345",
"=",
"4",
"0",
"=",
"1"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java#L49-L58 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java | BoofMiscOps.boundRectangleInside | public static void boundRectangleInside( ImageBase b , ImageRectangle r )
{
if( r.x0 < 0 )
r.x0 = 0;
if( r.x1 > b.width )
r.x1 = b.width;
if( r.y0 < 0 )
r.y0 = 0;
if( r.y1 > b.height )
r.y1 = b.height;
} | java | public static void boundRectangleInside( ImageBase b , ImageRectangle r )
{
if( r.x0 < 0 )
r.x0 = 0;
if( r.x1 > b.width )
r.x1 = b.width;
if( r.y0 < 0 )
r.y0 = 0;
if( r.y1 > b.height )
r.y1 = b.height;
} | [
"public",
"static",
"void",
"boundRectangleInside",
"(",
"ImageBase",
"b",
",",
"ImageRectangle",
"r",
")",
"{",
"if",
"(",
"r",
".",
"x0",
"<",
"0",
")",
"r",
".",
"x0",
"=",
"0",
";",
"if",
"(",
"r",
".",
"x1",
">",
"b",
".",
"width",
")",
"r... | Bounds the provided rectangle to be inside the image.
@param b An image.
@param r Rectangle | [
"Bounds",
"the",
"provided",
"rectangle",
"to",
"be",
"inside",
"the",
"image",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java#L149-L160 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java | BoofMiscOps.checkInside | public static boolean checkInside(ImageBase b, int x , int y , int radius ) {
if( x-radius < 0 )
return false;
if( x+radius >= b.width )
return false;
if( y-radius < 0 )
return false;
if( y+radius >= b.height )
return false;
return true;
} | java | public static boolean checkInside(ImageBase b, int x , int y , int radius ) {
if( x-radius < 0 )
return false;
if( x+radius >= b.width )
return false;
if( y-radius < 0 )
return false;
if( y+radius >= b.height )
return false;
return true;
} | [
"public",
"static",
"boolean",
"checkInside",
"(",
"ImageBase",
"b",
",",
"int",
"x",
",",
"int",
"y",
",",
"int",
"radius",
")",
"{",
"if",
"(",
"x",
"-",
"radius",
"<",
"0",
")",
"return",
"false",
";",
"if",
"(",
"x",
"+",
"radius",
">=",
"b",... | Returns true if the point is contained inside the image and 'radius' away from the image border.
@param b Image
@param x x-coordinate of point
@param y y-coordinate of point
@param radius How many pixels away from the border it needs to be to be considered inside
@return true if the point is inside and false if it is outside | [
"Returns",
"true",
"if",
"the",
"point",
"is",
"contained",
"inside",
"the",
"image",
"and",
"radius",
"away",
"from",
"the",
"image",
"border",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java#L184-L195 | train |
lessthanoptimal/BoofCV | main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java | BoofMiscOps.pause | public static void pause(long milli) {
final Thread t = Thread.currentThread();
long start = System.currentTimeMillis();
while( System.currentTimeMillis() - start < milli ) {
synchronized( t ) {
try {
long target = milli - (System.currentTimeMillis() - start);
if( target > 0 )
t.wait(target);
} catch (InterruptedException ignore) {
}
}
}
} | java | public static void pause(long milli) {
final Thread t = Thread.currentThread();
long start = System.currentTimeMillis();
while( System.currentTimeMillis() - start < milli ) {
synchronized( t ) {
try {
long target = milli - (System.currentTimeMillis() - start);
if( target > 0 )
t.wait(target);
} catch (InterruptedException ignore) {
}
}
}
} | [
"public",
"static",
"void",
"pause",
"(",
"long",
"milli",
")",
"{",
"final",
"Thread",
"t",
"=",
"Thread",
".",
"currentThread",
"(",
")",
";",
"long",
"start",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"System",
".",
"curr... | Invokes wait until the elapsed time has passed. In the thread is interrupted, the interrupt is ignored.
@param milli Length of desired pause in milliseconds. | [
"Invokes",
"wait",
"until",
"the",
"elapsed",
"time",
"has",
"passed",
".",
"In",
"the",
"thread",
"is",
"interrupted",
"the",
"interrupt",
"is",
"ignored",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-types/src/main/java/boofcv/misc/BoofMiscOps.java#L300-L313 | train |
lessthanoptimal/BoofCV | applications/src/main/java/boofcv/app/FiducialDetection.java | FiducialDetection.processStream | private void processStream(CameraPinholeBrown intrinsic , SimpleImageSequence<GrayU8> sequence , ImagePanel gui , long pauseMilli) {
Font font = new Font("Serif", Font.BOLD, 24);
Se3_F64 fiducialToCamera = new Se3_F64();
int frameNumber = 0;
while( sequence.hasNext() ) {
long before = System.currentTimeMillis();
GrayU8 input = sequence.next();
BufferedImage buffered = sequence.getGuiImage();
try {
detector.detect(input);
} catch( RuntimeException e ) {
System.err.println("BUG!!! saving image to crash_image.png");
UtilImageIO.saveImage(buffered,"crash_image.png");
throw e;
}
Graphics2D g2 = buffered.createGraphics();
for (int i = 0; i < detector.totalFound(); i++) {
detector.getFiducialToCamera(i,fiducialToCamera);
long id = detector.getId(i);
double width = detector.getWidth(i);
VisualizeFiducial.drawCube(fiducialToCamera,intrinsic,width,3,g2);
VisualizeFiducial.drawLabelCenter(fiducialToCamera,intrinsic,""+id,g2);
}
saveResults(frameNumber++);
if( intrinsicPath == null ) {
g2.setColor(Color.RED);
g2.setFont(font);
g2.drawString("Uncalibrated",10,20);
}
gui.setImage(buffered);
long after = System.currentTimeMillis();
long time = Math.max(0,pauseMilli-(after-before));
if( time > 0 ) {
try { Thread.sleep(time); } catch (InterruptedException ignore) {}
}
}
} | java | private void processStream(CameraPinholeBrown intrinsic , SimpleImageSequence<GrayU8> sequence , ImagePanel gui , long pauseMilli) {
Font font = new Font("Serif", Font.BOLD, 24);
Se3_F64 fiducialToCamera = new Se3_F64();
int frameNumber = 0;
while( sequence.hasNext() ) {
long before = System.currentTimeMillis();
GrayU8 input = sequence.next();
BufferedImage buffered = sequence.getGuiImage();
try {
detector.detect(input);
} catch( RuntimeException e ) {
System.err.println("BUG!!! saving image to crash_image.png");
UtilImageIO.saveImage(buffered,"crash_image.png");
throw e;
}
Graphics2D g2 = buffered.createGraphics();
for (int i = 0; i < detector.totalFound(); i++) {
detector.getFiducialToCamera(i,fiducialToCamera);
long id = detector.getId(i);
double width = detector.getWidth(i);
VisualizeFiducial.drawCube(fiducialToCamera,intrinsic,width,3,g2);
VisualizeFiducial.drawLabelCenter(fiducialToCamera,intrinsic,""+id,g2);
}
saveResults(frameNumber++);
if( intrinsicPath == null ) {
g2.setColor(Color.RED);
g2.setFont(font);
g2.drawString("Uncalibrated",10,20);
}
gui.setImage(buffered);
long after = System.currentTimeMillis();
long time = Math.max(0,pauseMilli-(after-before));
if( time > 0 ) {
try { Thread.sleep(time); } catch (InterruptedException ignore) {}
}
}
} | [
"private",
"void",
"processStream",
"(",
"CameraPinholeBrown",
"intrinsic",
",",
"SimpleImageSequence",
"<",
"GrayU8",
">",
"sequence",
",",
"ImagePanel",
"gui",
",",
"long",
"pauseMilli",
")",
"{",
"Font",
"font",
"=",
"new",
"Font",
"(",
"\"Serif\"",
",",
"F... | Displays a continuous stream of images | [
"Displays",
"a",
"continuous",
"stream",
"of",
"images"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/FiducialDetection.java#L395-L439 | train |
lessthanoptimal/BoofCV | applications/src/main/java/boofcv/app/FiducialDetection.java | FiducialDetection.processImage | private void processImage(CameraPinholeBrown intrinsic , BufferedImage buffered , ImagePanel gui ) {
Font font = new Font("Serif", Font.BOLD, 24);
GrayU8 gray = new GrayU8(buffered.getWidth(),buffered.getHeight());
ConvertBufferedImage.convertFrom(buffered,gray);
Se3_F64 fiducialToCamera = new Se3_F64();
try {
detector.detect(gray);
} catch( RuntimeException e ) {
System.err.println("BUG!!! saving image to crash_image.png");
UtilImageIO.saveImage(buffered,"crash_image.png");
throw e;
}
Graphics2D g2 = buffered.createGraphics();
for (int i = 0; i < detector.totalFound(); i++) {
detector.getFiducialToCamera(i,fiducialToCamera);
long id = detector.getId(i);
double width = detector.getWidth(i);
VisualizeFiducial.drawCube(fiducialToCamera,intrinsic,width,3,g2);
VisualizeFiducial.drawLabelCenter(fiducialToCamera,intrinsic,""+id,g2);
}
saveResults(0);
if( intrinsicPath == null ) {
g2.setColor(Color.RED);
g2.setFont(font);
g2.drawString("Uncalibrated",10,20);
}
gui.setImage(buffered);
} | java | private void processImage(CameraPinholeBrown intrinsic , BufferedImage buffered , ImagePanel gui ) {
Font font = new Font("Serif", Font.BOLD, 24);
GrayU8 gray = new GrayU8(buffered.getWidth(),buffered.getHeight());
ConvertBufferedImage.convertFrom(buffered,gray);
Se3_F64 fiducialToCamera = new Se3_F64();
try {
detector.detect(gray);
} catch( RuntimeException e ) {
System.err.println("BUG!!! saving image to crash_image.png");
UtilImageIO.saveImage(buffered,"crash_image.png");
throw e;
}
Graphics2D g2 = buffered.createGraphics();
for (int i = 0; i < detector.totalFound(); i++) {
detector.getFiducialToCamera(i,fiducialToCamera);
long id = detector.getId(i);
double width = detector.getWidth(i);
VisualizeFiducial.drawCube(fiducialToCamera,intrinsic,width,3,g2);
VisualizeFiducial.drawLabelCenter(fiducialToCamera,intrinsic,""+id,g2);
}
saveResults(0);
if( intrinsicPath == null ) {
g2.setColor(Color.RED);
g2.setFont(font);
g2.drawString("Uncalibrated",10,20);
}
gui.setImage(buffered);
} | [
"private",
"void",
"processImage",
"(",
"CameraPinholeBrown",
"intrinsic",
",",
"BufferedImage",
"buffered",
",",
"ImagePanel",
"gui",
")",
"{",
"Font",
"font",
"=",
"new",
"Font",
"(",
"\"Serif\"",
",",
"Font",
".",
"BOLD",
",",
"24",
")",
";",
"GrayU8",
... | Displays a simple image | [
"Displays",
"a",
"simple",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/applications/src/main/java/boofcv/app/FiducialDetection.java#L444-L479 | train |
lessthanoptimal/BoofCV | main/boofcv-io/src/main/java/boofcv/io/video/VideoMjpegCodec.java | VideoMjpegCodec.readFrame | public byte[] readFrame( DataInputStream in ) {
try {
if( findMarker(in,SOI) && in.available() > 0 ) {
return readJpegData(in, EOI);
}
} catch (IOException e) {}
return null;
} | java | public byte[] readFrame( DataInputStream in ) {
try {
if( findMarker(in,SOI) && in.available() > 0 ) {
return readJpegData(in, EOI);
}
} catch (IOException e) {}
return null;
} | [
"public",
"byte",
"[",
"]",
"readFrame",
"(",
"DataInputStream",
"in",
")",
"{",
"try",
"{",
"if",
"(",
"findMarker",
"(",
"in",
",",
"SOI",
")",
"&&",
"in",
".",
"available",
"(",
")",
">",
"0",
")",
"{",
"return",
"readJpegData",
"(",
"in",
",",
... | Read a single frame at a time | [
"Read",
"a",
"single",
"frame",
"at",
"a",
"time"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-io/src/main/java/boofcv/io/video/VideoMjpegCodec.java#L59-L66 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdLocalOtsu.java | ThresholdLocalOtsu.applyToBorder | void applyToBorder(GrayU8 input, GrayU8 output, int y0, int y1, int x0, int x1, ApplyHelper h) {
// top-left corner
h.computeHistogram(0,0,input);
h.applyToBlock(0,0,x0+1,y0+1,input,output);
// top-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,0,input);
h.applyToBlock(x,0,x+1,y0,input,output);
}
// top-right
h.updateHistogramX(x1-x0,0,input);
h.applyToBlock(x1,0,input.width,y0+1,input,output);
// middle-right
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(x1-x0,y-y0,input);
h.applyToBlock(x1,y,input.width,y+1,input,output);
}
// bottom-right
h.updateHistogramY(x1-x0,y1-y0,input);
h.applyToBlock(x1,y1,input.width,input.height,input,output);
//Start over in the top-left. Yes this step could be avoided...
// middle-left
h.computeHistogram(0,0,input);
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(0,y-y0,input);
h.applyToBlock(0,y,x0,y+1,input,output);
}
// bottom-left
h.updateHistogramY(0,y1-y0,input);
h.applyToBlock(0,y1,x0+1,input.height,input,output);
// bottom-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,y1-y0,input);
h.applyToBlock(x,y1,x+1,input.height,input,output);
}
} | java | void applyToBorder(GrayU8 input, GrayU8 output, int y0, int y1, int x0, int x1, ApplyHelper h) {
// top-left corner
h.computeHistogram(0,0,input);
h.applyToBlock(0,0,x0+1,y0+1,input,output);
// top-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,0,input);
h.applyToBlock(x,0,x+1,y0,input,output);
}
// top-right
h.updateHistogramX(x1-x0,0,input);
h.applyToBlock(x1,0,input.width,y0+1,input,output);
// middle-right
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(x1-x0,y-y0,input);
h.applyToBlock(x1,y,input.width,y+1,input,output);
}
// bottom-right
h.updateHistogramY(x1-x0,y1-y0,input);
h.applyToBlock(x1,y1,input.width,input.height,input,output);
//Start over in the top-left. Yes this step could be avoided...
// middle-left
h.computeHistogram(0,0,input);
for (int y = y0+1; y < y1; y++) {
h.updateHistogramY(0,y-y0,input);
h.applyToBlock(0,y,x0,y+1,input,output);
}
// bottom-left
h.updateHistogramY(0,y1-y0,input);
h.applyToBlock(0,y1,x0+1,input.height,input,output);
// bottom-middle
for (int x = x0+1; x < x1; x++) {
h.updateHistogramX(x-x0,y1-y0,input);
h.applyToBlock(x,y1,x+1,input.height,input,output);
}
} | [
"void",
"applyToBorder",
"(",
"GrayU8",
"input",
",",
"GrayU8",
"output",
",",
"int",
"y0",
",",
"int",
"y1",
",",
"int",
"x0",
",",
"int",
"x1",
",",
"ApplyHelper",
"h",
")",
"{",
"// top-left corner",
"h",
".",
"computeHistogram",
"(",
"0",
",",
"0",... | Apply around the image border. Use a region that's the full size but apply to all pixels that the region
would go outside of it was centered on them. | [
"Apply",
"around",
"the",
"image",
"border",
".",
"Use",
"a",
"region",
"that",
"s",
"the",
"full",
"size",
"but",
"apply",
"to",
"all",
"pixels",
"that",
"the",
"region",
"would",
"go",
"outside",
"of",
"it",
"was",
"centered",
"on",
"them",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdLocalOtsu.java#L132-L174 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/UtilImageMotion.java | UtilImageMotion.createPixelTransform | public static PixelTransform<Point2D_F32> createPixelTransform(InvertibleTransform transform) {
PixelTransform<Point2D_F32> pixelTran;
if( transform instanceof Homography2D_F64) {
Homography2D_F32 t = ConvertFloatType.convert((Homography2D_F64) transform, null);
pixelTran = new PixelTransformHomography_F32(t);
} else if( transform instanceof Homography2D_F32) {
pixelTran = new PixelTransformHomography_F32((Homography2D_F32)transform);
} else if( transform instanceof Affine2D_F64) {
Affine2D_F32 t = UtilAffine.convert((Affine2D_F64) transform, null);
pixelTran = new PixelTransformAffine_F32(t);
} else if( transform instanceof Affine2D_F32) {
pixelTran = new PixelTransformAffine_F32((Affine2D_F32)transform);
} else {
throw new RuntimeException("Unknown model type");
}
return pixelTran;
} | java | public static PixelTransform<Point2D_F32> createPixelTransform(InvertibleTransform transform) {
PixelTransform<Point2D_F32> pixelTran;
if( transform instanceof Homography2D_F64) {
Homography2D_F32 t = ConvertFloatType.convert((Homography2D_F64) transform, null);
pixelTran = new PixelTransformHomography_F32(t);
} else if( transform instanceof Homography2D_F32) {
pixelTran = new PixelTransformHomography_F32((Homography2D_F32)transform);
} else if( transform instanceof Affine2D_F64) {
Affine2D_F32 t = UtilAffine.convert((Affine2D_F64) transform, null);
pixelTran = new PixelTransformAffine_F32(t);
} else if( transform instanceof Affine2D_F32) {
pixelTran = new PixelTransformAffine_F32((Affine2D_F32)transform);
} else {
throw new RuntimeException("Unknown model type");
}
return pixelTran;
} | [
"public",
"static",
"PixelTransform",
"<",
"Point2D_F32",
">",
"createPixelTransform",
"(",
"InvertibleTransform",
"transform",
")",
"{",
"PixelTransform",
"<",
"Point2D_F32",
">",
"pixelTran",
";",
"if",
"(",
"transform",
"instanceof",
"Homography2D_F64",
")",
"{",
... | Given a motion model create a PixelTransform used to distort the image
@param transform Motion transform
@return PixelTransform_F32 used to distort the image | [
"Given",
"a",
"motion",
"model",
"create",
"a",
"PixelTransform",
"used",
"to",
"distort",
"the",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d2/UtilImageMotion.java#L44-L60 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/factory/feature/orientation/FactoryOrientation.java | FactoryOrientation.sift | public static <T extends ImageGray<T>>
OrientationImage<T> sift(ConfigSiftScaleSpace configSS , ConfigSiftOrientation configOri, Class<T> imageType ) {
if( configSS == null )
configSS = new ConfigSiftScaleSpace();
configSS.checkValidity();
OrientationHistogramSift<GrayF32> ori = FactoryOrientationAlgs.sift(configOri,GrayF32.class);
SiftScaleSpace ss = new SiftScaleSpace(
configSS.firstOctave,configSS.lastOctave,configSS.numScales,configSS.sigma0);
return new OrientationSiftToImage<>(ori, ss, imageType);
} | java | public static <T extends ImageGray<T>>
OrientationImage<T> sift(ConfigSiftScaleSpace configSS , ConfigSiftOrientation configOri, Class<T> imageType ) {
if( configSS == null )
configSS = new ConfigSiftScaleSpace();
configSS.checkValidity();
OrientationHistogramSift<GrayF32> ori = FactoryOrientationAlgs.sift(configOri,GrayF32.class);
SiftScaleSpace ss = new SiftScaleSpace(
configSS.firstOctave,configSS.lastOctave,configSS.numScales,configSS.sigma0);
return new OrientationSiftToImage<>(ori, ss, imageType);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"OrientationImage",
"<",
"T",
">",
"sift",
"(",
"ConfigSiftScaleSpace",
"configSS",
",",
"ConfigSiftOrientation",
"configOri",
",",
"Class",
"<",
"T",
">",
"imageType",
")",
"{",
"if",... | Creates an implementation of the SIFT orientation estimation algorithm
@param configSS Configuration of the scale-space. null for default
@param configOri Orientation configuration. null for default
@param imageType Type of input image
@return SIFT orientation image | [
"Creates",
"an",
"implementation",
"of",
"the",
"SIFT",
"orientation",
"estimation",
"algorithm"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/orientation/FactoryOrientation.java#L69-L80 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/calib/CalibrationDetectorChessboard2.java | CalibrationDetectorChessboard2.gridChess | public static List<Point2D_F64> gridChess(int numRows, int numCols, double squareWidth)
{
List<Point2D_F64> all = new ArrayList<>();
// convert it into the number of calibration points
numCols = numCols - 1;
numRows = numRows - 1;
// center the grid around the origin. length of a size divided by two
double startX = -((numCols-1)*squareWidth)/2.0;
double startY = -((numRows-1)*squareWidth)/2.0;
for( int i = numRows-1; i >= 0; i-- ) {
double y = startY+i*squareWidth;
for( int j = 0; j < numCols; j++ ) {
double x = startX+j*squareWidth;
all.add( new Point2D_F64(x,y));
}
}
return all;
} | java | public static List<Point2D_F64> gridChess(int numRows, int numCols, double squareWidth)
{
List<Point2D_F64> all = new ArrayList<>();
// convert it into the number of calibration points
numCols = numCols - 1;
numRows = numRows - 1;
// center the grid around the origin. length of a size divided by two
double startX = -((numCols-1)*squareWidth)/2.0;
double startY = -((numRows-1)*squareWidth)/2.0;
for( int i = numRows-1; i >= 0; i-- ) {
double y = startY+i*squareWidth;
for( int j = 0; j < numCols; j++ ) {
double x = startX+j*squareWidth;
all.add( new Point2D_F64(x,y));
}
}
return all;
} | [
"public",
"static",
"List",
"<",
"Point2D_F64",
">",
"gridChess",
"(",
"int",
"numRows",
",",
"int",
"numCols",
",",
"double",
"squareWidth",
")",
"{",
"List",
"<",
"Point2D_F64",
">",
"all",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// convert it int... | This target is composed of a checkered chess board like squares. Each corner of an interior square
touches an adjacent square, but the sides are separated. Only interior square corners provide
calibration points.
@param numRows Number of grid rows in the calibration target
@param numCols Number of grid columns in the calibration target
@param squareWidth How wide each square is. Units are target dependent.
@return Target description | [
"This",
"target",
"is",
"composed",
"of",
"a",
"checkered",
"chess",
"board",
"like",
"squares",
".",
"Each",
"corner",
"of",
"an",
"interior",
"square",
"touches",
"an",
"adjacent",
"square",
"but",
"the",
"sides",
"are",
"separated",
".",
"Only",
"interior... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/abst/fiducial/calib/CalibrationDetectorChessboard2.java#L143-L164 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/impl/ImplSurfDescribeOps.java | ImplSurfDescribeOps.naiveGradient | public static <T extends ImageGray<T>>
void naiveGradient(T ii, double tl_x, double tl_y, double samplePeriod ,
int regionSize, double kernelSize,
boolean useHaar, double[] derivX, double derivY[])
{
SparseScaleGradient<T,?> gg = SurfDescribeOps.createGradient(useHaar,(Class<T>)ii.getClass());
gg.setWidth(kernelSize);
gg.setImage(ii);
SparseGradientSafe g = new SparseGradientSafe(gg);
// add 0.5 to c_x and c_y to have it round when converted to an integer pixel
// this is faster than the straight forward method
tl_x += 0.5;
tl_y += 0.5;
int i = 0;
for( int y = 0; y < regionSize; y++ ) {
for( int x = 0; x < regionSize; x++ , i++) {
int xx = (int)(tl_x + x * samplePeriod);
int yy = (int)(tl_y + y * samplePeriod);
GradientValue deriv = g.compute(xx,yy);
derivX[i] = deriv.getX();
derivY[i] = deriv.getY();
// System.out.printf("%2d %2d %2d %2d dx = %6.2f dy = %6.2f\n",x,y,xx,yy,derivX[i],derivY[i]);
}
}
} | java | public static <T extends ImageGray<T>>
void naiveGradient(T ii, double tl_x, double tl_y, double samplePeriod ,
int regionSize, double kernelSize,
boolean useHaar, double[] derivX, double derivY[])
{
SparseScaleGradient<T,?> gg = SurfDescribeOps.createGradient(useHaar,(Class<T>)ii.getClass());
gg.setWidth(kernelSize);
gg.setImage(ii);
SparseGradientSafe g = new SparseGradientSafe(gg);
// add 0.5 to c_x and c_y to have it round when converted to an integer pixel
// this is faster than the straight forward method
tl_x += 0.5;
tl_y += 0.5;
int i = 0;
for( int y = 0; y < regionSize; y++ ) {
for( int x = 0; x < regionSize; x++ , i++) {
int xx = (int)(tl_x + x * samplePeriod);
int yy = (int)(tl_y + y * samplePeriod);
GradientValue deriv = g.compute(xx,yy);
derivX[i] = deriv.getX();
derivY[i] = deriv.getY();
// System.out.printf("%2d %2d %2d %2d dx = %6.2f dy = %6.2f\n",x,y,xx,yy,derivX[i],derivY[i]);
}
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"void",
"naiveGradient",
"(",
"T",
"ii",
",",
"double",
"tl_x",
",",
"double",
"tl_y",
",",
"double",
"samplePeriod",
",",
"int",
"regionSize",
",",
"double",
"kernelSize",
",",
"b... | Simple algorithm for computing the gradient of a region. Can handle image borders | [
"Simple",
"algorithm",
"for",
"computing",
"the",
"gradient",
"of",
"a",
"region",
".",
"Can",
"handle",
"image",
"borders"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/describe/impl/ImplSurfDescribeOps.java#L161-L188 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java | DescribeDenseSiftAlg.setImageGradient | public void setImageGradient(D derivX , D derivY ) {
InputSanityCheck.checkSameShape(derivX,derivY);
if( derivX.stride != derivY.stride || derivX.startIndex != derivY.startIndex )
throw new IllegalArgumentException("stride and start index must be the same");
savedAngle.reshape(derivX.width,derivX.height);
savedMagnitude.reshape(derivX.width,derivX.height);
imageDerivX.wrap(derivX);
imageDerivY.wrap(derivY);
precomputeAngles(derivX);
} | java | public void setImageGradient(D derivX , D derivY ) {
InputSanityCheck.checkSameShape(derivX,derivY);
if( derivX.stride != derivY.stride || derivX.startIndex != derivY.startIndex )
throw new IllegalArgumentException("stride and start index must be the same");
savedAngle.reshape(derivX.width,derivX.height);
savedMagnitude.reshape(derivX.width,derivX.height);
imageDerivX.wrap(derivX);
imageDerivY.wrap(derivY);
precomputeAngles(derivX);
} | [
"public",
"void",
"setImageGradient",
"(",
"D",
"derivX",
",",
"D",
"derivY",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"derivX",
",",
"derivY",
")",
";",
"if",
"(",
"derivX",
".",
"stride",
"!=",
"derivY",
".",
"stride",
"||",
"derivX",
... | Sets the gradient and precomputes pixel orientation and magnitude
@param derivX image derivative x-axis
@param derivY image derivative y-axis | [
"Sets",
"the",
"gradient",
"and",
"precomputes",
"pixel",
"orientation",
"and",
"magnitude"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java#L103-L115 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java | DescribeDenseSiftAlg.process | public void process() {
int width = widthSubregion*widthGrid;
int radius = width/2;
int X0 = radius,X1 = savedAngle.width-radius;
int Y0 = radius,Y1 = savedAngle.height-radius;
int numX = (int)((X1-X0)/periodColumns);
int numY = (int)((Y1-Y0)/periodRows);
descriptors.reset();
sampleLocations.reset();
for (int i = 0; i < numY; i++) {
int y = (Y1-Y0)*i/(numY-1) + Y0;
for (int j = 0; j < numX; j++) {
int x = (X1-X0)*j/(numX-1) + X0;
TupleDesc_F64 desc = descriptors.grow();
computeDescriptor(x,y,desc);
sampleLocations.grow().set(x,y);
}
}
} | java | public void process() {
int width = widthSubregion*widthGrid;
int radius = width/2;
int X0 = radius,X1 = savedAngle.width-radius;
int Y0 = radius,Y1 = savedAngle.height-radius;
int numX = (int)((X1-X0)/periodColumns);
int numY = (int)((Y1-Y0)/periodRows);
descriptors.reset();
sampleLocations.reset();
for (int i = 0; i < numY; i++) {
int y = (Y1-Y0)*i/(numY-1) + Y0;
for (int j = 0; j < numX; j++) {
int x = (X1-X0)*j/(numX-1) + X0;
TupleDesc_F64 desc = descriptors.grow();
computeDescriptor(x,y,desc);
sampleLocations.grow().set(x,y);
}
}
} | [
"public",
"void",
"process",
"(",
")",
"{",
"int",
"width",
"=",
"widthSubregion",
"*",
"widthGrid",
";",
"int",
"radius",
"=",
"width",
"/",
"2",
";",
"int",
"X0",
"=",
"radius",
",",
"X1",
"=",
"savedAngle",
".",
"width",
"-",
"radius",
";",
"int",... | Computes SIFT descriptors across the entire image | [
"Computes",
"SIFT",
"descriptors",
"across",
"the",
"entire",
"image"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java#L120-L146 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java | DescribeDenseSiftAlg.precomputeAngles | void precomputeAngles(D image) {
int savecIndex = 0;
for (int y = 0; y < image.height; y++) {
int pixelIndex = y*image.stride + image.startIndex;
for (int x = 0; x < image.width; x++, pixelIndex++, savecIndex++ ) {
float spacialDX = imageDerivX.getF(pixelIndex);
float spacialDY = imageDerivY.getF(pixelIndex);
savedAngle.data[savecIndex] = UtilAngle.domain2PI(Math.atan2(spacialDY,spacialDX));
savedMagnitude.data[savecIndex] = (float)Math.sqrt(spacialDX*spacialDX + spacialDY*spacialDY);
}
}
} | java | void precomputeAngles(D image) {
int savecIndex = 0;
for (int y = 0; y < image.height; y++) {
int pixelIndex = y*image.stride + image.startIndex;
for (int x = 0; x < image.width; x++, pixelIndex++, savecIndex++ ) {
float spacialDX = imageDerivX.getF(pixelIndex);
float spacialDY = imageDerivY.getF(pixelIndex);
savedAngle.data[savecIndex] = UtilAngle.domain2PI(Math.atan2(spacialDY,spacialDX));
savedMagnitude.data[savecIndex] = (float)Math.sqrt(spacialDX*spacialDX + spacialDY*spacialDY);
}
}
} | [
"void",
"precomputeAngles",
"(",
"D",
"image",
")",
"{",
"int",
"savecIndex",
"=",
"0",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"image",
".",
"height",
";",
"y",
"++",
")",
"{",
"int",
"pixelIndex",
"=",
"y",
"*",
"image",
".",
"s... | Computes the angle of each pixel and its gradient magnitude | [
"Computes",
"the",
"angle",
"of",
"each",
"pixel",
"and",
"its",
"gradient",
"magnitude"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java#L151-L164 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java | DescribeDenseSiftAlg.computeDescriptor | public void computeDescriptor( int cx , int cy , TupleDesc_F64 desc ) {
desc.fill(0);
int widthPixels = widthSubregion*widthGrid;
int radius = widthPixels/2;
for (int i = 0; i < widthPixels; i++) {
int angleIndex = (cy-radius+i)*savedAngle.width + (cx-radius);
float subY = i/(float)widthSubregion;
for (int j = 0; j < widthPixels; j++, angleIndex++ ) {
float subX = j/(float)widthSubregion;
double angle = savedAngle.data[angleIndex];
float weightGaussian = gaussianWeight[i*widthPixels+j];
float weightGradient = savedMagnitude.data[angleIndex];
// trilinear interpolation intro descriptor
trilinearInterpolation(weightGaussian*weightGradient,subX,subY,angle,desc);
}
}
normalizeDescriptor(desc,maxDescriptorElementValue);
} | java | public void computeDescriptor( int cx , int cy , TupleDesc_F64 desc ) {
desc.fill(0);
int widthPixels = widthSubregion*widthGrid;
int radius = widthPixels/2;
for (int i = 0; i < widthPixels; i++) {
int angleIndex = (cy-radius+i)*savedAngle.width + (cx-radius);
float subY = i/(float)widthSubregion;
for (int j = 0; j < widthPixels; j++, angleIndex++ ) {
float subX = j/(float)widthSubregion;
double angle = savedAngle.data[angleIndex];
float weightGaussian = gaussianWeight[i*widthPixels+j];
float weightGradient = savedMagnitude.data[angleIndex];
// trilinear interpolation intro descriptor
trilinearInterpolation(weightGaussian*weightGradient,subX,subY,angle,desc);
}
}
normalizeDescriptor(desc,maxDescriptorElementValue);
} | [
"public",
"void",
"computeDescriptor",
"(",
"int",
"cx",
",",
"int",
"cy",
",",
"TupleDesc_F64",
"desc",
")",
"{",
"desc",
".",
"fill",
"(",
"0",
")",
";",
"int",
"widthPixels",
"=",
"widthSubregion",
"*",
"widthGrid",
";",
"int",
"radius",
"=",
"widthPi... | Computes the descriptor centered at the specified coordinate
@param cx center of region x-axis
@param cy center of region y-axis
@param desc The descriptor | [
"Computes",
"the",
"descriptor",
"centered",
"at",
"the",
"specified",
"coordinate"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/dense/DescribeDenseSiftAlg.java#L172-L198 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/edge/impl/ImplEdgeNonMaxSuppression_MT.java | ImplEdgeNonMaxSuppression_MT.naive4 | static public void naive4(GrayF32 _intensity , GrayS8 direction , GrayF32 output )
{
final int w = _intensity.width;
final int h = _intensity.height;
ImageBorder_F32 intensity = (ImageBorder_F32)FactoryImageBorderAlgs.value(_intensity, 0);
BoofConcurrency.loopFor(0,h,y->{
for( int x = 0; x < w; x++ ) {
int dir = direction.get(x,y);
int dx,dy;
if( dir == 0 ) {
dx = 1; dy = 0;
} else if( dir == 1 ) {
dx = 1; dy = 1;
} else if( dir == 2 ) {
dx = 0; dy = 1;
} else {
dx = 1; dy = -1;
}
float left = intensity.get(x-dx,y-dy);
float middle = intensity.get(x,y);
float right = intensity.get(x+dx,y+dy);
// suppress the value if either of its neighboring values are more than or equal to it
if( left > middle || right > middle ) {
output.set(x,y,0);
} else {
output.set(x,y,middle);
}
}
});
} | java | static public void naive4(GrayF32 _intensity , GrayS8 direction , GrayF32 output )
{
final int w = _intensity.width;
final int h = _intensity.height;
ImageBorder_F32 intensity = (ImageBorder_F32)FactoryImageBorderAlgs.value(_intensity, 0);
BoofConcurrency.loopFor(0,h,y->{
for( int x = 0; x < w; x++ ) {
int dir = direction.get(x,y);
int dx,dy;
if( dir == 0 ) {
dx = 1; dy = 0;
} else if( dir == 1 ) {
dx = 1; dy = 1;
} else if( dir == 2 ) {
dx = 0; dy = 1;
} else {
dx = 1; dy = -1;
}
float left = intensity.get(x-dx,y-dy);
float middle = intensity.get(x,y);
float right = intensity.get(x+dx,y+dy);
// suppress the value if either of its neighboring values are more than or equal to it
if( left > middle || right > middle ) {
output.set(x,y,0);
} else {
output.set(x,y,middle);
}
}
});
} | [
"static",
"public",
"void",
"naive4",
"(",
"GrayF32",
"_intensity",
",",
"GrayS8",
"direction",
",",
"GrayF32",
"output",
")",
"{",
"final",
"int",
"w",
"=",
"_intensity",
".",
"width",
";",
"final",
"int",
"h",
"=",
"_intensity",
".",
"height",
";",
"Im... | Slow algorithm which processes the whole image. | [
"Slow",
"algorithm",
"which",
"processes",
"the",
"whole",
"image",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/feature/detect/edge/impl/ImplEdgeNonMaxSuppression_MT.java#L83-L118 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCode.java | QrCode.reset | public void reset() {
for (int i = 0; i < 4; i++) {
ppCorner.get(i).set(0,0);
ppDown.get(i).set(0,0);
ppRight.get(i).set(0,0);
}
this.threshCorner = 0;
this.threshDown = 0;
this.threshRight = 0;
version = -1;
error = L;
mask = QrCodeMaskPattern.M111;
alignment.reset();
mode = Mode.UNKNOWN;
failureCause = Failure.NONE;
rawbits = null;
corrected = null;
message = null;
} | java | public void reset() {
for (int i = 0; i < 4; i++) {
ppCorner.get(i).set(0,0);
ppDown.get(i).set(0,0);
ppRight.get(i).set(0,0);
}
this.threshCorner = 0;
this.threshDown = 0;
this.threshRight = 0;
version = -1;
error = L;
mask = QrCodeMaskPattern.M111;
alignment.reset();
mode = Mode.UNKNOWN;
failureCause = Failure.NONE;
rawbits = null;
corrected = null;
message = null;
} | [
"public",
"void",
"reset",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"ppCorner",
".",
"get",
"(",
"i",
")",
".",
"set",
"(",
"0",
",",
"0",
")",
";",
"ppDown",
".",
"get",
"(",
"i",
"... | Resets the QR-Code so that it's in its initial state. | [
"Resets",
"the",
"QR",
"-",
"Code",
"so",
"that",
"it",
"s",
"in",
"its",
"initial",
"state",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCode.java#L398-L416 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCode.java | QrCode.set | public void set( QrCode o ) {
this.version = o.version;
this.error = o.error;
this.mask = o.mask;
this.mode = o.mode;
this.rawbits = o.rawbits == null ? null : o.rawbits.clone();
this.corrected = o.corrected == null ? null : o.corrected.clone();
this.message = o.message;
this.threshCorner = o.threshCorner;
this.threshDown = o.threshDown;
this.threshRight = o.threshRight;
this.ppCorner.set(o.ppCorner);
this.ppDown.set(o.ppDown);
this.ppRight.set(o.ppRight);
this.failureCause = o.failureCause;
this.bounds.set(o.bounds);
this.alignment.reset();
for (int i = 0; i < o.alignment.size; i++) {
this.alignment.grow().set(o.alignment.get(i));
}
this.Hinv.set(o.Hinv);
} | java | public void set( QrCode o ) {
this.version = o.version;
this.error = o.error;
this.mask = o.mask;
this.mode = o.mode;
this.rawbits = o.rawbits == null ? null : o.rawbits.clone();
this.corrected = o.corrected == null ? null : o.corrected.clone();
this.message = o.message;
this.threshCorner = o.threshCorner;
this.threshDown = o.threshDown;
this.threshRight = o.threshRight;
this.ppCorner.set(o.ppCorner);
this.ppDown.set(o.ppDown);
this.ppRight.set(o.ppRight);
this.failureCause = o.failureCause;
this.bounds.set(o.bounds);
this.alignment.reset();
for (int i = 0; i < o.alignment.size; i++) {
this.alignment.grow().set(o.alignment.get(i));
}
this.Hinv.set(o.Hinv);
} | [
"public",
"void",
"set",
"(",
"QrCode",
"o",
")",
"{",
"this",
".",
"version",
"=",
"o",
".",
"version",
";",
"this",
".",
"error",
"=",
"o",
".",
"error",
";",
"this",
".",
"mask",
"=",
"o",
".",
"mask",
";",
"this",
".",
"mode",
"=",
"o",
"... | Sets 'this' so that it's equivalent to 'o'.
@param o The target object | [
"Sets",
"this",
"so",
"that",
"it",
"s",
"equivalent",
"to",
"o",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/fiducial/qrcode/QrCode.java#L429-L450 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationSingle.java | SelfCalibrationLinearRotationSingle.ensureDeterminantOfOne | public static void ensureDeterminantOfOne(List<Homography2D_F64> homography0toI) {
int N = homography0toI.size();
for (int i = 0; i < N; i++) {
Homography2D_F64 H = homography0toI.get(i);
double d = CommonOps_DDF3.det(H);
// System.out.println("Before = "+d);
if( d < 0 )
CommonOps_DDF3.divide(H,-Math.pow(-d,1.0/3));
else
CommonOps_DDF3.divide(H,Math.pow(d,1.0/3));
// System.out.println("determinant = "+ CommonOps_DDF3.det(H));
}
} | java | public static void ensureDeterminantOfOne(List<Homography2D_F64> homography0toI) {
int N = homography0toI.size();
for (int i = 0; i < N; i++) {
Homography2D_F64 H = homography0toI.get(i);
double d = CommonOps_DDF3.det(H);
// System.out.println("Before = "+d);
if( d < 0 )
CommonOps_DDF3.divide(H,-Math.pow(-d,1.0/3));
else
CommonOps_DDF3.divide(H,Math.pow(d,1.0/3));
// System.out.println("determinant = "+ CommonOps_DDF3.det(H));
}
} | [
"public",
"static",
"void",
"ensureDeterminantOfOne",
"(",
"List",
"<",
"Homography2D_F64",
">",
"homography0toI",
")",
"{",
"int",
"N",
"=",
"homography0toI",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"i",
... | Scales all homographies so that their determinants are equal to one
@param homography0toI | [
"Scales",
"all",
"homographies",
"so",
"that",
"their",
"determinants",
"are",
"equal",
"to",
"one"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationSingle.java#L107-L119 | train |
lessthanoptimal/BoofCV | main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationSingle.java | SelfCalibrationLinearRotationSingle.extractCalibration | private boolean extractCalibration(DMatrixRMaj x , CameraPinhole calibration) {
double s = x.data[5];
double cx = calibration.cx = x.data[2]/s;
double cy = calibration.cy = x.data[4]/s;
double fy = calibration.fy = Math.sqrt(x.data[3]/s-cy*cy);
double sk = calibration.skew = (x.data[1]/s-cx*cy)/fy;
calibration.fx = Math.sqrt(x.data[0]/s - sk*sk - cx*cx);
if( calibration.fx < 0 || calibration.fy < 0 )
return false;
if(UtilEjml.isUncountable(fy) || UtilEjml.isUncountable(calibration.fx))
return false;
if(UtilEjml.isUncountable(sk))
return false;
return true;
} | java | private boolean extractCalibration(DMatrixRMaj x , CameraPinhole calibration) {
double s = x.data[5];
double cx = calibration.cx = x.data[2]/s;
double cy = calibration.cy = x.data[4]/s;
double fy = calibration.fy = Math.sqrt(x.data[3]/s-cy*cy);
double sk = calibration.skew = (x.data[1]/s-cx*cy)/fy;
calibration.fx = Math.sqrt(x.data[0]/s - sk*sk - cx*cx);
if( calibration.fx < 0 || calibration.fy < 0 )
return false;
if(UtilEjml.isUncountable(fy) || UtilEjml.isUncountable(calibration.fx))
return false;
if(UtilEjml.isUncountable(sk))
return false;
return true;
} | [
"private",
"boolean",
"extractCalibration",
"(",
"DMatrixRMaj",
"x",
",",
"CameraPinhole",
"calibration",
")",
"{",
"double",
"s",
"=",
"x",
".",
"data",
"[",
"5",
"]",
";",
"double",
"cx",
"=",
"calibration",
".",
"cx",
"=",
"x",
".",
"data",
"[",
"2"... | Extracts camera parameters from the solution. Checks for errors | [
"Extracts",
"camera",
"parameters",
"from",
"the",
"solution",
".",
"Checks",
"for",
"errors"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-calibration/src/main/java/boofcv/alg/geo/selfcalib/SelfCalibrationLinearRotationSingle.java#L123-L139 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/transform/wavelet/FactoryWaveletDaub.java | FactoryWaveletDaub.computeBorderCoefficients | private static WlBorderCoef<WlCoef_F32> computeBorderCoefficients( BorderIndex1D border ,
WlCoef_F32 forward ,
WlCoef_F32 inverse ) {
int N = Math.max(forward.getScalingLength(),forward.getWaveletLength());
N += N%2;
N *= 2;
border.setLength(N);
// Because the wavelet transform is a linear invertible system the inverse coefficients
// can be found by creating a matrix and inverting the matrix. Boundary conditions are then
// extracted from this inverted matrix.
DMatrixRMaj A = new DMatrixRMaj(N,N);
for( int i = 0; i < N; i += 2 ) {
for( int j = 0; j < forward.scaling.length; j++ ) {
int index = border.getIndex(j+i+forward.offsetScaling);
A.add(i,index,forward.scaling[j]);
}
for( int j = 0; j < forward.wavelet.length; j++ ) {
int index = border.getIndex(j+i+forward.offsetWavelet);
A.add(i+1,index,forward.wavelet[j]);
}
}
LinearSolverDense<DMatrixRMaj> solver = LinearSolverFactory_DDRM.linear(N);
if( !solver.setA(A) || solver.quality() < 1e-5) {
throw new IllegalArgumentException("Can't invert matrix");
}
DMatrixRMaj A_inv = new DMatrixRMaj(N,N);
solver.invert(A_inv);
int numBorder = UtilWavelet.borderForwardLower(inverse)/2;
WlBorderCoefFixed<WlCoef_F32> ret = new WlBorderCoefFixed<>(numBorder, numBorder + 1);
ret.setInnerCoef(inverse);
// add the lower coefficients first
for( int i = 0; i < ret.getLowerLength(); i++) {
computeLowerCoef(inverse, A_inv, ret, i*2);
}
// add upper coefficients
for( int i = 0; i < ret.getUpperLength(); i++) {
computeUpperCoef(inverse, N, A_inv, ret, i*2);
}
return ret;
} | java | private static WlBorderCoef<WlCoef_F32> computeBorderCoefficients( BorderIndex1D border ,
WlCoef_F32 forward ,
WlCoef_F32 inverse ) {
int N = Math.max(forward.getScalingLength(),forward.getWaveletLength());
N += N%2;
N *= 2;
border.setLength(N);
// Because the wavelet transform is a linear invertible system the inverse coefficients
// can be found by creating a matrix and inverting the matrix. Boundary conditions are then
// extracted from this inverted matrix.
DMatrixRMaj A = new DMatrixRMaj(N,N);
for( int i = 0; i < N; i += 2 ) {
for( int j = 0; j < forward.scaling.length; j++ ) {
int index = border.getIndex(j+i+forward.offsetScaling);
A.add(i,index,forward.scaling[j]);
}
for( int j = 0; j < forward.wavelet.length; j++ ) {
int index = border.getIndex(j+i+forward.offsetWavelet);
A.add(i+1,index,forward.wavelet[j]);
}
}
LinearSolverDense<DMatrixRMaj> solver = LinearSolverFactory_DDRM.linear(N);
if( !solver.setA(A) || solver.quality() < 1e-5) {
throw new IllegalArgumentException("Can't invert matrix");
}
DMatrixRMaj A_inv = new DMatrixRMaj(N,N);
solver.invert(A_inv);
int numBorder = UtilWavelet.borderForwardLower(inverse)/2;
WlBorderCoefFixed<WlCoef_F32> ret = new WlBorderCoefFixed<>(numBorder, numBorder + 1);
ret.setInnerCoef(inverse);
// add the lower coefficients first
for( int i = 0; i < ret.getLowerLength(); i++) {
computeLowerCoef(inverse, A_inv, ret, i*2);
}
// add upper coefficients
for( int i = 0; i < ret.getUpperLength(); i++) {
computeUpperCoef(inverse, N, A_inv, ret, i*2);
}
return ret;
} | [
"private",
"static",
"WlBorderCoef",
"<",
"WlCoef_F32",
">",
"computeBorderCoefficients",
"(",
"BorderIndex1D",
"border",
",",
"WlCoef_F32",
"forward",
",",
"WlCoef_F32",
"inverse",
")",
"{",
"int",
"N",
"=",
"Math",
".",
"max",
"(",
"forward",
".",
"getScalingL... | Computes inverse coefficients
@param border
@param forward Forward coefficients.
@param inverse Inverse used in the inner portion of the data stream.
@return | [
"Computes",
"inverse",
"coefficients"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/transform/wavelet/FactoryWaveletDaub.java#L182-L231 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/transform/wavelet/FactoryWaveletDaub.java | FactoryWaveletDaub.convertToInt | public static WlBorderCoefFixed<WlCoef_I32> convertToInt( WlBorderCoefFixed<WlCoef_F32> orig ,
WlCoef_I32 inner ) {
WlBorderCoefFixed<WlCoef_I32> ret =
new WlBorderCoefFixed<>(orig.getLowerLength(), orig.getUpperLength());
for( int i = 0; i < orig.getLowerLength(); i++ ) {
WlCoef_F32 o = orig.getLower(i);
WlCoef_I32 r = new WlCoef_I32();
ret.setLower(i,r);
convertCoef_F32_to_I32(inner.denominatorScaling, inner.denominatorWavelet, o, r);
}
for( int i = 0; i < orig.getUpperLength(); i++ ) {
WlCoef_F32 o = orig.getUpper(i);
WlCoef_I32 r = new WlCoef_I32();
ret.setUpper(i,r);
convertCoef_F32_to_I32(inner.denominatorScaling, inner.denominatorWavelet, o, r);
}
ret.setInnerCoef(inner);
return ret;
} | java | public static WlBorderCoefFixed<WlCoef_I32> convertToInt( WlBorderCoefFixed<WlCoef_F32> orig ,
WlCoef_I32 inner ) {
WlBorderCoefFixed<WlCoef_I32> ret =
new WlBorderCoefFixed<>(orig.getLowerLength(), orig.getUpperLength());
for( int i = 0; i < orig.getLowerLength(); i++ ) {
WlCoef_F32 o = orig.getLower(i);
WlCoef_I32 r = new WlCoef_I32();
ret.setLower(i,r);
convertCoef_F32_to_I32(inner.denominatorScaling, inner.denominatorWavelet, o, r);
}
for( int i = 0; i < orig.getUpperLength(); i++ ) {
WlCoef_F32 o = orig.getUpper(i);
WlCoef_I32 r = new WlCoef_I32();
ret.setUpper(i,r);
convertCoef_F32_to_I32(inner.denominatorScaling, inner.denominatorWavelet, o, r);
}
ret.setInnerCoef(inner);
return ret;
} | [
"public",
"static",
"WlBorderCoefFixed",
"<",
"WlCoef_I32",
">",
"convertToInt",
"(",
"WlBorderCoefFixed",
"<",
"WlCoef_F32",
">",
"orig",
",",
"WlCoef_I32",
"inner",
")",
"{",
"WlBorderCoefFixed",
"<",
"WlCoef_I32",
">",
"ret",
"=",
"new",
"WlBorderCoefFixed",
"<... | todo rename and move to a utility function? | [
"todo",
"rename",
"and",
"move",
"to",
"a",
"utility",
"function?"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/transform/wavelet/FactoryWaveletDaub.java#L351-L372 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundGmmCommon.java | BackgroundGmmCommon.updateMixture | public int updateMixture( float[] pixelValue , float[] dataRow , int modelIndex ) {
// see which gaussian is the best fit based on Mahalanobis distance
int index = modelIndex;
float bestDistance = maxDistance*numBands;
int bestIndex=-1;
int ng; // number of gaussians in use
for (ng = 0; ng < maxGaussians; ng++, index += gaussianStride) {
float variance = dataRow[index+1];
if( variance <= 0 ) {
break;
}
float mahalanobis = 0;
for (int i = 0; i < numBands; i++) {
float mean = dataRow[index+2+i];
float delta = pixelValue[i]-mean;
mahalanobis += delta*delta/variance;
}
if( mahalanobis < bestDistance ) {
bestDistance = mahalanobis;
bestIndex = index;
}
}
// Update the model for the best gaussian
if( bestIndex != -1 ) {
// If there is a good fit update the model
float weight = dataRow[bestIndex];
float variance = dataRow[bestIndex+1];
weight += learningRate*(1f-weight);
dataRow[bestIndex] = 1; // set to one so that it can't possible go negative
float sumDeltaSq = 0;
for (int i = 0; i < numBands; i++) {
float mean = dataRow[bestIndex+2+i];
float delta = pixelValue[i]-mean;
dataRow[bestIndex+2+i] = mean + delta*learningRate/weight;
sumDeltaSq += delta*delta;
}
sumDeltaSq /= numBands;
dataRow[bestIndex+1] = variance + (learningRate /weight)*(sumDeltaSq*1.2F - variance);
// 1.2f is a fudge factor. Empirical testing shows that the above equation is biased. Can't be bothered
// to verify the derivation and see if there's a mistake
// Update Gaussian weights and prune models
updateWeightAndPrune(dataRow, modelIndex, ng, bestIndex, weight);
return weight >= significantWeight ? 0 : 1;
} else if( ng < maxGaussians ) {
// if there is no good fit then create a new model, if there is room
bestIndex = modelIndex + ng*gaussianStride;
dataRow[bestIndex] = 1; // weight is changed later or it's the only model
dataRow[bestIndex+1] = initialVariance;
for (int i = 0; i < numBands; i++) {
dataRow[bestIndex+2+i] = pixelValue[i];
}
// There are no models. Return unknown
if( ng == 0 )
return unknownValue;
updateWeightAndPrune(dataRow, modelIndex, ng+1, bestIndex, learningRate);
return 1;
} else {
// didn't match any models and can't create a new model
return 1;
}
} | java | public int updateMixture( float[] pixelValue , float[] dataRow , int modelIndex ) {
// see which gaussian is the best fit based on Mahalanobis distance
int index = modelIndex;
float bestDistance = maxDistance*numBands;
int bestIndex=-1;
int ng; // number of gaussians in use
for (ng = 0; ng < maxGaussians; ng++, index += gaussianStride) {
float variance = dataRow[index+1];
if( variance <= 0 ) {
break;
}
float mahalanobis = 0;
for (int i = 0; i < numBands; i++) {
float mean = dataRow[index+2+i];
float delta = pixelValue[i]-mean;
mahalanobis += delta*delta/variance;
}
if( mahalanobis < bestDistance ) {
bestDistance = mahalanobis;
bestIndex = index;
}
}
// Update the model for the best gaussian
if( bestIndex != -1 ) {
// If there is a good fit update the model
float weight = dataRow[bestIndex];
float variance = dataRow[bestIndex+1];
weight += learningRate*(1f-weight);
dataRow[bestIndex] = 1; // set to one so that it can't possible go negative
float sumDeltaSq = 0;
for (int i = 0; i < numBands; i++) {
float mean = dataRow[bestIndex+2+i];
float delta = pixelValue[i]-mean;
dataRow[bestIndex+2+i] = mean + delta*learningRate/weight;
sumDeltaSq += delta*delta;
}
sumDeltaSq /= numBands;
dataRow[bestIndex+1] = variance + (learningRate /weight)*(sumDeltaSq*1.2F - variance);
// 1.2f is a fudge factor. Empirical testing shows that the above equation is biased. Can't be bothered
// to verify the derivation and see if there's a mistake
// Update Gaussian weights and prune models
updateWeightAndPrune(dataRow, modelIndex, ng, bestIndex, weight);
return weight >= significantWeight ? 0 : 1;
} else if( ng < maxGaussians ) {
// if there is no good fit then create a new model, if there is room
bestIndex = modelIndex + ng*gaussianStride;
dataRow[bestIndex] = 1; // weight is changed later or it's the only model
dataRow[bestIndex+1] = initialVariance;
for (int i = 0; i < numBands; i++) {
dataRow[bestIndex+2+i] = pixelValue[i];
}
// There are no models. Return unknown
if( ng == 0 )
return unknownValue;
updateWeightAndPrune(dataRow, modelIndex, ng+1, bestIndex, learningRate);
return 1;
} else {
// didn't match any models and can't create a new model
return 1;
}
} | [
"public",
"int",
"updateMixture",
"(",
"float",
"[",
"]",
"pixelValue",
",",
"float",
"[",
"]",
"dataRow",
",",
"int",
"modelIndex",
")",
"{",
"// see which gaussian is the best fit based on Mahalanobis distance",
"int",
"index",
"=",
"modelIndex",
";",
"float",
"be... | Updates the mixtures of gaussian and determines if the pixel matches the background model
@return true if it matches the background or false if not | [
"Updates",
"the",
"mixtures",
"of",
"gaussian",
"and",
"determines",
"if",
"the",
"pixel",
"matches",
"the",
"background",
"model"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundGmmCommon.java#L112-L183 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundGmmCommon.java | BackgroundGmmCommon.updateWeightAndPrune | public void updateWeightAndPrune(float[] dataRow, int modelIndex, int ng, int bestIndex, float bestWeight) {
int index = modelIndex;
float weightTotal = 0;
for (int i = 0; i < ng; ) {
float weight = dataRow[index];
// if( ng > 1 )
// System.out.println("["+i+"] = "+ng+" weight "+weight);
weight = weight - learningRate*(weight + decay); // <-- original equation
// weight = weight - learningRate*decay;
if( weight <= 0 ) {
// copy the last Gaussian into this location
int indexLast = modelIndex + (ng-1)*gaussianStride;
for (int j = 0; j < gaussianStride; j++) {
dataRow[index+j] = dataRow[indexLast+j];
}
// see if the best Gaussian just got moved to here
if( indexLast == bestIndex )
bestIndex = index;
// mark it as unused by setting variance to zero
dataRow[indexLast+1] = 0;
// decrease the number of gaussians
ng -= 1;
} else {
dataRow[index] = weight;
weightTotal += weight;
index += gaussianStride;
i++;
}
}
// undo the change to the best model. It was done in the for loop to avoid an if statement which would
// have slowed it down
if( bestIndex != -1 ) {
weightTotal -= dataRow[bestIndex];
weightTotal += bestWeight;
dataRow[bestIndex] = bestWeight;
}
// Normalize the weight so that it sums up to one
index = modelIndex;
for (int i = 0; i < ng; i++, index += gaussianStride) {
dataRow[index] /= weightTotal;
}
} | java | public void updateWeightAndPrune(float[] dataRow, int modelIndex, int ng, int bestIndex, float bestWeight) {
int index = modelIndex;
float weightTotal = 0;
for (int i = 0; i < ng; ) {
float weight = dataRow[index];
// if( ng > 1 )
// System.out.println("["+i+"] = "+ng+" weight "+weight);
weight = weight - learningRate*(weight + decay); // <-- original equation
// weight = weight - learningRate*decay;
if( weight <= 0 ) {
// copy the last Gaussian into this location
int indexLast = modelIndex + (ng-1)*gaussianStride;
for (int j = 0; j < gaussianStride; j++) {
dataRow[index+j] = dataRow[indexLast+j];
}
// see if the best Gaussian just got moved to here
if( indexLast == bestIndex )
bestIndex = index;
// mark it as unused by setting variance to zero
dataRow[indexLast+1] = 0;
// decrease the number of gaussians
ng -= 1;
} else {
dataRow[index] = weight;
weightTotal += weight;
index += gaussianStride;
i++;
}
}
// undo the change to the best model. It was done in the for loop to avoid an if statement which would
// have slowed it down
if( bestIndex != -1 ) {
weightTotal -= dataRow[bestIndex];
weightTotal += bestWeight;
dataRow[bestIndex] = bestWeight;
}
// Normalize the weight so that it sums up to one
index = modelIndex;
for (int i = 0; i < ng; i++, index += gaussianStride) {
dataRow[index] /= weightTotal;
}
} | [
"public",
"void",
"updateWeightAndPrune",
"(",
"float",
"[",
"]",
"dataRow",
",",
"int",
"modelIndex",
",",
"int",
"ng",
",",
"int",
"bestIndex",
",",
"float",
"bestWeight",
")",
"{",
"int",
"index",
"=",
"modelIndex",
";",
"float",
"weightTotal",
"=",
"0"... | Updates the weight of each Gaussian and prunes one which have a negative weight after the update. | [
"Updates",
"the",
"weight",
"of",
"each",
"Gaussian",
"and",
"prunes",
"one",
"which",
"have",
"a",
"negative",
"weight",
"after",
"the",
"update",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundGmmCommon.java#L188-L234 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundGmmCommon.java | BackgroundGmmCommon.checkBackground | public int checkBackground( float[] pixelValue , float[] dataRow , int modelIndex ) {
// see which gaussian is the best fit based on Mahalanobis distance
int index = modelIndex;
float bestDistance = maxDistance*numBands;
float bestWeight = 0;
int ng; // number of gaussians in use
for (ng = 0; ng < maxGaussians; ng++, index += gaussianStride) {
float variance = dataRow[index + 1];
if (variance <= 0) {
break;
}
float mahalanobis = 0;
for (int i = 0; i < numBands; i++) {
float mean = dataRow[index + 2+i];
float delta = pixelValue[i] - mean;
mahalanobis += delta * delta / variance;
}
if (mahalanobis < bestDistance) {
bestDistance = mahalanobis;
bestWeight = dataRow[index];
}
}
if( ng == 0 ) // There are no models. Return unknown
return unknownValue;
return bestWeight >= significantWeight ? 0 : 1;
} | java | public int checkBackground( float[] pixelValue , float[] dataRow , int modelIndex ) {
// see which gaussian is the best fit based on Mahalanobis distance
int index = modelIndex;
float bestDistance = maxDistance*numBands;
float bestWeight = 0;
int ng; // number of gaussians in use
for (ng = 0; ng < maxGaussians; ng++, index += gaussianStride) {
float variance = dataRow[index + 1];
if (variance <= 0) {
break;
}
float mahalanobis = 0;
for (int i = 0; i < numBands; i++) {
float mean = dataRow[index + 2+i];
float delta = pixelValue[i] - mean;
mahalanobis += delta * delta / variance;
}
if (mahalanobis < bestDistance) {
bestDistance = mahalanobis;
bestWeight = dataRow[index];
}
}
if( ng == 0 ) // There are no models. Return unknown
return unknownValue;
return bestWeight >= significantWeight ? 0 : 1;
} | [
"public",
"int",
"checkBackground",
"(",
"float",
"[",
"]",
"pixelValue",
",",
"float",
"[",
"]",
"dataRow",
",",
"int",
"modelIndex",
")",
"{",
"// see which gaussian is the best fit based on Mahalanobis distance",
"int",
"index",
"=",
"modelIndex",
";",
"float",
"... | Checks to see if the the pivel value refers to the background or foreground
@return true for background or false for foreground | [
"Checks",
"to",
"see",
"if",
"the",
"the",
"pivel",
"value",
"refers",
"to",
"the",
"background",
"or",
"foreground"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/background/BackgroundGmmCommon.java#L311-L341 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertYuv420_888.java | ConvertYuv420_888.yuvToGray | public static <T extends ImageGray<T>>
T yuvToGray(ByteBuffer bufferY , int width , int height, int strideRow , T output , BWorkArrays workArrays, Class<T> outputType )
{
if( outputType == GrayU8.class ) {
return (T) yuvToGray(bufferY,width,height,strideRow,(GrayU8)output);
} else if( outputType == GrayF32.class ) {
return (T) yuvToGray(bufferY,width,height,strideRow,(GrayF32)output,workArrays);
} else {
throw new IllegalArgumentException("Unsupported BoofCV Image Type "+outputType.getSimpleName());
}
} | java | public static <T extends ImageGray<T>>
T yuvToGray(ByteBuffer bufferY , int width , int height, int strideRow , T output , BWorkArrays workArrays, Class<T> outputType )
{
if( outputType == GrayU8.class ) {
return (T) yuvToGray(bufferY,width,height,strideRow,(GrayU8)output);
} else if( outputType == GrayF32.class ) {
return (T) yuvToGray(bufferY,width,height,strideRow,(GrayF32)output,workArrays);
} else {
throw new IllegalArgumentException("Unsupported BoofCV Image Type "+outputType.getSimpleName());
}
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"T",
"yuvToGray",
"(",
"ByteBuffer",
"bufferY",
",",
"int",
"width",
",",
"int",
"height",
",",
"int",
"strideRow",
",",
"T",
"output",
",",
"BWorkArrays",
"workArrays",
",",
"Clas... | Converts an YUV 420 888 into gray
@param output Output: Optional storage for output image. Can be null.
@param outputType Output: Type of output image
@param <T> Output image type
@return Gray scale image | [
"Converts",
"an",
"YUV",
"420",
"888",
"into",
"gray"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/core/encoding/ConvertYuv420_888.java#L111-L121 | train |
lessthanoptimal/BoofCV | demonstrations/src/main/java/boofcv/demonstrations/shapes/DetectBlackShapeAppBase.java | DetectBlackShapeAppBase.requestSaveInputImage | public void requestSaveInputImage() {
saveRequested = false;
switch( inputMethod ) {
case IMAGE:
new Thread(() -> saveInputImage()).start();
break;
case VIDEO:
case WEBCAM:
if( streamPaused ) {
saveInputImage();
} else {
saveRequested = true;
}
break;
}
} | java | public void requestSaveInputImage() {
saveRequested = false;
switch( inputMethod ) {
case IMAGE:
new Thread(() -> saveInputImage()).start();
break;
case VIDEO:
case WEBCAM:
if( streamPaused ) {
saveInputImage();
} else {
saveRequested = true;
}
break;
}
} | [
"public",
"void",
"requestSaveInputImage",
"(",
")",
"{",
"saveRequested",
"=",
"false",
";",
"switch",
"(",
"inputMethod",
")",
"{",
"case",
"IMAGE",
":",
"new",
"Thread",
"(",
"(",
")",
"->",
"saveInputImage",
"(",
")",
")",
".",
"start",
"(",
")",
"... | Makes a request that the input image be saved. This request might be carried out immediately
or when then next image is processed. | [
"Makes",
"a",
"request",
"that",
"the",
"input",
"image",
"be",
"saved",
".",
"This",
"request",
"might",
"be",
"carried",
"out",
"immediately",
"or",
"when",
"then",
"next",
"image",
"is",
"processed",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/demonstrations/src/main/java/boofcv/demonstrations/shapes/DetectBlackShapeAppBase.java#L170-L186 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/robust/Se3FromEssentialGenerator.java | Se3FromEssentialGenerator.generate | @Override
public boolean generate(List<AssociatedPair> dataSet, Se3_F64 model ) {
if( !computeEssential.process(dataSet,E) )
return false;
// extract the possible motions
decomposeE.decompose(E);
selectBest.select(decomposeE.getSolutions(),dataSet,model);
return true;
} | java | @Override
public boolean generate(List<AssociatedPair> dataSet, Se3_F64 model ) {
if( !computeEssential.process(dataSet,E) )
return false;
// extract the possible motions
decomposeE.decompose(E);
selectBest.select(decomposeE.getSolutions(),dataSet,model);
return true;
} | [
"@",
"Override",
"public",
"boolean",
"generate",
"(",
"List",
"<",
"AssociatedPair",
">",
"dataSet",
",",
"Se3_F64",
"model",
")",
"{",
"if",
"(",
"!",
"computeEssential",
".",
"process",
"(",
"dataSet",
",",
"E",
")",
")",
"return",
"false",
";",
"// e... | Computes the camera motion from the set of observations. The motion is from the first
into the second camera frame.
@param dataSet Associated pairs in normalized camera coordinates.
@param model The best pose according to the positive depth constraint. | [
"Computes",
"the",
"camera",
"motion",
"from",
"the",
"set",
"of",
"observations",
".",
"The",
"motion",
"is",
"from",
"the",
"first",
"into",
"the",
"second",
"camera",
"frame",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/robust/Se3FromEssentialGenerator.java#L69-L79 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java | VisOdomDirectColorDepth.setCameraParameters | public void setCameraParameters( float fx , float fy , float cx , float cy ,
int width , int height ) {
this.fx = fx;
this.fy = fy;
this.cx = cx;
this.cy = cy;
derivX.reshape(width, height);
derivY.reshape(width, height);
// set these to the maximum possible size
int N = width*height*imageType.getNumBands();
A.reshape(N,6);
y.reshape(N,1);
} | java | public void setCameraParameters( float fx , float fy , float cx , float cy ,
int width , int height ) {
this.fx = fx;
this.fy = fy;
this.cx = cx;
this.cy = cy;
derivX.reshape(width, height);
derivY.reshape(width, height);
// set these to the maximum possible size
int N = width*height*imageType.getNumBands();
A.reshape(N,6);
y.reshape(N,1);
} | [
"public",
"void",
"setCameraParameters",
"(",
"float",
"fx",
",",
"float",
"fy",
",",
"float",
"cx",
",",
"float",
"cy",
",",
"int",
"width",
",",
"int",
"height",
")",
"{",
"this",
".",
"fx",
"=",
"fx",
";",
"this",
".",
"fy",
"=",
"fy",
";",
"t... | Specifies intrinsic camera parameters. Must be called.
@param fx focal length x (pixels)
@param fy focal length y (pixels)
@param cx principle point x (pixels)
@param cy principle point y (pixels)
@param width Width of the image
@param height Height of the image | [
"Specifies",
"intrinsic",
"camera",
"parameters",
".",
"Must",
"be",
"called",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java#L143-L157 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java | VisOdomDirectColorDepth.setInterpolation | public void setInterpolation( double inputMin , double inputMax, double derivMin , double derivMax ,
InterpolationType type) {
interpI = FactoryInterpolation.createPixelS(inputMin,inputMax,type, BorderType.EXTENDED, imageType.getImageClass());
interpDX = FactoryInterpolation.createPixelS(derivMin,derivMax,type, BorderType.EXTENDED, derivType.getImageClass());
interpDY = FactoryInterpolation.createPixelS(derivMin,derivMax,type, BorderType.EXTENDED, derivType.getImageClass());
} | java | public void setInterpolation( double inputMin , double inputMax, double derivMin , double derivMax ,
InterpolationType type) {
interpI = FactoryInterpolation.createPixelS(inputMin,inputMax,type, BorderType.EXTENDED, imageType.getImageClass());
interpDX = FactoryInterpolation.createPixelS(derivMin,derivMax,type, BorderType.EXTENDED, derivType.getImageClass());
interpDY = FactoryInterpolation.createPixelS(derivMin,derivMax,type, BorderType.EXTENDED, derivType.getImageClass());
} | [
"public",
"void",
"setInterpolation",
"(",
"double",
"inputMin",
",",
"double",
"inputMax",
",",
"double",
"derivMin",
",",
"double",
"derivMax",
",",
"InterpolationType",
"type",
")",
"{",
"interpI",
"=",
"FactoryInterpolation",
".",
"createPixelS",
"(",
"inputMi... | Used to change interpolation method. Probably don't want to do this.
@param inputMin min value for input pixels. 0 is typical
@param inputMax max value for input pixels. 255 is typical
@param derivMin min value for the derivative of input pixels
@param derivMax max value for the derivative of input pixels
@param type Type of interpolation method to use | [
"Used",
"to",
"change",
"interpolation",
"method",
".",
"Probably",
"don",
"t",
"want",
"to",
"do",
"this",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java#L167-L172 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java | VisOdomDirectColorDepth.setKeyFrame | void setKeyFrame(Planar<I> input, ImagePixelTo3D pixelTo3D) {
InputSanityCheck.checkSameShape(derivX,input);
wrapI.wrap(input);
keypixels.reset();
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
// See if there's a valid 3D point at this location
if( !pixelTo3D.process(x,y) ) {
continue;
}
float P_x = (float)pixelTo3D.getX();
float P_y = (float)pixelTo3D.getY();
float P_z = (float)pixelTo3D.getZ();
float P_w = (float)pixelTo3D.getW();
// skip point if it's at infinity or has a negative value
if( P_w <= 0 )
continue;
// save the results
Pixel p = keypixels.grow();
p.valid = true;
wrapI.get(x,y,p.bands);
p.x = x;
p.y = y;
p.p3.set(P_x/P_w,P_y/P_w,P_z/P_w);
}
}
} | java | void setKeyFrame(Planar<I> input, ImagePixelTo3D pixelTo3D) {
InputSanityCheck.checkSameShape(derivX,input);
wrapI.wrap(input);
keypixels.reset();
for (int y = 0; y < input.height; y++) {
for (int x = 0; x < input.width; x++) {
// See if there's a valid 3D point at this location
if( !pixelTo3D.process(x,y) ) {
continue;
}
float P_x = (float)pixelTo3D.getX();
float P_y = (float)pixelTo3D.getY();
float P_z = (float)pixelTo3D.getZ();
float P_w = (float)pixelTo3D.getW();
// skip point if it's at infinity or has a negative value
if( P_w <= 0 )
continue;
// save the results
Pixel p = keypixels.grow();
p.valid = true;
wrapI.get(x,y,p.bands);
p.x = x;
p.y = y;
p.p3.set(P_x/P_w,P_y/P_w,P_z/P_w);
}
}
} | [
"void",
"setKeyFrame",
"(",
"Planar",
"<",
"I",
">",
"input",
",",
"ImagePixelTo3D",
"pixelTo3D",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"derivX",
",",
"input",
")",
";",
"wrapI",
".",
"wrap",
"(",
"input",
")",
";",
"keypixels",
".",
... | Set's the keyframe. This is the image which motion is estimated relative to. The 3D location of points in
the keyframe must be known.
@param input Image which is to be used as the key frame
@param pixelTo3D Used to compute 3D points from pixels in key frame | [
"Set",
"s",
"the",
"keyframe",
".",
"This",
"is",
"the",
"image",
"which",
"motion",
"is",
"estimated",
"relative",
"to",
".",
"The",
"3D",
"location",
"of",
"points",
"in",
"the",
"keyframe",
"must",
"be",
"known",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java#L192-L223 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java | VisOdomDirectColorDepth.computeFeatureDiversity | public double computeFeatureDiversity(Se3_F32 keyToCurrent ) {
diversity.reset();
for (int i = 0; i < keypixels.size(); i++) {
Pixel p = keypixels.data[i];
if( !p.valid )
continue;
SePointOps_F32.transform(keyToCurrent, p.p3, S);
diversity.addPoint(S.x, S.y, S.z);
}
diversity.process();
return diversity.getSpread();
} | java | public double computeFeatureDiversity(Se3_F32 keyToCurrent ) {
diversity.reset();
for (int i = 0; i < keypixels.size(); i++) {
Pixel p = keypixels.data[i];
if( !p.valid )
continue;
SePointOps_F32.transform(keyToCurrent, p.p3, S);
diversity.addPoint(S.x, S.y, S.z);
}
diversity.process();
return diversity.getSpread();
} | [
"public",
"double",
"computeFeatureDiversity",
"(",
"Se3_F32",
"keyToCurrent",
")",
"{",
"diversity",
".",
"reset",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"keypixels",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Pixel",... | Computes the diversity of valid pixels in keyframe to the location in the current frame.
@return Angular spread along the smallest axis in radians | [
"Computes",
"the",
"diversity",
"of",
"valid",
"pixels",
"in",
"keyframe",
"to",
"the",
"location",
"in",
"the",
"current",
"frame",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java#L229-L244 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java | VisOdomDirectColorDepth.estimateMotion | public boolean estimateMotion(Planar<I> input , Se3_F32 hintKeyToInput ) {
InputSanityCheck.checkSameShape(derivX,input);
initMotion(input);
keyToCurrent.set(hintKeyToInput);
boolean foundSolution = false;
float previousError = Float.MAX_VALUE;
for (int i = 0; i < maxIterations; i++) {
constructLinearSystem(input, keyToCurrent);
if (!solveSystem())
break;
if( Math.abs(previousError-errorOptical)/previousError < convergeTol )
break;
else {
// update the estimated motion from the computed twist
previousError = errorOptical;
keyToCurrent.concat(motionTwist, tmp);
keyToCurrent.set(tmp);
foundSolution = true;
}
}
return foundSolution;
} | java | public boolean estimateMotion(Planar<I> input , Se3_F32 hintKeyToInput ) {
InputSanityCheck.checkSameShape(derivX,input);
initMotion(input);
keyToCurrent.set(hintKeyToInput);
boolean foundSolution = false;
float previousError = Float.MAX_VALUE;
for (int i = 0; i < maxIterations; i++) {
constructLinearSystem(input, keyToCurrent);
if (!solveSystem())
break;
if( Math.abs(previousError-errorOptical)/previousError < convergeTol )
break;
else {
// update the estimated motion from the computed twist
previousError = errorOptical;
keyToCurrent.concat(motionTwist, tmp);
keyToCurrent.set(tmp);
foundSolution = true;
}
}
return foundSolution;
} | [
"public",
"boolean",
"estimateMotion",
"(",
"Planar",
"<",
"I",
">",
"input",
",",
"Se3_F32",
"hintKeyToInput",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"derivX",
",",
"input",
")",
";",
"initMotion",
"(",
"input",
")",
";",
"keyToCurrent",
... | Estimates the motion relative to the key frame.
@param input Next image in the sequence
@param hintKeyToInput estimated transform from keyframe to the current input image
@return true if it was successful at estimating the motion or false if it failed for some reason | [
"Estimates",
"the",
"motion",
"relative",
"to",
"the",
"key",
"frame",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java#L252-L276 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java | VisOdomDirectColorDepth.initMotion | void initMotion(Planar<I> input) {
if( solver == null ) {
solver = LinearSolverFactory_DDRM.qr(input.width*input.height*input.getNumBands(),6);
}
// compute image derivative and setup interpolation functions
computeD.process(input,derivX,derivY);
} | java | void initMotion(Planar<I> input) {
if( solver == null ) {
solver = LinearSolverFactory_DDRM.qr(input.width*input.height*input.getNumBands(),6);
}
// compute image derivative and setup interpolation functions
computeD.process(input,derivX,derivY);
} | [
"void",
"initMotion",
"(",
"Planar",
"<",
"I",
">",
"input",
")",
"{",
"if",
"(",
"solver",
"==",
"null",
")",
"{",
"solver",
"=",
"LinearSolverFactory_DDRM",
".",
"qr",
"(",
"input",
".",
"width",
"*",
"input",
".",
"height",
"*",
"input",
".",
"get... | Initialize motion related data structures | [
"Initialize",
"motion",
"related",
"data",
"structures"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/sfm/d3/direct/VisOdomDirectColorDepth.java#L281-L288 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/f/EssentialNister5.java | EssentialNister5.process | public boolean process( List<AssociatedPair> points , FastQueue<DMatrixRMaj> solutions ) {
if( points.size() != 5 )
throw new IllegalArgumentException("Exactly 5 points are required, not "+points.size());
solutions.reset();
// Computes the 4-vector span which contains E. See equations 7-9
computeSpan(points);
// Construct a linear system based on the 10 constraint equations. See equations 5,6, and 10 .
helper.setNullSpace(X,Y,Z,W);
helper.setupA1(A1);
helper.setupA2(A2);
// instead of Gauss-Jordan elimination LU decomposition is used to solve the system
solver.setA(A1);
solver.solve(A2, C);
// construct the z-polynomial matrix. Equations 11-14
helper.setDeterminantVectors(C);
helper.extractPolynomial(poly.getCoefficients());
if( !findRoots.process(poly) )
return false;
for( Complex_F64 c : findRoots.getRoots() ) {
if( !c.isReal() )
continue;
solveForXandY(c.real);
DMatrixRMaj E = solutions.grow();
for( int i = 0; i < 9; i++ ) {
E.data[i] = x*X[i] + y*Y[i] + z*Z[i] + W[i];
}
}
return true;
} | java | public boolean process( List<AssociatedPair> points , FastQueue<DMatrixRMaj> solutions ) {
if( points.size() != 5 )
throw new IllegalArgumentException("Exactly 5 points are required, not "+points.size());
solutions.reset();
// Computes the 4-vector span which contains E. See equations 7-9
computeSpan(points);
// Construct a linear system based on the 10 constraint equations. See equations 5,6, and 10 .
helper.setNullSpace(X,Y,Z,W);
helper.setupA1(A1);
helper.setupA2(A2);
// instead of Gauss-Jordan elimination LU decomposition is used to solve the system
solver.setA(A1);
solver.solve(A2, C);
// construct the z-polynomial matrix. Equations 11-14
helper.setDeterminantVectors(C);
helper.extractPolynomial(poly.getCoefficients());
if( !findRoots.process(poly) )
return false;
for( Complex_F64 c : findRoots.getRoots() ) {
if( !c.isReal() )
continue;
solveForXandY(c.real);
DMatrixRMaj E = solutions.grow();
for( int i = 0; i < 9; i++ ) {
E.data[i] = x*X[i] + y*Y[i] + z*Z[i] + W[i];
}
}
return true;
} | [
"public",
"boolean",
"process",
"(",
"List",
"<",
"AssociatedPair",
">",
"points",
",",
"FastQueue",
"<",
"DMatrixRMaj",
">",
"solutions",
")",
"{",
"if",
"(",
"points",
".",
"size",
"(",
")",
"!=",
"5",
")",
"throw",
"new",
"IllegalArgumentException",
"("... | Computes the essential matrix from point correspondences.
@param points Input: List of points correspondences in normalized image coordinates
@param solutions Output: Storage for the found solutions. .
@return true for success or false if a fault has been detected | [
"Computes",
"the",
"essential",
"matrix",
"from",
"point",
"correspondences",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/f/EssentialNister5.java#L104-L142 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/f/EssentialNister5.java | EssentialNister5.solveForXandY | private void solveForXandY( double z ) {
this.z = z;
// solve for x and y using the first two rows of B
tmpA.data[0] = ((helper.K00*z + helper.K01)*z + helper.K02)*z + helper.K03;
tmpA.data[1] = ((helper.K04*z + helper.K05)*z + helper.K06)*z + helper.K07;
tmpY.data[0] = (((helper.K08*z + helper.K09)*z + helper.K10)*z + helper.K11)*z + helper.K12;
tmpA.data[2] = ((helper.L00*z + helper.L01)*z + helper.L02)*z + helper.L03;
tmpA.data[3] = ((helper.L04*z + helper.L05)*z + helper.L06)*z + helper.L07;
tmpY.data[1] = (((helper.L08*z + helper.L09)*z + helper.L10)*z + helper.L11)*z + helper.L12;
tmpA.data[4] = ((helper.M00*z + helper.M01)*z + helper.M02)*z + helper.M03;
tmpA.data[5] = ((helper.M04*z + helper.M05)*z + helper.M06)*z + helper.M07;
tmpY.data[2] = (((helper.M08*z + helper.M09)*z + helper.M10)*z + helper.M11)*z + helper.M12;
CommonOps_DDRM.scale(-1,tmpY);
CommonOps_DDRM.solve(tmpA,tmpY,tmpX);
this.x = tmpX.get(0,0);
this.y = tmpX.get(1,0);
} | java | private void solveForXandY( double z ) {
this.z = z;
// solve for x and y using the first two rows of B
tmpA.data[0] = ((helper.K00*z + helper.K01)*z + helper.K02)*z + helper.K03;
tmpA.data[1] = ((helper.K04*z + helper.K05)*z + helper.K06)*z + helper.K07;
tmpY.data[0] = (((helper.K08*z + helper.K09)*z + helper.K10)*z + helper.K11)*z + helper.K12;
tmpA.data[2] = ((helper.L00*z + helper.L01)*z + helper.L02)*z + helper.L03;
tmpA.data[3] = ((helper.L04*z + helper.L05)*z + helper.L06)*z + helper.L07;
tmpY.data[1] = (((helper.L08*z + helper.L09)*z + helper.L10)*z + helper.L11)*z + helper.L12;
tmpA.data[4] = ((helper.M00*z + helper.M01)*z + helper.M02)*z + helper.M03;
tmpA.data[5] = ((helper.M04*z + helper.M05)*z + helper.M06)*z + helper.M07;
tmpY.data[2] = (((helper.M08*z + helper.M09)*z + helper.M10)*z + helper.M11)*z + helper.M12;
CommonOps_DDRM.scale(-1,tmpY);
CommonOps_DDRM.solve(tmpA,tmpY,tmpX);
this.x = tmpX.get(0,0);
this.y = tmpX.get(1,0);
} | [
"private",
"void",
"solveForXandY",
"(",
"double",
"z",
")",
"{",
"this",
".",
"z",
"=",
"z",
";",
"// solve for x and y using the first two rows of B",
"tmpA",
".",
"data",
"[",
"0",
"]",
"=",
"(",
"(",
"helper",
".",
"K00",
"*",
"z",
"+",
"helper",
"."... | Once z is known then x and y can be solved for using the B matrix | [
"Once",
"z",
"is",
"known",
"then",
"x",
"and",
"y",
"can",
"be",
"solved",
"for",
"using",
"the",
"B",
"matrix"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/f/EssentialNister5.java#L189-L210 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/feature/associate/StereoConsistencyCheck.java | StereoConsistencyCheck.checkPixel | public boolean checkPixel( Point2D_F64 left , Point2D_F64 right ) {
leftImageToRect.compute(left.x,left.y,rectLeft);
rightImageToRect.compute(right.x, right.y, rectRight);
return checkRectified(rectLeft,rectRight);
} | java | public boolean checkPixel( Point2D_F64 left , Point2D_F64 right ) {
leftImageToRect.compute(left.x,left.y,rectLeft);
rightImageToRect.compute(right.x, right.y, rectRight);
return checkRectified(rectLeft,rectRight);
} | [
"public",
"boolean",
"checkPixel",
"(",
"Point2D_F64",
"left",
",",
"Point2D_F64",
"right",
")",
"{",
"leftImageToRect",
".",
"compute",
"(",
"left",
".",
"x",
",",
"left",
".",
"y",
",",
"rectLeft",
")",
";",
"rightImageToRect",
".",
"compute",
"(",
"righ... | Checks to see if the observations from the left and right camera are consistent. Observations
are assumed to be in the original image pixel coordinates.
@param left Left camera observation in original pixels
@param right Right camera observation in original pixels
@return true for consistent | [
"Checks",
"to",
"see",
"if",
"the",
"observations",
"from",
"the",
"left",
"and",
"right",
"camera",
"are",
"consistent",
".",
"Observations",
"are",
"assumed",
"to",
"be",
"in",
"the",
"original",
"image",
"pixel",
"coordinates",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/feature/associate/StereoConsistencyCheck.java#L87-L92 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/feature/associate/StereoConsistencyCheck.java | StereoConsistencyCheck.checkRectified | public boolean checkRectified( Point2D_F64 left , Point2D_F64 right ) {
// rectifications should make them appear along the same y-coordinate/epipolar line
if( Math.abs(left.y - right.y) > toleranceY )
return false;
// features in the right camera should appear left of features in the image image
return right.x <= left.x + toleranceX;
} | java | public boolean checkRectified( Point2D_F64 left , Point2D_F64 right ) {
// rectifications should make them appear along the same y-coordinate/epipolar line
if( Math.abs(left.y - right.y) > toleranceY )
return false;
// features in the right camera should appear left of features in the image image
return right.x <= left.x + toleranceX;
} | [
"public",
"boolean",
"checkRectified",
"(",
"Point2D_F64",
"left",
",",
"Point2D_F64",
"right",
")",
"{",
"// rectifications should make them appear along the same y-coordinate/epipolar line",
"if",
"(",
"Math",
".",
"abs",
"(",
"left",
".",
"y",
"-",
"right",
".",
"y... | Checks to see if the observations from the left and right camera are consistent. Observations
are assumed to be in the rectified image pixel coordinates.
@param left Left camera observation in rectified pixels
@param right Right camera observation in rectified pixels
@return true for consistent | [
"Checks",
"to",
"see",
"if",
"the",
"observations",
"from",
"the",
"left",
"and",
"right",
"camera",
"are",
"consistent",
".",
"Observations",
"are",
"assumed",
"to",
"be",
"in",
"the",
"rectified",
"image",
"pixel",
"coordinates",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/feature/associate/StereoConsistencyCheck.java#L102-L109 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribePointAlgs.java | FactoryDescribePointAlgs.briefso | public static <T extends ImageGray<T>>
DescribePointBriefSO<T> briefso(BinaryCompareDefinition_I32 definition, BlurFilter<T> filterBlur) {
Class<T> imageType = filterBlur.getInputType().getImageClass();
InterpolatePixelS<T> interp = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED);
return new DescribePointBriefSO<>(definition, filterBlur, interp);
} | java | public static <T extends ImageGray<T>>
DescribePointBriefSO<T> briefso(BinaryCompareDefinition_I32 definition, BlurFilter<T> filterBlur) {
Class<T> imageType = filterBlur.getInputType().getImageClass();
InterpolatePixelS<T> interp = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED);
return new DescribePointBriefSO<>(definition, filterBlur, interp);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageGray",
"<",
"T",
">",
">",
"DescribePointBriefSO",
"<",
"T",
">",
"briefso",
"(",
"BinaryCompareDefinition_I32",
"definition",
",",
"BlurFilter",
"<",
"T",
">",
"filterBlur",
")",
"{",
"Class",
"<",
"T",
">",
... | todo remove filterBlur for all BRIEF change to radius,sigma,type | [
"todo",
"remove",
"filterBlur",
"for",
"all",
"BRIEF",
"change",
"to",
"radius",
"sigma",
"type"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/factory/feature/describe/FactoryDescribePointAlgs.java#L91-L98 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java | TldVarianceFilter.checkVariance | public boolean checkVariance( ImageRectangle r ) {
double sigma2 = computeVariance(r.x0,r.y0,r.x1,r.y1);
return sigma2 >= thresholdLower;
} | java | public boolean checkVariance( ImageRectangle r ) {
double sigma2 = computeVariance(r.x0,r.y0,r.x1,r.y1);
return sigma2 >= thresholdLower;
} | [
"public",
"boolean",
"checkVariance",
"(",
"ImageRectangle",
"r",
")",
"{",
"double",
"sigma2",
"=",
"computeVariance",
"(",
"r",
".",
"x0",
",",
"r",
".",
"y0",
",",
"r",
".",
"x1",
",",
"r",
".",
"y1",
")",
";",
"return",
"sigma2",
">=",
"threshold... | Performs variance test at the specified rectangle
@return true if it passes and false if not | [
"Performs",
"variance",
"test",
"at",
"the",
"specified",
"rectangle"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java#L94-L99 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java | TldVarianceFilter.computeVariance | protected double computeVariance(int x0, int y0, int x1, int y1) {
// can use unsafe operations here since x0 > 0 and y0 > 0
double square = GIntegralImageOps.block_unsafe(integralSq, x0 - 1, y0 - 1, x1 - 1, y1 - 1);
double area = (x1-x0)*(y1-y0);
double mean = GIntegralImageOps.block_unsafe(integral, x0 - 1, y0 - 1, x1 - 1, y1 - 1)/area;
return square/area - mean*mean;
} | java | protected double computeVariance(int x0, int y0, int x1, int y1) {
// can use unsafe operations here since x0 > 0 and y0 > 0
double square = GIntegralImageOps.block_unsafe(integralSq, x0 - 1, y0 - 1, x1 - 1, y1 - 1);
double area = (x1-x0)*(y1-y0);
double mean = GIntegralImageOps.block_unsafe(integral, x0 - 1, y0 - 1, x1 - 1, y1 - 1)/area;
return square/area - mean*mean;
} | [
"protected",
"double",
"computeVariance",
"(",
"int",
"x0",
",",
"int",
"y0",
",",
"int",
"x1",
",",
"int",
"y1",
")",
"{",
"// can use unsafe operations here since x0 > 0 and y0 > 0",
"double",
"square",
"=",
"GIntegralImageOps",
".",
"block_unsafe",
"(",
"integral... | Computes the variance inside the specified rectangle. x0 and y0 must be > 0.
@return variance | [
"Computes",
"the",
"variance",
"inside",
"the",
"specified",
"rectangle",
".",
"x0",
"and",
"y0",
"must",
"be",
">",
";",
"0",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java#L106-L114 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java | TldVarianceFilter.computeVarianceSafe | protected double computeVarianceSafe(int x0, int y0, int x1, int y1) {
// can use unsafe operations here since x0 > 0 and y0 > 0
double square = GIntegralImageOps.block_zero(integralSq, x0 - 1, y0 - 1, x1 - 1, y1 - 1);
double area = (x1-x0)*(y1-y0);
double mean = GIntegralImageOps.block_zero(integral, x0 - 1, y0 - 1, x1 - 1, y1 - 1)/area;
return square/area - mean*mean;
} | java | protected double computeVarianceSafe(int x0, int y0, int x1, int y1) {
// can use unsafe operations here since x0 > 0 and y0 > 0
double square = GIntegralImageOps.block_zero(integralSq, x0 - 1, y0 - 1, x1 - 1, y1 - 1);
double area = (x1-x0)*(y1-y0);
double mean = GIntegralImageOps.block_zero(integral, x0 - 1, y0 - 1, x1 - 1, y1 - 1)/area;
return square/area - mean*mean;
} | [
"protected",
"double",
"computeVarianceSafe",
"(",
"int",
"x0",
",",
"int",
"y0",
",",
"int",
"x1",
",",
"int",
"y1",
")",
"{",
"// can use unsafe operations here since x0 > 0 and y0 > 0",
"double",
"square",
"=",
"GIntegralImageOps",
".",
"block_zero",
"(",
"integr... | Computes the variance inside the specified rectangle.
@return variance | [
"Computes",
"the",
"variance",
"inside",
"the",
"specified",
"rectangle",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java#L120-L128 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java | TldVarianceFilter.transformSq | public static void transformSq(final GrayU8 input , final GrayS64 transformed )
{
int indexSrc = input.startIndex;
int indexDst = transformed.startIndex;
int end = indexSrc + input.width;
long total = 0;
for( ; indexSrc < end; indexSrc++ ) {
int value = input.data[indexSrc]& 0xFF;
transformed.data[indexDst++] = total += value*value;
}
for( int y = 1; y < input.height; y++ ) {
indexSrc = input.startIndex + input.stride*y;
indexDst = transformed.startIndex + transformed.stride*y;
int indexPrev = indexDst - transformed.stride;
end = indexSrc + input.width;
total = 0;
for( ; indexSrc < end; indexSrc++ ) {
int value = input.data[indexSrc]& 0xFF;
total += value*value;
transformed.data[indexDst++] = transformed.data[indexPrev++] + total;
}
}
} | java | public static void transformSq(final GrayU8 input , final GrayS64 transformed )
{
int indexSrc = input.startIndex;
int indexDst = transformed.startIndex;
int end = indexSrc + input.width;
long total = 0;
for( ; indexSrc < end; indexSrc++ ) {
int value = input.data[indexSrc]& 0xFF;
transformed.data[indexDst++] = total += value*value;
}
for( int y = 1; y < input.height; y++ ) {
indexSrc = input.startIndex + input.stride*y;
indexDst = transformed.startIndex + transformed.stride*y;
int indexPrev = indexDst - transformed.stride;
end = indexSrc + input.width;
total = 0;
for( ; indexSrc < end; indexSrc++ ) {
int value = input.data[indexSrc]& 0xFF;
total += value*value;
transformed.data[indexDst++] = transformed.data[indexPrev++] + total;
}
}
} | [
"public",
"static",
"void",
"transformSq",
"(",
"final",
"GrayU8",
"input",
",",
"final",
"GrayS64",
"transformed",
")",
"{",
"int",
"indexSrc",
"=",
"input",
".",
"startIndex",
";",
"int",
"indexDst",
"=",
"transformed",
".",
"startIndex",
";",
"int",
"end"... | Integral image of pixel value squared. integer | [
"Integral",
"image",
"of",
"pixel",
"value",
"squared",
".",
"integer"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java#L133-L159 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java | TldVarianceFilter.transformSq | public static void transformSq(final GrayF32 input , final GrayF64 transformed )
{
int indexSrc = input.startIndex;
int indexDst = transformed.startIndex;
int end = indexSrc + input.width;
double total = 0;
for( ; indexSrc < end; indexSrc++ ) {
float value = input.data[indexSrc];
transformed.data[indexDst++] = total += value*value;
}
for( int y = 1; y < input.height; y++ ) {
indexSrc = input.startIndex + input.stride*y;
indexDst = transformed.startIndex + transformed.stride*y;
int indexPrev = indexDst - transformed.stride;
end = indexSrc + input.width;
total = 0;
for( ; indexSrc < end; indexSrc++ ) {
float value = input.data[indexSrc];
total += value*value;
transformed.data[indexDst++] = transformed.data[indexPrev++] + total;
}
}
} | java | public static void transformSq(final GrayF32 input , final GrayF64 transformed )
{
int indexSrc = input.startIndex;
int indexDst = transformed.startIndex;
int end = indexSrc + input.width;
double total = 0;
for( ; indexSrc < end; indexSrc++ ) {
float value = input.data[indexSrc];
transformed.data[indexDst++] = total += value*value;
}
for( int y = 1; y < input.height; y++ ) {
indexSrc = input.startIndex + input.stride*y;
indexDst = transformed.startIndex + transformed.stride*y;
int indexPrev = indexDst - transformed.stride;
end = indexSrc + input.width;
total = 0;
for( ; indexSrc < end; indexSrc++ ) {
float value = input.data[indexSrc];
total += value*value;
transformed.data[indexDst++] = transformed.data[indexPrev++] + total;
}
}
} | [
"public",
"static",
"void",
"transformSq",
"(",
"final",
"GrayF32",
"input",
",",
"final",
"GrayF64",
"transformed",
")",
"{",
"int",
"indexSrc",
"=",
"input",
".",
"startIndex",
";",
"int",
"indexDst",
"=",
"transformed",
".",
"startIndex",
";",
"int",
"end... | Integral image of pixel value squared. floating point | [
"Integral",
"image",
"of",
"pixel",
"value",
"squared",
".",
"floating",
"point"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldVarianceFilter.java#L164-L190 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/TriangulateProjectiveLinearDLT.java | TriangulateProjectiveLinearDLT.addView | private int addView( DMatrixRMaj P , Point2D_F64 a , int index ) {
final double sx = stats.stdX, sy = stats.stdY;
// final double cx = stats.meanX, cy = stats.meanY;
// Easier to read the code when P is broken up this way
double r11 = P.data[0], r12 = P.data[1], r13 = P.data[2], r14=P.data[3];
double r21 = P.data[4], r22 = P.data[5], r23 = P.data[6], r24=P.data[7];
double r31 = P.data[8], r32 = P.data[9], r33 = P.data[10], r34=P.data[11];
// These rows are derived by applying the scaling matrix to pixels and camera matrix
// px = (a.x/sx - cx/sx)
// A[0,0] = a.x*r31 - r11 (before normalization)
// A[0,0] = px*r31 - (r11-cx*r31)/sx (after normalization)
// first row
A.data[index++] = (a.x*r31-r11)/sx;
A.data[index++] = (a.x*r32-r12)/sx;
A.data[index++] = (a.x*r33-r13)/sx;
A.data[index++] = (a.x*r34-r14)/sx;
// second row
A.data[index++] = (a.y*r31-r21)/sy;
A.data[index++] = (a.y*r32-r22)/sy;
A.data[index++] = (a.y*r33-r23)/sy;
A.data[index++] = (a.y*r34-r24)/sy;
return index;
} | java | private int addView( DMatrixRMaj P , Point2D_F64 a , int index ) {
final double sx = stats.stdX, sy = stats.stdY;
// final double cx = stats.meanX, cy = stats.meanY;
// Easier to read the code when P is broken up this way
double r11 = P.data[0], r12 = P.data[1], r13 = P.data[2], r14=P.data[3];
double r21 = P.data[4], r22 = P.data[5], r23 = P.data[6], r24=P.data[7];
double r31 = P.data[8], r32 = P.data[9], r33 = P.data[10], r34=P.data[11];
// These rows are derived by applying the scaling matrix to pixels and camera matrix
// px = (a.x/sx - cx/sx)
// A[0,0] = a.x*r31 - r11 (before normalization)
// A[0,0] = px*r31 - (r11-cx*r31)/sx (after normalization)
// first row
A.data[index++] = (a.x*r31-r11)/sx;
A.data[index++] = (a.x*r32-r12)/sx;
A.data[index++] = (a.x*r33-r13)/sx;
A.data[index++] = (a.x*r34-r14)/sx;
// second row
A.data[index++] = (a.y*r31-r21)/sy;
A.data[index++] = (a.y*r32-r22)/sy;
A.data[index++] = (a.y*r33-r23)/sy;
A.data[index++] = (a.y*r34-r24)/sy;
return index;
} | [
"private",
"int",
"addView",
"(",
"DMatrixRMaj",
"P",
",",
"Point2D_F64",
"a",
",",
"int",
"index",
")",
"{",
"final",
"double",
"sx",
"=",
"stats",
".",
"stdX",
",",
"sy",
"=",
"stats",
".",
"stdY",
";",
"//\t\tfinal double cx = stats.meanX, cy = stats.meanY;... | Adds a view to the A matrix. Computed using cross product. | [
"Adds",
"a",
"view",
"to",
"the",
"A",
"matrix",
".",
"Computed",
"using",
"cross",
"product",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/alg/geo/triangulate/TriangulateProjectiveLinearDLT.java#L111-L140 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldDetection.java | TldDetection.detectionCascade | protected void detectionCascade( FastQueue<ImageRectangle> cascadeRegions ) {
// initialize data structures
success = false;
ambiguous = false;
best = null;
candidateDetections.reset();
localMaximums.reset();
ambiguousRegions.clear();
storageMetric.reset();
storageIndexes.reset();
storageRect.clear();
fernRegions.clear();
fernInfo.reset();
int totalP = 0;
int totalN = 0;
// Run through all candidate regions, ignore ones without enough variance, compute
// the fern for each one
TldRegionFernInfo info = fernInfo.grow();
for( int i = 0; i < cascadeRegions.size; i++ ) {
ImageRectangle region = cascadeRegions.get(i);
if( !variance.checkVariance(region)) {
continue;
}
info.r = region;
if( fern.lookupFernPN(info)) {
totalP += info.sumP;
totalN += info.sumN;
info = fernInfo.grow();
}
}
fernInfo.removeTail();
// avoid overflow errors in the future by re-normalizing the Fern detector
if( totalP > 0x0fffffff)
fern.renormalizeP();
if( totalN > 0x0fffffff)
fern.renormalizeN();
// Select the ferns with the highest likelihood
selectBestRegionsFern(totalP, totalN);
// From the remaining regions, score using the template algorithm
computeTemplateConfidence();
if( candidateDetections.size == 0 ) {
return;
}
// use non-maximum suppression to reduce the number of candidates
nonmax.process(candidateDetections, localMaximums);
best = selectBest();
if( best != null ) {
ambiguous = checkAmbiguous(best);
success = true;
}
} | java | protected void detectionCascade( FastQueue<ImageRectangle> cascadeRegions ) {
// initialize data structures
success = false;
ambiguous = false;
best = null;
candidateDetections.reset();
localMaximums.reset();
ambiguousRegions.clear();
storageMetric.reset();
storageIndexes.reset();
storageRect.clear();
fernRegions.clear();
fernInfo.reset();
int totalP = 0;
int totalN = 0;
// Run through all candidate regions, ignore ones without enough variance, compute
// the fern for each one
TldRegionFernInfo info = fernInfo.grow();
for( int i = 0; i < cascadeRegions.size; i++ ) {
ImageRectangle region = cascadeRegions.get(i);
if( !variance.checkVariance(region)) {
continue;
}
info.r = region;
if( fern.lookupFernPN(info)) {
totalP += info.sumP;
totalN += info.sumN;
info = fernInfo.grow();
}
}
fernInfo.removeTail();
// avoid overflow errors in the future by re-normalizing the Fern detector
if( totalP > 0x0fffffff)
fern.renormalizeP();
if( totalN > 0x0fffffff)
fern.renormalizeN();
// Select the ferns with the highest likelihood
selectBestRegionsFern(totalP, totalN);
// From the remaining regions, score using the template algorithm
computeTemplateConfidence();
if( candidateDetections.size == 0 ) {
return;
}
// use non-maximum suppression to reduce the number of candidates
nonmax.process(candidateDetections, localMaximums);
best = selectBest();
if( best != null ) {
ambiguous = checkAmbiguous(best);
success = true;
}
} | [
"protected",
"void",
"detectionCascade",
"(",
"FastQueue",
"<",
"ImageRectangle",
">",
"cascadeRegions",
")",
"{",
"// initialize data structures",
"success",
"=",
"false",
";",
"ambiguous",
"=",
"false",
";",
"best",
"=",
"null",
";",
"candidateDetections",
".",
... | Detects the object inside the image. Eliminates candidate regions using a cascade of tests | [
"Detects",
"the",
"object",
"inside",
"the",
"image",
".",
"Eliminates",
"candidate",
"regions",
"using",
"a",
"cascade",
"of",
"tests"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldDetection.java#L95-L160 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldDetection.java | TldDetection.computeTemplateConfidence | protected void computeTemplateConfidence() {
double max = 0;
for( int i = 0; i < fernRegions.size(); i++ ) {
ImageRectangle region = fernRegions.get(i);
double confidence = template.computeConfidence(region);
max = Math.max(max,confidence);
if( confidence < config.confidenceThresholdUpper)
continue;
TldRegion r = candidateDetections.grow();
r.connections = 0;
r.rect.set(region);
r.confidence = confidence;
}
} | java | protected void computeTemplateConfidence() {
double max = 0;
for( int i = 0; i < fernRegions.size(); i++ ) {
ImageRectangle region = fernRegions.get(i);
double confidence = template.computeConfidence(region);
max = Math.max(max,confidence);
if( confidence < config.confidenceThresholdUpper)
continue;
TldRegion r = candidateDetections.grow();
r.connections = 0;
r.rect.set(region);
r.confidence = confidence;
}
} | [
"protected",
"void",
"computeTemplateConfidence",
"(",
")",
"{",
"double",
"max",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fernRegions",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"ImageRectangle",
"region",
"=",
"fernRe... | Computes the confidence for all the regions which pass the fern test | [
"Computes",
"the",
"confidence",
"for",
"all",
"the",
"regions",
"which",
"pass",
"the",
"fern",
"test"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldDetection.java#L165-L181 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldDetection.java | TldDetection.selectBestRegionsFern | protected void selectBestRegionsFern(double totalP, double totalN) {
for( int i = 0; i < fernInfo.size; i++ ) {
TldRegionFernInfo info = fernInfo.get(i);
double probP = info.sumP/totalP;
double probN = info.sumN/totalN;
// only consider regions with a higher P likelihood
if( probP > probN ) {
// reward regions with a large difference between the P and N values
storageMetric.add(-(probP-probN));
storageRect.add( info.r );
}
}
// Select the N regions with the highest fern probability
if( config.maximumCascadeConsider < storageMetric.size ) {
int N = Math.min(config.maximumCascadeConsider, storageMetric.size);
storageIndexes.resize(storageMetric.size);
QuickSelect.selectIndex(storageMetric.data, N - 1, storageMetric.size, storageIndexes.data);
for( int i = 0; i < N; i++ ) {
fernRegions.add(storageRect.get(storageIndexes.get(i)));
}
} else {
fernRegions.addAll(storageRect);
}
} | java | protected void selectBestRegionsFern(double totalP, double totalN) {
for( int i = 0; i < fernInfo.size; i++ ) {
TldRegionFernInfo info = fernInfo.get(i);
double probP = info.sumP/totalP;
double probN = info.sumN/totalN;
// only consider regions with a higher P likelihood
if( probP > probN ) {
// reward regions with a large difference between the P and N values
storageMetric.add(-(probP-probN));
storageRect.add( info.r );
}
}
// Select the N regions with the highest fern probability
if( config.maximumCascadeConsider < storageMetric.size ) {
int N = Math.min(config.maximumCascadeConsider, storageMetric.size);
storageIndexes.resize(storageMetric.size);
QuickSelect.selectIndex(storageMetric.data, N - 1, storageMetric.size, storageIndexes.data);
for( int i = 0; i < N; i++ ) {
fernRegions.add(storageRect.get(storageIndexes.get(i)));
}
} else {
fernRegions.addAll(storageRect);
}
} | [
"protected",
"void",
"selectBestRegionsFern",
"(",
"double",
"totalP",
",",
"double",
"totalN",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"fernInfo",
".",
"size",
";",
"i",
"++",
")",
"{",
"TldRegionFernInfo",
"info",
"=",
"fernInfo",
... | compute the probability that each region is the target conditional upon this image
the sumP and sumN are needed for image conditional probability
NOTE: This is a big change from the original paper | [
"compute",
"the",
"probability",
"that",
"each",
"region",
"is",
"the",
"target",
"conditional",
"upon",
"this",
"image",
"the",
"sumP",
"and",
"sumN",
"are",
"needed",
"for",
"image",
"conditional",
"probability"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/tld/TldDetection.java#L189-L217 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/PyramidKltTracker.java | PyramidKltTracker.setImage | public void setImage(ImagePyramid<InputImage> image,
DerivativeImage[] derivX, DerivativeImage[] derivY) {
if( image.getNumLayers() != derivX.length || image.getNumLayers() != derivY.length )
throw new IllegalArgumentException("Number of layers does not match.");
this.image = image;
this.derivX = derivX;
this.derivY = derivY;
} | java | public void setImage(ImagePyramid<InputImage> image,
DerivativeImage[] derivX, DerivativeImage[] derivY) {
if( image.getNumLayers() != derivX.length || image.getNumLayers() != derivY.length )
throw new IllegalArgumentException("Number of layers does not match.");
this.image = image;
this.derivX = derivX;
this.derivY = derivY;
} | [
"public",
"void",
"setImage",
"(",
"ImagePyramid",
"<",
"InputImage",
">",
"image",
",",
"DerivativeImage",
"[",
"]",
"derivX",
",",
"DerivativeImage",
"[",
"]",
"derivY",
")",
"{",
"if",
"(",
"image",
".",
"getNumLayers",
"(",
")",
"!=",
"derivX",
".",
... | Sets the current input images for the tracker to use.
@param image Original image pyramid.
@param derivX Derivative along x-axis.
@param derivY Derivative along y-axis. | [
"Sets",
"the",
"current",
"input",
"images",
"for",
"the",
"tracker",
"to",
"use",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/PyramidKltTracker.java#L79-L87 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/PyramidKltTracker.java | PyramidKltTracker.setImage | public void setImage(ImagePyramid<InputImage> image ) {
this.image = image;
this.derivX = null;
this.derivY = null;
} | java | public void setImage(ImagePyramid<InputImage> image ) {
this.image = image;
this.derivX = null;
this.derivY = null;
} | [
"public",
"void",
"setImage",
"(",
"ImagePyramid",
"<",
"InputImage",
">",
"image",
")",
"{",
"this",
".",
"image",
"=",
"image",
";",
"this",
".",
"derivX",
"=",
"null",
";",
"this",
".",
"derivY",
"=",
"null",
";",
"}"
] | Only sets the image pyramid. The derivatives are set to null. Only use this when tracking.
@param image Image pyramid | [
"Only",
"sets",
"the",
"image",
"pyramid",
".",
"The",
"derivatives",
"are",
"set",
"to",
"null",
".",
"Only",
"use",
"this",
"when",
"tracking",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/main/java/boofcv/alg/tracker/klt/PyramidKltTracker.java#L93-L97 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/enhance/EnhanceImageOps.java | EnhanceImageOps.equalize | public static void equalize( int histogram[] , int transform[] ) {
int sum = 0;
for( int i = 0; i < histogram.length; i++ ) {
transform[i] = sum += histogram[i];
}
int maxValue = histogram.length-1;
for( int i = 0; i < histogram.length; i++ ) {
transform[i] = (transform[i]*maxValue)/sum;
}
} | java | public static void equalize( int histogram[] , int transform[] ) {
int sum = 0;
for( int i = 0; i < histogram.length; i++ ) {
transform[i] = sum += histogram[i];
}
int maxValue = histogram.length-1;
for( int i = 0; i < histogram.length; i++ ) {
transform[i] = (transform[i]*maxValue)/sum;
}
} | [
"public",
"static",
"void",
"equalize",
"(",
"int",
"histogram",
"[",
"]",
",",
"int",
"transform",
"[",
"]",
")",
"{",
"int",
"sum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"histogram",
".",
"length",
";",
"i",
"++",
")... | Computes a transformation table which will equalize the provided histogram. An equalized histogram spreads
the 'weight' across the whole spectrum of values. Often used to make dim images easier for people to see.
@param histogram Input image histogram.
@param transform Output transformation table. | [
"Computes",
"a",
"transformation",
"table",
"which",
"will",
"equalize",
"the",
"provided",
"histogram",
".",
"An",
"equalized",
"histogram",
"spreads",
"the",
"weight",
"across",
"the",
"whole",
"spectrum",
"of",
"values",
".",
"Often",
"used",
"to",
"make",
... | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/enhance/EnhanceImageOps.java#L65-L77 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/enhance/EnhanceImageOps.java | EnhanceImageOps.sharpen8 | public static void sharpen8(GrayU8 input , GrayU8 output ) {
InputSanityCheck.checkSameShape(input, output);
if( BoofConcurrency.USE_CONCURRENT ) {
ImplEnhanceFilter_MT.sharpenInner8(input,output,0,255);
ImplEnhanceFilter_MT.sharpenBorder8(input,output,0,255);
} else {
ImplEnhanceFilter.sharpenInner8(input,output,0,255);
ImplEnhanceFilter.sharpenBorder8(input,output,0,255);
}
} | java | public static void sharpen8(GrayU8 input , GrayU8 output ) {
InputSanityCheck.checkSameShape(input, output);
if( BoofConcurrency.USE_CONCURRENT ) {
ImplEnhanceFilter_MT.sharpenInner8(input,output,0,255);
ImplEnhanceFilter_MT.sharpenBorder8(input,output,0,255);
} else {
ImplEnhanceFilter.sharpenInner8(input,output,0,255);
ImplEnhanceFilter.sharpenBorder8(input,output,0,255);
}
} | [
"public",
"static",
"void",
"sharpen8",
"(",
"GrayU8",
"input",
",",
"GrayU8",
"output",
")",
"{",
"InputSanityCheck",
".",
"checkSameShape",
"(",
"input",
",",
"output",
")",
";",
"if",
"(",
"BoofConcurrency",
".",
"USE_CONCURRENT",
")",
"{",
"ImplEnhanceFilt... | Applies a Laplacian-8 based sharpen filter to the image.
@param input Input image.
@param output Output image. | [
"Applies",
"a",
"Laplacian",
"-",
"8",
"based",
"sharpen",
"filter",
"to",
"the",
"image",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/enhance/EnhanceImageOps.java#L343-L353 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociateTwoPass.java | DetectDescribeAssociateTwoPass.updateTrackLocation | protected void updateTrackLocation( SetTrackInfo<Desc> info, FastQueue<AssociatedIndex> matches) {
info.matches.resize(matches.size);
for (int i = 0; i < matches.size; i++) {
info.matches.get(i).set(matches.get(i));
}
tracksActive.clear();
for( int i = 0; i < info.matches.size; i++ ) {
AssociatedIndex indexes = info.matches.data[i];
PointTrack track = info.tracks.get(indexes.src);
Point2D_F64 loc = info.locDst.data[indexes.dst];
track.set(loc.x, loc.y);
tracksActive.add(track);
}
} | java | protected void updateTrackLocation( SetTrackInfo<Desc> info, FastQueue<AssociatedIndex> matches) {
info.matches.resize(matches.size);
for (int i = 0; i < matches.size; i++) {
info.matches.get(i).set(matches.get(i));
}
tracksActive.clear();
for( int i = 0; i < info.matches.size; i++ ) {
AssociatedIndex indexes = info.matches.data[i];
PointTrack track = info.tracks.get(indexes.src);
Point2D_F64 loc = info.locDst.data[indexes.dst];
track.set(loc.x, loc.y);
tracksActive.add(track);
}
} | [
"protected",
"void",
"updateTrackLocation",
"(",
"SetTrackInfo",
"<",
"Desc",
">",
"info",
",",
"FastQueue",
"<",
"AssociatedIndex",
">",
"matches",
")",
"{",
"info",
".",
"matches",
".",
"resize",
"(",
"matches",
".",
"size",
")",
";",
"for",
"(",
"int",
... | Update each track's location only and not its description. Update the active list too | [
"Update",
"each",
"track",
"s",
"location",
"only",
"and",
"not",
"its",
"description",
".",
"Update",
"the",
"active",
"list",
"too"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociateTwoPass.java#L139-L153 | train |
lessthanoptimal/BoofCV | main/boofcv-feature/src/experimental/java/boofcv/alg/descriptor/ExperimentalDescriptorDistance.java | ExperimentalDescriptorDistance.hamming | public static int hamming(TupleDesc_B a, TupleDesc_B b ) {
int score = 0;
final int N = a.data.length;
for( int i = 0; i < N; i++ ) {
score += hamming(a.data[i] ^ b.data[i]);
}
return score;
} | java | public static int hamming(TupleDesc_B a, TupleDesc_B b ) {
int score = 0;
final int N = a.data.length;
for( int i = 0; i < N; i++ ) {
score += hamming(a.data[i] ^ b.data[i]);
}
return score;
} | [
"public",
"static",
"int",
"hamming",
"(",
"TupleDesc_B",
"a",
",",
"TupleDesc_B",
"b",
")",
"{",
"int",
"score",
"=",
"0",
";",
"final",
"int",
"N",
"=",
"a",
".",
"data",
".",
"length",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"N... | Computes the hamming distance between two binary feature descriptors
@param a First variable
@param b Second variable
@return The hamming distance | [
"Computes",
"the",
"hamming",
"distance",
"between",
"two",
"binary",
"feature",
"descriptors"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-feature/src/experimental/java/boofcv/alg/descriptor/ExperimentalDescriptorDistance.java#L34-L41 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientThree_Share.java | GradientThree_Share.derivX_F32 | public static void derivX_F32(GrayF32 orig,
GrayF32 derivX) {
final float[] data = orig.data;
final float[] imgX = derivX.data;
final int width = orig.getWidth();
final int height = orig.getHeight();
for (int y = 0; y < height; y++) {
int index = width * y + 1;
int endX = index + width - 2;
int endXAlt = endX - (width - 2) % 3;
float x0 = data[index - 1];
float x1 = data[index];
for (; index < endXAlt;) {
float x2 = data[index + 1];
imgX[index++] = (x2 - x0) * 0.5f;
x0 = data[index + 1];
imgX[index++] = (x0 - x1) * 0.5f;
x1 = data[index + 1];
imgX[index++] = (x1 - x2) * 0.5f;
}
for (; index < endX; index++) {
imgX[index] = (data[index + 1] - data[index - 1]) * 0.5f;
}
}
} | java | public static void derivX_F32(GrayF32 orig,
GrayF32 derivX) {
final float[] data = orig.data;
final float[] imgX = derivX.data;
final int width = orig.getWidth();
final int height = orig.getHeight();
for (int y = 0; y < height; y++) {
int index = width * y + 1;
int endX = index + width - 2;
int endXAlt = endX - (width - 2) % 3;
float x0 = data[index - 1];
float x1 = data[index];
for (; index < endXAlt;) {
float x2 = data[index + 1];
imgX[index++] = (x2 - x0) * 0.5f;
x0 = data[index + 1];
imgX[index++] = (x0 - x1) * 0.5f;
x1 = data[index + 1];
imgX[index++] = (x1 - x2) * 0.5f;
}
for (; index < endX; index++) {
imgX[index] = (data[index + 1] - data[index - 1]) * 0.5f;
}
}
} | [
"public",
"static",
"void",
"derivX_F32",
"(",
"GrayF32",
"orig",
",",
"GrayF32",
"derivX",
")",
"{",
"final",
"float",
"[",
"]",
"data",
"=",
"orig",
".",
"data",
";",
"final",
"float",
"[",
"]",
"imgX",
"=",
"derivX",
".",
"data",
";",
"final",
"in... | Can only be used with images that are NOT sub-images. | [
"Can",
"only",
"be",
"used",
"with",
"images",
"that",
"are",
"NOT",
"sub",
"-",
"images",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/derivative/impl/GradientThree_Share.java#L41-L70 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java | DetectDescribeAssociate.pruneTracks | private void pruneTracks(SetTrackInfo<Desc> info, GrowQueue_I32 unassociated) {
if( unassociated.size > maxInactiveTracks ) {
// make the first N elements the ones which will be dropped
int numDrop = unassociated.size-maxInactiveTracks;
for (int i = 0; i < numDrop; i++) {
int selected = rand.nextInt(unassociated.size-i)+i;
int a = unassociated.get(i);
unassociated.data[i] = unassociated.data[selected];
unassociated.data[selected] = a;
}
List<PointTrack> dropList = new ArrayList<>();
for (int i = 0; i < numDrop; i++) {
dropList.add( info.tracks.get(unassociated.get(i)) );
}
for (int i = 0; i < dropList.size(); i++) {
dropTrack(dropList.get(i));
}
}
} | java | private void pruneTracks(SetTrackInfo<Desc> info, GrowQueue_I32 unassociated) {
if( unassociated.size > maxInactiveTracks ) {
// make the first N elements the ones which will be dropped
int numDrop = unassociated.size-maxInactiveTracks;
for (int i = 0; i < numDrop; i++) {
int selected = rand.nextInt(unassociated.size-i)+i;
int a = unassociated.get(i);
unassociated.data[i] = unassociated.data[selected];
unassociated.data[selected] = a;
}
List<PointTrack> dropList = new ArrayList<>();
for (int i = 0; i < numDrop; i++) {
dropList.add( info.tracks.get(unassociated.get(i)) );
}
for (int i = 0; i < dropList.size(); i++) {
dropTrack(dropList.get(i));
}
}
} | [
"private",
"void",
"pruneTracks",
"(",
"SetTrackInfo",
"<",
"Desc",
">",
"info",
",",
"GrowQueue_I32",
"unassociated",
")",
"{",
"if",
"(",
"unassociated",
".",
"size",
">",
"maxInactiveTracks",
")",
"{",
"// make the first N elements the ones which will be dropped",
... | If there are too many unassociated tracks, randomly select some of those tracks and drop them | [
"If",
"there",
"are",
"too",
"many",
"unassociated",
"tracks",
"randomly",
"select",
"some",
"of",
"those",
"tracks",
"and",
"drop",
"them"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java#L174-L192 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java | DetectDescribeAssociate.putIntoSrcList | protected void putIntoSrcList( SetTrackInfo<Desc> info ) {
// make sure isAssociated is large enough
if( info.isAssociated.length < info.tracks.size() ) {
info.isAssociated = new boolean[ info.tracks.size() ];
}
info.featSrc.reset();
info.locSrc.reset();
for( int i = 0; i < info.tracks.size(); i++ ) {
PointTrack t = info.tracks.get(i);
Desc desc = t.getDescription();
info.featSrc.add(desc);
info.locSrc.add(t);
info.isAssociated[i] = false;
}
} | java | protected void putIntoSrcList( SetTrackInfo<Desc> info ) {
// make sure isAssociated is large enough
if( info.isAssociated.length < info.tracks.size() ) {
info.isAssociated = new boolean[ info.tracks.size() ];
}
info.featSrc.reset();
info.locSrc.reset();
for( int i = 0; i < info.tracks.size(); i++ ) {
PointTrack t = info.tracks.get(i);
Desc desc = t.getDescription();
info.featSrc.add(desc);
info.locSrc.add(t);
info.isAssociated[i] = false;
}
} | [
"protected",
"void",
"putIntoSrcList",
"(",
"SetTrackInfo",
"<",
"Desc",
">",
"info",
")",
"{",
"// make sure isAssociated is large enough",
"if",
"(",
"info",
".",
"isAssociated",
".",
"length",
"<",
"info",
".",
"tracks",
".",
"size",
"(",
")",
")",
"{",
"... | Put existing tracks into source list for association | [
"Put",
"existing",
"tracks",
"into",
"source",
"list",
"for",
"association"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java#L218-L234 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java | DetectDescribeAssociate.spawnTracks | @Override
public void spawnTracks() {
for (int setIndex = 0; setIndex < sets.length; setIndex++) {
SetTrackInfo<Desc> info = sets[setIndex];
// setup data structures
if( info.isAssociated.length < info.featDst.size ) {
info.isAssociated = new boolean[ info.featDst.size ];
}
// see which features are associated in the dst list
for( int i = 0; i < info.featDst.size; i++ ) {
info.isAssociated[i] = false;
}
for( int i = 0; i < info.matches.size; i++ ) {
info.isAssociated[info.matches.data[i].dst] = true;
}
// create new tracks from latest unassociated detected features
for( int i = 0; i < info.featDst.size; i++ ) {
if( info.isAssociated[i] )
continue;
Point2D_F64 loc = info.locDst.get(i);
addNewTrack(setIndex, loc.x,loc.y,info.featDst.get(i));
}
}
} | java | @Override
public void spawnTracks() {
for (int setIndex = 0; setIndex < sets.length; setIndex++) {
SetTrackInfo<Desc> info = sets[setIndex];
// setup data structures
if( info.isAssociated.length < info.featDst.size ) {
info.isAssociated = new boolean[ info.featDst.size ];
}
// see which features are associated in the dst list
for( int i = 0; i < info.featDst.size; i++ ) {
info.isAssociated[i] = false;
}
for( int i = 0; i < info.matches.size; i++ ) {
info.isAssociated[info.matches.data[i].dst] = true;
}
// create new tracks from latest unassociated detected features
for( int i = 0; i < info.featDst.size; i++ ) {
if( info.isAssociated[i] )
continue;
Point2D_F64 loc = info.locDst.get(i);
addNewTrack(setIndex, loc.x,loc.y,info.featDst.get(i));
}
}
} | [
"@",
"Override",
"public",
"void",
"spawnTracks",
"(",
")",
"{",
"for",
"(",
"int",
"setIndex",
"=",
"0",
";",
"setIndex",
"<",
"sets",
".",
"length",
";",
"setIndex",
"++",
")",
"{",
"SetTrackInfo",
"<",
"Desc",
">",
"info",
"=",
"sets",
"[",
"setIn... | Takes the current crop of detected features and makes them the keyframe | [
"Takes",
"the",
"current",
"crop",
"of",
"detected",
"features",
"and",
"makes",
"them",
"the",
"keyframe"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java#L260-L289 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java | DetectDescribeAssociate.addNewTrack | protected PointTrack addNewTrack( int setIndex, double x , double y , Desc desc ) {
PointTrack p = getUnused();
p.set(x, y);
((Desc)p.getDescription()).setTo(desc);
if( checkValidSpawn(setIndex,p) ) {
p.setId = setIndex;
p.featureId = featureID++;
sets[setIndex].tracks.add(p);
tracksNew.add(p);
tracksActive.add(p);
tracksAll.add(p);
return p;
} else {
unused.add(p);
return null;
}
} | java | protected PointTrack addNewTrack( int setIndex, double x , double y , Desc desc ) {
PointTrack p = getUnused();
p.set(x, y);
((Desc)p.getDescription()).setTo(desc);
if( checkValidSpawn(setIndex,p) ) {
p.setId = setIndex;
p.featureId = featureID++;
sets[setIndex].tracks.add(p);
tracksNew.add(p);
tracksActive.add(p);
tracksAll.add(p);
return p;
} else {
unused.add(p);
return null;
}
} | [
"protected",
"PointTrack",
"addNewTrack",
"(",
"int",
"setIndex",
",",
"double",
"x",
",",
"double",
"y",
",",
"Desc",
"desc",
")",
"{",
"PointTrack",
"p",
"=",
"getUnused",
"(",
")",
";",
"p",
".",
"set",
"(",
"x",
",",
"y",
")",
";",
"(",
"(",
... | Adds a new track given its location and description | [
"Adds",
"a",
"new",
"track",
"given",
"its",
"location",
"and",
"description"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java#L294-L311 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java | DetectDescribeAssociate.getUnused | protected PointTrack getUnused() {
PointTrack p;
if( unused.size() > 0 ) {
p = unused.remove( unused.size()-1 );
} else {
p = new PointTrack();
p.setDescription(manager.createDescription());
}
return p;
} | java | protected PointTrack getUnused() {
PointTrack p;
if( unused.size() > 0 ) {
p = unused.remove( unused.size()-1 );
} else {
p = new PointTrack();
p.setDescription(manager.createDescription());
}
return p;
} | [
"protected",
"PointTrack",
"getUnused",
"(",
")",
"{",
"PointTrack",
"p",
";",
"if",
"(",
"unused",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"p",
"=",
"unused",
".",
"remove",
"(",
"unused",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}",
"el... | Returns an unused track. If there are no unused tracks then it creates a ne one. | [
"Returns",
"an",
"unused",
"track",
".",
"If",
"there",
"are",
"no",
"unused",
"tracks",
"then",
"it",
"creates",
"a",
"ne",
"one",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java#L323-L332 | train |
lessthanoptimal/BoofCV | main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java | DetectDescribeAssociate.dropTrack | @Override
public boolean dropTrack(PointTrack track) {
if( !tracksAll.remove(track) )
return false;
if( !sets[track.setId].tracks.remove(track) ) {
return false;
}
// the track may or may not be in the active list
tracksActive.remove(track);
tracksInactive.remove(track);
// it must be in the all list
// recycle the data
unused.add(track);
return true;
} | java | @Override
public boolean dropTrack(PointTrack track) {
if( !tracksAll.remove(track) )
return false;
if( !sets[track.setId].tracks.remove(track) ) {
return false;
}
// the track may or may not be in the active list
tracksActive.remove(track);
tracksInactive.remove(track);
// it must be in the all list
// recycle the data
unused.add(track);
return true;
} | [
"@",
"Override",
"public",
"boolean",
"dropTrack",
"(",
"PointTrack",
"track",
")",
"{",
"if",
"(",
"!",
"tracksAll",
".",
"remove",
"(",
"track",
")",
")",
"return",
"false",
";",
"if",
"(",
"!",
"sets",
"[",
"track",
".",
"setId",
"]",
".",
"tracks... | Remove from active list and mark so that it is dropped in the next cycle
@param track The track which is to be dropped | [
"Remove",
"from",
"active",
"list",
"and",
"mark",
"so",
"that",
"it",
"is",
"dropped",
"in",
"the",
"next",
"cycle"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-geo/src/main/java/boofcv/abst/feature/tracker/DetectDescribeAssociate.java#L353-L368 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/geo/pose/PnPStereoJacobianRodrigues.java | PnPStereoJacobianRodrigues.addRodriguesJacobian | private void addRodriguesJacobian( DMatrixRMaj Rj , Point3D_F64 worldPt , Point3D_F64 cameraPt )
{
// (1/z)*dot(R)*X
double Rx = (Rj.data[0]*worldPt.x + Rj.data[1]*worldPt.y + Rj.data[2]*worldPt.z)/cameraPt.z;
double Ry = (Rj.data[3]*worldPt.x + Rj.data[4]*worldPt.y + Rj.data[5]*worldPt.z)/cameraPt.z;
// dot(z)/(z^2)
double zDot_div_z2 = (Rj.data[6]*worldPt.x + Rj.data[7]*worldPt.y + Rj.data[8]*worldPt.z)/
(cameraPt.z*cameraPt.z);
output[indexX++] = -zDot_div_z2*cameraPt.x + Rx;
output[indexY++] = -zDot_div_z2*cameraPt.y + Ry;
} | java | private void addRodriguesJacobian( DMatrixRMaj Rj , Point3D_F64 worldPt , Point3D_F64 cameraPt )
{
// (1/z)*dot(R)*X
double Rx = (Rj.data[0]*worldPt.x + Rj.data[1]*worldPt.y + Rj.data[2]*worldPt.z)/cameraPt.z;
double Ry = (Rj.data[3]*worldPt.x + Rj.data[4]*worldPt.y + Rj.data[5]*worldPt.z)/cameraPt.z;
// dot(z)/(z^2)
double zDot_div_z2 = (Rj.data[6]*worldPt.x + Rj.data[7]*worldPt.y + Rj.data[8]*worldPt.z)/
(cameraPt.z*cameraPt.z);
output[indexX++] = -zDot_div_z2*cameraPt.x + Rx;
output[indexY++] = -zDot_div_z2*cameraPt.y + Ry;
} | [
"private",
"void",
"addRodriguesJacobian",
"(",
"DMatrixRMaj",
"Rj",
",",
"Point3D_F64",
"worldPt",
",",
"Point3D_F64",
"cameraPt",
")",
"{",
"// (1/z)*dot(R)*X",
"double",
"Rx",
"=",
"(",
"Rj",
".",
"data",
"[",
"0",
"]",
"*",
"worldPt",
".",
"x",
"+",
"R... | Adds to the Jacobian matrix using the derivative from a Rodrigues parameter.
deriv [x,y] = -dot(z)/(z^2)*(R*X+T) + (1/z)*dot(R)*X
where R is rotation matrix, T is translation, z = z-coordinate of point in camera frame
@param Rj Jacobian for Rodrigues
@param worldPt Location of point in world coordinates
@param cameraPt Location of point in camera coordinates | [
"Adds",
"to",
"the",
"Jacobian",
"matrix",
"using",
"the",
"derivative",
"from",
"a",
"Rodrigues",
"parameter",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/geo/pose/PnPStereoJacobianRodrigues.java#L154-L166 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/geo/pose/PnPStereoJacobianRodrigues.java | PnPStereoJacobianRodrigues.addTranslationJacobian | private void addTranslationJacobian( Point3D_F64 cameraPt )
{
double divZ = 1.0/cameraPt.z;
double divZ2 = 1.0/(cameraPt.z*cameraPt.z);
// partial T.x
output[indexX++] = divZ;
output[indexY++] = 0;
// partial T.y
output[indexX++] = 0;
output[indexY++] = divZ;
// partial T.z
output[indexX++] = -cameraPt.x*divZ2;
output[indexY++] = -cameraPt.y*divZ2;
} | java | private void addTranslationJacobian( Point3D_F64 cameraPt )
{
double divZ = 1.0/cameraPt.z;
double divZ2 = 1.0/(cameraPt.z*cameraPt.z);
// partial T.x
output[indexX++] = divZ;
output[indexY++] = 0;
// partial T.y
output[indexX++] = 0;
output[indexY++] = divZ;
// partial T.z
output[indexX++] = -cameraPt.x*divZ2;
output[indexY++] = -cameraPt.y*divZ2;
} | [
"private",
"void",
"addTranslationJacobian",
"(",
"Point3D_F64",
"cameraPt",
")",
"{",
"double",
"divZ",
"=",
"1.0",
"/",
"cameraPt",
".",
"z",
";",
"double",
"divZ2",
"=",
"1.0",
"/",
"(",
"cameraPt",
".",
"z",
"*",
"cameraPt",
".",
"z",
")",
";",
"//... | Derivative for translation element
deriv [x,y] = -dot(z)*T/(z^2) + dot(T)/z
where T is translation, z = z-coordinate of point in camera frame | [
"Derivative",
"for",
"translation",
"element"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/geo/pose/PnPStereoJacobianRodrigues.java#L175-L189 | train |
lessthanoptimal/BoofCV | main/boofcv-sfm/src/main/java/boofcv/alg/geo/pose/PnPStereoJacobianRodrigues.java | PnPStereoJacobianRodrigues.addTranslationJacobian | private void addTranslationJacobian( DMatrixRMaj R ,
Point3D_F64 cameraPt )
{
double z = cameraPt.z;
double z2 = z*z;
// partial T.x
output[indexX++] = R.get(0,0)/cameraPt.z - R.get(2,0)/z2*cameraPt.x;
output[indexY++] = R.get(1,0)/cameraPt.z - R.get(2,0)/z2*cameraPt.y;
// partial T.y
output[indexX++] = R.get(0,1)/cameraPt.z - R.get(2,1)/z2*cameraPt.x;
output[indexY++] = R.get(1,1)/cameraPt.z - R.get(2,1)/z2*cameraPt.y;
// partial T.z
output[indexX++] = R.get(0,2)/cameraPt.z - R.get(2,2)/z2*cameraPt.x;
output[indexY++] = R.get(1,2)/cameraPt.z - R.get(2,2)/z2*cameraPt.y;
} | java | private void addTranslationJacobian( DMatrixRMaj R ,
Point3D_F64 cameraPt )
{
double z = cameraPt.z;
double z2 = z*z;
// partial T.x
output[indexX++] = R.get(0,0)/cameraPt.z - R.get(2,0)/z2*cameraPt.x;
output[indexY++] = R.get(1,0)/cameraPt.z - R.get(2,0)/z2*cameraPt.y;
// partial T.y
output[indexX++] = R.get(0,1)/cameraPt.z - R.get(2,1)/z2*cameraPt.x;
output[indexY++] = R.get(1,1)/cameraPt.z - R.get(2,1)/z2*cameraPt.y;
// partial T.z
output[indexX++] = R.get(0,2)/cameraPt.z - R.get(2,2)/z2*cameraPt.x;
output[indexY++] = R.get(1,2)/cameraPt.z - R.get(2,2)/z2*cameraPt.y;
} | [
"private",
"void",
"addTranslationJacobian",
"(",
"DMatrixRMaj",
"R",
",",
"Point3D_F64",
"cameraPt",
")",
"{",
"double",
"z",
"=",
"cameraPt",
".",
"z",
";",
"double",
"z2",
"=",
"z",
"*",
"z",
";",
"// partial T.x",
"output",
"[",
"indexX",
"++",
"]",
... | The translation vector is now multiplied by 3x3 matrix R. The components of T are no longer decoupled.
deriv [x,y] = R*dot(T)/z - (dot(z)/(z^2))(R*T)
@param R
@param cameraPt | [
"The",
"translation",
"vector",
"is",
"now",
"multiplied",
"by",
"3x3",
"matrix",
"R",
".",
"The",
"components",
"of",
"T",
"are",
"no",
"longer",
"decoupled",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-sfm/src/main/java/boofcv/alg/geo/pose/PnPStereoJacobianRodrigues.java#L199-L214 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/UtilDenoiseWavelet.java | UtilDenoiseWavelet.subbandAbsVal | public static float[] subbandAbsVal(GrayF32 subband, float[] coef ) {
if( coef == null ) {
coef = new float[subband.width*subband.height];
}
int i = 0;
for( int y = 0; y < subband.height; y++ ) {
int index = subband.startIndex + subband.stride*y;
int end = index + subband.width;
for( ;index < end; index++ ) {
coef[i++] = Math.abs(subband.data[index]);
}
}
return coef;
} | java | public static float[] subbandAbsVal(GrayF32 subband, float[] coef ) {
if( coef == null ) {
coef = new float[subband.width*subband.height];
}
int i = 0;
for( int y = 0; y < subband.height; y++ ) {
int index = subband.startIndex + subband.stride*y;
int end = index + subband.width;
for( ;index < end; index++ ) {
coef[i++] = Math.abs(subband.data[index]);
}
}
return coef;
} | [
"public",
"static",
"float",
"[",
"]",
"subbandAbsVal",
"(",
"GrayF32",
"subband",
",",
"float",
"[",
"]",
"coef",
")",
"{",
"if",
"(",
"coef",
"==",
"null",
")",
"{",
"coef",
"=",
"new",
"float",
"[",
"subband",
".",
"width",
"*",
"subband",
".",
... | Computes the absolute value of each element in the subband image are places it into
'coef' | [
"Computes",
"the",
"absolute",
"value",
"of",
"each",
"element",
"in",
"the",
"subband",
"image",
"are",
"places",
"it",
"into",
"coef"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/denoise/wavelet/UtilDenoiseWavelet.java#L65-L80 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/blur/FactoryBlurFilter.java | FactoryBlurFilter.median | public static <T extends ImageBase<T>> BlurStorageFilter<T> median(ImageType<T> type , int radius ) {
return new BlurStorageFilter<>("median", type, radius);
} | java | public static <T extends ImageBase<T>> BlurStorageFilter<T> median(ImageType<T> type , int radius ) {
return new BlurStorageFilter<>("median", type, radius);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageBase",
"<",
"T",
">",
">",
"BlurStorageFilter",
"<",
"T",
">",
"median",
"(",
"ImageType",
"<",
"T",
">",
"type",
",",
"int",
"radius",
")",
"{",
"return",
"new",
"BlurStorageFilter",
"<>",
"(",
"\"median\""... | Creates a median filter for the specified image type.
@param type Image type.
@param radius Size of the filter.
@return Median image filter. | [
"Creates",
"a",
"median",
"filter",
"for",
"the",
"specified",
"image",
"type",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/blur/FactoryBlurFilter.java#L40-L42 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/blur/FactoryBlurFilter.java | FactoryBlurFilter.mean | public static <T extends ImageBase<T>> BlurStorageFilter<T> mean(ImageType<T> type , int radius ) {
return new BlurStorageFilter<>("mean", type, radius);
} | java | public static <T extends ImageBase<T>> BlurStorageFilter<T> mean(ImageType<T> type , int radius ) {
return new BlurStorageFilter<>("mean", type, radius);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageBase",
"<",
"T",
">",
">",
"BlurStorageFilter",
"<",
"T",
">",
"mean",
"(",
"ImageType",
"<",
"T",
">",
"type",
",",
"int",
"radius",
")",
"{",
"return",
"new",
"BlurStorageFilter",
"<>",
"(",
"\"mean\"",
... | Creates a mean filter for the specified image type.
@param type Image type.
@param radius Size of the filter.
@return mean image filter. | [
"Creates",
"a",
"mean",
"filter",
"for",
"the",
"specified",
"image",
"type",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/blur/FactoryBlurFilter.java#L55-L57 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/factory/filter/blur/FactoryBlurFilter.java | FactoryBlurFilter.gaussian | public static <T extends ImageBase<T>> BlurStorageFilter<T> gaussian(ImageType<T> type , double sigma , int radius ) {
return new BlurStorageFilter<>("gaussian", type, sigma, radius);
} | java | public static <T extends ImageBase<T>> BlurStorageFilter<T> gaussian(ImageType<T> type , double sigma , int radius ) {
return new BlurStorageFilter<>("gaussian", type, sigma, radius);
} | [
"public",
"static",
"<",
"T",
"extends",
"ImageBase",
"<",
"T",
">",
">",
"BlurStorageFilter",
"<",
"T",
">",
"gaussian",
"(",
"ImageType",
"<",
"T",
">",
"type",
",",
"double",
"sigma",
",",
"int",
"radius",
")",
"{",
"return",
"new",
"BlurStorageFilter... | Creates a Gaussian filter for the specified image type.
@param type Image type.
@param radius Size of the filter.
@return mean image filter. | [
"Creates",
"a",
"Gaussian",
"filter",
"for",
"the",
"specified",
"image",
"type",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/factory/filter/blur/FactoryBlurFilter.java#L70-L72 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.initialize | public void initialize( T image , int x0 , int y0 , int regionWidth , int regionHeight ) {
this.imageWidth = image.width;
this.imageHeight = image.height;
setTrackLocation(x0,y0,regionWidth,regionHeight);
initialLearning(image);
} | java | public void initialize( T image , int x0 , int y0 , int regionWidth , int regionHeight ) {
this.imageWidth = image.width;
this.imageHeight = image.height;
setTrackLocation(x0,y0,regionWidth,regionHeight);
initialLearning(image);
} | [
"public",
"void",
"initialize",
"(",
"T",
"image",
",",
"int",
"x0",
",",
"int",
"y0",
",",
"int",
"regionWidth",
",",
"int",
"regionHeight",
")",
"{",
"this",
".",
"imageWidth",
"=",
"image",
".",
"width",
";",
"this",
".",
"imageHeight",
"=",
"image"... | Initializes tracking around the specified rectangle region
@param image Image to start tracking from
@param x0 top-left corner of region
@param y0 top-left corner of region
@param regionWidth region's width
@param regionHeight region's height | [
"Initializes",
"tracking",
"around",
"the",
"specified",
"rectangle",
"region"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L189-L197 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.setTrackLocation | public void setTrackLocation( int x0 , int y0 , int regionWidth , int regionHeight ) {
if( imageWidth < regionWidth || imageHeight < regionHeight)
throw new IllegalArgumentException("Track region is larger than input image: "+regionWidth+" "+regionHeight);
regionOut.width = regionWidth;
regionOut.height = regionHeight;
// adjust for padding
int w = (int)(regionWidth*(1+padding));
int h = (int)(regionHeight*(1+padding));
int cx = x0 + regionWidth/2;
int cy = y0 + regionHeight/2;
// save the track location
this.regionTrack.width = w;
this.regionTrack.height = h;
this.regionTrack.x0 = cx-w/2;
this.regionTrack.y0 = cy-h/2;
stepX = (w-1)/(float)(workRegionSize-1);
stepY = (h-1)/(float)(workRegionSize-1);
updateRegionOut();
} | java | public void setTrackLocation( int x0 , int y0 , int regionWidth , int regionHeight ) {
if( imageWidth < regionWidth || imageHeight < regionHeight)
throw new IllegalArgumentException("Track region is larger than input image: "+regionWidth+" "+regionHeight);
regionOut.width = regionWidth;
regionOut.height = regionHeight;
// adjust for padding
int w = (int)(regionWidth*(1+padding));
int h = (int)(regionHeight*(1+padding));
int cx = x0 + regionWidth/2;
int cy = y0 + regionHeight/2;
// save the track location
this.regionTrack.width = w;
this.regionTrack.height = h;
this.regionTrack.x0 = cx-w/2;
this.regionTrack.y0 = cy-h/2;
stepX = (w-1)/(float)(workRegionSize-1);
stepY = (h-1)/(float)(workRegionSize-1);
updateRegionOut();
} | [
"public",
"void",
"setTrackLocation",
"(",
"int",
"x0",
",",
"int",
"y0",
",",
"int",
"regionWidth",
",",
"int",
"regionHeight",
")",
"{",
"if",
"(",
"imageWidth",
"<",
"regionWidth",
"||",
"imageHeight",
"<",
"regionHeight",
")",
"throw",
"new",
"IllegalArg... | Used to change the track's location. If this method is used it is assumed that tracking is active and that
the appearance of the target has not changed
@param x0 top-left corner of region
@param y0 top-left corner of region
@param regionWidth region's width
@param regionHeight region's height | [
"Used",
"to",
"change",
"the",
"track",
"s",
"location",
".",
"If",
"this",
"method",
"is",
"used",
"it",
"is",
"assumed",
"that",
"tracking",
"is",
"active",
"and",
"that",
"the",
"appearance",
"of",
"the",
"target",
"has",
"not",
"changed"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L207-L230 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.initialLearning | protected void initialLearning( T image ) {
// get subwindow at current estimated target position, to train classifier
get_subwindow(image, template);
// Kernel Regularized Least-Squares, calculate alphas (in Fourier domain)
// k = dense_gauss_kernel(sigma, x);
dense_gauss_kernel(sigma, template, template,k);
fft.forward(k, kf);
// new_alphaf = yf ./ (fft2(k) + lambda); %(Eq. 7)
computeAlphas(gaussianWeightDFT, kf, lambda, alphaf);
} | java | protected void initialLearning( T image ) {
// get subwindow at current estimated target position, to train classifier
get_subwindow(image, template);
// Kernel Regularized Least-Squares, calculate alphas (in Fourier domain)
// k = dense_gauss_kernel(sigma, x);
dense_gauss_kernel(sigma, template, template,k);
fft.forward(k, kf);
// new_alphaf = yf ./ (fft2(k) + lambda); %(Eq. 7)
computeAlphas(gaussianWeightDFT, kf, lambda, alphaf);
} | [
"protected",
"void",
"initialLearning",
"(",
"T",
"image",
")",
"{",
"// get subwindow at current estimated target position, to train classifier",
"get_subwindow",
"(",
"image",
",",
"template",
")",
";",
"// Kernel Regularized Least-Squares, calculate alphas (in Fourier domain)",
... | Learn the target's appearance. | [
"Learn",
"the",
"target",
"s",
"appearance",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L236-L247 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.computeCosineWindow | protected static void computeCosineWindow( GrayF64 cosine ) {
double cosX[] = new double[ cosine.width ];
for( int x = 0; x < cosine.width; x++ ) {
cosX[x] = 0.5*(1 - Math.cos( 2.0*Math.PI*x/(cosine.width-1) ));
}
for( int y = 0; y < cosine.height; y++ ) {
int index = cosine.startIndex + y*cosine.stride;
double cosY = 0.5*(1 - Math.cos( 2.0*Math.PI*y/(cosine.height-1) ));
for( int x = 0; x < cosine.width; x++ ) {
cosine.data[index++] = cosX[x]*cosY;
}
}
} | java | protected static void computeCosineWindow( GrayF64 cosine ) {
double cosX[] = new double[ cosine.width ];
for( int x = 0; x < cosine.width; x++ ) {
cosX[x] = 0.5*(1 - Math.cos( 2.0*Math.PI*x/(cosine.width-1) ));
}
for( int y = 0; y < cosine.height; y++ ) {
int index = cosine.startIndex + y*cosine.stride;
double cosY = 0.5*(1 - Math.cos( 2.0*Math.PI*y/(cosine.height-1) ));
for( int x = 0; x < cosine.width; x++ ) {
cosine.data[index++] = cosX[x]*cosY;
}
}
} | [
"protected",
"static",
"void",
"computeCosineWindow",
"(",
"GrayF64",
"cosine",
")",
"{",
"double",
"cosX",
"[",
"]",
"=",
"new",
"double",
"[",
"cosine",
".",
"width",
"]",
";",
"for",
"(",
"int",
"x",
"=",
"0",
";",
"x",
"<",
"cosine",
".",
"width"... | Computes the cosine window | [
"Computes",
"the",
"cosine",
"window"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L252-L264 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.computeGaussianWeights | protected void computeGaussianWeights( int width ) {
// desired output (gaussian shaped), bandwidth proportional to target size
double output_sigma = Math.sqrt(width*width) * output_sigma_factor;
double left = -0.5/(output_sigma*output_sigma);
int radius = width/2;
for( int y = 0; y < gaussianWeight.height; y++ ) {
int index = gaussianWeight.startIndex + y*gaussianWeight.stride;
double ry = y-radius;
for( int x = 0; x < width; x++ ) {
double rx = x-radius;
gaussianWeight.data[index++] = Math.exp(left * (ry * ry + rx * rx));
}
}
fft.forward(gaussianWeight,gaussianWeightDFT);
} | java | protected void computeGaussianWeights( int width ) {
// desired output (gaussian shaped), bandwidth proportional to target size
double output_sigma = Math.sqrt(width*width) * output_sigma_factor;
double left = -0.5/(output_sigma*output_sigma);
int radius = width/2;
for( int y = 0; y < gaussianWeight.height; y++ ) {
int index = gaussianWeight.startIndex + y*gaussianWeight.stride;
double ry = y-radius;
for( int x = 0; x < width; x++ ) {
double rx = x-radius;
gaussianWeight.data[index++] = Math.exp(left * (ry * ry + rx * rx));
}
}
fft.forward(gaussianWeight,gaussianWeightDFT);
} | [
"protected",
"void",
"computeGaussianWeights",
"(",
"int",
"width",
")",
"{",
"// desired output (gaussian shaped), bandwidth proportional to target size",
"double",
"output_sigma",
"=",
"Math",
".",
"sqrt",
"(",
"width",
"*",
"width",
")",
"*",
"output_sigma_factor",
";"... | Computes the weights used in the gaussian kernel
This isn't actually symmetric for even widths. These weights are used has label in the learning phase. Closer
to one the more likely it is the true target. It should be a peak in the image center. If it is not then
it will learn an incorrect model. | [
"Computes",
"the",
"weights",
"used",
"in",
"the",
"gaussian",
"kernel"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L273-L294 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.performTracking | public void performTracking( T image ) {
if( image.width != imageWidth || image.height != imageHeight )
throw new IllegalArgumentException("Tracking image size is not the same as " +
"input image. Expected "+imageWidth+" x "+imageHeight);
updateTrackLocation(image);
if( interp_factor != 0 )
performLearning(image);
} | java | public void performTracking( T image ) {
if( image.width != imageWidth || image.height != imageHeight )
throw new IllegalArgumentException("Tracking image size is not the same as " +
"input image. Expected "+imageWidth+" x "+imageHeight);
updateTrackLocation(image);
if( interp_factor != 0 )
performLearning(image);
} | [
"public",
"void",
"performTracking",
"(",
"T",
"image",
")",
"{",
"if",
"(",
"image",
".",
"width",
"!=",
"imageWidth",
"||",
"image",
".",
"height",
"!=",
"imageHeight",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tracking image size is not the same ... | Search for the track in the image and
@param image Next image in the sequence | [
"Search",
"for",
"the",
"track",
"in",
"the",
"image",
"and"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L320-L327 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.updateTrackLocation | protected void updateTrackLocation(T image) {
get_subwindow(image, templateNew);
// calculate response of the classifier at all locations
// matlab: k = dense_gauss_kernel(sigma, x, z);
dense_gauss_kernel(sigma, templateNew, template,k);
fft.forward(k,kf);
// response = real(ifft2(alphaf .* fft2(k))); %(Eq. 9)
DiscreteFourierTransformOps.multiplyComplex(alphaf, kf, tmpFourier0);
fft.inverse(tmpFourier0, response);
// find the pixel with the largest response
int N = response.width*response.height;
int indexBest = -1;
double valueBest = -1;
for( int i = 0; i < N; i++ ) {
double v = response.data[i];
if( v > valueBest ) {
valueBest = v;
indexBest = i;
}
}
int peakX = indexBest % response.width;
int peakY = indexBest / response.width;
// sub-pixel peak estimation
subpixelPeak(peakX, peakY);
// peak in region's coordinate system
float deltaX = (peakX+offX) - templateNew.width/2;
float deltaY = (peakY+offY) - templateNew.height/2;
// convert peak location into image coordinate system
regionTrack.x0 = regionTrack.x0 + deltaX*stepX;
regionTrack.y0 = regionTrack.y0 + deltaY*stepY;
updateRegionOut();
} | java | protected void updateTrackLocation(T image) {
get_subwindow(image, templateNew);
// calculate response of the classifier at all locations
// matlab: k = dense_gauss_kernel(sigma, x, z);
dense_gauss_kernel(sigma, templateNew, template,k);
fft.forward(k,kf);
// response = real(ifft2(alphaf .* fft2(k))); %(Eq. 9)
DiscreteFourierTransformOps.multiplyComplex(alphaf, kf, tmpFourier0);
fft.inverse(tmpFourier0, response);
// find the pixel with the largest response
int N = response.width*response.height;
int indexBest = -1;
double valueBest = -1;
for( int i = 0; i < N; i++ ) {
double v = response.data[i];
if( v > valueBest ) {
valueBest = v;
indexBest = i;
}
}
int peakX = indexBest % response.width;
int peakY = indexBest / response.width;
// sub-pixel peak estimation
subpixelPeak(peakX, peakY);
// peak in region's coordinate system
float deltaX = (peakX+offX) - templateNew.width/2;
float deltaY = (peakY+offY) - templateNew.height/2;
// convert peak location into image coordinate system
regionTrack.x0 = regionTrack.x0 + deltaX*stepX;
regionTrack.y0 = regionTrack.y0 + deltaY*stepY;
updateRegionOut();
} | [
"protected",
"void",
"updateTrackLocation",
"(",
"T",
"image",
")",
"{",
"get_subwindow",
"(",
"image",
",",
"templateNew",
")",
";",
"// calculate response of the classifier at all locations",
"// matlab: k = dense_gauss_kernel(sigma, x, z);",
"dense_gauss_kernel",
"(",
"sigma... | Find the target inside the current image by searching around its last known location | [
"Find",
"the",
"target",
"inside",
"the",
"current",
"image",
"by",
"searching",
"around",
"its",
"last",
"known",
"location"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L332-L372 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.subpixelPeak | protected void subpixelPeak(int peakX, int peakY) {
// this function for r was determined empirically by using work regions of 32,64,128
int r = Math.min(2,response.width/25);
if( r < 0 )
return;
localPeak.setSearchRadius(r);
localPeak.search(peakX,peakY);
offX = localPeak.getPeakX() - peakX;
offY = localPeak.getPeakY() - peakY;
} | java | protected void subpixelPeak(int peakX, int peakY) {
// this function for r was determined empirically by using work regions of 32,64,128
int r = Math.min(2,response.width/25);
if( r < 0 )
return;
localPeak.setSearchRadius(r);
localPeak.search(peakX,peakY);
offX = localPeak.getPeakX() - peakX;
offY = localPeak.getPeakY() - peakY;
} | [
"protected",
"void",
"subpixelPeak",
"(",
"int",
"peakX",
",",
"int",
"peakY",
")",
"{",
"// this function for r was determined empirically by using work regions of 32,64,128",
"int",
"r",
"=",
"Math",
".",
"min",
"(",
"2",
",",
"response",
".",
"width",
"/",
"25",
... | Refine the local-peak using a search algorithm for sub-pixel accuracy. | [
"Refine",
"the",
"local",
"-",
"peak",
"using",
"a",
"search",
"algorithm",
"for",
"sub",
"-",
"pixel",
"accuracy",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L377-L388 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.performLearning | public void performLearning(T image) {
// use the update track location
get_subwindow(image, templateNew);
// Kernel Regularized Least-Squares, calculate alphas (in Fourier domain)
// k = dense_gauss_kernel(sigma, x);
dense_gauss_kernel(sigma, templateNew, templateNew, k);
fft.forward(k,kf);
// new_alphaf = yf ./ (fft2(k) + lambda); %(Eq. 7)
computeAlphas(gaussianWeightDFT, kf, lambda, newAlphaf);
// subsequent frames, interpolate model
// alphaf = (1 - interp_factor) * alphaf + interp_factor * new_alphaf;
int N = alphaf.width*alphaf.height*2;
for( int i = 0; i < N; i++ ) {
alphaf.data[i] = (1-interp_factor)*alphaf.data[i] + interp_factor*newAlphaf.data[i];
}
// Set the previous image to be an interpolated version
// z = (1 - interp_factor) * z + interp_factor * new_z;
N = templateNew.width* templateNew.height;
for( int i = 0; i < N; i++ ) {
template.data[i] = (1-interp_factor)* template.data[i] + interp_factor*templateNew.data[i];
}
} | java | public void performLearning(T image) {
// use the update track location
get_subwindow(image, templateNew);
// Kernel Regularized Least-Squares, calculate alphas (in Fourier domain)
// k = dense_gauss_kernel(sigma, x);
dense_gauss_kernel(sigma, templateNew, templateNew, k);
fft.forward(k,kf);
// new_alphaf = yf ./ (fft2(k) + lambda); %(Eq. 7)
computeAlphas(gaussianWeightDFT, kf, lambda, newAlphaf);
// subsequent frames, interpolate model
// alphaf = (1 - interp_factor) * alphaf + interp_factor * new_alphaf;
int N = alphaf.width*alphaf.height*2;
for( int i = 0; i < N; i++ ) {
alphaf.data[i] = (1-interp_factor)*alphaf.data[i] + interp_factor*newAlphaf.data[i];
}
// Set the previous image to be an interpolated version
// z = (1 - interp_factor) * z + interp_factor * new_z;
N = templateNew.width* templateNew.height;
for( int i = 0; i < N; i++ ) {
template.data[i] = (1-interp_factor)* template.data[i] + interp_factor*templateNew.data[i];
}
} | [
"public",
"void",
"performLearning",
"(",
"T",
"image",
")",
"{",
"// use the update track location",
"get_subwindow",
"(",
"image",
",",
"templateNew",
")",
";",
"// Kernel Regularized Least-Squares, calculate alphas (in Fourier domain)",
"//\tk = dense_gauss_kernel(sigma, x);",
... | Update the alphas and the track's appearance | [
"Update",
"the",
"alphas",
"and",
"the",
"track",
"s",
"appearance"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L398-L423 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.imageDotProduct | public static double imageDotProduct(GrayF64 a) {
double total = 0;
int N = a.width*a.height;
for( int index = 0; index < N; index++ ) {
double value = a.data[index];
total += value*value;
}
return total;
} | java | public static double imageDotProduct(GrayF64 a) {
double total = 0;
int N = a.width*a.height;
for( int index = 0; index < N; index++ ) {
double value = a.data[index];
total += value*value;
}
return total;
} | [
"public",
"static",
"double",
"imageDotProduct",
"(",
"GrayF64",
"a",
")",
"{",
"double",
"total",
"=",
"0",
";",
"int",
"N",
"=",
"a",
".",
"width",
"*",
"a",
".",
"height",
";",
"for",
"(",
"int",
"index",
"=",
"0",
";",
"index",
"<",
"N",
";",... | Computes the dot product of the image with itself | [
"Computes",
"the",
"dot",
"product",
"of",
"the",
"image",
"with",
"itself"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L488-L499 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.elementMultConjB | public static void elementMultConjB( InterleavedF64 a , InterleavedF64 b , InterleavedF64 output ) {
for( int y = 0; y < a.height; y++ ) {
int index = a.startIndex + y*a.stride;
for( int x = 0; x < a.width; x++, index += 2 ) {
double realA = a.data[index];
double imgA = a.data[index+1];
double realB = b.data[index];
double imgB = b.data[index+1];
output.data[index] = realA*realB + imgA*imgB;
output.data[index+1] = -realA*imgB + imgA*realB;
}
}
} | java | public static void elementMultConjB( InterleavedF64 a , InterleavedF64 b , InterleavedF64 output ) {
for( int y = 0; y < a.height; y++ ) {
int index = a.startIndex + y*a.stride;
for( int x = 0; x < a.width; x++, index += 2 ) {
double realA = a.data[index];
double imgA = a.data[index+1];
double realB = b.data[index];
double imgB = b.data[index+1];
output.data[index] = realA*realB + imgA*imgB;
output.data[index+1] = -realA*imgB + imgA*realB;
}
}
} | [
"public",
"static",
"void",
"elementMultConjB",
"(",
"InterleavedF64",
"a",
",",
"InterleavedF64",
"b",
",",
"InterleavedF64",
"output",
")",
"{",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",
"a",
".",
"height",
";",
"y",
"++",
")",
"{",
"int",
"... | Element-wise multiplication of 'a' and the complex conjugate of 'b' | [
"Element",
"-",
"wise",
"multiplication",
"of",
"a",
"and",
"the",
"complex",
"conjugate",
"of",
"b"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L504-L520 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.gaussianKernel | protected static void gaussianKernel(double xx , double yy , GrayF64 xy , double sigma , GrayF64 output ) {
double sigma2 = sigma*sigma;
double N = xy.width*xy.height;
for( int y = 0; y < xy.height; y++ ) {
int index = xy.startIndex + y*xy.stride;
for( int x = 0; x < xy.width; x++ , index++ ) {
// (xx + yy - 2 * xy) / numel(x)
double value = (xx + yy - 2*xy.data[index])/N;
double v = Math.exp(-Math.max(0, value) / sigma2);
output.data[index] = v;
}
}
} | java | protected static void gaussianKernel(double xx , double yy , GrayF64 xy , double sigma , GrayF64 output ) {
double sigma2 = sigma*sigma;
double N = xy.width*xy.height;
for( int y = 0; y < xy.height; y++ ) {
int index = xy.startIndex + y*xy.stride;
for( int x = 0; x < xy.width; x++ , index++ ) {
// (xx + yy - 2 * xy) / numel(x)
double value = (xx + yy - 2*xy.data[index])/N;
double v = Math.exp(-Math.max(0, value) / sigma2);
output.data[index] = v;
}
}
} | [
"protected",
"static",
"void",
"gaussianKernel",
"(",
"double",
"xx",
",",
"double",
"yy",
",",
"GrayF64",
"xy",
",",
"double",
"sigma",
",",
"GrayF64",
"output",
")",
"{",
"double",
"sigma2",
"=",
"sigma",
"*",
"sigma",
";",
"double",
"N",
"=",
"xy",
... | Computes the output of the Gaussian kernel for each element in the target region
k = exp(-1 / sigma^2 * max(0, (xx + yy - 2 * xy) / numel(x)));
@param xx ||x||^2
@param yy ||y||^2 | [
"Computes",
"the",
"output",
"of",
"the",
"Gaussian",
"kernel",
"for",
"each",
"element",
"in",
"the",
"target",
"region"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L555-L572 | train |
lessthanoptimal/BoofCV | main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java | CirculantTracker.get_subwindow | protected void get_subwindow( T image , GrayF64 output ) {
// copy the target region
interp.setImage(image);
int index = 0;
for( int y = 0; y < workRegionSize; y++ ) {
float yy = regionTrack.y0 + y*stepY;
for( int x = 0; x < workRegionSize; x++ ) {
float xx = regionTrack.x0 + x*stepX;
if( interp.isInFastBounds(xx,yy))
output.data[index++] = interp.get_fast(xx,yy);
else if( BoofMiscOps.checkInside(image, xx, yy))
output.data[index++] = interp.get(xx, yy);
else {
// randomize to make pixels outside the image poorly correlate. It will then focus on matching
// what's inside the image since it has structure
output.data[index++] = rand.nextFloat()*maxPixelValue;
}
}
}
// normalize values to be from -0.5 to 0.5
PixelMath.divide(output, maxPixelValue, output);
PixelMath.plus(output, -0.5f, output);
// apply the cosine window to it
PixelMath.multiply(output,cosine,output);
} | java | protected void get_subwindow( T image , GrayF64 output ) {
// copy the target region
interp.setImage(image);
int index = 0;
for( int y = 0; y < workRegionSize; y++ ) {
float yy = regionTrack.y0 + y*stepY;
for( int x = 0; x < workRegionSize; x++ ) {
float xx = regionTrack.x0 + x*stepX;
if( interp.isInFastBounds(xx,yy))
output.data[index++] = interp.get_fast(xx,yy);
else if( BoofMiscOps.checkInside(image, xx, yy))
output.data[index++] = interp.get(xx, yy);
else {
// randomize to make pixels outside the image poorly correlate. It will then focus on matching
// what's inside the image since it has structure
output.data[index++] = rand.nextFloat()*maxPixelValue;
}
}
}
// normalize values to be from -0.5 to 0.5
PixelMath.divide(output, maxPixelValue, output);
PixelMath.plus(output, -0.5f, output);
// apply the cosine window to it
PixelMath.multiply(output,cosine,output);
} | [
"protected",
"void",
"get_subwindow",
"(",
"T",
"image",
",",
"GrayF64",
"output",
")",
"{",
"// copy the target region",
"interp",
".",
"setImage",
"(",
"image",
")",
";",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"int",
"y",
"=",
"0",
";",
"y",
"<",... | Copies the target into the output image and applies the cosine window to it. | [
"Copies",
"the",
"target",
"into",
"the",
"output",
"image",
"and",
"applies",
"the",
"cosine",
"window",
"to",
"it",
"."
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-recognition/src/main/java/boofcv/alg/tracker/circulant/CirculantTracker.java#L577-L606 | train |
lessthanoptimal/BoofCV | main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdBlock.java | ThresholdBlock.selectBlockSize | void selectBlockSize( int width , int height , int requestedBlockWidth) {
if( height < requestedBlockWidth ) {
blockHeight = height;
} else {
int rows = height/requestedBlockWidth;
blockHeight = height/rows;
}
if( width < requestedBlockWidth ) {
blockWidth = width;
} else {
int cols = width/requestedBlockWidth;
blockWidth = width/cols;
}
} | java | void selectBlockSize( int width , int height , int requestedBlockWidth) {
if( height < requestedBlockWidth ) {
blockHeight = height;
} else {
int rows = height/requestedBlockWidth;
blockHeight = height/rows;
}
if( width < requestedBlockWidth ) {
blockWidth = width;
} else {
int cols = width/requestedBlockWidth;
blockWidth = width/cols;
}
} | [
"void",
"selectBlockSize",
"(",
"int",
"width",
",",
"int",
"height",
",",
"int",
"requestedBlockWidth",
")",
"{",
"if",
"(",
"height",
"<",
"requestedBlockWidth",
")",
"{",
"blockHeight",
"=",
"height",
";",
"}",
"else",
"{",
"int",
"rows",
"=",
"height",... | Selects a block size which is close to the requested block size by the user | [
"Selects",
"a",
"block",
"size",
"which",
"is",
"close",
"to",
"the",
"requested",
"block",
"size",
"by",
"the",
"user"
] | f01c0243da0ec086285ee722183804d5923bc3ac | https://github.com/lessthanoptimal/BoofCV/blob/f01c0243da0ec086285ee722183804d5923bc3ac/main/boofcv-ip/src/main/java/boofcv/alg/filter/binary/ThresholdBlock.java#L112-L127 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.