code
stringlengths
73
34.1k
label
stringclasses
1 value
protected static double change( EllipseRotated_F64 a , EllipseRotated_F64 b ) { double total = 0; total += Math.abs(a.center.x - b.center.x); total += Math.abs(a.center.y - b.center.y); total += Math.abs(a.a - b.a); total += Math.abs(a.b - b.b); // only care about the change of angle when it is not a circ...
java
public static <T extends ImageGray<T>> MonocularPlaneVisualOdometry<T> monoPlaneInfinity(int thresholdAdd, int thresholdRetire, double inlierPixelTol, int ransacIterations, PointTracker<T> tracker, ImageType<T> imageType) { //squared pixel...
java
public static <T extends ImageGray<T>> MonocularPlaneVisualOdometry<T> monoPlaneOverhead(double cellSize, double maxCellsPerPixel, double mapHeightFraction , double inlierGroundTol, int ransacIterations , int thresholdRetire , ...
java
public static <T extends ImageGray<T>> StereoVisualOdometry<T> stereoDepth(double inlierPixelTol, int thresholdAdd, int thresholdRetire , int ransacIterations , int refineIterations , boolean doublePass , StereoDisparitySparse<T> sparseDisparity, Po...
java
public static <Vis extends ImageGray<Vis>, Depth extends ImageGray<Depth>> DepthVisualOdometry<Vis,Depth> depthDepthPnP(double inlierPixelTol, int thresholdAdd, int thresholdRetire , int ransacIterations , int refineIterations , boolean doublePass , ...
java
public static <T extends ImageGray<T>, Desc extends TupleDesc> StereoVisualOdometry<T> stereoDualTrackerPnP(int thresholdAdd, int thresholdRetire, double inlierPixelTol, double epipolarPixelTol, int ransacIterations, int refineIterations, PointTracker<T>...
java
public static void computeCameraControl(double beta[], List<Point3D_F64> nullPts[], FastQueue<Point3D_F64> cameraPts , int numControl ) { cameraPts.reset(); for( int i = 0; i < numControl; i++ ) { cameraPts.grow().set(0,0,0); } for( int i = 0; i < numControl; i++ ) { dou...
java
public static void constraintMatrix6x3( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x3 ) { int index = 0; for( int i = 0; i < 6; i++ ) { L_6x3.data[index++] = L_6x10.get(i,0); L_6x3.data[index++] = L_6x10.get(i,1); L_6x3.data[index++] = L_6x10.get(i,4); } }
java
public static void constraintMatrix6x6( DMatrixRMaj L_6x10 , DMatrixRMaj L_6x6 ) { int index = 0; for( int i = 0; i < 6; i++ ) { L_6x6.data[index++] = L_6x10.get(i,0); L_6x6.data[index++] = L_6x10.get(i,1); L_6x6.data[index++] = L_6x10.get(i,2); L_6x6.data[index++] = L_6x10.get(i,4); L_6x6.data[inde...
java
public static void constraintMatrix3x3( DMatrixRMaj L_3x6 , DMatrixRMaj L_6x3 ) { int index = 0; for( int i = 0; i < 3; i++ ) { L_6x3.data[index++] = L_3x6.get(i,0); L_6x3.data[index++] = L_3x6.get(i,1); L_6x3.data[index++] = L_3x6.get(i,3); } }
java
public static void constraintMatrix3x6( DMatrixRMaj L , DMatrixRMaj y , FastQueue<Point3D_F64> controlWorldPts , List<Point3D_F64> nullPts[] ) { int row = 0; for( int i = 0; i < 3; i++ ) { Point3D_F64 ci = controlWorldPts.get(i); Point3D_F64 vai = nullPts[0].get(i); Point3D_F64 vbi = ...
java
public static void jacobian_Control4( DMatrixRMaj L_full , double beta[] , DMatrixRMaj A ) { int indexA = 0; double b0 = beta[0]; double b1 = beta[1]; double b2 = beta[2]; double b3 = beta[3]; final double ld[] = L_full.data; for( int i = 0; i < 6; i++ ) { int li = L_full.numCols*i; A.data...
java
public static void jacobian_Control3( DMatrixRMaj L_full , double beta[] , DMatrixRMaj A) { int indexA = 0; double b0 = beta[0]; double b1 = beta[1]; double b2 = beta[2]; final double ld[] = L_full.data; for( int i = 0; i < 3; i++ ) { int li = L_full.numCols*i; A.data[indexA++] = 2*ld[li+...
java
public void process( ImagePyramid<T> pyramidPrev , ImagePyramid<T> pyramidCurr ) { InputSanityCheck.checkSameShape(pyramidPrev, pyramidCurr); int numLayers = pyramidPrev.getNumLayers(); for( int i = numLayers-1; i >= 0; i-- ) { T prev = pyramidPrev.getLayer(i); T curr = pyramidCurr.getLayer(i); flow...
java
public void setDirection(double yaw, double pitch, double roll ) { ConvertRotation3D_F64.eulerToMatrix(EulerType.YZX,pitch,yaw,roll,R); }
java
protected void declareVectors( int width , int height ) { this.outWidth = width; if( vectors.length < width*height ) { Point3D_F64[] tmp = new Point3D_F64[width*height]; System.arraycopy(vectors,0,tmp,0,vectors.length); for (int i = vectors.length; i < tmp.length; i++) { tmp[i] = new Point3D_F64(); ...
java
public void polyScale(GrowQueue_I8 input , int scale , GrowQueue_I8 output) { output.resize(input.size); for (int i = 0; i < input.size; i++) { output.data[i] = (byte)multiply(input.data[i]&0xFF, scale); } }
java
public void polyAdd(GrowQueue_I8 polyA , GrowQueue_I8 polyB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); // compute offset that would align the smaller polynomial with the larger polynomial int offsetA = Math.max(0,polyB.size-polyA.size); int offsetB = Math.max(0,polyA.size-polyB.s...
java
public void polyAdd_S(GrowQueue_I8 polyA , GrowQueue_I8 polyB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); int M = Math.min(polyA.size, polyB.size); for (int i = M; i < polyA.size; i++) { output.data[i] = polyA.data[i]; } for (int i = M; i < polyB.size; i++) { output.data[i...
java
public void polyAddScaleB(GrowQueue_I8 polyA , GrowQueue_I8 polyB , int scaleB , GrowQueue_I8 output ) { output.resize(Math.max(polyA.size,polyB.size)); // compute offset that would align the smaller polynomial with the larger polynomial int offsetA = Math.max(0,polyB.size-polyA.size); int offsetB = Math.max(0...
java
public int polyEval(GrowQueue_I8 input , int x ) { int y = input.data[0]&0xFF; for (int i = 1; i < input.size; i++) { y = multiply(y,x) ^ (input.data[i]&0xFF); } return y; }
java
public int polyEvalContinue( int previousOutput, GrowQueue_I8 part , int x ) { int y = previousOutput; for (int i = 0; i < part.size; i++) { y = multiply(y,x) ^ (part.data[i]&0xFF); } return y; }
java
public void polyDivide(GrowQueue_I8 dividend , GrowQueue_I8 divisor , GrowQueue_I8 quotient, GrowQueue_I8 remainder ) { // handle special case if( divisor.size > dividend.size ) { remainder.setTo(dividend); quotient.resize(0); return; } else { remainder.resize(divisor.size-1); quotient.se...
java
public static ConfigQrCode fast() { // A global threshold is faster than any local algorithm // plus it will generate a simpler set of internal contours speeding up that process ConfigQrCode config = new ConfigQrCode(); config.threshold = ConfigThreshold.global(ThresholdType.GLOBAL_OTSU); return config; }
java
private void drawDistribution( Graphics2D g2 , List<Point2D_F64> candidates , int offX, int offY , double scale) { findStatistics(); // draw all the features, adjusting their size based on the first score g2.setColor(Color.RED); g2.setStroke(new BasicStroke(3)); double normalizer; if( scorer.getSco...
java
public void process(List<ChessboardCorner> corners ) { this.corners = corners; // reset internal data structures vertexes.reset(); edges.reset(); clusters.reset(); // Create a vertex for each corner for (int idx = 0; idx < corners.size(); idx++) { Vertex v = vertexes.grow(); v.reset(); v.index ...
java
public void printDualGraph() { System.out.println("============= Dual"); int l = BoofMiscOps.numDigits(vertexes.size); String format = "%"+l+"d"; for( Vertex n : vertexes.toList() ) { ChessboardCorner c = corners.get(n.index); System.out.printf("["+format+"] {%3.0f, %3.0f} -> 90[ ",n.index,c.x,c.y); ...
java
void findVertexNeighbors(Vertex target , List<ChessboardCorner> corners ) { // if( target.index == 18 ) { // System.out.println("Vertex Neighbors "+target.index); // } ChessboardCorner targetCorner = corners.get(target.index); // distance is Euclidean squared double maxDist = Double.MAX_VALUE==maxNeighborDi...
java
void handleAmbiguousVertexes(List<ChessboardCorner> corners) { List<Vertex> candidates = new ArrayList<>(); for (int idx = 0; idx < vertexes.size(); idx++) { Vertex target = vertexes.get(idx); // median distance was previously found based on the closer neighbors. In an actual chessboard // there are solid...
java
void disconnectInvalidVertices() { // add elements with 1 or 2 edges openVertexes.clear(); for (int idxVert = 0; idxVert < vertexes.size; idxVert++) { Vertex n = vertexes.get(idxVert); if( n.connections.size() == 1 || n.connections.size()==2) { openVertexes.add(n); } } // continue until there ar...
java
void removeReferences( Vertex remove , EdgeType type ) { EdgeSet removeSet = remove.getEdgeSet(type); for (int i = removeSet.size()-1; i >= 0; i--) { Vertex v = removeSet.get(i).dst; EdgeSet setV = v.getEdgeSet(type); // remove the connection from v to 'remove'. Be careful since the connection isn't always...
java
void selectConnections( Vertex target ) { // There needs to be at least two corners if( target.perpendicular.size() <= 1 ) return; // if( target.index == 16 ) { // System.out.println("ASDSAD"); // } // System.out.println("======= Connecting "+target.index); double bestError = Double.MAX_VALUE; List<Ed...
java
boolean findNext( int firstIdx , EdgeSet splitterSet , EdgeSet candidateSet , double parallel, SearchResults results ) { Edge e0 = candidateSet.get(firstIdx); results.index = -1; results.error = Double.MAX_VALUE; boolean checkParallel = !Double.isNaN(parallel); for (int i = 0; i < candidateSet...
java
boolean findSplitter(double ccw0 , double ccw1 , EdgeSet master , EdgeSet other1 , EdgeSet other2 , TupleI32 output ) { double bestDistance = Double.MAX_VALUE; for (int i = 0; i < master.size(); i++) { // select the splitter Edge me = master.get(i); // TODO decide if this is helpful or not...
java
private void repairVertexes() { // System.out.println("######## Repair"); for (int idxV = 0; idxV < dirtyVertexes.size(); idxV++) { final Vertex v = dirtyVertexes.get(idxV); // System.out.println(" dirty="+v.index); bestSolution.clear(); for (int idxE = 0; idxE < v.perpendicular.size(); idxE++) { /...
java
private void convertToOutput(List<ChessboardCorner> corners) { c2n.resize(corners.size()); n2c.resize(vertexes.size()); open.reset(); n2c.fill(-1); c2n.fill(-1); for (int seedIdx = 0; seedIdx < vertexes.size; seedIdx++) { Vertex seedN = vertexes.get(seedIdx); if( seedN.marked) continue; Chess...
java
private void growCluster(List<ChessboardCorner> corners, int seedIdx, ChessboardCornerGraph graph) { // open contains corner list indexes open.add(seedIdx); while( open.size > 0 ) { int cornerIdx = open.pop(); Vertex v = vertexes.get(cornerIdx); // make sure it hasn't already been processed if( v.mar...
java
public void setTransform( PixelTransform<Point2D_F32> undistToDist ) { if( undistToDist != null ) { InterpolatePixelS<T> interpolate = FactoryInterpolation.bilinearPixelS(imageType, BorderType.EXTENDED); integralImage = new GImageGrayDistorted<>(undistToDist, interpolate); } else { integralImage = FactoryG...
java
public void process( Point3D_F64 e2 , Point3D_F64 e3 , DMatrixRMaj A ) { // construct the linear system that the solution which solves the unknown square // matrices in the camera matrices constructE(e2, e3); // Computes U, which is used to map the 18 unknowns onto the 27 trifocal unknowns svdU.decompose(E);...
java
protected void constructE( Point3D_F64 e2 , Point3D_F64 e3 ) { E.zero(); for( int i = 0; i < 3; i++ ) { for( int j = 0; j < 3; j++ ) { for( int k = 0; k < 3; k++ ) { // which element in the trifocal tensor is being manipulated int row = 9*i + 3*j + k; // which unknowns are being multiplied by...
java
public TrifocalTensor copy() { TrifocalTensor ret = new TrifocalTensor(); ret.T1.set(T1); ret.T2.set(T2); ret.T3.set(T3); return ret; }
java
public void setImages( Input left , Input right ) { InputSanityCheck.checkSameShape(left, right); this.left = left; this.right = right; }
java
protected <T extends ImageBase> ImageType<T> getImageType( int which ) { synchronized ( inputStreams ) { return inputStreams.get(which).imageType; } }
java
private void updateRecentItems() { if( menuRecent == null ) return; menuRecent.removeAll(); List<String> recentFiles = BoofSwingUtil.getListOfRecentFiles(this); for( String filePath : recentFiles ) { final File f = new File(filePath); JMenuItem recentItem = new JMenuItem(f.getName()); recentItem.add...
java
public void openExample( Object o ) { if (o instanceof PathLabel) { PathLabel p = (PathLabel)o; if( p.path.length == 1 ) openFile(new File(p.path[0])); else { // openFile(new File(p.path[0])); openImageSet(p.path); } } else if (o instanceof String) { openFile(new File((String) o)); } els...
java
public void stopAllInputProcessing() { ProcessThread threadProcess; synchronized (inputStreams) { threadProcess = this.threadProcess; if( threadProcess != null ) { if( threadProcess.running ) { threadProcess.requestStop = true; } else { threadProcess = this.threadProcess = null; } } ...
java
public void openFile(File file) { final String path = massageFilePath(file); if( path == null ) return; inputFilePath = path; // update recent items menu BoofSwingUtil.invokeNowOrLater(() -> { BoofSwingUtil.addToRecentFiles(DemonstrationBase.this,path); updateRecentItems(); }); BufferedImage bu...
java
public void openImageSet(String ...files ) { synchronized (lockStartingProcess) { if( startingProcess ) { System.out.println("Ignoring open image set request. Detected spamming"); return; } startingProcess = true; } stopAllInputProcessing(); synchronized (inputStreams) { inputMethod = Inp...
java
public void openNextFile() { if( inputFilePath == null || inputMethod != InputMethod.IMAGE ) return; String path; try { // need to remove annoying %20 from the path is there is whitespace path = URLDecoder.decode(inputFilePath, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(...
java
protected void openVideo(boolean reopen , String ...filePaths) { synchronized (lockStartingProcess) { if( startingProcess ) { System.out.println("Ignoring video request. Detected spamming"); return; } startingProcess = true; } synchronized (inputStreams) { if (inputStreams.size() != filePath...
java
public void display(String appName ) { waitUntilInputSizeIsKnown(); this.appName = appName; window = ShowImages.showWindow(this,appName,true); window.setJMenuBar(menuBar); }
java
protected void openFileMenuBar() { List<BoofSwingUtil.FileTypes> types = new ArrayList<>(); if( allowImages ) types.add(BoofSwingUtil.FileTypes.IMAGES); if( allowVideos ) types.add(BoofSwingUtil.FileTypes.VIDEOS); BoofSwingUtil.FileTypes array[] = types.toArray(new BoofSwingUtil.FileTypes[0]); File fil...
java
public void reprocessInput() { if ( inputMethod == InputMethod.VIDEO ) { openVideo(true,inputFilePath); } else if( inputMethod == InputMethod.IMAGE ) { BufferedImage buff = inputStreams.get(0).getBufferedImage(); openImage(true,new File(inputFilePath).getName(),buff);// TODO still does a pointless image co...
java
public void process(I image, D derivX, D derivY, D derivXX, D derivYY, D derivXY) { intensity.process(image, derivX, derivY, derivXX, derivYY, derivXY); GrayF32 intensityImage = intensity.getIntensity(); int numSelectMin = -1; int numSelectMax = -1; if( maxFeatures > 0 ) { if( intensity.localMinimums() ) ...
java
public static <T extends ImageBase<T>, II extends ImageGray<II>> DescribeRegionPoint<T,BrightFeature> surfColorStable(ConfigSurfDescribe.Stability config, ImageType<T> imageType) { Class bandType = imageType.getImageClass(); Class<II> integralType = GIntegralImageOps.getIntegralType(bandType); DescribePointSur...
java
@SuppressWarnings({"unchecked"}) public static <T extends ImageGray<T>, D extends TupleDesc> DescribeRegionPoint<T,D> pixel( int regionWidth , int regionHeight , Class<T> imageType ) { return new WrapDescribePixelRegion( FactoryDescribePointAlgs.pixelRegion(regionWidth,regionHeight,imageType),imageType); }
java
@SuppressWarnings({"unchecked"}) public static <T extends ImageGray<T>> DescribeRegionPoint<T,NccFeature> pixelNCC( int regionWidth , int regionHeight , Class<T> imageType ) { return new WrapDescribePixelRegionNCC( FactoryDescribePointAlgs.pixelRegionNCC(regionWidth,regionHeight,imageType),imageType); }
java
public static <T extends CameraPinhole> void save(T parameters , Writer outputWriter ) { PrintWriter out = new PrintWriter(outputWriter); Yaml yaml = createYmlObject(); Map<String, Object> data = new HashMap<>(); if( parameters instanceof CameraPinholeBrown) { out.println("# Pinhole camera model with radi...
java
public static void save(StereoParameters parameters , Writer outputWriter ) { Map<String, Object> map = new HashMap<>(); map.put("model",MODEL_STEREO); map.put(VERSION,0); map.put("left",putModelRadial(parameters.left,null)); map.put("right",putModelRadial(parameters.right,null)); map.put("rightToLeft",put...
java
public static <T> T load(Reader reader ) { Yaml yaml = createYmlObject(); Map<String,Object> data = (Map<String, Object>) yaml.load(reader); try { reader.close(); } catch (IOException e) { throw new RuntimeException(e); } return load(data); }
java
public boolean process( List<CalibrationObservation> observations ) { // compute initial parameter estimates using linear algebra if( !linearEstimate(observations) ) return false; status("Non-linear refinement"); // perform non-linear optimization to improve results if( !performBundleAdjustment()) ret...
java
protected boolean linearEstimate(List<CalibrationObservation> observations ) { status("Estimating Homographies"); List<DMatrixRMaj> homographies = new ArrayList<>(); List<Se3_F64> motions = new ArrayList<>(); for( CalibrationObservation obs : observations ) { if( !computeHomography.computeHomography(obs) ...
java
public boolean performBundleAdjustment() { // Configure the sparse Levenberg-Marquardt solver ConfigLevenbergMarquardt configLM = new ConfigLevenbergMarquardt(); configLM.hessianScaling = false; ConfigBundleAdjustment configSBA = new ConfigBundleAdjustment(); configSBA.configOptimizer = configLM; BundleA...
java
public static void applyDistortion(Point2D_F64 normPt, double[] radial, double t1 , double t2 ) { final double x = normPt.x; final double y = normPt.y; double a = 0; double r2 = x*x + y*y; double r2i = r2; for( int i = 0; i < radial.length; i++ ) { a += radial[i]*r2i; r2i *= r2; } normPt.x = x ...
java
@Override public double computeDistance(AssociatedPair obs) { // triangulate the point in 3D space triangulate.triangulate(obs.p1,obs.p2,keyToCurr,p); if( p.z < 0 ) return Double.MAX_VALUE; // compute observational error in each view double error = errorCam1.errorSq(obs.p1.x,obs.p1.y,p.x/p.z,p.y/p.z); ...
java
public static <I extends ImageGray<I>, D extends ImageGray<D>> Class<D> getDerivativeType( Class<I> imageType ) { if( imageType == GrayF32.class ) { return (Class<D>) GrayF32.class; } else if( imageType == GrayU8.class ) { return (Class<D>) GrayS16.class; } else if( imageType == GrayU16.class ) { retur...
java
public static <I extends ImageGray<I>, D extends ImageGray<D>> void hessian( DerivativeType type , I input , D derivXX , D derivYY , D derivXY , BorderType borderType ) { ImageBorder<I> border = BorderType.SKIP == borderType ? null : FactoryImageBorder.wrap(borderType, input); switch( type ) { case SOBEL: ...
java
public static <D extends ImageGray<D>> void hessian( DerivativeType type , D derivX , D derivY , D derivXX , D derivYY , D derivXY , BorderType borderType ) { ImageBorder<D> border = BorderType.SKIP == borderType ? null : FactoryImageBorder.wrap(borderType, derivX); switch( type ) { case PREWITT: if( deriv...
java
public static KernelBase lookupKernelX( DerivativeType type , boolean isInteger) { switch( type ) { case PREWITT: return GradientPrewitt.getKernelX(isInteger); case SOBEL: return GradientSobel.getKernelX(isInteger); case THREE: return GradientThree.getKernelX(isInteger); case TWO_0: ret...
java
boolean computeEllipseCenters() { keypoints.reset(); for (int tangentIdx = 0; tangentIdx < tangents.size(); tangentIdx++) { // System.out.println("tangent id "+tangentIdx); Tangents t = tangents.get(tangentIdx); Point2D_F64 center = keypoints.grow(); center.set(0,0); double totalWeight = 0; for (...
java
public T getBand(int band) { if (band >= bands.length || band < 0) throw new IllegalArgumentException("The specified band is out of bounds: "+band); return bands[band]; }
java
@Override public void setTo( Planar<T> orig) { if (orig.width != width || orig.height != height) reshape(orig.width,orig.height); if( orig.getBandType() != getBandType() ) throw new IllegalArgumentException("The band type must be the same"); int N = orig.getNumBands(); if( N != getNumBands() ) { setN...
java
@Override public Planar<T> createNew(int imgWidth, int imgHeight) { return new Planar<>(type, imgWidth, imgHeight, bands.length); }
java
public void reorderBands( int ...order ) { T[] bands = (T[]) Array.newInstance(type, order.length); for (int i = 0; i < order.length; i++) { bands[i] = this.bands[order[i]]; } this.bands = bands; }
java
@Override public void setNumberOfBands( int numberOfBands ) { if( numberOfBands == this.bands.length ) return; T[] bands = (T[]) Array.newInstance(type, numberOfBands); int N = Math.min(numberOfBands, this.bands.length ); for (int i = 0; i < N; i++) { bands[i] = this.bands[i]; } for (int i = N; i < ...
java
public double computeAccuracy() { double totalCorrect = 0; double totalIncorrect = 0; for (int i = 0; i < actualCounts.length; i++) { for (int j = 0; j < actualCounts.length; j++) { if( i == j ) { totalCorrect += matrix.get(i,j); } else { totalIncorrect += matrix.get(i,j); } } } ...
java
public void addImage( CalibrationObservation observation ) { if( imageWidth == 0 ) { this.imageWidth = observation.getWidth(); this.imageHeight = observation.getHeight(); } else if( observation.getWidth() != this.imageWidth || observation.getHeight() != this.imageHeight) { throw new IllegalArgumentExceptio...
java
public <T extends CameraModel>T process() { if( zhang99 == null ) throw new IllegalArgumentException("Please call configure first."); zhang99.setVerbose(verbose,0); if( !zhang99.process(observations) ) { throw new RuntimeException("Zhang99 algorithm failed!"); } structure = zhang99.getStructure(); e...
java
public static void printErrors( List<ImageResults> results ) { double totalError = 0; for( int i = 0; i < results.size(); i++ ) { ImageResults r = results.get(i); totalError += r.meanError; System.out.printf("image %3d Euclidean ( mean = %7.1e max = %7.1e ) bias ( X = %8.1e Y %8.1e )\n",i,r.meanError,r.ma...
java
private void renderLabels(Graphics2D g2, double fontSize) { int numCategories = confusion.getNumRows(); int longestLabel = 0; if(renderLabels) { for (int i = 0; i < numCategories; i++) { longestLabel = Math.max(longestLabel,labels.get(i).length()); } } Font fontLabel = new Font("monospaced", Font....
java
private void renderMatrix(Graphics2D g2, double fontSize) { int numCategories = confusion.getNumRows(); Font fontNumber = new Font("Serif", Font.BOLD, (int)(0.6*fontSize + 0.5)); g2.setFont(fontNumber); FontMetrics metrics = g2.getFontMetrics(fontNumber); for (int i = 0; i < numCategories; i++) { int y0 =...
java
public LocationInfo whatIsAtPoint( int pixelX , int pixelY , LocationInfo output ) { if( output == null ) output = new LocationInfo(); int numCategories = confusion.getNumRows(); synchronized ( this ) { if( pixelX >= gridWidth ) { output.insideMatrix = false; output.col = output.row = pixelY*numCa...
java
public void configure( int widthStitch, int heightStitch , IT worldToInit ) { this.worldToInit = (IT)worldToCurr.createInstance(); if( worldToInit != null ) this.worldToInit.set(worldToInit); this.widthStitch = widthStitch; this.heightStitch = heightStitch; }
java
public void reset() { if( stitchedImage != null ) GImageMiscOps.fill(stitchedImage, 0); motion.reset(); worldToCurr.reset(); first = true; }
java
private boolean checkLargeMotion( int width , int height ) { if( first ) { getImageCorners(width,height,corners); previousArea = computeArea(corners); first = false; } else { getImageCorners(width,height,corners); double area = computeArea(corners); double change = Math.max(area/previousArea,pre...
java
private void update(I image) { computeCurrToInit_PixelTran(); // only process a cropped portion to speed up processing RectangleLength2D_I32 box = DistortImageOps.boundBox(image.width, image.height, stitchedImage.width, stitchedImage.height,work, tranCurrToWorld); int x0 = box.x0; int y0 = box.y0; int...
java
public void resizeStitchImage( int widthStitch, int heightStitch , IT newToOldStitch ) { // copy the old image into the new one workImage.reshape(widthStitch,heightStitch); GImageMiscOps.fill(workImage, 0); if( newToOldStitch != null ) { PixelTransform<Point2D_F32> newToOld = converter.convertPixel(newToOld...
java
public Corners getImageCorners( int width , int height , Corners corners ) { if( corners == null ) corners = new Corners(); int w = width; int h = height; tranCurrToWorld.compute(0,0,work); corners.p0.set(work.x, work.y); tranCurrToWorld.compute(w,0,work); corners.p1.set(work.x, work.y); tranCurrTo...
java
private void minimizeWithGeometricConstraints() { extractEpipoles.setTensor(solutionN); extractEpipoles.extractEpipoles(e2,e3); // encode the parameters being optimized param[0] = e2.x; param[1] = e2.y; param[2] = e2.z; param[3] = e3.x; param[4] = e3.y; param[5] = e3.z; // adjust the error function for th...
java
public boolean checkConstraint( Point2D_F64 viewA , Point2D_F64 viewB , Se3_F64 fromAtoB ) { triangulate.triangulate(viewA,viewB,fromAtoB,P); if( P.z > 0 ) { SePointOps_F64.transform(fromAtoB,P,P); return P.z > 0; } return false; }
java
public static <I extends ImageBase<I>, IT extends InvertibleTransform> ImageMotion2D<I,IT> createMotion2D( int ransacIterations , double inlierThreshold,int outlierPrune, int absoluteMinimumTracks, double respawnTrackFraction, double respawnCoverageFraction, boolean refineEstimate , ...
java
@SuppressWarnings("unchecked") public static <I extends ImageBase<I>, IT extends InvertibleTransform> StitchingFromMotion2D<I, IT> createVideoStitch( double maxJumpFraction , ImageMotion2D<I,IT> motion2D , ImageType<I> imageType ) { StitchingTransform<IT> transform; if( motion2D.getTransformType() == Affine2D_F...
java
public static int min( GrayS32 input ) { if( BoofConcurrency.USE_CONCURRENT ) { return ImplImageStatistics_MT.min(input.data, input.startIndex, input.height, input.width , input.stride); } else { return ImplImageStatistics.min(input.data, input.startIndex, input.height, input.width , input.stride); } }
java
public static float maxAbs( InterleavedF32 input ) { if( BoofConcurrency.USE_CONCURRENT ) { return ImplImageStatistics_MT.maxAbs(input.data, input.startIndex, input.height, input.width*input.numBands , input.stride); } else { return ImplImageStatistics.maxAbs(input.data, input.startIndex, input.height, input....
java
private void connectToNeighbors(int x, int y ) { List<LineSegment2D_F32> lines = grid.get(x,y); Iterator<LineSegment2D_F32> iter = lines.iterator(); while( iter.hasNext() ) { LineSegment2D_F32 l = iter.next(); boolean connected = false; if( connectTry(l,x+1,y) ) connected = true; if( !connecte...
java
private boolean connectTry( LineSegment2D_F32 target , int x , int y ) { if( !grid.isInBounds(x,y) ) return false; List<LineSegment2D_F32> lines = grid.get(x,y); int index = findBestCompatible(target,lines,0); if( index == -1 ) return false; LineSegment2D_F32 b = lines.remove(index); // join the ...
java
private void connectInSameElement(List<LineSegment2D_F32> lines ) { for( int i = 0; i < lines.size(); i++ ) { LineSegment2D_F32 a = lines.get(i); int index = findBestCompatible(a,lines,i+1); if( index == -1 ) continue; // remove the line from the index which it is being connected to LineSegment2D...
java
private int findBestCompatible( LineSegment2D_F32 target , List<LineSegment2D_F32> candidates , int start ) { int bestIndex = -1; double bestDistance = Double.MAX_VALUE; int bestFarthest = 0; float targetAngle = UtilAngle.atanSafe(target.slopeY(),target.slopeX()); float cos = (float)Math.c...
java
private void closestFarthestPoints(LineSegment2D_F32 a, LineSegment2D_F32 b) { dist[0] = a.a.distance2(b.a); dist[1] = a.a.distance2(b.b); dist[2] = a.b.distance2(b.a); dist[3] = a.b.distance2(b.b); // find the two points which are closest together and save which ones those are // for future reference f...
java
protected void selectBoundaryCorners() { List<Point2D_F64> layout = detector.getLayout(); Polygon2D_F64 hull = new Polygon2D_F64(); UtilPolygons2D_F64.convexHull(layout,hull); UtilPolygons2D_F64.removeAlmostParallel(hull,0.02); boundaryIndexes = new int[hull.size()]; for (int i = 0; i < hull.size(); i++) ...
java