Tiny interface change

This commit is contained in:
Paul Schaller 2023-11-27 15:00:50 +01:00
parent 595743bda2
commit 24b41531ae
9 changed files with 29 additions and 49 deletions

View File

@ -16,15 +16,15 @@ public class FourSidedScanner extends SingleColorScanner {
//TODO
frontSideScanner = new SingleColoredSideScanner(frontSideImages, this.gammaDelta, , , );
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta, , , );
behindSideScanner = new SingleColoredSideScanner(behindSideScanner, this.gammaDelta, , , );
leftSideScanner = new SingleColoredSideScanner(leftSideScanner, this.gammaDelta, , , );
}
@Override
public Homograph scan() {
// TODO Auto-generated method stub
frontSideScanner = new SingleColoredSideScanner(frontSideImages, this.gammaDelta);
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta);
behindSideScanner = new SingleColoredSideScanner(behindSideScanner, this.gammaDelta);
leftSideScanner = new SingleColoredSideScanner(leftSideScanner, this.gammaDelta);
frontSideScanner.scan();
frontSideScanner.normalizePoints();
Point2D[] frontPoints = frontSideScanner.getPoints();
@ -41,6 +41,6 @@ public class FourSidedScanner extends SingleColorScanner {
leftSideScanner.normalizePoints();
Point2D[] leftSidePoints = leftSideScanner.getPoints();
return new Homograph4(rightSidePoints, rightSidePoints, behindSidePoints, leftSidePoints);
return new Homograph4(frontPoints, rightSidePoints, behindSidePoints, leftSidePoints);
}
}

View File

@ -1,8 +1,11 @@
package com.cringe_studios.christmastreescanning;
import java.awt.geom.Point2D;
public interface Homograph {
void normalize(Double baseline, Double minX, Double maxX);
default void normalize() {
normalize(null, null, null);
}
void merge();
void renormalize();
Point3D[] getPoints();

View File

@ -2,7 +2,7 @@ package com.cringe_studios.christmastreescanning;
public class Point3D {
public double x; // baseline
public double y; // coming out of the image
public double y; // going into the image
public double z; // The height
public Point3D(double nx, double ny, double nz) {

View File

@ -26,6 +26,7 @@ public abstract class Scanner {
// BufferedImage leftSideImagesBlue[];
protected byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
protected boolean toMultipleGrayscaleImages = false;
// Boolean distinctColorChannels = null; // use the non-primitive datatype, so the user has to set the state
// Boolean sideCount = null; // use the non-primitive datatype, so the user has to set the state
@ -197,6 +198,15 @@ public abstract Homograph scan();
this.gammaDelta = gammaDelta;
}
/**
* Set, wether an image should be converted to multiple grayscale images (per color channel), or to a single grayscale image
* Default: false
* @param toMultipleGrayscaleImages
*/
public void setMultipleGrayScaleImages(boolean toMultipleGrayscaleImages) {
this.toMultipleGrayscaleImages = toMultipleGrayscaleImages;
}
// /**
// *
// * @param useDistinctRGBImages if this parameter is true, you have to use the IMAGE_*_RED/_GREEN/_BLUE enum types in the setData method

View File

@ -21,8 +21,8 @@ public class TwoSidedScanner extends SingleColorScanner {
@Override
public Homograph scan() {
frontSideScanner = new SingleColoredSideScanner(frontSideImages, this.gammaDelta, , , );
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta, , , );
frontSideScanner = new SingleColoredSideScanner(frontSideImages, this.gammaDelta);
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta);
frontSideScanner.scan();
frontSideScanner.normalizePoints();

View File

@ -11,26 +11,16 @@ public class MultiColoredSideScanner extends SideScanner{
private BufferedImage sideImagesBlue[];
byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
double baseline = 0.0;
double minX = Double.NEGATIVE_INFINITY;
double maxX = Double.POSITIVE_INFINITY;
boolean useDefaultValues;
Point2D foundPoints[] = null;
public MultiColoredSideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue, byte gammaDelta, double baseline, double minX, double maxX) {
public MultiColoredSideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue, byte gammaDelta) {
if(!(imagesRed.length == imagesGreen.length && imagesGreen.length == imagesBlue.length)); // TODO error
this.sideImagesRed = imagesRed;
this.sideImagesGreen = imagesGreen;
this.sideImagesBlue = imagesBlue;
this.gammaDelta = gammaDelta;
this.baseline = baseline;
this.minX = minX;
this.maxX = maxX;
this.useDefaultValues = false;
}
public MultiColoredSideScanner(BufferedImage[] imagesRed, BufferedImage[] imagesGreen, BufferedImage[] imagesBlue) {
@ -39,8 +29,6 @@ public class MultiColoredSideScanner extends SideScanner{
this.sideImagesRed = imagesRed;
this.sideImagesGreen = imagesGreen;
this.sideImagesBlue = imagesBlue;
this.useDefaultValues = true;
}
@Override

View File

@ -12,11 +12,6 @@ public abstract class SideScanner {
// private BufferedImage sideImagesBlue[];
//
protected byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
protected double baseline = 0.0;
protected double minX = Double.NEGATIVE_INFINITY;
protected double maxX = Double.POSITIVE_INFINITY;
protected boolean useDefaultValues;
protected Point2D foundPoints[] = null;
//

View File

@ -9,30 +9,18 @@ public class SingleColoredSideScanner extends SideScanner {
private BufferedImage sideImages[];
byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
double baseline = 0.0;
double minX = Double.NEGATIVE_INFINITY;
double maxX = Double.POSITIVE_INFINITY;
boolean useDefaultValues;
Point2D foundPoints[] = null;
public SingleColoredSideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX, double maxX) {
public SingleColoredSideScanner(BufferedImage[] images, byte gammaDelta) {
this.sideImages = images;
this.gammaDelta = gammaDelta;
this.baseline = baseline;
this.minX = minX;
this.maxX = maxX;
this.useDefaultValues = false;
}
// Everything default values
public SingleColoredSideScanner(BufferedImage[] images) {
this.sideImages = images;
this.useDefaultValues = true;
}
@Override
@ -42,15 +30,10 @@ public class SingleColoredSideScanner extends SideScanner {
foundPoints = new Point2D[imagesLength];
for (int i = 0; i < imagesLength; i++) {
if (this.useDefaultValues) {
//TODO
//foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i]);
} else {
//TODO
//foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i], this.gammaDelta);
}
}
}
@Override
public Point2D[] getPoints() {

View File

@ -41,6 +41,7 @@ public class ExampleTest {
Scanner scanner = new TwoSidedScanner(new BufferedImage[] {LED1Front, LED2Front, LED3Front}, new BufferedImage[] {LED1Right, LED2Right, LED3Right});
scanner.setGammaDelta((byte)(0.1 * 255));
Homograph homo = scanner.scan();
homo.normalize();
homo.merge();
homo.renormalize();
Point3D points[] = homo.getPoints();