code
stringlengths
73
34.1k
label
stringclasses
1 value
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 ki...
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(); }
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 ...
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....
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( !zeroPrinciple...
java
public void initializeMerge(int numRegions) { mergeList.resize(numRegions); for( int i = 0; i < numRegions; i++ ) mergeList.data[i] = i; }
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 pixe...
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++; ...
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]...
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; d...
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 IllegalArgumentExc...
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)); ret...
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 = FactoryM...
java
public static Estimate1ofPnP computePnPwithEPnP(int numIterations, double magicNumber) { PnPLepetitEPnP alg = new PnPLepetitEPnP(magicNumber); alg.setNumIterations(numIterations); return new WrapPnPLepetitEPnP(alg); }
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(...
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); currentL...
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; f...
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; }
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; }
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; }
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(targe...
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.currentTimeMil...
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(); t...
java
public byte[] readFrame( DataInputStream in ) { try { if( findMarker(in,SOI) && in.available() > 0 ) { return readJpegData(in, EOI); } } catch (IOException e) {} return null; }
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...
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)...
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(c...
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 doub...
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...
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); s...
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()...
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(pix...
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; ...
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++ ) { ...
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; ...
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.threshCorn...
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...
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; calibra...
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 ...
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 = or...
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;...
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 = wei...
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 < maxGaus...
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.cla...
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; } }
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; }
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*imageTy...
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...
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.proce...
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(); re...
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++) { constructLinearS...
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); }
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(point...
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 + help...
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); }
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 rig...
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 ne...
java
public boolean checkVariance( ImageRectangle r ) { double sigma2 = computeVariance(r.x0,r.y0,r.x1,r.y1); return sigma2 >= thresholdLower; }
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, ...
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, ...
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[ind...
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[inde...
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 =...
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.clea...
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) contin...
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 ) { //...
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 = deriv...
java
public void setImage(ImagePyramid<InputImage> image ) { this.image = image; this.derivX = null; this.derivY = null; }
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; } }
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(in...
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 ...
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; }
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; ...
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(unas...
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++ ) { ...
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...
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); ...
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; }
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 l...
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(...
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++] = -cam...
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[...
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;...
java
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> mean(ImageType<T> type , int radius ) { return new BlurStorageFilter<>("mean", type, 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); }
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); }
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 = reg...
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)...
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; ...
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...
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 ) performLear...
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))); ...
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 = ...
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_alph...
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; }
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 re...
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++ ) { // (...
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( inte...
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/r...
java