idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
27,500
private void requestCameraPermission ( ) { int permissionCheck = ContextCompat . checkSelfPermission ( this , Manifest . permission . CAMERA ) ; if ( permissionCheck != android . content . pm . PackageManager . PERMISSION_GRANTED ) { ActivityCompat . requestPermissions ( this , new String [ ] { Manifest . permission . ...
Newer versions of Android require explicit permission from the user
27,501
public static < T extends ImageGray < T > > T bitmapToGray ( Bitmap input , T output , Class < T > imageType , byte [ ] storage ) { if ( imageType == GrayF32 . class ) return ( T ) bitmapToGray ( input , ( GrayF32 ) output , storage ) ; else if ( imageType == GrayU8 . class ) return ( T ) bitmapToGray ( input , ( GrayU...
Converts Bitmap image into a single band image of arbitrary type .
27,502
public static GrayU8 bitmapToGray ( Bitmap input , GrayU8 output , byte [ ] storage ) { if ( output == null ) { output = new GrayU8 ( input . getWidth ( ) , input . getHeight ( ) ) ; } else { output . reshape ( input . getWidth ( ) , input . getHeight ( ) ) ; } if ( storage == null ) storage = declareStorage ( input , ...
Converts Bitmap image into GrayU8 .
27,503
public static < T extends ImageGray < T > > Planar < T > bitmapToPlanar ( Bitmap input , Planar < T > output , Class < T > type , byte [ ] storage ) { if ( output == null ) { output = new Planar < > ( type , input . getWidth ( ) , input . getHeight ( ) , 3 ) ; } else { int numBands = Math . min ( 4 , Math . max ( 3 , o...
Converts Bitmap image into Planar image of the appropriate type .
27,504
public static void boofToBitmap ( ImageBase input , Bitmap output , byte [ ] storage ) { if ( BOverrideConvertAndroid . invokeBoofToBitmap ( ColorFormat . RGB , input , output , storage ) ) return ; if ( input instanceof Planar ) { planarToBitmap ( ( Planar ) input , output , storage ) ; } else if ( input instanceof Im...
Converts many BoofCV image types into a Bitmap .
27,505
public static < T extends ImageGray < T > > void planarToBitmap ( Planar < T > input , Bitmap output , byte [ ] storage ) { if ( output . getWidth ( ) != input . getWidth ( ) || output . getHeight ( ) != input . getHeight ( ) ) { throw new IllegalArgumentException ( "Image shapes are not the same" ) ; } if ( storage ==...
Converts Planar image into Bitmap .
27,506
public static Bitmap grayToBitmap ( GrayU8 input , Bitmap . Config config ) { Bitmap output = Bitmap . createBitmap ( input . width , input . height , config ) ; grayToBitmap ( input , output , null ) ; return output ; }
Converts GrayU8 into a new Bitmap .
27,507
public void process ( FastQueue < AssociatedIndex > matches , int numSource , int numDestination ) { if ( checkSource ) { if ( checkDestination ) { processSource ( matches , numSource , firstPass ) ; processDestination ( firstPass , numDestination , pruned ) ; } else { processSource ( matches , numSource , pruned ) ; }...
Given a set of matches enforce the uniqueness rules it was configured to .
27,508
private void processSource ( FastQueue < AssociatedIndex > matches , int numSource , FastQueue < AssociatedIndex > output ) { scores . resize ( numSource ) ; solutions . resize ( numSource ) ; for ( int i = 0 ; i < numSource ; i ++ ) { solutions . data [ i ] = - 1 ; } for ( int i = 0 ; i < matches . size ( ) ; i ++ ) {...
Selects a subset of matches that have at most one association for each source feature .
27,509
private void processDestination ( FastQueue < AssociatedIndex > matches , int numDestination , FastQueue < AssociatedIndex > output ) { scores . resize ( numDestination ) ; solutions . resize ( numDestination ) ; for ( int i = 0 ; i < numDestination ; i ++ ) { solutions . data [ i ] = - 1 ; } for ( int i = 0 ; i < matc...
Selects a subset of matches that have at most one association for each destination feature .
27,510
private int applyFog ( int rgb , float fraction ) { int adjustment = ( int ) ( 1000 * fraction ) ; int r = ( rgb >> 16 ) & 0xFF ; int g = ( rgb >> 8 ) & 0xFF ; int b = rgb & 0xFF ; r = ( r * adjustment + ( ( backgroundColor >> 16 ) & 0xFF ) * ( 1000 - adjustment ) ) / 1000 ; g = ( g * adjustment + ( ( backgroundColor >...
Fades color into background as a function of distance
27,511
private void renderDot ( int cx , int cy , float Z , int rgb ) { for ( int i = - dotRadius ; i <= dotRadius ; i ++ ) { int y = cy + i ; if ( y < 0 || y >= imageRgb . height ) continue ; for ( int j = - dotRadius ; j <= dotRadius ; j ++ ) { int x = cx + j ; if ( x < 0 || x >= imageRgb . width ) continue ; int pixelIndex...
Renders a dot as a square sprite with the specified color
27,512
protected void imageToOutput ( double x , double y , Point2D_F64 pt ) { pt . x = x / scale - tranX / scale ; pt . y = y / scale - tranY / scale ; }
Converts a coordinate from pixel to the output image coordinates
27,513
protected void outputToImage ( double x , double y , Point2D_F64 pt ) { pt . x = x * scale + tranX ; pt . y = y * scale + tranY ; }
Converts a coordinate from output image coordinates to input image
27,514
public static void RGB_to_PLU8 ( Picture input , Planar < GrayU8 > output ) { if ( input . getColor ( ) != ColorSpace . RGB ) throw new RuntimeException ( "Unexpected input color space!" ) ; if ( output . getNumBands ( ) != 3 ) throw new RuntimeException ( "Unexpected number of bands in output image!" ) ; output . resh...
Converts a picture in JCodec RGB into RGB BoofCV
27,515
static void backsubstitution0134 ( DMatrixRMaj P_plus , DMatrixRMaj P , DMatrixRMaj X , double H [ ] ) { final int N = P . numRows ; DMatrixRMaj tmp = new DMatrixRMaj ( N * 2 , 1 ) ; double H6 = H [ 6 ] ; double H7 = H [ 7 ] ; double H8 = H [ 8 ] ; for ( int i = 0 , index = 0 ; i < N ; i ++ ) { double x = - X . data [ ...
Backsubstitution for solving for 0 1 and 3 4 using solution for 6 7 8
27,516
void constructA678 ( ) { final int N = X1 . numRows ; computePseudo ( X1 , P_plus ) ; DMatrixRMaj PPpXP = new DMatrixRMaj ( 1 , 1 ) ; DMatrixRMaj PPpYP = new DMatrixRMaj ( 1 , 1 ) ; computePPXP ( X1 , P_plus , X2 , 0 , PPpXP ) ; computePPXP ( X1 , P_plus , X2 , 1 , PPpYP ) ; DMatrixRMaj PPpX = new DMatrixRMaj ( 1 , 1 )...
Constructs equation for elements 6 to 8 in H
27,517
public void sanityCheck ( ) { for ( View v : nodes ) { for ( Motion m : v . connections ) { if ( m . viewDst != v && m . viewSrc != v ) throw new RuntimeException ( "Not member of connection" ) ; } } for ( Motion m : edges ) { if ( m . viewDst != m . destination ( m . viewSrc ) ) throw new RuntimeException ( "Unexpecte...
Performs simple checks to see if the data structure is avlid
27,518
public boolean process ( FastQueue < AssociatedPair > pairs , Rectangle2D_F64 targetRectangle ) { if ( ! estimateMotion . process ( pairs . toList ( ) ) ) return false ; ScaleTranslate2D motion = estimateMotion . getModelParameters ( ) ; adjustRectangle ( targetRectangle , motion ) ; if ( targetRectangle . p0 . x < 0 |...
Adjusts target rectangle using track information
27,519
protected void adjustRectangle ( Rectangle2D_F64 rect , ScaleTranslate2D motion ) { rect . p0 . x = rect . p0 . x * motion . scale + motion . transX ; rect . p0 . y = rect . p0 . y * motion . scale + motion . transY ; rect . p1 . x = rect . p1 . x * motion . scale + motion . transX ; rect . p1 . y = rect . p1 . y * mot...
Estimate motion of points inside the rectangle and updates the rectangle using the found motion .
27,520
public void associate ( BufferedImage imageA , BufferedImage imageB ) { T inputA = ConvertBufferedImage . convertFromSingle ( imageA , null , imageType ) ; T inputB = ConvertBufferedImage . convertFromSingle ( imageB , null , imageType ) ; pointsA = new ArrayList < > ( ) ; pointsB = new ArrayList < > ( ) ; FastQueue < ...
Detect and associate point features in the two images . Display the results .
27,521
public static < T extends ImageGray < T > > WaveletDenoiseFilter < T > waveletVisu ( Class < T > imageType , int numLevels , double minPixelValue , double maxPixelValue ) { ImageDataType info = ImageDataType . classToType ( imageType ) ; WaveletTransform descTran = createDefaultShrinkTransform ( info , numLevels , minP...
Denoises an image using VISU Shrink wavelet denoiser .
27,522
public static < T extends ImageGray < T > > WaveletDenoiseFilter < T > waveletBayes ( Class < T > imageType , int numLevels , double minPixelValue , double maxPixelValue ) { ImageDataType info = ImageDataType . classToType ( imageType ) ; WaveletTransform descTran = createDefaultShrinkTransform ( info , numLevels , min...
Denoises an image using BayesShrink wavelet denoiser .
27,523
private static WaveletTransform createDefaultShrinkTransform ( ImageDataType imageType , int numLevels , double minPixelValue , double maxPixelValue ) { WaveletTransform descTran ; if ( ! imageType . isInteger ( ) ) { WaveletDescription < WlCoef_F32 > waveletDesc_F32 = FactoryWaveletDaub . daubJ_F32 ( 4 ) ; descTran = ...
Default wavelet transform used for denoising images .
27,524
public static int minusPOffset ( int index , int offset , int size ) { index -= offset ; if ( index < 0 ) { return size + index ; } else { return index ; } }
Subtracts a positive offset to index in a circular buffer .
27,525
public static int distanceP ( int index0 , int index1 , int size ) { int difference = index1 - index0 ; if ( difference < 0 ) { difference = size + difference ; } return difference ; }
Returns how many elements away in the positive direction you need to travel to get from index0 to index1 .
27,526
public static int subtract ( int index0 , int index1 , int size ) { int distance = distanceP ( index0 , index1 , size ) ; if ( distance >= size / 2 + size % 2 ) { return distance - size ; } else { return distance ; } }
Subtracts index1 from index0 . positive number if its closer in the positive direction or negative if closer in the negative direction . if equal distance then it will return a negative number .
27,527
protected static void removeChildInsidePanel ( JComponent root , JComponent target ) { int N = root . getComponentCount ( ) ; for ( int i = 0 ; i < N ; i ++ ) { try { JPanel p = ( JPanel ) root . getComponent ( i ) ; Component [ ] children = p . getComponents ( ) ; for ( int j = 0 ; j < children . length ; j ++ ) { if ...
Searches inside the children of root for a component that s a JPanel . Then inside the JPanel it looks for the target . If the target is inside the JPanel the JPanel is removed from root .
27,528
protected static void removeChildAndPrevious ( JComponent root , JComponent target ) { int N = root . getComponentCount ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( root . getComponent ( i ) == target ) { root . remove ( i ) ; root . remove ( i - 1 ) ; return ; } } throw new RuntimeException ( "Can't find component" )...
Searches inside the children of root for target . If found it is removed and the previous component .
27,529
public static float distanceSq ( float [ ] a , float [ ] b ) { float ret = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { float d = a [ i ] - b [ i ] ; ret += d * d ; } return ret ; }
Returns the Euclidean distance squared between the two vectors
27,530
protected float weight ( float distance ) { float findex = distance * 100f ; int index = ( int ) findex ; if ( index >= 99 ) return weightTable [ 99 ] ; float sample0 = weightTable [ index ] ; float sample1 = weightTable [ index + 1 ] ; float w = findex - index ; return sample0 * ( 1f - w ) + sample1 * w ; }
Returns the weight given the normalized distance . Instead of computing the kernel distance every time a lookup table with linear interpolation is used . The distance has a domain from 0 to 1 inclusive
27,531
public void process ( ) { processed = true ; for ( int i = 0 ; i < histogram . length ; i ++ ) { histogram [ i ] /= total ; } }
No more features are being added . Normalized the computed histogram .
27,532
public void transform ( GrayU8 binary ) { ImageMiscOps . fill ( transform , 0 ) ; originX = binary . width / 2 ; originY = binary . height / 2 ; r_max = Math . sqrt ( originX * originX + originY * originY ) ; for ( int y = 0 ; y < binary . height ; y ++ ) { int start = binary . startIndex + y * binary . stride ; int st...
Computes the Hough transform of the image .
27,533
public void lineToCoordinate ( LineParametric2D_F32 line , Point2D_F64 coordinate ) { line = line . copy ( ) ; line . p . x -= originX ; line . p . y -= originY ; LinePolar2D_F32 polar = new LinePolar2D_F32 ( ) ; UtilLine2D_F32 . convert ( line , polar ) ; if ( polar . angle < 0 ) { polar . distance = - polar . distanc...
Compute the parameterized coordinate for the line
27,534
public void parameterize ( int x , int y ) { x -= originX ; y -= originY ; int w2 = transform . width / 2 ; for ( int i = 0 ; i < transform . height ; i ++ ) { double p = x * tableTrig . c [ i ] + y * tableTrig . s [ i ] ; int col = ( int ) Math . floor ( p * w2 / r_max ) + w2 ; int index = transform . startIndex + i *...
Converts the pixel coordinate into a line in parameter space
27,535
public void set ( Vector3D_F64 l1 , Vector3D_F64 l2 ) { this . l1 . set ( l1 ) ; this . l2 . set ( l2 ) ; }
Sets the value of p1 and p2 to be equal to the values of the passed in objects
27,536
public void setClassificationData ( List < HistogramScene > memory , int numScenes ) { nn . setPoints ( memory , false ) ; scenes = new double [ numScenes ] ; }
Provides a set of labeled word histograms to use to classify a new image
27,537
public int classify ( T image ) { if ( numNeighbors == 0 ) throw new IllegalArgumentException ( "Must specify number of neighbors!" ) ; describe . process ( image ) ; featureToHistogram . reset ( ) ; List < Desc > imageFeatures = describe . getDescriptions ( ) ; for ( int i = 0 ; i < imageFeatures . size ( ) ; i ++ ) {...
Finds the scene which most resembles the provided image
27,538
public void unusual ( ) { pyramid = FactoryPyramid . discreteGaussian ( new int [ ] { 2 , 6 } , - 1 , 2 , true , ImageType . single ( imageType ) ) ; Kernel1D kernel ; if ( GeneralizedImageOps . isFloatingPoint ( imageType ) ) { kernel = FactoryKernel . table1D_F32 ( 2 , true ) ; } else { kernel = FactoryKernel . table...
Creates a more unusual pyramid and updater .
27,539
public void process ( BufferedImage image ) { T input = ConvertBufferedImage . convertFromSingle ( image , null , imageType ) ; pyramid . process ( input ) ; DiscretePyramidPanel gui = new DiscretePyramidPanel ( ) ; gui . setPyramid ( pyramid ) ; gui . render ( ) ; ShowImages . showWindow ( gui , "Image Pyramid" ) ; T ...
Updates and displays the pyramid .
27,540
public static < T extends ImageGray < T > > ImageFunctionSparse < T > createLaplacian ( Class < T > imageType , ImageBorder < T > border ) { if ( border == null ) { border = FactoryImageBorder . single ( imageType , BorderType . EXTENDED ) ; } if ( GeneralizedImageOps . isFloatingPoint ( imageType ) ) { ImageConvolveSp...
Creates a sparse Laplacian filter .
27,541
public static < T extends ImageGray < T > , G extends GradientValue > SparseImageGradient < T , G > createSobel ( Class < T > imageType , ImageBorder < T > border ) { if ( imageType == GrayF32 . class ) { return ( SparseImageGradient ) new GradientSparseSobel_F32 ( ( ImageBorder_F32 ) border ) ; } else if ( imageType =...
Creates a sparse sobel gradient operator .
27,542
public static < T extends ImageGray < T > , G extends GradientValue > SparseImageGradient < T , G > createPrewitt ( Class < T > imageType , ImageBorder < T > border ) { if ( imageType == GrayF32 . class ) { return ( SparseImageGradient ) new GradientSparsePrewitt_F32 ( ( ImageBorder_F32 ) border ) ; } else if ( imageTy...
Creates a sparse prewitt gradient operator .
27,543
public static < T extends ImageGray < T > , G extends GradientValue > SparseImageGradient < T , G > createThree ( Class < T > imageType , ImageBorder < T > border ) { if ( imageType == GrayF32 . class ) { return ( SparseImageGradient ) new GradientSparseThree_F32 ( ( ImageBorder_F32 ) border ) ; } else if ( imageType =...
Creates a sparse three gradient operator .
27,544
public static < T extends ImageGray < T > , G extends GradientValue > SparseImageGradient < T , G > createTwo0 ( Class < T > imageType , ImageBorder < T > border ) { if ( imageType == GrayF32 . class ) { return ( SparseImageGradient ) new GradientSparseTwo0_F32 ( ( ImageBorder_F32 ) border ) ; } else if ( imageType == ...
Creates a sparse two - 0 gradient operator .
27,545
public static < T extends ImageGray < T > , G extends GradientValue > SparseImageGradient < T , G > createTwo1 ( Class < T > imageType , ImageBorder < T > border ) { if ( imageType == GrayF32 . class ) { return ( SparseImageGradient ) new GradientSparseTwo1_F32 ( ( ImageBorder_F32 ) border ) ; } else if ( imageType == ...
Creates a sparse two - 1 gradient operator .
27,546
public void process ( T image1 , T image2 ) { if ( pyr1 == null || pyr1 . getInputWidth ( ) != image1 . width || pyr1 . getInputHeight ( ) != image1 . height ) { pyr1 = UtilDenseOpticalFlow . standardPyramid ( image1 . width , image1 . height , scale , sigma , 5 , maxLayers , GrayF32 . class ) ; pyr2 = UtilDenseOptical...
Processes the raw input images . Normalizes them and creates image pyramids from them .
27,547
protected static < T extends ImageGray < T > > void imageNormalization ( T image1 , T image2 , GrayF32 normalized1 , GrayF32 normalized2 ) { float max1 = ( float ) GImageStatistics . max ( image1 ) ; float max2 = ( float ) GImageStatistics . max ( image2 ) ; float min1 = ( float ) GImageStatistics . min ( image1 ) ; fl...
Function to normalize the images between 0 and 255 .
27,548
public boolean process ( AssociatedPair p1 , AssociatedPair p2 , AssociatedPair p3 ) { fillM ( p1 . p1 , p2 . p1 , p3 . p1 ) ; b . x = computeB ( p1 . p2 ) ; b . y = computeB ( p2 . p2 ) ; b . z = computeB ( p3 . p2 ) ; if ( ! solver . setA ( M ) ) return false ; GeometryMath_F64 . toMatrix ( b , temp0 ) ; solver . sol...
Estimates the homography from view 1 to view 2 induced by a plane from 3 point associations . Each pair must pass the epipolar constraint . This can fail if the points are colinear .
27,549
private void fillM ( Point2D_F64 x1 , Point2D_F64 x2 , Point2D_F64 x3 ) { M . data [ 0 ] = x1 . x ; M . data [ 1 ] = x1 . y ; M . data [ 2 ] = 1 ; M . data [ 3 ] = x2 . x ; M . data [ 4 ] = x2 . y ; M . data [ 5 ] = 1 ; M . data [ 6 ] = x3 . x ; M . data [ 7 ] = x3 . y ; M . data [ 8 ] = 1 ; }
Fill rows of M with observations from image 1
27,550
public boolean decompose ( DMatrix4x4 Q ) { CommonOps_DDF4 . scale ( 1.0 / Q . a33 , Q ) ; k . a11 = Q . a11 ; k . a12 = Q . a12 ; k . a13 = Q . a13 ; k . a21 = Q . a21 ; k . a22 = Q . a22 ; k . a23 = Q . a23 ; k . a31 = Q . a31 ; k . a32 = Q . a32 ; k . a33 = Q . a33 ; if ( ! CommonOps_DDF3 . invert ( k , w_inv ) ) re...
Decomposes the passed in absolute quadratic
27,551
public void recomputeQ ( DMatrix4x4 Q ) { CommonOps_DDF3 . multTransB ( k , k , w ) ; Q . a11 = w . a11 ; Q . a12 = w . a12 ; Q . a13 = w . a13 ; Q . a21 = w . a21 ; Q . a22 = w . a22 ; Q . a23 = w . a23 ; Q . a31 = w . a31 ; Q . a32 = w . a32 ; Q . a33 = w . a33 ; CommonOps_DDF3 . mult ( w , p , t ) ; CommonOps_DDF3 ....
Recomputes Q from w and p .
27,552
public boolean computeRectifyingHomography ( DMatrixRMaj H ) { H . reshape ( 4 , 4 ) ; H . zero ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { for ( int j = i ; j < 3 ; j ++ ) { H . set ( i , j , k . get ( i , j ) ) ; } } H . set ( 3 , 0 , - ( p . a1 * k . a11 + p . a2 * k . a21 + p . a3 * k . a31 ) ) ; H . set ( 3 , 1 , - (...
Computes the rectifying homography from the decomposed Q
27,553
public void process ( ) { Webcam webcam = UtilWebcamCapture . openDefault ( desiredWidth , desiredHeight ) ; Dimension actualSize = webcam . getViewSize ( ) ; setPreferredSize ( actualSize ) ; setMinimumSize ( actualSize ) ; window . setMinimumSize ( actualSize ) ; window . setPreferredSize ( actualSize ) ; window . se...
Invoke to start the main processing loop .
27,554
public static void easy ( GrayF32 image ) { DetectDescribePoint < GrayF32 , BrightFeature > surf = FactoryDetectDescribe . surfStable ( new ConfigFastHessian ( 0 , 2 , 200 , 2 , 9 , 4 , 4 ) , null , null , GrayF32 . class ) ; surf . detect ( image ) ; System . out . println ( "Found Features: " + surf . getNumberOfFeat...
Use generalized interfaces for working with SURF . This removes much of the drudgery but also reduces flexibility and slightly increases memory and computational requirements .
27,555
public static < II extends ImageGray < II > > void harder ( GrayF32 image ) { Class < II > integralType = GIntegralImageOps . getIntegralType ( GrayF32 . class ) ; NonMaxSuppression extractor = FactoryFeatureExtractor . nonmax ( new ConfigExtract ( 2 , 0 , 5 , true ) ) ; FastHessianFeatureDetector < II > detector = new...
Configured exactly the same as the easy example above but require a lot more code and a more in depth understanding of how SURF works and is configured . Instead of TupleDesc_F64 SurfFeature are computed in this case . They are almost the same as TupleDesc_F64 but contain the Laplacian s sign which can be used to speed...
27,556
public void updateBackground ( MotionModel homeToCurrent , T frame ) { worldToHome . concat ( homeToCurrent , worldToCurrent ) ; worldToCurrent . invert ( currentToWorld ) ; transform . setModel ( currentToWorld ) ; transform . compute ( 0 , 0 , corners [ 0 ] ) ; transform . compute ( frame . width - 1 , 0 , corners [ ...
Updates the background with new image information .
27,557
public void segment ( MotionModel homeToCurrent , T frame , GrayU8 segmented ) { InputSanityCheck . checkSameShape ( frame , segmented ) ; worldToHome . concat ( homeToCurrent , worldToCurrent ) ; worldToCurrent . invert ( currentToWorld ) ; _segment ( currentToWorld , frame , segmented ) ; }
Invoke to use the background image to segment the current frame into background and foreground pixels
27,558
public void process ( Polygon2D_F64 polygon , boolean clockwise ) { int N = polygon . size ( ) ; segments . resize ( N ) ; for ( int i = N - 1 , j = 0 ; j < N ; i = j , j ++ ) { int ii , jj ; if ( clockwise ) { ii = i ; jj = j ; } else { ii = j ; jj = i ; } Point2D_F64 a = polygon . get ( ii ) , b = polygon . get ( jj ...
Processes and adjusts the polygon . If after adjustment a corner needs to be removed because two sides are parallel then the size of the polygon can be changed .
27,559
static int closestCorner4 ( Grid g ) { double bestDistance = g . get ( 0 , 0 ) . center . normSq ( ) ; int bestIdx = 0 ; double d = g . get ( 0 , g . columns - 1 ) . center . normSq ( ) ; if ( d < bestDistance ) { bestDistance = d ; bestIdx = 3 ; } d = g . get ( g . rows - 1 , g . columns - 1 ) . center . normSq ( ) ; ...
Number of CCW rotations to put selected corner into the canonical location . Only works when there are 4 possible solutions
27,560
void rotateGridCCW ( Grid g ) { work . clear ( ) ; for ( int i = 0 ; i < g . rows * g . columns ; i ++ ) { work . add ( null ) ; } for ( int row = 0 ; row < g . rows ; row ++ ) { for ( int col = 0 ; col < g . columns ; col ++ ) { work . set ( col * g . rows + row , g . get ( g . rows - row - 1 , col ) ) ; } } g . ellip...
performs a counter - clockwise rotation
27,561
void reverse ( Grid g ) { work . clear ( ) ; int N = g . rows * g . columns ; for ( int i = 0 ; i < N ; i ++ ) { work . add ( g . ellipses . get ( N - i - 1 ) ) ; } g . ellipses . clear ( ) ; g . ellipses . addAll ( work ) ; }
Reverse the order of elements inside the grid
27,562
static void pruneIncorrectShape ( FastQueue < Grid > grids , int numRows , int numCols ) { for ( int i = grids . size ( ) - 1 ; i >= 0 ; i -- ) { Grid g = grids . get ( i ) ; if ( ( g . rows != numRows || g . columns != numCols ) && ( g . rows != numCols || g . columns != numRows ) ) { grids . remove ( i ) ; } } }
Remove grids which cannot possible match the expected shape
27,563
static void pruneIncorrectSize ( List < List < EllipsesIntoClusters . Node > > clusters , int N ) { for ( int i = clusters . size ( ) - 1 ; i >= 0 ; i -- ) { if ( clusters . get ( i ) . size ( ) != N ) { clusters . remove ( i ) ; } } }
Prune clusters which do not have the expected number of elements
27,564
public boolean process ( T input , GrayU8 binary ) { double maxCornerDistancePixels = maxCornerDistance . computeI ( Math . min ( input . width , input . height ) ) ; s2c . setMaxCornerDistance ( maxCornerDistancePixels ) ; configureContourDetector ( input ) ; boundPolygon . vertexes . reset ( ) ; detectorSquare . proc...
Detects chessboard in the binary image . Square corners must be disconnected . Returns true if a chessboard was found false otherwise .
27,565
public void adjustBeforeOptimize ( Polygon2D_F64 polygon , GrowQueue_B touchesBorder , boolean clockwise ) { int N = polygon . size ( ) ; work . vertexes . resize ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { work . get ( i ) . set ( 0 , 0 ) ; } for ( int i = N - 1 , j = 0 ; j < N ; i = j , j ++ ) { int ii , jj , kk , mm ...
The polygon detected from the contour is too small because the binary image was eroded . This expand the size of the polygon so that it fits the image edge better
27,566
boolean computeCalibrationPoints ( SquareGrid grid ) { calibrationPoints . reset ( ) ; for ( int row = 0 ; row < grid . rows - 1 ; row ++ ) { int offset = row % 2 ; for ( int col = offset ; col < grid . columns ; col += 2 ) { SquareNode a = grid . get ( row , col ) ; if ( col > 0 ) { SquareNode b = grid . get ( row + 1...
Find inner corner points across the grid . Start from the top row and work its way down . Corners are found by finding the average point between two adjacent corners on adjacent squares .
27,567
public static void process ( GrayI input , GrayI output , int radius , int [ ] storage ) { int w = 2 * radius + 1 ; if ( storage == null ) { storage = new int [ w * w ] ; } else if ( storage . length < w * w ) { throw new IllegalArgumentException ( "'storage' must be at least of length " + ( w * w ) ) ; } for ( int y =...
Performs a median filter .
27,568
public static < I extends ImageGray < I > , D extends ImageGray < D > > PointTracker < I > dda_ST_BRIEF ( int maxAssociationError , ConfigGeneralDetector configExtract , Class < I > imageType , Class < D > derivType ) { if ( derivType == null ) derivType = GImageDerivativeOps . getDerivativeType ( imageType ) ; Describ...
Creates a tracker which detects Shi - Tomasi corner features and describes them with BRIEF .
27,569
public static < I extends ImageGray < I > , D extends ImageGray < D > > PointTracker < I > dda_FAST_BRIEF ( ConfigFastCorner configFast , ConfigGeneralDetector configExtract , int maxAssociationError , Class < I > imageType ) { DescribePointBrief < I > brief = FactoryDescribePointAlgs . brief ( FactoryBriefDefinition ....
Creates a tracker which detects FAST corner features and describes them with BRIEF .
27,570
public static < I extends ImageGray < I > , Desc extends TupleDesc > DetectDescribeAssociate < I , Desc > dda ( InterestPointDetector < I > detector , OrientationImage < I > orientation , DescribeRegionPoint < I , Desc > describe , AssociateDescription2D < Desc > associate , ConfigTrackerDda config ) { DetectDescribeFu...
Creates a tracker which uses the detect describe associate architecture .
27,571
public static < I extends ImageGray < I > > PointTracker < I > combined_FH_SURF_KLT ( PkltConfig kltConfig , int reactivateThreshold , ConfigFastHessian configDetector , ConfigSurfDescribe . Stability configDescribe , ConfigSlidingIntegral configOrientation , Class < I > imageType ) { ScoreAssociation < TupleDesc_F64 >...
Creates a tracker which detects Fast - Hessian features describes them with SURF nominally tracks them using KLT .
27,572
public static < I extends ImageGray < I > , D extends ImageGray < D > > GeneralFeatureDetector < I , D > createShiTomasi ( ConfigGeneralDetector config , Class < D > derivType ) { GradientCornerIntensity < D > cornerIntensity = FactoryIntensityPointAlg . shiTomasi ( 1 , false , derivType ) ; return FactoryDetectPoint ....
Creates a Shi - Tomasi corner detector specifically designed for SFM . Smaller feature radius work better . Variable detectRadius to control the number of features . When larger features are used weighting should be set to true but because this is so small it is set to false
27,573
public void handleWebcam ( ) { final Webcam webcam = openSelectedCamera ( ) ; if ( desiredWidth > 0 && desiredHeight > 0 ) UtilWebcamCapture . adjustResolution ( webcam , desiredWidth , desiredHeight ) ; webcam . open ( ) ; Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( ) { public void run ( ) { if ( webcam ...
Captures calibration data live using a webcam and a GUI to assist the user
27,574
public void setTemplate ( GrayF32 image , List < Point2D_F64 > sides ) { if ( sides . size ( ) != 4 ) throw new IllegalArgumentException ( "Expected 4 sidesCollision" ) ; removePerspective . apply ( image , sides . get ( 0 ) , sides . get ( 1 ) , sides . get ( 2 ) , sides . get ( 3 ) ) ; templateOriginal . setTo ( remo...
Creates a template of the fiducial and this is then used to determine how blurred the image is
27,575
public synchronized void process ( GrayF32 image , List < Point2D_F64 > sides ) { if ( sides . size ( ) != 4 ) throw new IllegalArgumentException ( "Expected 4 sidesCollision" ) ; updateScore ( image , sides ) ; if ( currentScore < bestScore ) { bestScore = currentScore ; if ( bestImage == null ) { bestImage = new Buff...
Computes the sharpness score for the current image if better than the current best image it s then saved .
27,576
public synchronized void updateScore ( GrayF32 image , List < Point2D_F64 > sides ) { removePerspective . apply ( image , sides . get ( 0 ) , sides . get ( 1 ) , sides . get ( 2 ) , sides . get ( 3 ) ) ; GrayF32 current = removePerspective . getOutput ( ) ; float mean = ( float ) ImageStatistics . mean ( current ) ; Pi...
Used when you just want to update the score for visualization purposes but not update the best image .
27,577
public synchronized void save ( ) { if ( bestImage != null ) { File path = new File ( outputDirectory , String . format ( "image%04d.png" , imageNumber ) ) ; UtilImageIO . saveImage ( bestImage , path . getAbsolutePath ( ) ) ; imageNumber ++ ; } clearHistory ( ) ; }
Saves the image to a file
27,578
public void setImageRepaint ( BufferedImage image ) { ScaleOffset workspace ; if ( SwingUtilities . isEventDispatchThread ( ) ) { workspace = adjustmentGUI ; } else { workspace = new ScaleOffset ( ) ; } repaintJustImage ( img , workspace ) ; this . img = image ; if ( image != null ) { repaintJustImage ( img , workspace...
Changes the buffered image and calls repaint . Does not need to be called in the UI thread .
27,579
private void computeContainment ( int imageArea ) { contRect . x0 = contRect . y0 = Double . MAX_VALUE ; contRect . x1 = contRect . y1 = - Double . MAX_VALUE ; for ( AssociatedPair p : motion . getModelMatcher ( ) . getMatchSet ( ) ) { Point2D_F64 t = p . p2 ; if ( t . x > contRect . x1 ) contRect . x1 = t . x ; if ( t...
Computes an axis - aligned rectangle that contains all the inliers . It then computes the area contained in that rectangle to the total area of the image
27,580
public boolean pruneViews ( int count ) { List < SceneStructureProjective . View > remainingS = new ArrayList < > ( ) ; List < SceneObservations . View > remainingO = new ArrayList < > ( ) ; int counts [ ] = new int [ structure . views . length ] ; for ( int pointIdx = 0 ; pointIdx < structure . points . length ; point...
Removes views with less than count features visible . Observations of features in removed views are also removed . Features are not automatically removed even if there are zero observations of them .
27,581
public void process ( Input left , Input right , Disparity disparity ) { InputSanityCheck . checkSameShape ( left , right , disparity ) ; if ( maxDisparity > left . width - 2 * radiusX ) throw new RuntimeException ( "The maximum disparity is too large for this image size: max size " + ( left . width - 2 * radiusX ) ) ;...
Computes disparity between two stereo images
27,582
public GeometricResult solve ( ) { if ( cameras . size < minimumProjectives ) throw new IllegalArgumentException ( "You need at least " + minimumProjectives + " motions" ) ; int N = cameras . size ; DMatrixRMaj L = new DMatrixRMaj ( N * eqs , 10 ) ; constructMatrix ( L ) ; if ( ! svd . decompose ( L ) ) { return Geomet...
Solve for camera calibration . A sanity check is performed to ensure that a valid calibration is found . All values must be countable numbers and the focal lengths must be positive numbers .
27,583
private void extractSolutionForQ ( DMatrix4x4 Q ) { DMatrixRMaj nv = new DMatrixRMaj ( 10 , 1 ) ; SingularOps_DDRM . nullVector ( svd , true , nv ) ; encodeQ ( Q , nv . data ) ; if ( Q . a11 < 0 || Q . a22 < 0 || Q . a33 < 0 ) { CommonOps_DDF4 . scale ( - 1 , Q ) ; } }
Extracts the null space and converts it into the Q matrix
27,584
private void computeSolutions ( DMatrix4x4 Q ) { DMatrixRMaj w_i = new DMatrixRMaj ( 3 , 3 ) ; for ( int i = 0 ; i < cameras . size ; i ++ ) { computeW ( cameras . get ( i ) , Q , w_i ) ; Intrinsic calib = solveForCalibration ( w_i ) ; if ( sanityCheck ( calib ) ) { solutions . add ( calib ) ; } } }
Computes the calibration for each view ..
27,585
private Intrinsic solveForCalibration ( DMatrixRMaj w ) { Intrinsic calib = new Intrinsic ( ) ; if ( zeroSkew ) { calib . skew = 0 ; calib . fy = Math . sqrt ( w . get ( 1 , 1 ) ) ; if ( knownAspect ) { calib . fx = calib . fy / aspectRatio ; } else { calib . fx = Math . sqrt ( w . get ( 0 , 0 ) ) ; } } else if ( known...
Given the solution for w and the constraints solve for the remaining parameters
27,586
boolean sanityCheck ( Intrinsic calib ) { if ( UtilEjml . isUncountable ( calib . fx ) ) return false ; if ( UtilEjml . isUncountable ( calib . fy ) ) return false ; if ( UtilEjml . isUncountable ( calib . skew ) ) return false ; if ( calib . fx < 0 ) return false ; if ( calib . fy < 0 ) return false ; return true ; }
Makes sure that the found solution is valid and physically possible
27,587
private int selectRightToLeft ( int col , int [ ] scores ) { int localMax = Math . min ( imageWidth - regionWidth , col + maxDisparity ) - col - minDisparity ; int indexBest = 0 ; int indexScore = col ; int scoreBest = scores [ col ] ; indexScore += imageWidth + 1 ; for ( int i = 1 ; i < localMax ; i ++ , indexScore +=...
Finds the best disparity going from right to left image .
27,588
public void process ( FastQueue < TldRegion > regions , FastQueue < TldRegion > output ) { final int N = regions . size ; conn . growArray ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { conn . data [ i ] . reset ( ) ; } for ( int i = 0 ; i < N ; i ++ ) { TldRegion ra = regions . get ( i ) ; Connections ca = conn . data [ i...
Finds local maximums from the set of provided regions
27,589
public T createImage ( int width , int height ) { switch ( family ) { case GRAY : return ( T ) GeneralizedImageOps . createSingleBand ( getImageClass ( ) , width , height ) ; case INTERLEAVED : return ( T ) GeneralizedImageOps . createInterleaved ( getImageClass ( ) , width , height , numBands ) ; case PLANAR : return ...
Creates a new image .
27,590
public T [ ] createArray ( int length ) { switch ( family ) { case GRAY : case INTERLEAVED : return ( T [ ] ) Array . newInstance ( getImageClass ( ) , length ) ; case PLANAR : return ( T [ ] ) new Planar [ length ] ; default : throw new IllegalArgumentException ( "Type not yet supported" ) ; } }
Creates an array of the specified iamge type
27,591
public boolean isSameType ( ImageType o ) { if ( family != o . family ) return false ; if ( dataType != o . dataType ) return false ; if ( numBands != o . numBands ) return false ; return true ; }
Returns true if the passed in ImageType is the same as this image type
27,592
public void setTo ( ImageType o ) { this . family = o . family ; this . dataType = o . dataType ; this . numBands = o . numBands ; }
Sets this to be identical to o
27,593
void growCellArray ( int imageWidth , int imageHeight ) { cellCols = imageWidth / pixelsPerCell ; cellRows = imageHeight / pixelsPerCell ; if ( cellRows * cellCols > cells . length ) { Cell [ ] a = new Cell [ cellCols * cellRows ] ; System . arraycopy ( cells , 0 , a , 0 , cells . length ) ; for ( int i = cells . lengt...
Determines if the cell array needs to grow . If it does a new array is declared . Old data is recycled when possible
27,594
public void getDescriptorsInRegion ( int pixelX0 , int pixelY0 , int pixelX1 , int pixelY1 , List < TupleDesc_F64 > output ) { int gridX0 = ( int ) Math . ceil ( pixelX0 / ( double ) pixelsPerCell ) ; int gridY0 = ( int ) Math . ceil ( pixelY0 / ( double ) pixelsPerCell ) ; int gridX1 = pixelX1 / pixelsPerCell - cellsP...
Convenience function which returns a list of all the descriptors computed inside the specified region in the image
27,595
void computeCellHistograms ( ) { int width = cellCols * pixelsPerCell ; int height = cellRows * pixelsPerCell ; float angleBinSize = GrlConstants . F_PI / orientationBins ; int indexCell = 0 ; for ( int i = 0 ; i < height ; i += pixelsPerCell ) { for ( int j = 0 ; j < width ; j += pixelsPerCell , indexCell ++ ) { Cell ...
Compute histograms for all the cells inside the image using precomputed derivative .
27,596
public void detect ( II grayII , Planar < II > colorII ) { descriptions . reset ( ) ; featureAngles . reset ( ) ; detector . detect ( grayII ) ; foundPoints = detector . getFoundPoints ( ) ; descriptions . resize ( foundPoints . size ( ) ) ; featureAngles . resize ( foundPoints . size ( ) ) ; describe ( grayII , colorI...
Detects and describes features inside provide images . All images are integral images .
27,597
public List < Point3D_F64 > getLandmark3D ( int version ) { int N = QrCode . totalModules ( version ) ; set3D ( 0 , 0 , N , point3D . get ( 0 ) ) ; set3D ( 0 , 7 , N , point3D . get ( 1 ) ) ; set3D ( 7 , 7 , N , point3D . get ( 2 ) ) ; set3D ( 7 , 0 , N , point3D . get ( 3 ) ) ; set3D ( 0 , N - 7 , N , point3D . get ( ...
Location of each corner in the QR Code s reference frame in 3D
27,598
private void setPair ( int which , int row , int col , int N , Point2D_F64 pixel ) { set3D ( row , col , N , point23 . get ( which ) . location ) ; pixelToNorm . compute ( pixel . x , pixel . y , point23 . get ( which ) . observation ) ; }
Specifies PNP parameters for a single feature
27,599
private void set3D ( int row , int col , int N , Point3D_F64 location ) { double _N = N ; double gridX = 2.0 * ( col / _N - 0.5 ) ; double gridY = 2.0 * ( 0.5 - row / _N ) ; location . set ( gridX , gridY , 0 ) ; }
Specifies 3D location of landmark in marker coordinate system