code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
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.CAMERA},
0);
... | java |
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,(GrayU8)output,storage);
else
... | java |
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,null);
inpu... | java |
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,output.getNumBands()));
output.resh... | java |
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 ImageGray ) {
grayT... | java |
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 == null )
storage = ... | java |
public static Bitmap grayToBitmap( GrayU8 input , Bitmap.Config config ) {
Bitmap output = Bitmap.createBitmap(input.width, input.height, config);
grayToBitmap(input,output,null);
return output;
} | java |
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);
}
... | java |
private void processSource(FastQueue<AssociatedIndex> matches, int numSource,
FastQueue<AssociatedIndex> output ) {
//set up data structures
scores.resize(numSource);
solutions.resize(numSource);
for( int i =0; i < numSource; i++ ) {
solutions.data[i] = -1;
}
// select best matches
for( int ... | java |
private void processDestination(FastQueue<AssociatedIndex> matches, int numDestination,
FastQueue<AssociatedIndex> output ) {
//set up data structures
scores.resize(numDestination);
solutions.resize(numDestination);
for( int i =0; i < numDestination; i++ ) {
solutions.data[i] = -1;
}
// select ... | java |
private int applyFog( int rgb , float fraction ) {
// avoid floating point math
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 + ((backgroundCo... | java |
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 pixe... | java |
protected void imageToOutput( double x , double y , Point2D_F64 pt ) {
pt.x = x/scale - tranX/scale;
pt.y = y/scale - tranY/scale;
} | java |
protected void outputToImage( double x , double y , Point2D_F64 pt ) {
pt.x = x*scale + tranX;
pt.y = y*scale + tranY;
} | java |
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.reshape(input.getWid... | java |
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[index],y = ... | java |
void constructA678() {
final int N = X1.numRows;
// Pseudo-inverse of hat(p)
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);
D... | java |
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... | java |
public boolean process( FastQueue<AssociatedPair> pairs , Rectangle2D_F64 targetRectangle ) {
// estimate how the rectangle has changed and update it
if( !estimateMotion.process(pairs.toList()) )
return false;
ScaleTranslate2D motion = estimateMotion.getModelParameters();
adjustRectangle(targetRectangle,mo... | java |
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*motion.scale + motion.transY;
} | java |
public void associate( BufferedImage imageA , BufferedImage imageB )
{
T inputA = ConvertBufferedImage.convertFromSingle(imageA, null, imageType);
T inputB = ConvertBufferedImage.convertFromSingle(imageB, null, imageType);
// stores the location of detected interest points
pointsA = new ArrayList<>();
point... | java |
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,minPixelValue,maxPixe... | java |
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,minPixelValue,maxPix... | java |
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);
des... | java |
public static int minusPOffset(int index, int offset, int size) {
index -= offset;
if( index < 0 ) {
return size + index;
} else {
return index;
}
} | java |
public static int distanceP(int index0, int index1, int size) {
int difference = index1-index0;
if( difference < 0 ) {
difference = size+difference;
}
return difference;
} | java |
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;
}
} | java |
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( children... | java |
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");
} | java |
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;
} | java |
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;
} | java |
@Override
public void process() {
processed = true;
for (int i = 0; i < histogram.length; i++) {
histogram[i] /= total;
}
} | java |
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 stop = start + binary.widt... | java |
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.distance;
polar.angle = ... | java |
public void parameterize( int x , int y )
{
// put the point in a new coordinate system centered at the image's origin
x -= originX;
y -= originY;
int w2 = transform.width/2;
// The line's slope is encoded using the tangent angle. Those bins are along the image's y-axis
for( int i = 0; i < transform.hei... | java |
public void set( Vector3D_F64 l1 , Vector3D_F64 l2 ) {
this.l1.set(l1);
this.l2.set(l2);
} | java |
public void setClassificationData(List<HistogramScene> memory , int numScenes ) {
nn.setPoints(memory, false);
scenes = new double[ numScenes ];
} | java |
public int classify(T image) {
if( numNeighbors == 0 )
throw new IllegalArgumentException("Must specify number of neighbors!");
// compute all the features inside the image
describe.process(image);
// find which word the feature matches and construct a frequency histogram
featureToHistogram.reset();
Li... | java |
public void unusual() {
// Note that the first level does not have to be one
pyramid = FactoryPyramid.discreteGaussian(new int[]{2,6},-1,2,true, ImageType.single(imageType));
// Other kernels can also be used besides Gaussian
Kernel1D kernel;
if(GeneralizedImageOps.isFloatingPoint(imageType) ) {
kernel = ... | java |
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");
// To get an image at ... | java |
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)) {
ImageConvolveSparse<GrayF32, Ker... | java |
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 == GrayU8.class ){
ret... | java |
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( imageType == GrayU8.class ){
... | java |
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 == GrayU8.class ){
ret... | java |
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 == GrayU8.class ){
retur... | java |
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 == GrayU8.class ){
retur... | java |
public void process( T image1 , T image2 )
{
// declare image data structures
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 = Util... | java |
protected static<T extends ImageGray<T>>
void imageNormalization(T image1, T image2, GrayF32 normalized1, GrayF32 normalized2 )
{
// find the max and min of both images
float max1 = (float)GImageStatistics.max(image1);
float max2 = (float)GImageStatistics.max(image2);
float min1 = (float)GImageStatistics.min(... | java |
public boolean process(AssociatedPair p1, AssociatedPair p2, AssociatedPair p3) {
// Fill rows of M with observations from image 1
fillM(p1.p1,p2.p1,p3.p1);
// Compute 'b' vector
b.x = computeB(p1.p2);
b.y = computeB(p2.p2);
b.z = computeB(p3.p2);
// A_inv_b = inv(A)*b
if( !solver.setA(M) )
return... | java |
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;
} | java |
public boolean decompose( DMatrix4x4 Q ) {
// scale Q so that Q(3,3) = 1 to provide a uniform scaling
CommonOps_DDF4.scale(1.0/Q.a33,Q);
// TODO consider using eigen decomposition like it was suggested
// Directly extract from the definition of Q
// Q = [w -w*p;-p'*w p'*w*p]
// w = k*k'
k.a11 = Q.a11;k... | java |
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.scale(-1,t);
Q.a14 = t.a1;Q.a24 = t.a2;Q.a34 = t.a3;
Q... | java |
public boolean computeRectifyingHomography( DMatrixRMaj H ) {
H.reshape(4,4);
// insert the results into H
// H = [K 0;-p'*K 1 ]
H.zero();
for (int i = 0; i < 3; i++) {
for (int j = i; j < 3; j++) {
H.set(i,j,k.get(i,j));
}
}
// p and k have different scales, fix that
H.set(3,0, -(p.a1*k.a11 ... | java |
public void process() {
Webcam webcam = UtilWebcamCapture.openDefault(desiredWidth,desiredHeight);
// adjust the window size and let the GUI know it has changed
Dimension actualSize = webcam.getViewSize();
setPreferredSize(actualSize);
setMinimumSize(actualSize);
window.setMinimumSize(actualSize);
window... | java |
public static void easy( GrayF32 image ) {
// create the detector and descriptors
DetectDescribePoint<GrayF32,BrightFeature> surf = FactoryDetectDescribe.
surfStable(new ConfigFastHessian(0, 2, 200, 2, 9, 4, 4), null, null,GrayF32.class);
// specify the image to process
surf.detect(image);
System.out.p... | java |
public static <II extends ImageGray<II>> void harder(GrayF32 image ) {
// SURF works off of integral images
Class<II> integralType = GIntegralImageOps.getIntegralType(GrayF32.class);
// define the feature detection algorithm
NonMaxSuppression extractor =
FactoryFeatureExtractor.nonmax(new ConfigExtract(2... | java |
public void updateBackground(MotionModel homeToCurrent, T frame) {
worldToHome.concat(homeToCurrent, worldToCurrent);
worldToCurrent.invert(currentToWorld);
// find the distorted polygon of the current image in the "home" background reference frame
transform.setModel(currentToWorld);
transform.compute(0, 0, ... | java |
public void segment( MotionModel homeToCurrent , T frame , GrayU8 segmented ) {
InputSanityCheck.checkSameShape(frame,segmented);
worldToHome.concat(homeToCurrent, worldToCurrent);
worldToCurrent.invert(currentToWorld);
_segment(currentToWorld,frame,segmented);
} | java |
public void process( Polygon2D_F64 polygon, boolean clockwise) {
int N = polygon.size();
segments.resize(N);
// Apply the adjustment independently to each side
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;
}
Point2... | java |
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();
if( d < bestDistance ) {
bestDistanc... | java |
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.ellipses.clear();
g.ellipses.add... | java |
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);
} | java |
static void pruneIncorrectShape(FastQueue<Grid> grids , int numRows, int numCols ) {
// prune clusters which can't be a member calibration target
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)) {... | java |
static void pruneIncorrectSize(List<List<EllipsesIntoClusters.Node>> clusters, int N) {
// prune clusters which can't be a member calibration target
for (int i = clusters.size()-1; i >= 0; i--) {
if( clusters.get(i).size() != N ) {
clusters.remove(i);
}
}
} | java |
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.process(input, binary);
de... | java |
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;
if( clockwise ) {
mm = ... | java |
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,col-1);
if... | java |
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 = 0; y < input.... | java |
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);
Descri... | java |
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(FactoryBriefDe... | java |
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 ) {
... | java |
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> i... | java |
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.createGener... | java |
public void handleWebcam() {
final Webcam webcam = openSelectedCamera();
if( desiredWidth > 0 && desiredHeight > 0 )
UtilWebcamCapture.adjustResolution(webcam, desiredWidth, desiredHeight);
webcam.open();
// close the webcam gracefully on exit
Runtime.getRuntime().addShutdownHook(new Thread(){public void... | java |
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(removePerspective.getOutput());
// blur the ... | java |
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 Buffered... | java |
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);
PixelMath.divide(current,mean,tempImage);
Pix... | java |
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();
} | java |
public void setImageRepaint(BufferedImage image) {
// if image is larger before than the new image then you need to make sure you repaint
// the entire image otherwise a ghost will be left
ScaleOffset workspace;
if( SwingUtilities.isEventDispatchThread() ) {
workspace = adjustmentGUI;
} else {
workspac... | java |
private void computeContainment( int imageArea ) {
// mark that the track is in the inlier set and compute the containment rectangle
contRect.x0 = contRect.y0 = Double.MAX_VALUE;
contRect.x1 = contRect.y1 = -Double.MAX_VALUE;
for( AssociatedPair p : motion.getModelMatcher().getMatchSet() ) {
Point2D_F64 t = ... | java |
public boolean pruneViews(int count) {
List<SceneStructureProjective.View> remainingS = new ArrayList<>();
List<SceneObservations.View> remainingO = new ArrayList<>();
// count number of observations in each view
int counts[] = new int[structure.views.length];
for (int pointIdx = 0; pointIdx < structure.poin... | java |
public void process( Input left , Input right , Disparity disparity ) {
// initialize data structures
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.w... | java |
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);
// Convert constraints into a (N*eqs) by 10 matrix. Null space is Q
constructMa... | java |
private void extractSolutionForQ( DMatrix4x4 Q ) {
DMatrixRMaj nv = new DMatrixRMaj(10,1);
SingularOps_DDRM.nullVector(svd,true,nv);
// Convert the solution into a fixed sized matrix because it's easier to read
encodeQ(Q,nv.data);
// diagonal elements must be positive because Q = [K*K' .. ; ... ]
// If th... | java |
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);
}
}
} | java |
private Intrinsic solveForCalibration(DMatrixRMaj w) {
Intrinsic calib = new Intrinsic();
// CholeskyDecomposition_F64<DMatrixRMaj> chol = DecompositionFactory_DDRM.chol(false);
//
// chol.decompose(w.copy());
// DMatrixRMaj R = chol.getT(w);
// R.print();
if( zeroSkew ) {
calib.skew = 0;
calib.fy = Mat... | java |
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;
} | java |
private int selectRightToLeft( int col , int[] scores ) {
// see how far it can search
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++ ,i... | java |
public void process( FastQueue<TldRegion> regions , FastQueue<TldRegion> output ) {
final int N = regions.size;
// set all connections to be a local maximum initially
conn.growArray(N);
for( int i = 0; i < N; i++ ) {
conn.data[i].reset();
}
// Create the graph of connected regions and mark which regio... | java |
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 (T)new Pl... | java |
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");
}
} | java |
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;
} | java |
public void setTo( ImageType o ) {
this.family = o.family;
this.dataType = o.dataType;
this.numBands = o.numBands;
} | java |
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.length; i < a.length; i++) {... | java |
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 - cellsPerBlockX;
i... | java |
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 c... | java |
public void detect( II grayII , Planar<II> colorII ) {
descriptions.reset();
featureAngles.reset();
// detect features
detector.detect(grayII);
// describe the found interest points
foundPoints = detector.getFoundPoints();
descriptions.resize(foundPoints.size());
featureAngles.resize(foundPoints.siz... | java |
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(4));
set3D( 0,N,N,point3D.get(5));
set3D( 7,N,N,point3D.get(6... | java |
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);
} | java |
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);
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.