idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
26,600 | boolean centerOnSquare ( QrCode . Alignment pattern , float guessY , float guessX ) { float step = 1 ; float bestMag = Float . MAX_VALUE ; float bestX = guessX ; float bestY = guessY ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int row = 0 ; row < 3 ; row ++ ) { float gridy = guessY - 1f + row ; for ( int col = 0 ; col ... | If the initial guess is within the inner white circle or black dot this will ensure that it is centered on the black dot |
26,601 | boolean localize ( QrCode . Alignment pattern , float guessY , float guessX ) { for ( int i = 0 ; i < arrayY . length ; i ++ ) { float x = guessX - 1.5f + i * 3f / 12.0f ; float y = guessY - 1.5f + i * 3f / 12.0f ; arrayX [ i ] = reader . read ( guessY , x ) ; arrayY [ i ] = reader . read ( y , guessX ) ; } int downX =... | Localizizes the alignment pattern crudely by searching for the black box in the center by looking for its edges in the gray scale image |
26,602 | public static void positive ( TupleDesc_F64 input , TupleDesc_U8 output ) { double max = 0 ; for ( int i = 0 ; i < input . size ( ) ; i ++ ) { double v = input . value [ i ] ; if ( v > max ) max = v ; } if ( max == 0 ) max = 1.0 ; for ( int i = 0 ; i < input . size ( ) ; i ++ ) { output . value [ i ] = ( byte ) ( 255.0... | Converts a floating point description with all positive values into the 8 - bit integer descriptor by dividing each element in the input by the element maximum value and multiplying by 255 . |
26,603 | public static void real ( TupleDesc_F64 input , TupleDesc_S8 output ) { double max = 0 ; for ( int i = 0 ; i < input . size ( ) ; i ++ ) { double v = Math . abs ( input . value [ i ] ) ; if ( v > max ) max = v ; } for ( int i = 0 ; i < input . size ( ) ; i ++ ) { output . value [ i ] = ( byte ) ( 127.0 * input . value ... | Converts a floating point description with real values into the 8 - bit integer descriptor by dividing each element in the input by the element maximum absolute value and multiplying by 127 . |
26,604 | public static void convertNcc ( TupleDesc_F64 input , NccFeature output ) { if ( input . size ( ) != output . size ( ) ) throw new IllegalArgumentException ( "Feature lengths do not match." ) ; double mean = 0 ; for ( int i = 0 ; i < input . value . length ; i ++ ) { mean += input . value [ i ] ; } mean /= input . valu... | Converts a regular feature description into a NCC feature description |
26,605 | private static void convolve1D ( GrayU8 gray ) { ImageBorder < GrayU8 > border = FactoryImageBorder . wrap ( BorderType . EXTENDED , gray ) ; Kernel1D_S32 kernel = new Kernel1D_S32 ( 2 ) ; kernel . offset = 1 ; kernel . data [ 0 ] = 1 ; kernel . data [ 1 ] = - 1 ; GrayS16 output = new GrayS16 ( gray . width , gray . he... | Convolves a 1D kernel horizontally and vertically |
26,606 | private static void convolve2D ( GrayU8 gray ) { Kernel2D_S32 kernel = new Kernel2D_S32 ( 3 ) ; kernel . set ( 1 , 0 , 2 ) ; kernel . set ( 2 , 1 , 2 ) ; kernel . set ( 0 , 1 , - 2 ) ; kernel . set ( 1 , 2 , - 2 ) ; GrayS16 output = new GrayS16 ( gray . width , gray . height ) ; ImageBorder < GrayU8 > border = FactoryI... | Convolves a 2D kernel |
26,607 | private static void normalize2D ( GrayU8 gray ) { Kernel2D_S32 kernel = FactoryKernelGaussian . gaussian2D ( GrayU8 . class , - 1 , 3 ) ; GrayU8 output = new GrayU8 ( gray . width , gray . height ) ; GConvolveImageOps . convolveNormalized ( kernel , gray , output ) ; panel . addImage ( VisualizeImageData . standard ( o... | Convolves a 2D normalized kernel . This kernel is divided by its sum after computation . |
26,608 | public void process ( List < DMatrixRMaj > homographies ) { if ( assumeZeroSkew ) { if ( homographies . size ( ) < 2 ) throw new IllegalArgumentException ( "At least two homographies are required. Found " + homographies . size ( ) ) ; } else if ( homographies . size ( ) < 3 ) { throw new IllegalArgumentException ( "At ... | Given a set of homographies computed from a sequence of images that observe the same plane it estimates the camera s calibration . |
26,609 | private void computeV ( DMatrixRMaj h1 , DMatrixRMaj h2 , DMatrixRMaj v ) { double h1x = h1 . get ( 0 , 0 ) ; double h1y = h1 . get ( 1 , 0 ) ; double h1z = h1 . get ( 2 , 0 ) ; double h2x = h2 . get ( 0 , 0 ) ; double h2y = h2 . get ( 1 , 0 ) ; double h2z = h2 . get ( 2 , 0 ) ; v . set ( 0 , 0 , h1x * h2x ) ; v . set ... | This computes the v_ij vector found in the paper . |
26,610 | private void computeParam ( ) { CommonOps_DDRM . divide ( b , CommonOps_DDRM . elementMaxAbs ( b ) ) ; double B11 = b . get ( 0 , 0 ) ; double B12 = b . get ( 1 , 0 ) ; double B22 = b . get ( 2 , 0 ) ; double B13 = b . get ( 3 , 0 ) ; double B23 = b . get ( 4 , 0 ) ; double B33 = b . get ( 5 , 0 ) ; double temp0 = B12 ... | Compute the calibration parameters from the b matrix . |
26,611 | public static void hessianNaive ( GrayF32 integral , int skip , int size , GrayF32 intensity ) { final int w = intensity . width ; final int h = intensity . height ; IntegralKernel kerXX = DerivativeIntegralImage . kernelDerivXX ( size , null ) ; IntegralKernel kerYY = DerivativeIntegralImage . kernelDerivYY ( size , n... | Brute force approach which is easy to validate through visual inspection . |
26,612 | public void openImageSet ( String ... files ) { synchronized ( lockProcessing ) { if ( processing ) { JOptionPane . showMessageDialog ( this , "Still processing" ) ; return ; } } setMenuBarEnabled ( false ) ; super . openImageSet ( files ) ; } | Prevent the user from tring to process more than one image at once |
26,613 | private BufferedImage scaleBuffered ( BufferedImage input ) { int m = Math . max ( input . getWidth ( ) , input . getHeight ( ) ) ; if ( m <= controls . maxImageSize ) return input ; else { double scale = controls . maxImageSize / ( double ) m ; int w = ( int ) ( scale * input . getWidth ( ) + 0.5 ) ; int h = ( int ) (... | Scale buffered image so that it meets the image size restrictions |
26,614 | private int [ ] selectBestPair ( SceneStructureMetric structure ) { Se3_F64 w_to_0 = structure . views [ 0 ] . worldToView ; Se3_F64 w_to_1 = structure . views [ 1 ] . worldToView ; Se3_F64 w_to_2 = structure . views [ 2 ] . worldToView ; Se3_F64 view0_to_1 = w_to_0 . invert ( null ) . concat ( w_to_1 , null ) ; Se3_F6... | Select two views which are the closest to an idea stereo pair . Little rotation and little translation along z - axis |
26,615 | private double score ( Se3_F64 se ) { double x = Math . abs ( se . T . x ) ; double y = Math . abs ( se . T . y ) ; double z = Math . abs ( se . T . z ) + 1e-8 ; double r = Math . max ( x / ( y + z ) , y / ( x + z ) ) ; return 1.0 / r ; } | Give lower scores to transforms with no rotation and translations along x or y axis . |
26,616 | public void process ( List < Point2D_I32 > contour , GrowQueue_I32 vertexes , Polygon2D_F64 output ) { int numDecreasing = 0 ; for ( int i = vertexes . size - 1 , j = 0 ; j < vertexes . size ; i = j , j ++ ) { if ( vertexes . get ( i ) > vertexes . get ( j ) ) numDecreasing ++ ; } boolean decreasing = numDecreasing > 1... | Refines the estimate using all the points in the contour |
26,617 | public boolean isDistorted ( ) { if ( radial != null && radial . length > 0 ) { for ( int i = 0 ; i < radial . length ; i ++ ) { if ( radial [ i ] != 0 ) return true ; } } return t1 != 0 || t2 != 0 ; } | If true then distortion parameters are specified . |
26,618 | public void process ( List < List < SquareNode > > clusters ) { valid . reset ( ) ; for ( int i = 0 ; i < clusters . size ( ) ; i ++ ) { List < SquareNode > graph = clusters . get ( i ) ; if ( graph . size ( ) < minimumElements ) continue ; switch ( checkNumberOfConnections ( graph ) ) { case 1 : orderIntoLine ( graph ... | Converts the set of provided clusters into ordered grids . |
26,619 | int checkNumberOfConnections ( List < SquareNode > graph ) { int histogram [ ] = new int [ 5 ] ; for ( int i = 0 ; i < graph . size ( ) ; i ++ ) { histogram [ graph . get ( i ) . getNumberOfConnections ( ) ] ++ ; } if ( graph . size ( ) == 1 ) { if ( histogram [ 0 ] != 1 ) return 0 ; return 1 ; } else if ( histogram [ ... | Does a weak check on the number of edges in the graph . Since the structure isn t known it can t make harder checks |
26,620 | boolean addRowsToGrid ( List < SquareNode > column , List < SquareNode > ordered ) { for ( int i = 0 ; i < column . size ( ) ; i ++ ) { column . get ( i ) . graph = 0 ; } int numFirsRow = 0 ; for ( int j = 0 ; j < column . size ( ) ; j ++ ) { SquareNode n = column . get ( j ) ; n . graph = SEARCHED ; ordered . add ( n ... | Competes the graph by traversing down the first column and adding the rows one at a time |
26,621 | int addLineToGrid ( SquareNode a , SquareNode b , List < SquareNode > list ) { int total = 2 ; while ( true ) { boolean matched = false ; int side ; for ( side = 0 ; side < 4 ; side ++ ) { if ( b . edges [ side ] != null && b . edges [ side ] . destination ( b ) == a ) { matched = true ; break ; } } if ( ! matched ) { ... | Add all the nodes into the list which lie along the line defined by a and b . a is assumed to be an end point . Care is taken to not cycle . |
26,622 | static SquareNode pickNot ( SquareNode target , SquareNode child ) { for ( int i = 0 ; i < 4 ; i ++ ) { SquareEdge e = target . edges [ i ] ; if ( e == null ) continue ; SquareNode c = e . destination ( target ) ; if ( c != child ) return c ; } throw new RuntimeException ( "There was no odd one out some how" ) ; } | There are only two edges on target . Pick the edge which does not go to the provided child |
26,623 | static SquareNode pickNot ( SquareNode target , SquareNode child0 , SquareNode child1 ) { for ( int i = 0 ; i < 4 ; i ++ ) { SquareEdge e = target . edges [ i ] ; if ( e == null ) continue ; SquareNode c = e . destination ( target ) ; if ( c != child0 && c != child1 ) return c ; } throw new RuntimeException ( "There wa... | There are only three edges on target and two of them are known . Pick the one which isn t an inptu child |
26,624 | public static int countRegionPixels ( GrayS32 labeled , int which ) { int total = 0 ; for ( int y = 0 ; y < labeled . height ; y ++ ) { int index = labeled . startIndex + y * labeled . stride ; for ( int x = 0 ; x < labeled . width ; x ++ ) { if ( labeled . data [ index ++ ] == which ) { total ++ ; } } } return total ;... | Counts the number of instances of which inside the labeled image . |
26,625 | public static void countRegionPixels ( GrayS32 labeled , int totalRegions , int counts [ ] ) { Arrays . fill ( counts , 0 , totalRegions , 0 ) ; for ( int y = 0 ; y < labeled . height ; y ++ ) { int index = labeled . startIndex + y * labeled . stride ; for ( int x = 0 ; x < labeled . width ; x ++ ) { counts [ labeled .... | Counts the number of pixels in all regions . Regions must be have labels from 0 to totalRegions - 1 . |
26,626 | public static void regionPixelId_to_Compact ( GrayS32 graph , GrowQueue_I32 segmentId , GrayS32 output ) { InputSanityCheck . checkSameShape ( graph , output ) ; for ( int i = 0 ; i < segmentId . size ; i ++ ) { graph . data [ segmentId . data [ i ] ] = i ; } for ( int y = 0 ; y < output . height ; y ++ ) { int indexGr... | Compacts the region labels such that they are consecutive numbers starting from 0 . The ID of a root node must the index of a pixel in the graph image taking in account the change in coordinates for sub - images . |
26,627 | public static < II extends ImageGray < II > > OrientationIntegral < II > image_ii ( double objectRadiusToScale , int sampleRadius , double samplePeriod , int sampleWidth , double weightSigma , Class < II > integralImage ) { return ( OrientationIntegral < II > ) new ImplOrientationImageAverageIntegral ( objectRadiusToSc... | Estimates the orientation without calculating the image derivative . |
26,628 | public static < II extends ImageGray < II > > OrientationIntegral < II > sliding_ii ( ConfigSlidingIntegral config , Class < II > integralType ) { if ( config == null ) config = new ConfigSlidingIntegral ( ) ; config . checkValidity ( ) ; return ( OrientationIntegral < II > ) new ImplOrientationSlidingWindowIntegral ( ... | Estimates the orientation of a region by using a sliding window across the different potential angles . |
26,629 | public static < D extends ImageGray < D > > OrientationHistogramSift < D > sift ( ConfigSiftOrientation config , Class < D > derivType ) { if ( config == null ) config = new ConfigSiftOrientation ( ) ; config . checkValidity ( ) ; return new OrientationHistogramSift ( config . histogramSize , config . sigmaEnlarge , de... | Estimates multiple orientations as specified in SIFT paper . |
26,630 | public void setTemplate ( T template , T mask , int maxMatches ) { this . template = template ; this . mask = mask ; this . maxMatches = maxMatches ; } | Specifies the template to search for and the maximum number of matches to return . |
26,631 | public void setImage ( T image ) { match . setInputImage ( image ) ; this . imageWidth = image . width ; this . imageHeight = image . height ; } | Specifies the input image which the template is to be found inside . |
26,632 | public void process ( ) { if ( mask == null ) match . process ( template ) ; else match . process ( template , mask ) ; GrayF32 intensity = match . getIntensity ( ) ; int offsetX = 0 ; int offsetY = 0 ; if ( ! match . isBorderProcessed ( ) ) { int x0 = match . getBorderX0 ( ) ; int x1 = imageWidth - ( template . width ... | Performs template matching . |
26,633 | public void refreshAlgorithm ( ) { Object cookie = algCookies . get ( algBox . getSelectedIndex ( ) ) ; String name = ( String ) algBox . getSelectedItem ( ) ; performSetAlgorithm ( name , cookie ) ; } | Tells it to switch again to the current algorithm . Useful if the input has changed and information needs to be rendered again . |
26,634 | public boolean process ( List < Point2D_I32 > contour ) { reset ( ) ; if ( loops ) { if ( contour . size ( ) < 3 ) return false ; if ( ! findInitialTriangle ( contour ) ) return false ; } else { if ( contour . size ( ) < 2 ) return false ; addCorner ( 0 ) ; addCorner ( contour . size ( ) - 1 ) ; initializeScore ( conto... | Process the contour and returns true if a polyline could be found . |
26,635 | boolean savePolyline ( ) { int N = loops ? 3 : 2 ; CandidatePolyline c ; if ( list . size ( ) <= polylines . size + N - 1 ) { c = polylines . get ( list . size ( ) - N ) ; if ( c . splits . size != list . size ( ) ) throw new RuntimeException ( "Egads saved polylines aren't in the expected order" ) ; } else { c = polyl... | Saves the current polyline |
26,636 | static double computeScore ( LinkedList < Corner > list , double cornerPenalty , boolean loops ) { double sumSides = 0 ; Element < Corner > e = list . getHead ( ) ; Element < Corner > end = loops ? null : list . getTail ( ) ; while ( e != end ) { sumSides += e . object . sideError ; e = e . next ; } int numSides = loop... | Computes the score for a list |
26,637 | boolean findInitialTriangle ( List < Point2D_I32 > contour ) { int cornerSeed = findCornerSeed ( contour ) ; if ( convex ) { if ( ! isConvexUsingMaxDistantPoints ( contour , 0 , cornerSeed ) ) return false ; } splitter . selectSplitPoint ( contour , 0 , cornerSeed , resultsA ) ; splitter . selectSplitPoint ( contour , ... | Select an initial triangle . A good initial triangle is needed . By good it should minimize the error of the contour from each side |
26,638 | private boolean initializeScore ( List < Point2D_I32 > contour , boolean loops ) { Element < Corner > e = list . getHead ( ) ; Element < Corner > end = loops ? null : list . getTail ( ) ; while ( e != end ) { if ( convex && ! isSideConvex ( contour , e ) ) return false ; Element < Corner > n = e . next ; double error ;... | Computes the score and potential split for each side |
26,639 | void ensureTriangleOrder ( List < Point2D_I32 > contour ) { Element < Corner > e = list . getHead ( ) ; Corner a = e . object ; e = e . next ; Corner b = e . object ; e = e . next ; Corner c = e . object ; int distB = CircularIndex . distanceP ( a . index , b . index , contour . size ( ) ) ; int distC = CircularIndex .... | Make sure the next corner after the head is the closest one to the head |
26,640 | boolean increaseNumberOfSidesByOne ( List < Point2D_I32 > contour , boolean loops ) { Element < Corner > selected = selectCornerToSplit ( loops ) ; if ( selected == null ) return false ; selected . object . sideError = selected . object . splitError0 ; Corner c = corners . grow ( ) ; c . reset ( ) ; c . index = selecte... | Increase the number of sides in the polyline . This is done greedily selecting the side which would improve the score by the most of it was split . |
26,641 | boolean isSideConvex ( List < Point2D_I32 > contour , Element < Corner > e1 ) { Element < Corner > e2 = next ( e1 ) ; int length = CircularIndex . distanceP ( e1 . object . index , e2 . object . index , contour . size ( ) ) ; Point2D_I32 p0 = contour . get ( e1 . object . index ) ; Point2D_I32 p1 = contour . get ( e2 .... | Checks to see if the side could belong to a convex shape |
26,642 | Element < Corner > selectCornerToSplit ( boolean loops ) { Element < Corner > selected = null ; double bestChange = convex ? 0 : - Double . MAX_VALUE ; Element < Corner > e = list . getHead ( ) ; Element < Corner > end = loops ? null : list . getTail ( ) ; while ( e != end ) { Corner c = e . object ; if ( ! c . splitab... | Selects the best side to split the polyline at . |
26,643 | Element < Corner > selectCornerToRemove ( List < Point2D_I32 > contour , ErrorValue sideError , boolean loops ) { if ( list . size ( ) <= 3 ) return null ; Element < Corner > target , end ; if ( loops ) { target = list . getHead ( ) ; end = null ; } else { target = list . getHead ( ) . next ; end = list . getTail ( ) ;... | Selects the best corner to remove . If no corner was found that can be removed then null is returned |
26,644 | boolean removeCornerAndSavePolyline ( Element < Corner > corner , double sideErrorAfterRemoved ) { Element < Corner > p = previous ( corner ) ; p . object . sideError = sideErrorAfterRemoved ; list . remove ( corner ) ; return savePolyline ( ) ; } | Remove the corner from the current polyline . If the new polyline has a better score than the currently saved one with the same number of corners save it |
26,645 | static int findCornerSeed ( List < Point2D_I32 > contour ) { Point2D_I32 a = contour . get ( 0 ) ; int best = - 1 ; double bestDistance = - Double . MAX_VALUE ; for ( int i = 1 ; i < contour . size ( ) ; i ++ ) { Point2D_I32 b = contour . get ( i ) ; double d = distanceSq ( a , b ) ; if ( d > bestDistance ) { bestDista... | The seed corner is the point farther away from the first point . In a perfect polygon with no noise this should be a corner . |
26,646 | static int maximumDistance ( List < Point2D_I32 > contour , int indexA , int indexB ) { Point2D_I32 a = contour . get ( indexA ) ; Point2D_I32 b = contour . get ( indexB ) ; int best = - 1 ; double bestDistance = - Double . MAX_VALUE ; for ( int i = 0 ; i < contour . size ( ) ; i ++ ) { Point2D_I32 c = contour . get ( ... | Finds the point in the contour which maximizes the distance between points A and B . |
26,647 | double computeSideError ( List < Point2D_I32 > contour , int indexA , int indexB ) { assignLine ( contour , indexA , indexB , line ) ; int numSamples ; double sumOfDistances = 0 ; int length ; if ( indexB >= indexA ) { length = indexB - indexA - 1 ; numSamples = Math . min ( length , maxNumberOfSideSamples ) ; for ( in... | Scores a side based on the sum of Euclidean distance squared of each point along the line . Euclidean squared is used because its fast to compute |
26,648 | void computePotentialSplitScore ( List < Point2D_I32 > contour , Element < Corner > e0 , boolean mustSplit ) { Element < Corner > e1 = next ( e0 ) ; e0 . object . splitable = canBeSplit ( contour , e0 , mustSplit ) ; if ( e0 . object . splitable ) { setSplitVariables ( contour , e0 , e1 ) ; } } | Computes the split location and the score of the two new sides if it s split there |
26,649 | void setSplitVariables ( List < Point2D_I32 > contour , Element < Corner > e0 , Element < Corner > e1 ) { int distance0 = CircularIndex . distanceP ( e0 . object . index , e1 . object . index , contour . size ( ) ) ; int index0 = CircularIndex . plusPOffset ( e0 . object . index , minimumSideLength , contour . size ( )... | Selects and splits the side defined by the e0 corner . If convex a check is performed to ensure that the polyline will be convex still . |
26,650 | boolean canBeSplit ( List < Point2D_I32 > contour , Element < Corner > e0 , boolean mustSplit ) { Element < Corner > e1 = next ( e0 ) ; int length = CircularIndex . distanceP ( e0 . object . index , e1 . object . index , contour . size ( ) ) ; if ( length <= 2 * minimumSideLength ) { return false ; } return mustSplit |... | Determines if the side can be split again . A side can always be split as long as it s &ge ; the minimum length or that the side score is larger the the split threshold |
26,651 | Element < Corner > next ( Element < Corner > e ) { if ( e . next == null ) { return list . getHead ( ) ; } else { return e . next ; } } | Returns the next corner in the list |
26,652 | Element < Corner > previous ( Element < Corner > e ) { if ( e . previous == null ) { return list . getTail ( ) ; } else { return e . previous ; } } | Returns the previous corner in the list |
26,653 | static double distanceSq ( Point2D_I32 a , Point2D_I32 b ) { double dx = b . x - a . x ; double dy = b . y - a . y ; return dx * dx + dy * dy ; } | Using double prevision here instead of int due to fear of overflow in very large images |
26,654 | public static void assignLine ( List < Point2D_I32 > contour , int indexA , int indexB , LineParametric2D_F64 line ) { Point2D_I32 endA = contour . get ( indexA ) ; Point2D_I32 endB = contour . get ( indexB ) ; line . p . x = endA . x ; line . p . y = endA . y ; line . slope . x = endB . x - endA . x ; line . slope . y... | Assigns the line so that it passes through points A and B . |
26,655 | protected void splitPixels ( int indexStart , int indexStop ) { if ( indexStart + 1 >= indexStop ) return ; int indexSplit = selectSplitBetween ( indexStart , indexStop ) ; if ( indexSplit >= 0 ) { splitPixels ( indexStart , indexSplit ) ; splits . add ( indexSplit ) ; splitPixels ( indexSplit , indexStop ) ; } } | Recursively splits pixels . Used in the initial segmentation . Only split points between the two ends are added |
26,656 | protected boolean splitSegments ( ) { boolean change = false ; work . reset ( ) ; for ( int i = 0 ; i < splits . size - 1 ; i ++ ) { int start = splits . data [ i ] ; int end = splits . data [ i + 1 ] ; int bestIndex = selectSplitBetween ( start , end ) ; if ( bestIndex >= 0 ) { change |= true ; work . add ( start ) ; ... | Splits a line in two if there is a paint that is too far away |
26,657 | protected boolean mergeSegments ( ) { if ( splits . size <= 2 ) return false ; boolean change = false ; work . reset ( ) ; work . add ( splits . data [ 0 ] ) ; for ( int i = 0 ; i < splits . size - 2 ; i ++ ) { if ( selectSplitBetween ( splits . data [ i ] , splits . data [ i + 2 ] ) < 0 ) { change = true ; } else { wo... | Merges lines together which have an acute angle less than the threshold . |
26,658 | public void initialize ( PyramidDiscrete < I > image ) { if ( previousDerivX == null || previousDerivX . length != image . getNumLayers ( ) || previousImage . getInputWidth ( ) != image . getInputWidth ( ) || previousImage . getInputHeight ( ) != image . getInputHeight ( ) ) { declareDataStructures ( image ) ; } for ( ... | Call for the first image being tracked |
26,659 | protected void declareDataStructures ( PyramidDiscrete < I > image ) { numPyramidLayers = image . getNumLayers ( ) ; previousDerivX = ( D [ ] ) Array . newInstance ( derivType , image . getNumLayers ( ) ) ; previousDerivY = ( D [ ] ) Array . newInstance ( derivType , image . getNumLayers ( ) ) ; currentDerivX = ( D [ ]... | Declares internal data structures based on the input image pyramid |
26,660 | public boolean process ( ImagePyramid < I > image , Rectangle2D_F64 targetRectangle ) { boolean success = true ; updateCurrent ( image ) ; spawnGrid ( targetRectangle ) ; if ( ! trackFeature ( ) ) success = false ; setCurrentToPrevious ( ) ; return success ; } | Creates several tracks inside the target rectangle and compuets their motion |
26,661 | protected void updateCurrent ( ImagePyramid < I > image ) { this . currentImage = image ; for ( int i = 0 ; i < image . getNumLayers ( ) ; i ++ ) { gradient . process ( image . getLayer ( i ) , currentDerivX [ i ] , currentDerivY [ i ] ) ; } } | Computes the gradient and changes the reference to the current pyramid |
26,662 | protected void spawnGrid ( Rectangle2D_F64 prevRect ) { spawnRect . p0 . x = prevRect . p0 . x + featureRadius ; spawnRect . p0 . y = prevRect . p0 . y + featureRadius ; spawnRect . p1 . x = prevRect . p1 . x - featureRadius ; spawnRect . p1 . y = prevRect . p1 . y - featureRadius ; double spawnWidth = spawnRect . getW... | Spawn KLT tracks at evenly spaced points inside a grid |
26,663 | public boolean process ( T left , T right ) { if ( first ) { associateL2R ( left , right ) ; first = false ; } else { associateL2R ( left , right ) ; associateF2F ( ) ; cyclicConsistency ( ) ; if ( ! estimateMotion ( ) ) return false ; } return true ; } | Estimates camera egomotion from the stereo pair |
26,664 | private void associateL2R ( T left , T right ) { ImageInfo < TD > tmp = featsLeft1 ; featsLeft1 = featsLeft0 ; featsLeft0 = tmp ; tmp = featsRight1 ; featsRight1 = featsRight0 ; featsRight0 = tmp ; featsLeft1 . reset ( ) ; featsRight1 . reset ( ) ; describeImage ( left , featsLeft1 ) ; describeImage ( right , featsRigh... | Associates image features from the left and right camera together while applying epipolar constraints . |
26,665 | private void associateF2F ( ) { quadViews . reset ( ) ; for ( int i = 0 ; i < detector . getNumberOfSets ( ) ; i ++ ) { SetMatches matches = setMatches [ i ] ; assocSame . setSource ( featsLeft0 . location [ i ] , featsLeft0 . description [ i ] ) ; assocSame . setDestination ( featsLeft1 . location [ i ] , featsLeft1 .... | Associates images between left and left and right and right images |
26,666 | private void cyclicConsistency ( ) { for ( int i = 0 ; i < detector . getNumberOfSets ( ) ; i ++ ) { FastQueue < Point2D_F64 > obs0 = featsLeft0 . location [ i ] ; FastQueue < Point2D_F64 > obs1 = featsRight0 . location [ i ] ; FastQueue < Point2D_F64 > obs2 = featsLeft1 . location [ i ] ; FastQueue < Point2D_F64 > obs... | Create a list of features which have a consistent cycle of matches 0 - > 1 - > 3 and 0 - > 2 - > 3 |
26,667 | private void describeImage ( T left , ImageInfo < TD > info ) { detector . process ( left ) ; for ( int i = 0 ; i < detector . getNumberOfSets ( ) ; i ++ ) { PointDescSet < TD > set = detector . getFeatureSet ( i ) ; FastQueue < Point2D_F64 > l = info . location [ i ] ; FastQueue < TD > d = info . description [ i ] ; f... | Computes image features and stores the results in info |
26,668 | private boolean estimateMotion ( ) { modelFitData . reset ( ) ; Point2D_F64 normLeft = new Point2D_F64 ( ) ; Point2D_F64 normRight = new Point2D_F64 ( ) ; for ( int i = 0 ; i < quadViews . size ; i ++ ) { QuadView obs = quadViews . get ( i ) ; leftImageToNorm . compute ( obs . v0 . x , obs . v0 . y , normLeft ) ; right... | Estimates camera egomotion between the two most recent image frames |
26,669 | public void setEquirectangularShape ( int width , int height ) { super . setEquirectangularShape ( width , height ) ; declareVectors ( width , height ) ; for ( int y = 0 ; y < height ; y ++ ) { for ( int x = 0 ; x < width ; x ++ ) { tools . equiToNormFV ( x , y , vectors [ y * width + x ] ) ; } } } | Specifies the image s width and height |
26,670 | public static < T extends ImageBase < T > > TrackerObjectQuad < T > meanShiftLikelihood ( int maxIterations , int numBins , double maxPixelValue , MeanShiftLikelihoodType modelType , ImageType < T > imageType ) { PixelLikelihood < T > likelihood ; switch ( modelType ) { case HISTOGRAM : likelihood = FactoryTrackerObjec... | Very basic and very fast implementation of mean - shift which uses a fixed sized rectangle for its region . Works best when the target is composed of a single color . |
26,671 | public static < T extends ImageBase < T > > TrackerObjectQuad < T > meanShiftComaniciu2003 ( ConfigComaniciu2003 config , ImageType < T > imageType ) { TrackerMeanShiftComaniciu2003 < T > alg = FactoryTrackerObjectAlgs . meanShiftComaniciu2003 ( config , imageType ) ; return new Comaniciu2003_to_TrackerObjectQuad < > (... | Implementation of mean - shift which matches the histogram and can handle targets composed of multiple colors . The tracker can also be configured to estimate gradual changes in scale . The track region is composed of a rotated rectangle . |
26,672 | public void updateBackground ( T frame , GrayU8 segment ) { updateBackground ( frame ) ; segment ( frame , segment ) ; } | Updates the background and segments it at the same time . In some implementations this can be significantly faster than doing it with separate function calls . Segmentation is performed using the model which it has prior to the update . |
26,673 | public void append ( int bits , int numberOfBits , boolean swapOrder ) { if ( numberOfBits > 32 ) throw new IllegalArgumentException ( "Number of bits exceeds the size of bits" ) ; int indexTail = size ; growArray ( numberOfBits , true ) ; if ( swapOrder ) { for ( int i = 0 ; i < numberOfBits ; i ++ ) { set ( indexTail... | Appends bits on to the end of the stack . |
26,674 | public int read ( int location , int length , boolean swapOrder ) { if ( length < 0 || length > 32 ) throw new IllegalArgumentException ( "Length can't exceed 32" ) ; if ( location + length > size ) throw new IllegalArgumentException ( "Attempting to read past the end" ) ; int output = 0 ; if ( swapOrder ) { for ( int ... | Read bits from the array and store them in an int |
26,675 | public void growArray ( int amountBits , boolean saveValue ) { size = size + amountBits ; int N = size / 8 + ( size % 8 == 0 ? 0 : 1 ) ; if ( N > data . length ) { int extra = Math . min ( 1024 , N + 10 ) ; byte [ ] tmp = new byte [ N + extra ] ; if ( saveValue ) System . arraycopy ( data , 0 , tmp , 0 , data . length ... | Increases the size of the data array so that it can store an addition number of bits |
26,676 | protected boolean computeH ( DMatrixRMaj A , DMatrixRMaj H ) { if ( ! solverNullspace . process ( A . copy ( ) , 1 , H ) ) return true ; H . numRows = 3 ; H . numCols = 3 ; return false ; } | Computes the SVD of A and extracts the homography matrix from its null space |
26,677 | public static void undoNormalizationH ( DMatrixRMaj M , NormalizationPoint2D N1 , NormalizationPoint2D N2 ) { SimpleMatrix a = SimpleMatrix . wrap ( M ) ; SimpleMatrix b = SimpleMatrix . wrap ( N1 . matrix ( ) ) ; SimpleMatrix c_inv = SimpleMatrix . wrap ( N2 . matrixInv ( ) ) ; SimpleMatrix result = c_inv . mult ( a )... | Undoes normalization for a homography matrix . |
26,678 | protected int addConicPairConstraints ( AssociatedPairConic a , AssociatedPairConic b , DMatrixRMaj A , int rowA ) { UtilCurves_F64 . convert ( a . p1 , C1 ) ; UtilCurves_F64 . convert ( a . p2 , V1 ) ; CommonOps_DDF3 . invert ( C1 , C1_inv ) ; CommonOps_DDF3 . invert ( V1 , V1_inv ) ; UtilCurves_F64 . convert ( b . p1... | Add constraint for a pair of conics |
26,679 | protected void initalize ( T input ) { this . input = input ; pixels . resize ( input . width * input . height ) ; initialSegments . reshape ( input . width , input . height ) ; int numberOfUsable = ( input . width - 2 * BORDER ) * ( input . height - 2 * BORDER ) ; gridInterval = ( int ) Math . sqrt ( numberOfUsable / ... | prepares all data structures |
26,680 | protected void initializeClusters ( ) { int offsetX = Math . max ( BORDER , ( ( input . width - 1 ) % gridInterval ) / 2 ) ; int offsetY = Math . max ( BORDER , ( ( input . height - 1 ) % gridInterval ) / 2 ) ; int clusterId = 0 ; clusters . reset ( ) ; for ( int y = offsetY ; y < input . height - BORDER ; y += gridInt... | initialize all the clusters at regularly spaced intervals . Their locations are perturbed a bit to reduce the likelihood of a bad location . Initial color is set to the image color at the location |
26,681 | protected void perturbCenter ( Cluster c , int x , int y ) { float best = Float . MAX_VALUE ; int bestX = 0 , bestY = 0 ; for ( int dy = - 1 ; dy <= 1 ; dy ++ ) { for ( int dx = - 1 ; dx <= 1 ; dx ++ ) { float d = gradient ( x + dx , y + dy ) ; if ( d < best ) { best = d ; bestX = dx ; bestY = dy ; } } } c . x = x + be... | Set the cluster s center to be the pixel in a 3x3 neighborhood with the smallest gradient |
26,682 | protected float gradient ( int x , int y ) { float dx = getIntensity ( x + 1 , y ) - getIntensity ( x - 1 , y ) ; float dy = getIntensity ( x , y + 1 ) - getIntensity ( x , y - 1 ) ; return dx * dx + dy * dy ; } | Computes the gradient at the specified pixel |
26,683 | protected void computeClusterDistance ( ) { for ( int i = 0 ; i < pixels . size ; i ++ ) { pixels . data [ i ] . reset ( ) ; } for ( int i = 0 ; i < clusters . size && ! stopRequested ; i ++ ) { Cluster c = clusters . data [ i ] ; int centerX = ( int ) ( c . x + 0.5f ) ; int centerY = ( int ) ( c . y + 0.5f ) ; int x0 ... | Computes how far away each cluster is from each pixel . Expectation step . |
26,684 | protected void updateClusters ( ) { for ( int i = 0 ; i < clusters . size ; i ++ ) { clusters . data [ i ] . reset ( ) ; } int indexPixel = 0 ; for ( int y = 0 ; y < input . height && ! stopRequested ; y ++ ) { int indexInput = input . startIndex + y * input . stride ; for ( int x = 0 ; x < input . width ; x ++ , index... | Update the value of each cluster using Maximization step . |
26,685 | public void assignLabelsToPixels ( GrayS32 pixelToRegions , GrowQueue_I32 regionMemberCount , FastQueue < float [ ] > regionColor ) { regionColor . reset ( ) ; for ( int i = 0 ; i < clusters . size ( ) ; i ++ ) { float [ ] r = regionColor . grow ( ) ; float [ ] c = clusters . get ( i ) . color ; for ( int j = 0 ; j < n... | Selects which region each pixel belongs to based on which cluster it is the closest to |
26,686 | public void process ( DMatrixRMaj F , List < AssociatedPair > observations , int width , int height ) { int centerX = width / 2 ; int centerY = height / 2 ; MultiViewOps . extractEpipoles ( F , epipole1 , epipole2 ) ; checkEpipoleInside ( width , height ) ; SimpleMatrix R = rotateEpipole ( epipole2 , centerX , centerY ... | Compute rectification transforms for the stereo pair given a fundamental matrix and its observations . |
26,687 | private void checkEpipoleInside ( int width , int height ) { double x1 = epipole1 . x / epipole1 . z ; double y1 = epipole1 . y / epipole1 . z ; double x2 = epipole2 . x / epipole2 . z ; double y2 = epipole2 . y / epipole2 . z ; if ( x1 >= 0 && x1 < width && y1 >= 0 && y1 < height ) throw new IllegalArgumentException (... | The epipoles need to be outside the image |
26,688 | private SimpleMatrix translateToOrigin ( int x0 , int y0 ) { SimpleMatrix T = SimpleMatrix . identity ( 3 ) ; T . set ( 0 , 2 , - x0 ) ; T . set ( 1 , 2 , - y0 ) ; return T ; } | Create a transform which will move the specified point to the origin |
26,689 | private SimpleMatrix computeAffineH ( List < AssociatedPair > observations , DMatrixRMaj H , DMatrixRMaj Hzero ) { SimpleMatrix A = new SimpleMatrix ( observations . size ( ) , 3 ) ; SimpleMatrix b = new SimpleMatrix ( A . numRows ( ) , 1 ) ; Point2D_F64 c = new Point2D_F64 ( ) ; Point2D_F64 k = new Point2D_F64 ( ) ; f... | Finds the values of a b c which minimize |
26,690 | public static URL pathExampleURL ( String path ) { try { File fpath = new File ( path ) ; if ( fpath . isAbsolute ( ) ) return fpath . toURI ( ) . toURL ( ) ; String pathToBase = getPathToBase ( ) ; if ( pathToBase != null ) { File pathExample = new File ( pathToBase , "data/example/" ) ; if ( pathExample . exists ( ) ... | Returns an absolute path to the file that is relative to the example directory |
26,691 | public static URL ensureURL ( String path ) { path = systemToUnix ( path ) ; URL url ; try { url = new URL ( path ) ; if ( url . getProtocol ( ) . equals ( "jar" ) ) { return simplifyJarPath ( url ) ; } } catch ( MalformedURLException e ) { try { url = new File ( path ) . toURI ( ) . toURL ( ) ; } catch ( MalformedURLE... | Given a path which may or may not be a URL return a URL |
26,692 | public static URL simplifyJarPath ( URL url ) { try { String segments [ ] = url . toString ( ) . split ( ".jar!/" ) ; String path = simplifyJarPath ( segments [ 1 ] ) ; return new URL ( segments [ 0 ] + ".jar!/" + path ) ; } catch ( IOException e ) { return url ; } } | Jar paths don t work if they include up directory . this wills trip those out . |
26,693 | public static String path ( String path ) { String pathToBase = getPathToBase ( ) ; if ( pathToBase == null ) return path ; return new File ( pathToBase , path ) . getAbsolutePath ( ) ; } | Searches for the root BoofCV directory and returns an absolute path from it . |
26,694 | public static String getPathToBase ( ) { String path = new File ( "." ) . getAbsoluteFile ( ) . getParent ( ) ; while ( path != null ) { File f = new File ( path ) ; if ( ! f . exists ( ) ) break ; String [ ] files = f . list ( ) ; if ( files == null ) break ; boolean foundMain = false ; boolean foundExamples = false ;... | Steps back until it finds the base BoofCV directory . |
26,695 | public static String selectFile ( boolean exitOnCancel ) { String fileName = null ; JFileChooser fc = new JFileChooser ( ) ; int returnVal = fc . showOpenDialog ( null ) ; if ( returnVal == JFileChooser . APPROVE_OPTION ) { fileName = fc . getSelectedFile ( ) . getAbsolutePath ( ) ; } else if ( exitOnCancel ) { System ... | Opens up a dialog box asking the user to select a file . If the user cancels it either returns null or quits the program . |
26,696 | public static List < String > listByPrefix ( String directory , String prefix , String suffix ) { List < String > ret = new ArrayList < > ( ) ; File d = new File ( directory ) ; if ( ! d . isDirectory ( ) ) { try { URL url = new URL ( directory ) ; if ( url . getProtocol ( ) . equals ( "file" ) ) { d = new File ( url .... | Loads a list of files with the specified prefix . |
26,697 | public static List < String > listAllMime ( String directory , String type ) { List < String > ret = new ArrayList < > ( ) ; try { URL url = new URL ( directory ) ; if ( url . getProtocol ( ) . equals ( "file" ) ) { directory = url . getFile ( ) ; } else if ( url . getProtocol ( ) . equals ( "jar" ) ) { return listJarM... | Lists all files in the directory with an MIME type that contains the string type |
26,698 | public boolean process ( CameraPinholeBrown intrinsic , Se3_F64 planeToCamera ) { proj . setPlaneToCamera ( planeToCamera , true ) ; proj . setIntrinsic ( intrinsic ) ; double x0 = Double . MAX_VALUE ; double y0 = Double . MAX_VALUE ; double x1 = - Double . MAX_VALUE ; double y1 = - Double . MAX_VALUE ; for ( int y = 0... | Computes the view s characteristics |
26,699 | public < T extends ImageBase < T > > OverheadView createOverhead ( ImageType < T > imageType ) { OverheadView ret = new OverheadView ( ) ; ret . image = imageType . createImage ( overheadWidth , overheadHeight ) ; ret . cellSize = cellSize ; ret . centerX = centerX ; ret . centerY = centerY ; return ret ; } | Creates a new instance of the overhead view |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.