idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
27,600 | public void setLensDistortion ( Point2Transform2_F64 pixelToNorm , Point2Transform2_F64 undistToDist ) { if ( pixelToNorm == null ) { this . pixelToNorm = new DoNothing2Transform2_F64 ( ) ; this . undistToDist = new DoNothing2Transform2_F64 ( ) ; } else { this . pixelToNorm = pixelToNorm ; this . undistToDist = undistT... | Specifies transform from pixel to normalize image coordinates |
27,601 | public boolean refine ( Point2D_F64 a , Point2D_F64 b , LineGeneral2D_F64 found ) { center . x = ( a . x + b . x ) / 2.0 ; center . y = ( a . y + b . y ) / 2.0 ; localScale = a . distance ( center ) ; double slopeX = ( b . x - a . x ) ; double slopeY = ( b . y - a . y ) ; double r = Math . sqrt ( slopeX * slopeX + slop... | Fits a line defined by the two points . When fitting the line the weight of the edge is used to determine . how influential the point is . Multiple calls might be required to get a perfect fit . |
27,602 | protected void localToGlobal ( LineGeneral2D_F64 line ) { line . C = localScale * line . C - center . x * line . A - center . y * line . B ; } | Converts the line from local to global image coordinates |
27,603 | public void process ( T image , GrayS32 pixelToRegion , GrowQueue_I32 regionMemberCount , FastQueue < float [ ] > regionColor ) { this . image = image ; regionSums . resize ( regionColor . size ) ; for ( int i = 0 ; i < regionSums . size ; i ++ ) { float v [ ] = regionSums . get ( i ) ; for ( int j = 0 ; j < v . length... | Compute the average color for each region |
27,604 | public boolean process ( PairwiseImageGraph pairwiseGraph ) { this . graph = new MetricSceneGraph ( pairwiseGraph ) ; for ( int i = 0 ; i < graph . edges . size ( ) ; i ++ ) { decomposeEssential ( graph . edges . get ( i ) ) ; } declareModelFitting ( ) ; for ( int i = 0 ; i < graph . edges . size ( ) ; i ++ ) { Motion ... | Processes the paired up scene features and computes an initial estimate for the scene s structure . |
27,605 | void decomposeEssential ( Motion motion ) { List < Se3_F64 > candidates = MultiViewOps . decomposeEssential ( motion . F ) ; int bestScore = 0 ; Se3_F64 best = null ; PositiveDepthConstraintCheck check = new PositiveDepthConstraintCheck ( ) ; for ( int i = 0 ; i < candidates . size ( ) ; i ++ ) { Se3_F64 a_to_b = candi... | Sets the a_to_b transform for the motion given . |
27,606 | double medianTriangulationAngle ( Motion edge ) { GrowQueue_F64 angles = new GrowQueue_F64 ( edge . associated . size ( ) ) ; angles . size = edge . associated . size ( ) ; for ( int i = 0 ; i < edge . associated . size ( ) ; i ++ ) { AssociatedIndex a = edge . associated . get ( i ) ; Point2D_F64 normA = edge . viewSr... | Compares the angle that different observations form when their lines intersect . Returns the median angle . Used to determine if this edge is good for triangulation |
27,607 | private void convertToOutput ( View origin ) { structure = new SceneStructureMetric ( false ) ; observations = new SceneObservations ( viewsAdded . size ( ) ) ; int idx = 0 ; for ( String key : graph . cameras . keySet ( ) ) { cameraToIndex . put ( key , idx ++ ) ; } structure . initialize ( cameraToIndex . size ( ) , ... | Converts the internal data structures into the output format for bundle adjustment . Camera models are omitted since they are not available |
27,608 | void addTriangulatedStereoFeatures ( View base , Motion edge , double scale ) { View viewA = edge . viewSrc ; View viewB = edge . viewDst ; boolean baseIsA = base == viewA ; View other = baseIsA ? viewB : viewA ; edge . a_to_b . T . scale ( scale ) ; Se3_F64 otherToBase = baseIsA ? edge . a_to_b . invert ( null ) : edg... | Adds features which were triangulated using the stereo pair after the scale factor has been determined . Don t mark the other view as being processed . It s 3D pose will be estimated later on using PNP with the new features and features determined later on |
27,609 | static double determineScale ( View base , Motion edge ) throws Exception { View viewA = edge . viewSrc ; View viewB = edge . viewDst ; boolean baseIsA = base == viewA ; Point3D_F64 worldInBase3D = new Point3D_F64 ( ) ; Point3D_F64 localInBase3D = new Point3D_F64 ( ) ; GrowQueue_F64 scales = new GrowQueue_F64 ( ) ; for... | Determine scale factor difference between edge triangulation and world |
27,610 | private void estimateAllFeatures ( View seedA , View seedB ) { List < View > open = new ArrayList < > ( ) ; addUnvistedToStack ( seedA , open ) ; addUnvistedToStack ( seedB , open ) ; while ( ! open . isEmpty ( ) ) { if ( stopRequested ) return ; if ( verbose != null ) verbose . println ( "### open.size=" + open . size... | Perform a breath first search to find the structure of all the remaining camrea views |
27,611 | int countFeaturesWith3D ( View v ) { int count = 0 ; for ( int i = 0 ; i < v . connections . size ( ) ; i ++ ) { Motion m = v . connections . get ( i ) ; boolean isSrc = m . viewSrc == v ; for ( int j = 0 ; j < m . associated . size ( ) ; j ++ ) { AssociatedIndex a = m . associated . get ( j ) ; if ( isSrc ) { count +=... | Count how many 3D features are in view . |
27,612 | boolean determinePose ( View target ) { List < Point2D3D > list = new ArrayList < > ( ) ; List < Feature3D > features = new ArrayList < > ( ) ; GrowQueue_I32 featureIndexes = new GrowQueue_I32 ( ) ; for ( Motion c : target . connections ) { boolean isSrc = c . viewSrc == target ; View other = c . destination ( target )... | Uses the previously found motion between the two cameras to estimate the scale and 3D point of common features . If a feature already has a known 3D point that is not modified . Scale is found by computing the 3D coordinate of all points with a 3D point again then dividing the two distances . New features are also tria... |
27,613 | private void triangulateNoLocation ( View target ) { Se3_F64 otherToTarget = new Se3_F64 ( ) ; Se3_F64 worldToTarget = target . viewToWorld . invert ( null ) ; for ( Motion c : target . connections ) { boolean isSrc = c . viewSrc == target ; View other = c . destination ( target ) ; if ( other . state != ViewState . PR... | Go through all connections to the view and triangulate all features which have not been triangulated already |
27,614 | double triangulationAngle ( Point2D_F64 normA , Point2D_F64 normB , Se3_F64 a_to_b ) { arrowA . set ( normA . x , normA . y , 1 ) ; arrowB . set ( normB . x , normB . y , 1 ) ; GeometryMath_F64 . mult ( a_to_b . R , arrowA , arrowA ) ; return UtilVector3D_F64 . acute ( arrowA , arrowB ) ; } | Computes the acture angle between two vectors . Larger this angle is the better the triangulation of the features 3D location is in general |
27,615 | void addUnvistedToStack ( View viewed , List < View > open ) { for ( int i = 0 ; i < viewed . connections . size ( ) ; i ++ ) { View other = viewed . connections . get ( i ) . destination ( viewed ) ; if ( other . state == ViewState . UNPROCESSED ) { other . state = ViewState . PENDING ; open . add ( other ) ; if ( ver... | Looks to see which connections have yet to be visited and adds them to the open list |
27,616 | void defineCoordinateSystem ( View viewA , Motion motion ) { View viewB = motion . destination ( viewA ) ; viewA . viewToWorld . reset ( ) ; viewB . viewToWorld . set ( motion . motionSrcToDst ( viewB ) ) ; double scale = viewB . viewToWorld . T . norm ( ) ; viewB . viewToWorld . T . scale ( 1.0 / scale ) ; viewsAdded ... | Sets the origin and scale of the coordinate system |
27,617 | View selectOriginNode ( ) { double bestScore = 0 ; View best = null ; if ( verbose != null ) verbose . println ( "selectOriginNode" ) ; for ( int i = 0 ; i < graph . nodes . size ( ) ; i ++ ) { double score = scoreNodeAsOrigin ( graph . nodes . get ( i ) ) ; if ( score > bestScore ) { bestScore = score ; best = graph .... | Select the view which will be coordinate system s origin . This should be a well connected node which have favorable geometry to the other views it s connected to . |
27,618 | Motion selectCoordinateBase ( View view ) { double bestScore = 0 ; Motion best = null ; if ( verbose != null ) verbose . println ( "selectCoordinateBase" ) ; for ( int i = 0 ; i < view . connections . size ( ) ; i ++ ) { Motion e = view . connections . get ( i ) ; double s = e . scoreTriangulation ( ) ; if ( verbose !=... | Select motion which will define the coordinate system . |
27,619 | void triangulateStereoEdges ( Motion edge ) { View viewA = edge . viewSrc ; View viewB = edge . viewDst ; triangulationError . configure ( viewA . camera . pinhole , viewB . camera . pinhole ) ; for ( int i = 0 ; i < edge . associated . size ( ) ; i ++ ) { AssociatedIndex f = edge . associated . get ( i ) ; Point2D_F64... | An edge has been declared as defining a good stereo pair . All associated feature will now be triangulated . It is assumed that there is no global coordinate system at this point . |
27,620 | public static CameraPinhole approximatePinhole ( Point2Transform2_F64 p2n , int width , int height ) { Point2D_F64 na = new Point2D_F64 ( ) ; Point2D_F64 nb = new Point2D_F64 ( ) ; p2n . compute ( 0 , height / 2 , na ) ; p2n . compute ( width - 1 , height / 2 , nb ) ; double abdot = na . x * nb . x + na . y * nb . y + ... | Approximates a pinhole camera using the distoriton model |
27,621 | public static CameraPinhole createIntrinsic ( int width , int height , double hfov , double vfov ) { CameraPinhole intrinsic = new CameraPinhole ( ) ; intrinsic . width = width ; intrinsic . height = height ; intrinsic . cx = width / 2 ; intrinsic . cy = height / 2 ; intrinsic . fx = intrinsic . cx / Math . tan ( UtilA... | Creates a set of intrinsic parameters without distortion for a camera with the specified characteristics |
27,622 | public static CameraPinholeBrown createIntrinsic ( int width , int height , double hfov ) { CameraPinholeBrown intrinsic = new CameraPinholeBrown ( ) ; intrinsic . width = width ; intrinsic . height = height ; intrinsic . cx = width / 2 ; intrinsic . cy = height / 2 ; intrinsic . fx = intrinsic . cx / Math . tan ( Util... | Creates a set of intrinsic parameters without distortion for a camera with the specified characteristics . The focal length is assumed to be the same for x and y . |
27,623 | public static void scaleIntrinsic ( CameraPinhole param , double scale ) { param . width = ( int ) ( param . width * scale ) ; param . height = ( int ) ( param . height * scale ) ; param . cx *= scale ; param . cy *= scale ; param . fx *= scale ; param . fy *= scale ; param . skew *= scale ; } | Multiplies each element of the intrinsic parameters by the provided scale factor . Useful if the image has been rescaled . |
27,624 | public static void invertPinhole ( DMatrix3x3 K , DMatrix3x3 Kinv ) { double fx = K . a11 ; double skew = K . a12 ; double cx = K . a13 ; double fy = K . a22 ; double cy = K . a23 ; Kinv . a11 = 1.0 / fx ; Kinv . a12 = - skew / ( fx * fy ) ; Kinv . a13 = ( skew * cy - cx * fy ) / ( fx * fy ) ; Kinv . a22 = 1.0 / fy ; K... | Analytic matrix inversion to 3x3 camera calibration matrix . Input and output can be the same matrix . Zeros are not set . |
27,625 | public static Point2D_F64 renderPixel ( Se3_F64 worldToCamera , DMatrixRMaj K , Point3D_F64 X ) { return ImplPerspectiveOps_F64 . renderPixel ( worldToCamera , K , X ) ; } | Renders a point in world coordinates into the image plane in pixels or normalized image coordinates . |
27,626 | public static Point2D_F64 renderPixel ( CameraPinhole intrinsic , Point3D_F64 X ) { Point2D_F64 norm = new Point2D_F64 ( X . x / X . z , X . y / X . z ) ; return convertNormToPixel ( intrinsic , norm , norm ) ; } | Renders a point in camera coordinates into the image plane in pixels . |
27,627 | public static Point2D_F64 renderPixel ( DMatrixRMaj worldToCamera , Point3D_F64 X ) { return renderPixel ( worldToCamera , X , ( Point2D_F64 ) null ) ; } | Computes the image coordinate of a point given its 3D location and the camera matrix . |
27,628 | public static double crossRatios ( Point3D_F64 a0 , Point3D_F64 a1 , Point3D_F64 a2 , Point3D_F64 a3 ) { double d01 = a0 . distance ( a1 ) ; double d23 = a2 . distance ( a3 ) ; double d02 = a0 . distance ( a2 ) ; double d13 = a1 . distance ( a3 ) ; return ( d01 * d23 ) / ( d02 * d13 ) ; } | Computes the cross - ratio between 4 points . This is an invariant under projective geometry . |
27,629 | public static void extractColumn ( DMatrixRMaj P , int col , GeoTuple3D_F64 a ) { a . x = P . unsafe_get ( 0 , col ) ; a . y = P . unsafe_get ( 1 , col ) ; a . z = P . unsafe_get ( 2 , col ) ; } | Extracts a column from the camera matrix and puts it into the geometric 3 - tuple . |
27,630 | public static void insertColumn ( DMatrixRMaj P , int col , GeoTuple3D_F64 a ) { P . unsafe_set ( 0 , col , a . x ) ; P . unsafe_set ( 1 , col , a . y ) ; P . unsafe_set ( 2 , col , a . z ) ; } | Inserts 3 - tuple into the camera matrix s columns |
27,631 | public void decompose ( DMatrixRMaj E ) { if ( svd . inputModified ( ) ) { E_copy . set ( E ) ; E = E_copy ; } if ( ! svd . decompose ( E ) ) throw new RuntimeException ( "Svd some how failed" ) ; U = svd . getU ( U , false ) ; V = svd . getV ( V , false ) ; S = svd . getW ( S ) ; SingularOps_DDRM . descendingOrder ( U... | Computes the decomposition from an essential matrix . |
27,632 | private void extractTransform ( DMatrixRMaj U , DMatrixRMaj V , DMatrixRMaj S , Se3_F64 se , boolean optionA , boolean optionB ) { DMatrixRMaj R = se . getR ( ) ; Vector3D_F64 T = se . getT ( ) ; if ( optionA ) CommonOps_DDRM . mult ( U , Rz , temp ) ; else CommonOps_DDRM . multTransB ( U , Rz , temp ) ; CommonOps_DDRM... | There are four possible reconstructions from an essential matrix . This function will compute different permutations depending on optionA and optionB being true or false . |
27,633 | public boolean process ( List < AssociatedPair > points ) { if ( points . size ( ) < estimateHomography . getMinimumPoints ( ) ) throw new IllegalArgumentException ( "At least " + estimateHomography . getMinimumPoints ( ) + " must be provided" ) ; zeroMeanWorldPoints ( points ) ; points = pointsAdj . toList ( ) ; if ( ... | Estimates the transform from world coordinate system to camera given known points and observations . For each observation p1 = World 3D location . z = 0 is implicit . p2 = Observed location of points in image in normalized image coordinates |
27,634 | double computeError ( List < AssociatedPair > points , Se3_F64 worldToCamera ) { double error = 0 ; for ( int i = 0 ; i < points . size ( ) ; i ++ ) { AssociatedPair pair = points . get ( i ) ; tmpP . set ( pair . p1 . x , pair . p1 . y , 0 ) ; SePointOps_F64 . transform ( worldToCamera , tmpP , tmpP ) ; error += pair ... | Computes reprojection error to select best model |
27,635 | private void zeroMeanWorldPoints ( List < AssociatedPair > points ) { center . set ( 0 , 0 ) ; pointsAdj . reset ( ) ; for ( int i = 0 ; i < points . size ( ) ; i ++ ) { AssociatedPair pair = points . get ( i ) ; Point2D_F64 p = pair . p1 ; pointsAdj . grow ( ) . p2 . set ( pair . p2 ) ; center . x += p . x ; center . ... | Ensure zero mean for world location . Creates a local copy of the input |
27,636 | void estimateTranslation ( DMatrixRMaj R , List < AssociatedPair > points , Vector3D_F64 T ) { final int N = points . size ( ) ; W . reshape ( N * 2 , 3 ) ; y . reshape ( N * 2 , 1 ) ; Wty . reshape ( 3 , 1 ) ; DMatrix3x3 Rtmp = new DMatrix3x3 ( ) ; ConvertDMatrixStruct . convert ( R , Rtmp ) ; int indexY = 0 , indexW ... | Estimate s the translation given the previously found rotation |
27,637 | protected void IPPE ( DMatrixRMaj R1 , DMatrixRMaj R2 ) { double norm_v = Math . sqrt ( v1 * v1 + v2 * v2 ) ; if ( norm_v <= UtilEjml . EPS ) { CommonOps_DDRM . setIdentity ( R_v ) ; } else { compute_Rv ( ) ; } compute_B ( B , R_v , v1 , v2 ) ; CommonOps_DDF2 . invert ( B , B ) ; CommonOps_DDF2 . mult ( B , J , A ) ; d... | Solves the IPPE problem |
27,638 | public void learnAndSave ( ) { System . out . println ( "======== Learning Classifier" ) ; AssignCluster < double [ ] > assignment ; if ( new File ( CLUSTER_FILE_NAME ) . exists ( ) ) { assignment = UtilIO . load ( CLUSTER_FILE_NAME ) ; } else { System . out . println ( " Computing clusters" ) ; assignment = computeClu... | Process all the data in the training data set to learn the classifications . See code for details . |
27,639 | private AssignCluster < double [ ] > computeClusters ( ) { System . out . println ( "Image Features" ) ; List < TupleDesc_F64 > features = new ArrayList < > ( ) ; for ( String scene : train . keySet ( ) ) { List < String > imagePaths = train . get ( scene ) ; System . out . println ( " " + scene ) ; for ( String path... | Extract dense features across the training set . Then clusters are found within those features . |
27,640 | public void grow ( ) { if ( tailBlockSize >= blockLength ) { tailBlockSize = 0 ; blocks . grow ( ) ; } BlockIndexLength s = sets . grow ( ) ; s . block = blocks . size - 1 ; s . start = tailBlockSize ; s . length = 0 ; tail = s ; } | Adds a new point set to the end . |
27,641 | public void removeTail ( ) { while ( blocks . size - 1 != tail . block ) blocks . removeTail ( ) ; tailBlockSize = tail . start ; sets . removeTail ( ) ; tail = sets . size > 0 ? sets . get ( sets . size - 1 ) : null ; } | Removes the current point set from the end |
27,642 | public void addPointToTail ( int x , int y ) { int index = tail . start + tail . length * 2 ; int block [ ] ; int blockIndex = tail . block + index / blockLength ; if ( blockIndex == blocks . size ) { tailBlockSize = 0 ; block = blocks . grow ( ) ; } else { block = blocks . get ( blockIndex ) ; } tailBlockSize += 2 ; i... | Adds a point to the tail point set |
27,643 | public void getSet ( int which , FastQueue < Point2D_I32 > list ) { list . reset ( ) ; BlockIndexLength set = sets . get ( which ) ; for ( int i = 0 ; i < set . length ; i ++ ) { int index = set . start + i * 2 ; int blockIndex = set . block + index / blockLength ; index %= blockLength ; int block [ ] = blocks . get ( ... | Copies all the points in the set into the specified list |
27,644 | public void writeOverSet ( int which , List < Point2D_I32 > points ) { BlockIndexLength set = sets . get ( which ) ; if ( set . length != points . size ( ) ) throw new IllegalArgumentException ( "points and set don't have the same length" ) ; for ( int i = 0 ; i < set . length ; i ++ ) { int index = set . start + i * 2... | Overwrites the points in the set with the list of points . |
27,645 | public void viewUpdated ( ) { BufferedImage active = null ; if ( controls . selectedView == 0 ) { active = original ; } else if ( controls . selectedView == 1 ) { synchronized ( lockProcessing ) { VisualizeBinaryData . renderBinary ( detector . getBinary ( ) , false , work ) ; } active = work ; work . setRGB ( 0 , 0 , ... | Called when how the data is visualized has changed |
27,646 | void disconnectSingleConnections ( ) { List < SquareNode > open = new ArrayList < > ( ) ; List < SquareNode > open2 = new ArrayList < > ( ) ; for ( int i = 0 ; i < nodes . size ( ) ; i ++ ) { SquareNode n = nodes . get ( i ) ; checkDisconnectSingleEdge ( open , n ) ; } while ( ! open . isEmpty ( ) ) { for ( int i = 0 ;... | Nodes that have only a single connection to one other node are disconnected since they are likely to be noise . This is done recursively |
27,647 | boolean areMiddlePointsClose ( Point2D_F64 p0 , Point2D_F64 p1 , Point2D_F64 p2 , Point2D_F64 p3 ) { UtilLine2D_F64 . convert ( p0 , p3 , line ) ; double tol1 = p0 . distance ( p1 ) * distanceTol ; if ( Distance2D_F64 . distance ( line , p1 ) > tol1 ) return false ; double tol2 = p2 . distance ( p3 ) * distanceTol ; if... | Returns true if point p1 and p2 are close to the line defined by points p0 and p3 . |
27,648 | public boolean process ( T left , T right ) { this . inputLeft = left ; this . inputRight = right ; tick ++ ; trackerLeft . process ( left ) ; trackerRight . process ( right ) ; if ( first ) { addNewTracks ( ) ; first = false ; } else { mutualTrackDrop ( ) ; selectCandidateTracks ( ) ; boolean failed = ! estimateMotion... | Updates motion estimate using the stereo pair . |
27,649 | private void refineMotionEstimate ( ) { List < Stereo2D3D > data = new ArrayList < > ( ) ; int N = matcher . getMatchSet ( ) . size ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int index = matcher . getInputIndex ( i ) ; PointTrack l = candidates . get ( index ) ; LeftTrackInfo info = l . getCookie ( ) ; PointTrack r = inf... | Non - linear refinement of motion estimate |
27,650 | private boolean estimateMotion ( ) { List < Stereo2D3D > data = new ArrayList < > ( ) ; for ( PointTrack l : candidates ) { LeftTrackInfo info = l . getCookie ( ) ; PointTrack r = info . right ; Stereo2D3D stereo = info . location ; leftImageToNorm . compute ( l . x , l . y , info . location . leftObs ) ; rightImageToN... | Given the set of active tracks estimate the cameras motion robustly |
27,651 | private void mutualTrackDrop ( ) { for ( PointTrack t : trackerLeft . getDroppedTracks ( null ) ) { LeftTrackInfo info = t . getCookie ( ) ; trackerRight . dropTrack ( info . right ) ; } for ( PointTrack t : trackerRight . getDroppedTracks ( null ) ) { RightTrackInfo info = t . getCookie ( ) ; trackerLeft . dropTrack (... | If a track was dropped in one image make sure it was dropped in the other image |
27,652 | private void selectCandidateTracks ( ) { List < PointTrack > activeRight = trackerRight . getActiveTracks ( null ) ; for ( PointTrack t : activeRight ) { RightTrackInfo info = t . getCookie ( ) ; info . lastActiveList = tick ; } int mutualActive = 0 ; List < PointTrack > activeLeft = trackerLeft . getActiveTracks ( nul... | Searches for tracks which are active and meet the epipolar constraints |
27,653 | private void addNewTracks ( ) { trackerLeft . spawnTracks ( ) ; trackerRight . spawnTracks ( ) ; List < PointTrack > newLeft = trackerLeft . getNewTracks ( null ) ; List < PointTrack > newRight = trackerRight . getNewTracks ( null ) ; addNewToList ( inputLeft , newLeft , pointsLeft , descLeft ) ; addNewToList ( inputRi... | Spawns tracks in each image and associates features together . |
27,654 | public void createImages ( ) { image = UtilImageIO . loadImage ( UtilIO . pathExample ( "standard/barbara.jpg" ) ) ; gray = ConvertBufferedImage . convertFromSingle ( image , null , GrayU8 . class ) ; derivX = GeneralizedImageOps . createSingleBand ( GrayS16 . class , gray . getWidth ( ) , gray . getHeight ( ) ) ; deri... | Load and generate images |
27,655 | public static void fillRectangle ( InterleavedS32 img , int value , int x0 , int y0 , int width , int height ) { int x1 = x0 + width ; int y1 = y0 + height ; if ( x0 < 0 ) x0 = 0 ; if ( x1 > img . width ) x1 = img . width ; if ( y0 < 0 ) y0 = 0 ; if ( y1 > img . height ) y1 = img . height ; int length = ( x1 - x0 ) * i... | Draws a filled rectangle that is aligned along the image axis inside the image . All bands are filled with the same value . |
27,656 | public static void flipVertical ( GrayS32 input ) { int h2 = input . height / 2 ; for ( int y = 0 ; y < h2 ; y ++ ) { int index1 = input . getStartIndex ( ) + y * input . getStride ( ) ; int index2 = input . getStartIndex ( ) + ( input . height - y - 1 ) * input . getStride ( ) ; int end = index1 + input . width ; whil... | Flips the image from top to bottom |
27,657 | public static void flipHorizontal ( GrayS32 input ) { int w2 = input . width / 2 ; for ( int y = 0 ; y < input . height ; y ++ ) { int index1 = input . getStartIndex ( ) + y * input . getStride ( ) ; int index2 = index1 + input . width - 1 ; int end = index1 + w2 ; while ( index1 < end ) { int tmp = input . data [ inde... | Flips the image from left to right |
27,658 | public static void rotateCCW ( GrayS64 image ) { if ( image . width != image . height ) throw new IllegalArgumentException ( "Image must be square" ) ; int w = image . height / 2 + image . height % 2 ; int h = image . height / 2 ; for ( int y0 = 0 ; y0 < h ; y0 ++ ) { int y1 = image . height - y0 - 1 ; for ( int x0 = 0... | In - place 90 degree image rotation in the counter - clockwise direction . Only works on square images . |
27,659 | public static void rotateCCW ( GrayS64 input , GrayS64 output ) { if ( input . width != output . height || input . height != output . width ) throw new IllegalArgumentException ( "Incompatible shapes" ) ; int w = input . width - 1 ; for ( int y = 0 ; y < input . height ; y ++ ) { int indexIn = input . startIndex + y * ... | Rotates the image 90 degrees in the counter - clockwise direction . |
27,660 | public static void fillBand ( InterleavedF64 input , int band , double value ) { final int numBands = input . numBands ; for ( int y = 0 ; y < input . height ; y ++ ) { int index = input . getStartIndex ( ) + y * input . getStride ( ) + band ; int end = index + input . width * numBands - band ; for ( ; index < end ; in... | Fills one band in the image with the specified value |
27,661 | public static void fillBorder ( GrayF64 input , double value , int radius ) { for ( int y = 0 ; y < radius ; y ++ ) { int indexTop = input . startIndex + y * input . stride ; int indexBottom = input . startIndex + ( input . height - y - 1 ) * input . stride ; for ( int x = 0 ; x < input . width ; x ++ ) { input . data ... | Fills the outside border with the specified value |
27,662 | public static void fillRectangle ( GrayF64 img , double value , int x0 , int y0 , int width , int height ) { int x1 = x0 + width ; int y1 = y0 + height ; if ( x0 < 0 ) x0 = 0 ; if ( x1 > img . width ) x1 = img . width ; if ( y0 < 0 ) y0 = 0 ; if ( y1 > img . height ) y1 = img . height ; for ( int y = y0 ; y < y1 ; y ++... | Draws a filled rectangle that is aligned along the image axis inside the image . |
27,663 | public static RectangleLength2D_F32 boundBoxInside ( int srcWidth , int srcHeight , PixelTransform < Point2D_F32 > transform , Point2D_F32 work ) { List < Point2D_F32 > points = computeBoundingPoints ( srcWidth , srcHeight , transform , work ) ; Point2D_F32 center = new Point2D_F32 ( ) ; UtilPoint2D_F32 . mean ( points... | Ensures that the entire box will be inside |
27,664 | public void initialize ( T image , RectangleRotate_F32 initial ) { this . region . set ( initial ) ; calcHistogram . computeHistogram ( image , initial ) ; System . arraycopy ( calcHistogram . getHistogram ( ) , 0 , keyHistogram , 0 , keyHistogram . length ) ; this . minimumWidth = initial . width * minimumSizeRatio ; ... | Specifies the initial image to learn the target description |
27,665 | public void track ( T image ) { region0 . set ( region ) ; region1 . set ( region ) ; region2 . set ( region ) ; region0 . width *= 1 - scaleChange ; region0 . height *= 1 - scaleChange ; region2 . width *= 1 + scaleChange ; region2 . height *= 1 + scaleChange ; double distance0 = 1 , distance1 , distance2 = 1 ; if ( !... | Searches for the target in the most recent image . |
27,666 | private int selectBest ( double a , double b , double c ) { if ( a < b ) { if ( a < c ) return 0 ; else return 2 ; } else if ( b <= c ) { return 1 ; } else { return 2 ; } } | Given the 3 scores return the index of the best |
27,667 | protected void updateLocation ( T image , RectangleRotate_F32 region ) { double bestHistScore = Double . MAX_VALUE ; float bestX = - 1 , bestY = - 1 ; for ( int i = 0 ; i < maxIterations ; i ++ ) { calcHistogram . computeHistogram ( image , region ) ; float histogram [ ] = calcHistogram . getHistogram ( ) ; updateWeigh... | Updates the region s location using the standard mean - shift algorithm |
27,668 | private void updateWeights ( float [ ] histogram ) { for ( int j = 0 ; j < weightHistogram . length ; j ++ ) { float h = histogram [ j ] ; if ( h != 0 ) { weightHistogram [ j ] = ( float ) Math . sqrt ( keyHistogram [ j ] / h ) ; } } } | Update the weights for each element in the histogram . Weights are used to favor colors which are less than expected . |
27,669 | protected double distanceHistogram ( float histogramA [ ] , float histogramB [ ] ) { double sumP = 0 ; for ( int i = 0 ; i < histogramA . length ; i ++ ) { float q = histogramA [ i ] ; float p = histogramB [ i ] ; sumP += Math . abs ( q - p ) ; } return sumP ; } | Computes the difference between two histograms using SAD . |
27,670 | public void setImageGradient ( Deriv derivX , Deriv derivY ) { this . imageDerivX . wrap ( derivX ) ; this . imageDerivY . wrap ( derivY ) ; } | Sets the image spacial derivatives . These should be computed from an image at the appropriate scale in scale - space . |
27,671 | public void process ( double c_x , double c_y , double sigma , double orientation , TupleDesc_F64 descriptor ) { descriptor . fill ( 0 ) ; computeRawDescriptor ( c_x , c_y , sigma , orientation , descriptor ) ; normalizeDescriptor ( descriptor , maxDescriptorElementValue ) ; } | Computes the SIFT descriptor for the specified key point |
27,672 | void computeRawDescriptor ( double c_x , double c_y , double sigma , double orientation , TupleDesc_F64 descriptor ) { double c = Math . cos ( orientation ) ; double s = Math . sin ( orientation ) ; float fwidthSubregion = widthSubregion ; int sampleWidth = widthGrid * widthSubregion ; double sampleRadius = sampleWidth... | Computes the descriptor by sampling the input image . This is raw because the descriptor hasn t been massaged yet . |
27,673 | public static void normalizeDescriptor ( TupleDesc_F64 descriptor , double maxDescriptorElementValue ) { UtilFeature . normalizeL2 ( descriptor ) ; for ( int i = 0 ; i < descriptor . size ( ) ; i ++ ) { double value = descriptor . value [ i ] ; if ( value > maxDescriptorElementValue ) { descriptor . value [ i ] = maxDe... | Adjusts the descriptor . This adds lighting invariance and reduces the affects of none - affine changes in lighting . |
27,674 | protected static float [ ] createGaussianWeightKernel ( double sigma , int radius ) { Kernel2D_F32 ker = FactoryKernelGaussian . gaussian2D_F32 ( sigma , radius , false , false ) ; float maxValue = KernelMath . maxAbs ( ker . data , 4 * radius * radius ) ; KernelMath . divide ( ker , maxValue ) ; return ker . data ; } | Creates a gaussian weighting kernel with an even number of elements along its width |
27,675 | protected void trilinearInterpolation ( float weight , float sampleX , float sampleY , double angle , TupleDesc_F64 descriptor ) { for ( int i = 0 ; i < widthGrid ; i ++ ) { double weightGridY = 1.0 - Math . abs ( sampleY - i ) ; if ( weightGridY <= 0 ) continue ; for ( int j = 0 ; j < widthGrid ; j ++ ) { double weigh... | Applies trilinear interpolation across the descriptor |
27,676 | private void computeFeatureMask ( int numModules , int [ ] alignment , boolean hasVersion ) { markSquare ( 0 , 0 , 9 ) ; markRectangle ( numModules - 8 , 0 , 9 , 8 ) ; markRectangle ( 0 , numModules - 8 , 8 , 9 ) ; markRectangle ( 8 , 6 , 1 , numModules - 8 - 8 ) ; markRectangle ( 6 , 8 , numModules - 8 - 8 , 1 ) ; if ... | Blocks out the location of features in the image . Needed for codeworld location extraction |
27,677 | private void computeBitLocations ( ) { int N = numRows ; int row = N - 1 ; int col = N - 1 ; int direction = - 1 ; while ( col > 0 ) { if ( col == 6 ) col -= 1 ; if ( ! get ( row , col ) ) { bits . add ( new Point2D_I32 ( col , row ) ) ; } if ( ! get ( row , col - 1 ) ) { bits . add ( new Point2D_I32 ( col - 1 , row ) ... | Snakes through and specifies the location of each bit for all the code words in the grid . |
27,678 | public static void drawRectangle ( Rectangle2D_I32 rect , Graphics2D g2 ) { g2 . drawLine ( rect . x0 , rect . y0 , rect . x1 , rect . y0 ) ; g2 . drawLine ( rect . x1 , rect . y0 , rect . x1 , rect . y1 ) ; g2 . drawLine ( rect . x0 , rect . y1 , rect . x1 , rect . y1 ) ; g2 . drawLine ( rect . x0 , rect . y1 , rect .... | Draws an axis aligned rectangle |
27,679 | public static SteerableCoefficients polynomial ( int order ) { if ( order == 1 ) return new PolyOrder1 ( ) ; else if ( order == 2 ) return new PolyOrder2 ( ) ; else if ( order == 3 ) return new PolyOrder3 ( ) ; else if ( order == 4 ) return new PolyOrder4 ( ) ; else throw new IllegalArgumentException ( "Only supports o... | Coefficients for even or odd parity polynomials . |
27,680 | private void pruneMatches ( ) { int index = 0 ; while ( index < matches . size ) { AssociatedTripleIndex a = matches . get ( index ) ; if ( a . c == - 1 ) { a . set ( matches . get ( matches . size - 1 ) ) ; matches . size -- ; } else { index ++ ; } } } | Removes by swapping all elements with a c index of - 1 |
27,681 | public void setNumberControl ( int numControl ) { this . numControl = numControl ; if ( numControl == 4 ) { x0 . reshape ( 10 , 1 , false ) ; AA . reshape ( 10 , 9 , false ) ; yy . reshape ( 10 , 1 , false ) ; xx . reshape ( 9 , 1 , false ) ; numNull = 3 ; } else { x0 . reshape ( 6 , 1 , false ) ; AA . reshape ( 4 , 2 ... | Specified the number of control points . |
27,682 | public void process ( DMatrixRMaj L_full , DMatrixRMaj y , double betas [ ] ) { svd . decompose ( L_full ) ; V = svd . getV ( null , true ) ; pseudo . setA ( L_full ) ; pseudo . solve ( y , x0 ) ; DMatrixRMaj alphas = solveConstraintMatrix ( ) ; for ( int i = 0 ; i < x0 . numRows ; i ++ ) { for ( int j = 0 ; j < numNul... | Estimates betas using relinearization . |
27,683 | protected DMatrixRMaj solveConstraintMatrix ( ) { int rowAA = 0 ; for ( int i = 0 ; i < numControl ; i ++ ) { for ( int j = i + 1 ; j < numControl ; j ++ ) { for ( int k = j ; k < numControl ; k ++ , rowAA ++ ) { extractXaXb ( getIndex ( i , i ) , getIndex ( j , k ) , XiiXjk ) ; extractXaXb ( getIndex ( i , k ) , getIn... | Apply additional constraints to reduce the number of possible solutions |
27,684 | public static < T extends ImageGray < T > > void orderBandsIntoRGB ( Planar < T > image , BufferedImage input ) { boolean swap = swapBandOrder ( input ) ; if ( swap ) { if ( image . getNumBands ( ) == 3 ) { int bufferedImageType = input . getType ( ) ; if ( bufferedImageType == BufferedImage . TYPE_3BYTE_BGR || buffere... | If a Planar was created from a BufferedImage its colors might not be in the expected order . Invoking this function ensures that the image will have the expected ordering . For images with 3 bands it will be RGB and for 4 bands it will be ARGB . |
27,685 | public static boolean isKnownByteFormat ( BufferedImage image ) { int type = image . getType ( ) ; return type != BufferedImage . TYPE_BYTE_INDEXED && type != BufferedImage . TYPE_BYTE_BINARY && type != BufferedImage . TYPE_CUSTOM ; } | Checks to see if it is a known byte format |
27,686 | public static List < BufferedImage > loadImages ( String directory , final String regex ) { List < String > paths = UtilIO . listByRegex ( directory , regex ) ; List < BufferedImage > ret = new ArrayList < > ( ) ; if ( paths . size ( ) == 0 ) return ret ; Collections . sort ( paths ) ; for ( String path : paths ) { Buf... | Loads all the image in the specified directory which match the provided regex |
27,687 | public static BufferedImage loadImage ( URL url ) { if ( url == null ) return null ; try { BufferedImage buffered = ImageIO . read ( url ) ; if ( buffered != null ) return buffered ; if ( url . getProtocol ( ) . equals ( "file" ) ) { String path = URLDecoder . decode ( url . getPath ( ) , "UTF-8" ) ; if ( ! new File ( ... | A function that load the specified image . If anything goes wrong it returns a null . |
27,688 | public static < T extends ImageGray < T > > T loadImage ( String fileName , Class < T > imageType ) { BufferedImage img = loadImage ( fileName ) ; if ( img == null ) return null ; return ConvertBufferedImage . convertFromSingle ( img , ( T ) null , imageType ) ; } | Loads the image and converts into the specified image type . |
27,689 | public static BufferedImage loadPPM ( String fileName , BufferedImage storage ) throws IOException { return loadPPM ( new FileInputStream ( fileName ) , storage ) ; } | Loads a PPM image from a file . |
27,690 | public static BufferedImage loadPGM ( String fileName , BufferedImage storage ) throws IOException { return loadPGM ( new FileInputStream ( fileName ) , storage ) ; } | Loads a PGM image from a file . |
27,691 | public static void savePPM ( Planar < GrayU8 > rgb , String fileName , GrowQueue_I8 temp ) throws IOException { File out = new File ( fileName ) ; DataOutputStream os = new DataOutputStream ( new FileOutputStream ( out ) ) ; String header = String . format ( "P6\n%d %d\n255\n" , rgb . width , rgb . height ) ; os . writ... | Saves an image in PPM format . |
27,692 | public static void savePGM ( GrayU8 gray , String fileName ) throws IOException { File out = new File ( fileName ) ; DataOutputStream os = new DataOutputStream ( new FileOutputStream ( out ) ) ; String header = String . format ( "P5\n%d %d\n255\n" , gray . width , gray . height ) ; os . write ( header . getBytes ( ) ) ... | Saves an image in PGM format . |
27,693 | public static < T extends KernelBase > T gaussian ( Class < T > kernelType , double sigma , int radius ) { if ( Kernel1D_F32 . class == kernelType ) { return gaussian ( 1 , true , 32 , sigma , radius ) ; } else if ( Kernel1D_F64 . class == kernelType ) { return gaussian ( 1 , true , 64 , sigma , radius ) ; } else if ( ... | Creates a Gaussian kernel of the specified type . |
27,694 | public static < T extends ImageGray < T > , K extends Kernel1D > K gaussian1D ( Class < T > imageType , double sigma , int radius ) { boolean isFloat = GeneralizedImageOps . isFloatingPoint ( imageType ) ; int numBits = GeneralizedImageOps . getNumBits ( imageType ) ; if ( numBits < 32 ) numBits = 32 ; return gaussian ... | Creates a 1D Gaussian kernel of the specified type . |
27,695 | public static < T extends ImageGray < T > , K extends Kernel2D > K gaussian2D ( Class < T > imageType , double sigma , int radius ) { boolean isFloat = GeneralizedImageOps . isFloatingPoint ( imageType ) ; int numBits = Math . max ( 32 , GeneralizedImageOps . getNumBits ( imageType ) ) ; return gaussian ( 2 , isFloat ,... | Creates a 2D Gaussian kernel of the specified type . |
27,696 | public static < T extends KernelBase > T gaussian ( int DOF , boolean isFloat , int numBits , double sigma , int radius ) { if ( radius <= 0 ) radius = FactoryKernelGaussian . radiusForSigma ( sigma , 0 ) ; else if ( sigma <= 0 ) sigma = FactoryKernelGaussian . sigmaForRadius ( radius , 0 ) ; if ( DOF == 2 ) { if ( num... | Creates a Gaussian kernel with the specified properties . |
27,697 | public static < T extends Kernel1D > T derivative ( int order , boolean isFloat , double sigma , int radius ) { if ( order == 0 ) { return gaussian ( 1 , isFloat , 32 , sigma , radius ) ; } if ( radius <= 0 ) radius = FactoryKernelGaussian . radiusForSigma ( sigma , order ) ; else if ( sigma <= 0 ) { sigma = FactoryKer... | Creates a 1D Gaussian kernel with the specified properties . |
27,698 | public static Kernel2D_F32 gaussian2D_F32 ( double sigma , int radius , boolean odd , boolean normalize ) { Kernel1D_F32 kernel1D = gaussian1D_F32 ( sigma , radius , odd , false ) ; Kernel2D_F32 ret = KernelMath . convolve2D ( kernel1D , kernel1D ) ; if ( normalize ) { KernelMath . normalizeSumToOne ( ret ) ; } return ... | Creates a kernel for a 2D convolution . This should only be used for validation purposes . |
27,699 | protected static Kernel1D_F32 derivative1D_F32 ( int order , double sigma , int radius , boolean normalize ) { Kernel1D_F32 ret = new Kernel1D_F32 ( radius * 2 + 1 ) ; float [ ] gaussian = ret . data ; int index = 0 ; switch ( order ) { case 1 : for ( int i = radius ; i >= - radius ; i -- ) { gaussian [ index ++ ] = ( ... | Computes the derivative of a Gaussian kernel . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.