Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lessthanoptimal committed May 19, 2023
1 parent e0ca91d commit 725d5fd
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -34,7 +34,7 @@
* @author Peter Abeles
*/
public class DisparitySmootherSpeckleFilter<Image extends ImageBase<Image>, Disp extends ImageGray<Disp>>
implements DisparitySmoother<Image,Disp> {
implements DisparitySmoother<Image, Disp> {

@Getter ConnectedSpeckleFiller<Disp> filler;

Expand All @@ -52,12 +52,12 @@ public DisparitySmootherSpeckleFilter( ConnectedSpeckleFiller<Disp> filler, Conf
int size = config.maximumArea.computeI(disp.totalPixels());

// Do nothing if it can't filer anything since the maximum size is zero
if (size==0)
if (size == 0)
return;
filler.process(disp,size,config.similarTol,disparityRange);
filler.process(disp, size, config.similarTol, disparityRange);

if (out!=null)
out.println("Speckle maxArea="+size+" filled="+filler.getTotalFilled());
if (out != null)
out.println("Speckle maxArea=" + size + " filled=" + filler.getTotalFilled());
}

@Override public void setVerbose( @Nullable PrintStream out, @Nullable Set<String> configuration ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Peter Abeles. All Rights Reserved.
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -41,8 +41,6 @@
* </p>
*
* @see StereoDisparitySparse
*
* @author Peter Abeles
*/
public interface StereoDisparity<Image extends ImageBase<Image>, Disparity extends ImageGray<Disparity>> {

Expand All @@ -52,7 +50,7 @@ public interface StereoDisparity<Image extends ImageBase<Image>, Disparity exten
* @param imageLeft Input left rectified image.
* @param imageRight Input right rectified image.
*/
void process( Image imageLeft , Image imageRight );
void process( Image imageLeft, Image imageRight );

/**
* Return the computed disparity image. See comments in class description on disparity image format.
Expand All @@ -64,7 +62,6 @@ public interface StereoDisparity<Image extends ImageBase<Image>, Disparity exten
/**
* Returns a score that represents the goodness of fit for the selected value. Meaning of the score
* is cost function dependent. If null is returned that means the score was not saved. This can be
*
*/
@Nullable GrayF32 getDisparityScore();

Expand All @@ -90,12 +87,14 @@ public interface StereoDisparity<Image extends ImageBase<Image>, Disparity exten

/**
* Border around the image's x-axis which is not processed.
*
* @return border x-axis
*/
int getBorderX();

/**
* Border around the image's y-axis which is not processed.
*
* @return border y-axis
*/
int getBorderY();
Expand All @@ -113,5 +112,4 @@ public interface StereoDisparity<Image extends ImageBase<Image>, Disparity exten
* @return Output image type
*/
Class<Disparity> getDisparityType();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -31,8 +31,6 @@
* </p>
*
* @see StereoDisparity
*
* @author Peter Abeles
*/
public interface StereoDisparitySparse<Image extends ImageGray> {

Expand All @@ -42,7 +40,7 @@ public interface StereoDisparitySparse<Image extends ImageGray> {
* @param imageLeft Input left rectified image.
* @param imageRight Input right rectified image.
*/
public void setImages( Image imageLeft , Image imageRight );
void setImages( Image imageLeft, Image imageRight );

/**
* Calculates the disparity at the specified point. Returns true if a valid
Expand All @@ -52,45 +50,47 @@ public interface StereoDisparitySparse<Image extends ImageGray> {
* @param y center of region y-axis
* @return true if a correspondence was found
*/
public boolean process( int x , int y );
boolean process( int x, int y );

/**
* The found disparity at the selected point
*
* @return disparity.
*/
public double getDisparity();
double getDisparity();

/**
* Border around the image's x-axis which is not processed.
*
* @return border x-axis
*/
public int getBorderX();
int getBorderX();

/**
* Border around the image's y-axis which is not processed.
*
* @return border y-axis
*/
public int getBorderY();
int getBorderY();

/**
* The minimum disparity which will be checked for.
*
* @return Minimum disparity.
*/
public int getMinDisparity();
int getMinDisparity();

/**
* The maximum disparity which will be checked for.
*
* @return Maximum disparity.
*/
public int getMaxDisparity();
int getMaxDisparity();

/**
* Type of input images it can process
*
* @return Input image type
*/
public Class<Image> getInputType();
Class<Image> getInputType();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Peter Abeles. All Rights Reserved.
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -31,23 +31,22 @@
* @author Peter Abeles
*/
@SuppressWarnings({"NullAway.Init"})
public abstract class WrapBaseBlockMatch <In extends ImageGray<In>, T extends ImageGray<T>, DI extends ImageGray<DI>>
implements StereoDisparity<In, DI>
{
public abstract class WrapBaseBlockMatch<In extends ImageGray<In>, T extends ImageGray<T>, DI extends ImageGray<DI>>
implements StereoDisparity<In, DI> {
DisparityBlockMatchRowFormat<T, DI> alg;

DI disparity;
@Nullable GrayF32 score;

protected WrapBaseBlockMatch(DisparityBlockMatchRowFormat<T,DI> alg) {
protected WrapBaseBlockMatch( DisparityBlockMatchRowFormat<T, DI> alg ) {
this.alg = alg;
}

@Override public void process(In imageLeft, In imageRight) {
if( disparity == null || disparity.width != imageLeft.width || disparity.height != imageLeft.height ) {
@Override public void process( In imageLeft, In imageRight ) {
if (disparity == null || disparity.width != imageLeft.width || disparity.height != imageLeft.height) {
// make sure the image borders are marked as invalid
disparity = GeneralizedImageOps.createSingleBand(alg.getDisparityType(),imageLeft.width,imageLeft.height);
GImageMiscOps.fill(disparity, getInvalidValue() );
disparity = GeneralizedImageOps.createSingleBand(alg.getDisparityType(), imageLeft.width, imageLeft.height);
GImageMiscOps.fill(disparity, getInvalidValue());
// TODO move this outside and run it every time. Need to fill border
// left border will be radius + min disparity
}
Expand All @@ -56,18 +55,18 @@ protected WrapBaseBlockMatch(DisparityBlockMatchRowFormat<T,DI> alg) {
if (score != null)
score.reshape(disparity);

_process(imageLeft,imageRight);
_process(imageLeft, imageRight);
}

protected abstract void _process(In imageLeft, In imageRight );
protected abstract void _process( In imageLeft, In imageRight );

public void setScoreEnabled( boolean enabled ) {
// see if the current state matches the request
if (enabled && score != null)
return;

if (enabled) {
score = new GrayF32(1,1);
score = new GrayF32(1, 1);
} else {
score = null;
}
Expand Down Expand Up @@ -105,7 +104,7 @@ public void setScoreEnabled( boolean enabled ) {
return alg.getDisparityType();
}

public DisparityBlockMatchRowFormat<T,DI> getAlg() {
public DisparityBlockMatchRowFormat<T, DI> getAlg() {
return alg;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Peter Abeles. All Rights Reserved.
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -30,35 +30,33 @@
* @author Peter Abeles
*/
public class WrapDisparityBlockMatchCensus
<T extends ImageGray<T>, C extends ImageGray<C>,DI extends ImageGray<DI>>
extends WrapBaseBlockMatch<T,C,DI>
{
<T extends ImageGray<T>, C extends ImageGray<C>, DI extends ImageGray<DI>>
extends WrapBaseBlockMatch<T, C, DI> {

FilterImageInterface<T, C> censusTran;

// Storage for census transform of left and right images
C cleft;
C cright;

public WrapDisparityBlockMatchCensus(FilterImageInterface<T, C> censusTran,
DisparityBlockMatchRowFormat<C, DI> alg)
{
public WrapDisparityBlockMatchCensus( FilterImageInterface<T, C> censusTran,
DisparityBlockMatchRowFormat<C, DI> alg ) {
super(alg);
this.censusTran = censusTran;
this.alg = alg;
disparity = GeneralizedImageOps.createSingleBand(alg.getDisparityType(),1,1);
cleft = censusTran.getOutputType().createImage(1,1);
cright = censusTran.getOutputType().createImage(1,1);
disparity = GeneralizedImageOps.createSingleBand(alg.getDisparityType(), 1, 1);
cleft = censusTran.getOutputType().createImage(1, 1);
cright = censusTran.getOutputType().createImage(1, 1);
}

@Override
public void _process(T imageLeft, T imageRight) {
public void _process( T imageLeft, T imageRight ) {
// Apply Census Transform to input images
censusTran.process(imageLeft,cleft);
censusTran.process(imageRight,cright);
censusTran.process(imageLeft, cleft);
censusTran.process(imageRight, cright);

// Now compute the disparity
alg.process(cleft,cright,disparity, score);
alg.process(cleft, cright, disparity, score);
}

public C getCLeft() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Peter Abeles. All Rights Reserved.
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -27,26 +27,26 @@

public class WrapDisparitySgm<DI extends ImageGray<DI>> implements StereoDisparity<GrayU8, DI> {

SgmStereoDisparity<GrayU8,?> sgm;
SgmStereoDisparity<GrayU8, ?> sgm;
@Nullable GrayF32 subpixel;

public WrapDisparitySgm( SgmStereoDisparity<GrayU8,?> sgm, boolean subPixel) {
public WrapDisparitySgm( SgmStereoDisparity<GrayU8, ?> sgm, boolean subPixel ) {
this.sgm = sgm;
this.subpixel = subPixel ? new GrayF32(1,1) : null;
this.subpixel = subPixel ? new GrayF32(1, 1) : null;
}

@Override
public void process(GrayU8 imageLeft, GrayU8 imageRight) {
sgm.process(imageLeft,imageRight);
public void process( GrayU8 imageLeft, GrayU8 imageRight ) {
sgm.process(imageLeft, imageRight);
sgm.saveScore();
if( subpixel != null ) {
if (subpixel != null) {
sgm.subpixel(sgm.getDisparity(), subpixel);
}
}

@Override
public DI getDisparity() {
if( subpixel != null ) {
if (subpixel != null) {
return (DI)subpixel;
} else {
return (DI)sgm.getDisparity();
Expand Down Expand Up @@ -92,7 +92,7 @@ public Class<DI> getDisparityType() {
return (Class)(subpixel == null ? GrayF32.class : GrayU8.class);
}

public SgmStereoDisparity<GrayU8,?> getAlgorithm() {
public SgmStereoDisparity<GrayU8, ?> getAlgorithm() {
return sgm;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2020, Peter Abeles. All Rights Reserved.
* Copyright (c) 2023, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
Expand Down Expand Up @@ -28,35 +28,34 @@
*
* @author Peter Abeles
*/
public class WrapDisparitySparseRectifiedBM<ArrayData,T extends ImageGray<T>>
implements StereoDisparitySparse<T>
{
@Getter DisparitySparseRectifiedScoreBM<ArrayData,T> computeScore;
public class WrapDisparitySparseRectifiedBM<ArrayData, T extends ImageGray<T>>
implements StereoDisparitySparse<T> {
@Getter DisparitySparseRectifiedScoreBM<ArrayData, T> computeScore;
@Getter DisparitySparseSelect<ArrayData> select;

// for an insignificant speed boost save this constant as a floating point number
double minDisparityFloat;

public WrapDisparitySparseRectifiedBM(DisparitySparseRectifiedScoreBM<ArrayData,T> computeScore,
DisparitySparseSelect<ArrayData> select ) {
public WrapDisparitySparseRectifiedBM( DisparitySparseRectifiedScoreBM<ArrayData, T> computeScore,
DisparitySparseSelect<ArrayData> select ) {
this.computeScore = computeScore;
this.select = select;
}

@Override
public void setImages(T imageLeft, T imageRight ) {
computeScore.setImages(imageLeft,imageRight);
public void setImages( T imageLeft, T imageRight ) {
computeScore.setImages(imageLeft, imageRight);
minDisparityFloat = computeScore.getDisparityMin();
}

@Override
public double getDisparity() {
return minDisparityFloat+select.getDisparity();
return minDisparityFloat + select.getDisparity();
}

@Override
public boolean process(int x, int y) {
return select.select(computeScore,x,y);
public boolean process( int x, int y ) {
return select.select(computeScore, x, y);
}

@Override
Expand Down
Loading

0 comments on commit 725d5fd

Please sign in to comment.