code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public void setLensDistortion(Point2Transform2_F64 pixelToNorm, Point2Transform2_F64 undistToDist) {
if( pixelToNorm == null ) {
this.pixelToNorm = new DoNothing2Transform2_F64();
this.undistToDist = new DoNothing2Transform2_F64();
} else {
this.pixelToNorm = pixelToNorm;
this.undistToDist = undistToDis... | java |
public boolean refine(Point2D_F64 a, Point2D_F64 b, LineGeneral2D_F64 found) {
// determine the local coordinate system
center.x = (a.x + b.x)/2.0;
center.y = (a.y + b.y)/2.0;
localScale = a.distance(center);
// define the line which points are going to be sampled along
double slopeX = (b.x - a.x);
doub... | java |
protected void localToGlobal( LineGeneral2D_F64 line ) {
line.C = localScale*line.C - center.x*line.A - center.y*line.B;
} | java |
public void process( T image , GrayS32 pixelToRegion ,
GrowQueue_I32 regionMemberCount ,
FastQueue<float[]> regionColor ) {
this.image = image;
// Initialize data structures
regionSums.resize(regionColor.size);
for( int i = 0; i < regionSums.size; i++ ) {
float v[] = regionSums.get(i);
f... | java |
@Override
public boolean process(PairwiseImageGraph pairwiseGraph ) {
this.graph = new MetricSceneGraph(pairwiseGraph);
for (int i = 0; i < graph.edges.size(); i++) {
decomposeEssential(graph.edges.get(i));
}
declareModelFitting();
for (int i = 0; i < graph.edges.size(); i++) {
Motion e = graph.edges... | java |
void decomposeEssential( Motion motion ) {
List<Se3_F64> candidates = MultiViewOps.decomposeEssential(motion.F);
int bestScore = 0;
Se3_F64 best = null;
PositiveDepthConstraintCheck check = new PositiveDepthConstraintCheck();
for (int i = 0; i < candidates.size(); i++) {
Se3_F64 a_to_b = candidates.get(... | java |
double medianTriangulationAngle( Motion edge ) {
GrowQueue_F64 angles = new GrowQueue_F64(edge.associated.size());
angles.size = edge.associated.size();
for (int i = 0; i < edge.associated.size(); i++) {
AssociatedIndex a = edge.associated.get(i);
Point2D_F64 normA = edge.viewSrc.observationNorm.get( a.sr... | java |
private void convertToOutput( View origin ) {
structure = new SceneStructureMetric(false);
observations = new SceneObservations(viewsAdded.size());
// TODO can this be simplified?
int idx = 0;
for( String key : graph.cameras.keySet() ) {
cameraToIndex.put(key,idx++);
}
structure.initialize(cameraToIn... | java |
void addTriangulatedStereoFeatures(View base , Motion edge , double scale ) {
View viewA = edge.viewSrc;
View viewB = edge.viewDst;
boolean baseIsA = base == viewA;
View other = baseIsA ? viewB : viewA;
// Determine transform from other to world
edge.a_to_b.T.scale(scale);
Se3_F64 otherToBase = baseIsA ... | java |
static double determineScale(View base , Motion edge )
throws Exception
{
View viewA = edge.viewSrc;
View viewB = edge.viewDst;
boolean baseIsA = base == viewA;
// determine the scale factor difference
Point3D_F64 worldInBase3D = new Point3D_F64();
Point3D_F64 localInBase3D = new Point3D_F64();
GrowQ... | java |
private void estimateAllFeatures(View seedA, View seedB ) {
List<View> open = new ArrayList<>();
// Add features for all the other views connected to the root view and determine the translation scale factor
addUnvistedToStack(seedA, open);
addUnvistedToStack(seedB, open);
// Do a breath first search. The qu... | java |
int countFeaturesWith3D(View v ) {
int count = 0;
for (int i = 0; i < v.connections.size(); i++) {
Motion m = v.connections.get(i);
boolean isSrc = m.viewSrc == v;
for (int j = 0; j < m.associated.size(); j++) {
AssociatedIndex a = m.associated.get(j);
if( isSrc ) {
count += m.viewDst.fea... | java |
boolean determinePose(View target ) {
// Find all Features which are visible in this view and have a known 3D location
List<Point2D3D> list = new ArrayList<>();
List<Feature3D> features = new ArrayList<>();
GrowQueue_I32 featureIndexes = new GrowQueue_I32();
// TODO mark need to handle casees where the targ... | java |
private void triangulateNoLocation( View target ) {
Se3_F64 otherToTarget = new Se3_F64();
Se3_F64 worldToTarget = target.viewToWorld.invert(null);
for( Motion c : target.connections ) {
boolean isSrc = c.viewSrc == target;
View other = c.destination(target);
if( other.state != ViewState.PROCESSED )
... | java |
double triangulationAngle( Point2D_F64 normA , Point2D_F64 normB , Se3_F64 a_to_b ) {
// the more parallel a line is worse the triangulation. Get rid of bad ideas early here
arrowA.set(normA.x,normA.y,1);
arrowB.set(normB.x,normB.y,1);
GeometryMath_F64.mult(a_to_b.R,arrowA,arrowA); // put them into the same ref... | java |
void addUnvistedToStack(View viewed, List<View> open) {
for (int i = 0; i < viewed.connections.size(); i++) {
View other = viewed.connections.get(i).destination(viewed);
if( other.state == ViewState.UNPROCESSED) {
other.state = ViewState.PENDING;
open.add(other);
if( verbose != null )
verbose.p... | java |
void defineCoordinateSystem(View viewA, Motion motion) {
View viewB = motion.destination(viewA);
viewA.viewToWorld.reset(); // identity since it's the origin
viewB.viewToWorld.set(motion.motionSrcToDst(viewB));
// translation is only known up to a scale factor so pick a reasonable scale factor
double scale =... | java |
View selectOriginNode() {
double bestScore = 0;
View best = null;
if( verbose != null )
verbose.println("selectOriginNode");
for (int i = 0; i < graph.nodes.size(); i++) {
double score = scoreNodeAsOrigin(graph.nodes.get(i));
if( score > bestScore ) {
bestScore = score;
best = graph.nodes.get... | java |
Motion selectCoordinateBase(View view ) {
double bestScore = 0;
Motion best = null;
if( verbose != null )
verbose.println("selectCoordinateBase");
for (int i = 0; i < view.connections.size(); i++) {
Motion e = view.connections.get(i);
double s = e.scoreTriangulation();
if( verbose != null )
ve... | java |
void triangulateStereoEdges(Motion edge ) {
View viewA = edge.viewSrc;
View viewB = edge.viewDst;
triangulationError.configure(viewA.camera.pinhole,viewB.camera.pinhole);
for (int i = 0; i < edge.associated.size(); i++) {
AssociatedIndex f = edge.associated.get(i);
Point2D_F64 normA = viewA.observation... | java |
public static CameraPinhole approximatePinhole( Point2Transform2_F64 p2n ,
int width , int height )
{
Point2D_F64 na = new Point2D_F64();
Point2D_F64 nb = new Point2D_F64();
// determine horizontal FOV using dot product of (na.x, na.y, 1 ) and (nb.x, nb.y, 1)
p2n.compute(0,height/2,na);
p2n.com... | java |
public static CameraPinhole createIntrinsic(int width, int height, double hfov, double vfov) {
CameraPinhole intrinsic = new CameraPinhole();
intrinsic.width = width;
intrinsic.height = height;
intrinsic.cx = width / 2;
intrinsic.cy = height / 2;
intrinsic.fx = intrinsic.cx / Math.tan(UtilAngle.degreeToRadi... | java |
public static CameraPinholeBrown createIntrinsic(int width, int height, double hfov) {
CameraPinholeBrown intrinsic = new CameraPinholeBrown();
intrinsic.width = width;
intrinsic.height = height;
intrinsic.cx = width / 2;
intrinsic.cy = height / 2;
intrinsic.fx = intrinsic.cx / Math.tan(UtilAngle.degreeToRa... | java |
public static void scaleIntrinsic(CameraPinhole param , double scale ) {
param.width = (int)(param.width*scale);
param.height = (int)(param.height*scale);
param.cx *= scale;
param.cy *= scale;
param.fx *= scale;
param.fy *= scale;
param.skew *= scale;
} | java |
public static void invertPinhole( DMatrix3x3 K , DMatrix3x3 Kinv) {
double fx = K.a11;
double skew = K.a12;
double cx = K.a13;
double fy = K.a22;
double cy = K.a23;
Kinv.a11 = 1.0/fx;
Kinv.a12 = -skew/(fx*fy);
Kinv.a13 = (skew*cy - cx*fy)/(fx*fy);
Kinv.a22 = 1.0/fy;
Kinv.a23 = -cy/fy;
Kinv.a33 = 1... | java |
public static Point2D_F64 renderPixel( Se3_F64 worldToCamera , DMatrixRMaj K , Point3D_F64 X ) {
return ImplPerspectiveOps_F64.renderPixel(worldToCamera,K,X);
// if( K == null )
// return renderPixel(worldToCamera,X);
// return ImplPerspectiveOps_F64.renderPixel(worldToCamera,
// K.data[0], K.data[1], K.data[2... | java |
public static Point2D_F64 renderPixel(CameraPinhole intrinsic , Point3D_F64 X ) {
Point2D_F64 norm = new Point2D_F64(X.x/X.z,X.y/X.z);
return convertNormToPixel(intrinsic, norm, norm);
} | java |
public static Point2D_F64 renderPixel( DMatrixRMaj worldToCamera , Point3D_F64 X ) {
return renderPixel(worldToCamera,X,(Point2D_F64)null);
} | java |
public static double crossRatios( Point3D_F64 a0 , Point3D_F64 a1 , Point3D_F64 a2 , Point3D_F64 a3) {
double d01 = a0.distance(a1);
double d23 = a2.distance(a3);
double d02 = a0.distance(a2);
double d13 = a1.distance(a3);
return (d01*d23)/(d02*d13);
} | java |
public static void extractColumn(DMatrixRMaj P, int col, GeoTuple3D_F64 a) {
a.x = P.unsafe_get(0,col);
a.y = P.unsafe_get(1,col);
a.z = P.unsafe_get(2,col);
} | java |
public static void insertColumn(DMatrixRMaj P, int col, GeoTuple3D_F64 a) {
P.unsafe_set(0,col,a.x);
P.unsafe_set(1,col,a.y);
P.unsafe_set(2,col,a.z);
} | java |
public void decompose( DMatrixRMaj E ) {
if( svd.inputModified() ) {
E_copy.set(E);
E = E_copy;
}
if( !svd.decompose(E))
throw new RuntimeException("Svd some how failed");
U = svd.getU(U,false);
V = svd.getV(V,false);
S = svd.getW(S);
SingularOps_DDRM.descendingOrder(U,false,S,V,false);
dec... | java |
private void extractTransform( DMatrixRMaj U , DMatrixRMaj V , DMatrixRMaj S ,
Se3_F64 se , boolean optionA , boolean optionB )
{
DMatrixRMaj R = se.getR();
Vector3D_F64 T = se.getT();
// extract rotation
if( optionA )
CommonOps_DDRM.mult(U,Rz,temp);
else
CommonOps_DDRM.multTransB(U,Rz,temp... | java |
public boolean process( List<AssociatedPair> points )
{
if( points.size() < estimateHomography.getMinimumPoints())
throw new IllegalArgumentException("At least "+estimateHomography.getMinimumPoints()+" must be provided");
// center location of points in model
zeroMeanWorldPoints(points);
// make sure there... | java |
double computeError( List<AssociatedPair> points , Se3_F64 worldToCamera ) {
double error = 0;
for (int i = 0; i < points.size(); i++) {
AssociatedPair pair = points.get(i);
tmpP.set(pair.p1.x,pair.p1.y,0);
SePointOps_F64.transform(worldToCamera,tmpP,tmpP);
error += pair.p2.distance2(tmpP.x/tmpP.z,tm... | java |
private void zeroMeanWorldPoints(List<AssociatedPair> points) {
center.set(0,0);
pointsAdj.reset();
for (int i = 0; i < points.size(); i++) {
AssociatedPair pair = points.get(i);
Point2D_F64 p = pair.p1;
pointsAdj.grow().p2.set(pair.p2);
center.x += p.x;
center.y += p.y;
}
center.x /= points.si... | java |
void estimateTranslation( DMatrixRMaj R , List<AssociatedPair> points , Vector3D_F64 T )
{
final int N = points.size();
W.reshape(N*2,3);
y.reshape(N*2,1);
Wty.reshape(3,1);
DMatrix3x3 Rtmp = new DMatrix3x3();
ConvertDMatrixStruct.convert(R,Rtmp);
int indexY = 0,indexW = 0;
for (int i = 0; i < N; i++... | java |
protected void IPPE( DMatrixRMaj R1 , DMatrixRMaj R2 ) {
// Equation 23 - Compute R_v from v
double norm_v = Math.sqrt(v1*v1 + v2*v2);
if( norm_v <= UtilEjml.EPS ) {
// the plane is fronto-parallel to the camera, so set the corrective rotation Rv to identity.
// There will be only one solution to pose.
... | java |
public void learnAndSave() {
System.out.println("======== Learning Classifier");
// Either load pre-computed words or compute the words from the training images
AssignCluster<double[]> assignment;
if( new File(CLUSTER_FILE_NAME).exists() ) {
assignment = UtilIO.load(CLUSTER_FILE_NAME);
} else {
System.... | java |
private AssignCluster<double[]> computeClusters() {
System.out.println("Image Features");
// computes features in the training image set
List<TupleDesc_F64> features = new ArrayList<>();
for( String scene : train.keySet() ) {
List<String> imagePaths = train.get(scene);
System.out.println(" " + scene);
... | java |
public void grow() {
if( tailBlockSize >= blockLength ) {
tailBlockSize = 0;
blocks.grow();
}
BlockIndexLength s = sets.grow();
s.block = blocks.size-1;
s.start = tailBlockSize;
s.length = 0;
tail = s;
} | java |
public void removeTail() {
while( blocks.size-1 != tail.block )
blocks.removeTail();
tailBlockSize = tail.start;
sets.removeTail();
tail = sets.size > 0 ? sets.get( sets.size-1 ) : null;
} | java |
public void addPointToTail( int x , int y ) {
int index = tail.start + tail.length*2;
int block[];
int blockIndex = tail.block + index/blockLength;
if( blockIndex == blocks.size ) {
tailBlockSize = 0;
block = blocks.grow();
} else {
block = blocks.get( blockIndex );
}
tailBlockSize += 2;
index... | java |
public void getSet(int which , FastQueue<Point2D_I32> list ) {
list.reset();
BlockIndexLength set = sets.get(which);
for (int i = 0; i < set.length; i++) {
int index = set.start + i*2;
int blockIndex = set.block + index/blockLength;
index %= blockLength;
int block[] = blocks.get( blockIndex );
l... | java |
public void writeOverSet(int which, List<Point2D_I32> points) {
BlockIndexLength set = sets.get(which);
if( set.length != points.size() )
throw new IllegalArgumentException("points and set don't have the same length");
for (int i = 0; i < set.length; i++) {
int index = set.start + i*2;
int blockIndex = ... | java |
public void viewUpdated() {
BufferedImage active = null;
if( controls.selectedView == 0 ) {
active = original;
} else if( controls.selectedView == 1 ) {
synchronized (lockProcessing) {
VisualizeBinaryData.renderBinary(detector.getBinary(), false, work);
}
active = work;
work.setRGB(0, 0, work.g... | java |
void disconnectSingleConnections() {
List<SquareNode> open = new ArrayList<>();
List<SquareNode> open2 = new ArrayList<>();
for (int i = 0; i < nodes.size(); i++) {
SquareNode n = nodes.get(i);
checkDisconnectSingleEdge(open, n);
}
while( !open.isEmpty() ) {
for (int i = 0; i < open.size(); i++) ... | java |
boolean areMiddlePointsClose( Point2D_F64 p0 , Point2D_F64 p1 , Point2D_F64 p2 , Point2D_F64 p3 ) {
UtilLine2D_F64.convert(p0,p3,line);
// (computed expected length of a square) * (fractional tolerance)
double tol1 = p0.distance(p1)*distanceTol;
// see if inner points are close to the line
if(Distance2D_F64... | java |
public boolean process( T left , T right ) {
// System.out.println("----------- Process --------------");
this.inputLeft = left;
this.inputRight = right;
tick++;
trackerLeft.process(left);
trackerRight.process(right);
if( first ) {
addNewTracks();
first = false;
} else {
mutualTrackDrop();
... | java |
private void refineMotionEstimate() {
// use observations from the inlier set
List<Stereo2D3D> data = new ArrayList<>();
int N = matcher.getMatchSet().size();
for( int i = 0; i < N; i++ ) {
int index = matcher.getInputIndex(i);
PointTrack l = candidates.get(index);
LeftTrackInfo info = l.getCookie()... | java |
private boolean estimateMotion() {
// organize the data
List<Stereo2D3D> data = new ArrayList<>();
for( PointTrack l : candidates ) {
LeftTrackInfo info = l.getCookie();
PointTrack r = info.right;
Stereo2D3D stereo = info.location;
// compute normalized image coordinate for track in left and right i... | java |
private void mutualTrackDrop() {
for( PointTrack t : trackerLeft.getDroppedTracks(null) ) {
LeftTrackInfo info = t.getCookie();
trackerRight.dropTrack(info.right);
}
for( PointTrack t : trackerRight.getDroppedTracks(null) ) {
RightTrackInfo info = t.getCookie();
// a track could be dropped twice here,... | java |
private void selectCandidateTracks() {
// mark tracks in right frame that are active
List<PointTrack> activeRight = trackerRight.getActiveTracks(null);
for( PointTrack t : activeRight ) {
RightTrackInfo info = t.getCookie();
info.lastActiveList = tick;
}
int mutualActive = 0;
List<PointTrack> activeL... | java |
private void addNewTracks() {
trackerLeft.spawnTracks();
trackerRight.spawnTracks();
List<PointTrack> newLeft = trackerLeft.getNewTracks(null);
List<PointTrack> newRight = trackerRight.getNewTracks(null);
// get a list of new tracks and their descriptions
addNewToList(inputLeft, newLeft, pointsLeft, descL... | java |
public void createImages() {
image = UtilImageIO.loadImage(UtilIO.pathExample("standard/barbara.jpg"));
gray = ConvertBufferedImage.convertFromSingle(image, null, GrayU8.class);
derivX = GeneralizedImageOps.createSingleBand(GrayS16.class, gray.getWidth(), gray.getHeight());
derivY = GeneralizedImageOps.createS... | java |
public static void fillRectangle(InterleavedS32 img, int value, int x0, int y0, int width, int height) {
int x1 = x0 + width;
int y1 = y0 + height;
if( x0 < 0 ) x0 = 0; if( x1 > img.width ) x1 = img.width;
if( y0 < 0 ) y0 = 0; if( y1 > img.height ) y1 = img.height;
int length = (x1-x0)*img.numBands;
for (... | java |
public static void flipVertical( GrayS32 input ) {
int h2 = input.height/2;
for( int y = 0; y < h2; y++ ) {
int index1 = input.getStartIndex() + y * input.getStride();
int index2 = input.getStartIndex() + (input.height - y - 1) * input.getStride();
int end = index1 + input.width;
while( index1 < end ... | java |
public static void flipHorizontal( GrayS32 input ) {
int w2 = input.width/2;
for( int y = 0; y < input.height; y++ ) {
int index1 = input.getStartIndex() + y * input.getStride();
int index2 = index1 + input.width-1;
int end = index1 + w2;
while( index1 < end ) {
int tmp = input.data[index1];
... | java |
public static void rotateCCW( GrayS64 image ) {
if( image.width != image.height )
throw new IllegalArgumentException("Image must be square");
int w = image.height/2 + image.height%2;
int h = image.height/2;
for( int y0 = 0; y0 < h; y0++ ) {
int y1 = image.height-y0-1;
for( int x0 = 0; x0 < w; x0++ )... | java |
public static void rotateCCW( GrayS64 input , GrayS64 output ) {
if( input.width != output.height || input.height != output.width )
throw new IllegalArgumentException("Incompatible shapes");
int w = input.width-1;
for( int y = 0; y < input.height; y++ ) {
int indexIn = input.startIndex + y*input.stride;
... | java |
public static void fillBand(InterleavedF64 input, int band , double value) {
final int numBands = input.numBands;
for (int y = 0; y < input.height; y++) {
int index = input.getStartIndex() + y * input.getStride() + band;
int end = index + input.width*numBands - band;
for (; index < end; index += numBands ... | java |
public static void fillBorder(GrayF64 input, double value, int radius ) {
// top and bottom
for (int y = 0; y < radius; y++) {
int indexTop = input.startIndex + y * input.stride;
int indexBottom = input.startIndex + (input.height-y-1) * input.stride;
for (int x = 0; x < input.width; x++) {
input.data[... | java |
public static void fillRectangle(GrayF64 img, double value, int x0, int y0, int width, int height) {
int x1 = x0 + width;
int y1 = y0 + height;
if( x0 < 0 ) x0 = 0; if( x1 > img.width ) x1 = img.width;
if( y0 < 0 ) y0 = 0; if( y1 > img.height ) y1 = img.height;
for (int y = y0; y < y1; y++) {
for (int x ... | java |
public static RectangleLength2D_F32 boundBoxInside(int srcWidth, int srcHeight,
PixelTransform<Point2D_F32> transform,
Point2D_F32 work )
{
List<Point2D_F32> points = computeBoundingPoints(srcWidth, srcHeight, transform, work);
Point2D_F32 center = new Point2D_F32();
UtilPoint2D_F... | java |
public void initialize( T image , RectangleRotate_F32 initial ) {
this.region.set(initial);
calcHistogram.computeHistogram(image,initial);
System.arraycopy(calcHistogram.getHistogram(),0,keyHistogram,0,keyHistogram.length);
this.minimumWidth = initial.width*minimumSizeRatio;
} | java |
public void track( T image ) {
// configure the different regions based on size
region0.set( region );
region1.set( region );
region2.set( region );
region0.width *= 1-scaleChange;
region0.height *= 1-scaleChange;
region2.width *= 1+scaleChange;
region2.height *= 1+scaleChange;
// distance from h... | java |
private int selectBest( double a , double b , double c ) {
if( a < b ) {
if( a < c )
return 0;
else
return 2;
} else if( b <= c ) {
return 1;
} else {
return 2;
}
} | java |
protected void updateLocation( T image , RectangleRotate_F32 region ) {
double bestHistScore = Double.MAX_VALUE;
float bestX = -1, bestY = -1;
for( int i = 0; i < maxIterations; i++ ) {
calcHistogram.computeHistogram(image,region);
float histogram[] = calcHistogram.getHistogram();
updateWeights(histog... | java |
private void updateWeights(float[] histogram) {
for( int j = 0; j < weightHistogram.length; j++ ) {
float h = histogram[j];
if( h != 0 ) {
weightHistogram[j] = (float)Math.sqrt(keyHistogram[j]/h);
}
}
} | java |
protected double distanceHistogram(float histogramA[], float histogramB[]) {
double sumP = 0;
for( int i = 0; i < histogramA.length; i++ ) {
float q = histogramA[i];
float p = histogramB[i];
sumP += Math.abs(q-p);
}
return sumP;
} | java |
public void setImageGradient(Deriv derivX , Deriv derivY ) {
this.imageDerivX.wrap(derivX);
this.imageDerivY.wrap(derivY);
} | java |
public void process( double c_x , double c_y , double sigma , double orientation , TupleDesc_F64 descriptor )
{
descriptor.fill(0);
computeRawDescriptor(c_x, c_y, sigma, orientation, descriptor);
normalizeDescriptor(descriptor,maxDescriptorElementValue);
} | java |
void computeRawDescriptor(double c_x, double c_y, double sigma, double orientation, TupleDesc_F64 descriptor) {
double c = Math.cos(orientation);
double s = Math.sin(orientation);
float fwidthSubregion = widthSubregion;
int sampleWidth = widthGrid*widthSubregion;
double sampleRadius = sampleWidth/2;
doubl... | java |
public static void normalizeDescriptor(TupleDesc_F64 descriptor , double maxDescriptorElementValue ) {
// normalize descriptor to unit length
UtilFeature.normalizeL2(descriptor);
// clip the values
for (int i = 0; i < descriptor.size(); i++) {
double value = descriptor.value[i];
if( value > maxDescriptor... | java |
protected static float[] createGaussianWeightKernel( double sigma , int radius ) {
Kernel2D_F32 ker = FactoryKernelGaussian.gaussian2D_F32(sigma,radius,false,false);
float maxValue = KernelMath.maxAbs(ker.data,4*radius*radius);
KernelMath.divide(ker,maxValue);
return ker.data;
} | java |
protected void trilinearInterpolation( float weight , float sampleX , float sampleY , double angle , TupleDesc_F64 descriptor )
{
for (int i = 0; i < widthGrid; i++) {
double weightGridY = 1.0 - Math.abs(sampleY-i);
if( weightGridY <= 0) continue;
for (int j = 0; j < widthGrid; j++) {
double weightGridX... | java |
private void computeFeatureMask(int numModules, int[] alignment, boolean hasVersion) {
// mark alignment patterns + format info
markSquare(0,0,9);
markRectangle(numModules-8,0,9,8);
markRectangle(0,numModules-8,8,9);
// timing pattern
markRectangle(8,6,1,numModules-8-8);
markRectangle(6,8,numModules-8-8,... | java |
private void computeBitLocations() {
int N = numRows;
int row = N-1;
int col = N-1;
int direction = -1;
while (col > 0) {
if (col == 6)
col -= 1;
if (!get(row,col)) {
bits.add( new Point2D_I32(col,row));
}
if (!get(row,col-1)) {
bits.add( new Point2D_I32(col-1,row));
}
row += ... | java |
public static void drawRectangle( Rectangle2D_I32 rect , Graphics2D g2 ) {
g2.drawLine(rect.x0, rect.y0, rect.x1, rect.y0);
g2.drawLine(rect.x1, rect.y0, rect.x1, rect.y1);
g2.drawLine(rect.x0, rect.y1, rect.x1, rect.y1);
g2.drawLine(rect.x0, rect.y1, rect.x0, rect.y0);
} | java |
public static SteerableCoefficients polynomial( int order ) {
if( order == 1 )
return new PolyOrder1();
else if( order == 2 )
return new PolyOrder2();
else if( order == 3 )
return new PolyOrder3();
else if( order == 4 )
return new PolyOrder4();
else
throw new IllegalArgumentException("Only supp... | java |
private void pruneMatches() {
int index = 0;
while( index < matches.size ) {
AssociatedTripleIndex a = matches.get(index);
// not matched. Remove it from the list by copying that last element over it
if( a.c == -1 ) {
a.set(matches.get(matches.size-1));
matches.size--;
} else {
index++;
}... | java |
public void setNumberControl( int numControl ) {
this.numControl = numControl;
if( numControl == 4 ) {
x0.reshape(10,1,false);
AA.reshape(10,9,false);
yy.reshape(10,1,false);
xx.reshape(9,1,false);
numNull = 3;
} else {
x0.reshape(6,1,false);
AA.reshape(4,2,false);
yy.reshape(4,1,false);
... | java |
public void process( DMatrixRMaj L_full , DMatrixRMaj y , double betas[] ) {
svd.decompose(L_full);
// extract null space
V = svd.getV(null,true);
// compute one possible solution
pseudo.setA(L_full);
pseudo.solve(y,x0);
// add additional constraints to reduce the number of possible solutions
DMatri... | java |
protected DMatrixRMaj solveConstraintMatrix() {
int rowAA = 0;
for( int i = 0; i < numControl; i++ ) {
for( int j = i+1; j < numControl; j++ ) {
for( int k = j; k < numControl; k++ , rowAA++ ) {
// x_{ii}*x_{jk} = x_{ik}*x_{ji}
extractXaXb(getIndex(i, i), getIndex(j, k), XiiXjk);
extractXaXb(... | java |
public static <T extends ImageGray<T>>
void orderBandsIntoRGB(Planar<T> image , BufferedImage input ) {
boolean swap = swapBandOrder(input);
// Output formats are: RGB and RGBA
if( swap ) {
if( image.getNumBands() == 3 ) {
int bufferedImageType = input.getType();
if( bufferedImageType == BufferedIm... | java |
public static boolean isKnownByteFormat( BufferedImage image ) {
int type = image.getType();
return type != BufferedImage.TYPE_BYTE_INDEXED &&
type != BufferedImage.TYPE_BYTE_BINARY &&
type != BufferedImage.TYPE_CUSTOM;
} | java |
public static List<BufferedImage> loadImages( String directory , final String regex ) {
List<String> paths = UtilIO.listByRegex(directory,regex);
List<BufferedImage> ret = new ArrayList<>();
if( paths.size() == 0 )
return ret;
// Sort so that the order is deterministic
Collections.sort(paths);
for( ... | java |
public static BufferedImage loadImage(URL url) {
if( url == null )
return null;
try {
BufferedImage buffered = ImageIO.read(url);
if( buffered != null )
return buffered;
if( url.getProtocol().equals("file")) {
String path = URLDecoder.decode(url.getPath(), "UTF-8");
if( !new File(path).exist... | java |
public static <T extends ImageGray<T>> T loadImage(String fileName, Class<T> imageType ) {
BufferedImage img = loadImage(fileName);
if( img == null )
return null;
return ConvertBufferedImage.convertFromSingle(img, (T) null, imageType);
} | java |
public static BufferedImage loadPPM( String fileName , BufferedImage storage ) throws IOException {
return loadPPM(new FileInputStream(fileName),storage);
} | java |
public static BufferedImage loadPGM( String fileName , BufferedImage storage ) throws IOException {
return loadPGM(new FileInputStream(fileName), storage);
} | java |
public static void savePPM(Planar<GrayU8> rgb , String fileName , GrowQueue_I8 temp ) throws IOException {
File out = new File(fileName);
DataOutputStream os = new DataOutputStream(new FileOutputStream(out));
String header = String.format("P6\n%d %d\n255\n", rgb.width, rgb.height);
os.write(header.getBytes());... | java |
public static void savePGM(GrayU8 gray , String fileName ) throws IOException {
File out = new File(fileName);
DataOutputStream os = new DataOutputStream(new FileOutputStream(out));
String header = String.format("P5\n%d %d\n255\n", gray.width, gray.height);
os.write(header.getBytes());
os.write(gray.data,0,... | java |
public static <T extends KernelBase> T gaussian(Class<T> kernelType, double sigma, int radius )
{
if (Kernel1D_F32.class == kernelType) {
return gaussian(1, true, 32, sigma, radius);
} else if (Kernel1D_F64.class == kernelType) {
return gaussian(1,true, 64, sigma,radius);
} else if (Kernel1D_S32.class == k... | java |
public static <T extends ImageGray<T>, K extends Kernel1D>
K gaussian1D(Class<T> imageType, double sigma, int radius )
{
boolean isFloat = GeneralizedImageOps.isFloatingPoint(imageType);
int numBits = GeneralizedImageOps.getNumBits(imageType);
if( numBits < 32 )
numBits = 32;
return gaussian(1,isFloat, num... | java |
public static <T extends ImageGray<T>, K extends Kernel2D>
K gaussian2D(Class<T> imageType, double sigma, int radius )
{
boolean isFloat = GeneralizedImageOps.isFloatingPoint(imageType);
int numBits = Math.max(32, GeneralizedImageOps.getNumBits(imageType));
return gaussian(2,isFloat, numBits, sigma,radius);
} | java |
public static <T extends KernelBase> T gaussian(int DOF, boolean isFloat, int numBits, double sigma, int radius)
{
if( radius <= 0 )
radius = FactoryKernelGaussian.radiusForSigma(sigma,0);
else if( sigma <= 0 )
sigma = FactoryKernelGaussian.sigmaForRadius(radius,0);
if( DOF == 2 ) {
if( numBits == 32 )... | java |
public static <T extends Kernel1D> T derivative( int order, boolean isFloat,
double sigma, int radius )
{
// zero order is a regular gaussian
if( order == 0 ) {
return gaussian(1,isFloat, 32, sigma,radius);
}
if( radius <= 0 )
radius = FactoryKernelGaussian.radiusForSigma(sigma,order);
e... | java |
public static Kernel2D_F32 gaussian2D_F32(double sigma, int radius, boolean odd, boolean normalize) {
Kernel1D_F32 kernel1D = gaussian1D_F32(sigma,radius, odd, false);
Kernel2D_F32 ret = KernelMath.convolve2D(kernel1D, kernel1D);
if (normalize) {
KernelMath.normalizeSumToOne(ret);
}
return ret;
} | java |
protected static Kernel1D_F32 derivative1D_F32(int order, double sigma, int radius, boolean normalize) {
Kernel1D_F32 ret = new Kernel1D_F32(radius * 2 + 1);
float[] gaussian = ret.data;
int index = 0;
switch( order ) {
case 1:
for (int i = radius; i >= -radius; i--) {
gaussian[index++] = (float) U... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.