Finished Implementation and Test, Test runs successfully and can scan
two sides. Added some debug code, removed some TODOs, fixed some errors. Fixed a semantical error which could become a problem with the front-end (y is now defined as "going into the image"). Redid some reverted stuff.
This commit is contained in:
parent
04a2d79653
commit
6807ee4a25
@ -12,22 +12,31 @@ public class FourSidedScanner extends SingleColorScanner {
|
||||
private SideScanner behindSideScanner;
|
||||
private SideScanner leftSideScanner;
|
||||
|
||||
public FourSidedScanner(BufferedImage frontSideImages[], BufferedImage rightSideImages[], BufferedImage behindSideImages[], BufferedImage leftSideImages[]) {
|
||||
private BufferedImage frontSideImages[];
|
||||
private BufferedImage rightSideImages[];
|
||||
private BufferedImage behindSideImages[];
|
||||
private BufferedImage leftSideImages[];
|
||||
|
||||
public FourSidedScanner(BufferedImage frontSideImages[], BufferedImage rightSideImages[], BufferedImage behindSideImages[], BufferedImage leftSideImages[]) {
|
||||
this.frontSideImages = frontSideImages;
|
||||
this.rightSideImages = rightSideImages;
|
||||
this.behindSideImages = behindSideImages;
|
||||
this.leftSideImages = leftSideImages;
|
||||
//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, null, null, null);
|
||||
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta, null, null, null);
|
||||
behindSideScanner = new SingleColoredSideScanner(behindSideImages, this.gammaDelta, null, null, null);
|
||||
leftSideScanner = new SingleColoredSideScanner(leftSideImages, this.gammaDelta, null, null, null);
|
||||
|
||||
frontSideScanner.scan();
|
||||
frontSideScanner.normalizePoints();
|
||||
Point2D[] frontPoints = frontSideScanner.getPoints();
|
||||
Point2D[] frontSidePoints = frontSideScanner.getPoints();
|
||||
|
||||
rightSideScanner.scan();
|
||||
rightSideScanner.normalizePoints();
|
||||
@ -41,6 +50,6 @@ public class FourSidedScanner extends SingleColorScanner {
|
||||
leftSideScanner.normalizePoints();
|
||||
Point2D[] leftSidePoints = leftSideScanner.getPoints();
|
||||
|
||||
return new Homograph4(rightSidePoints, rightSidePoints, behindSidePoints, leftSidePoints);
|
||||
return new Homograph4(frontSidePoints, rightSidePoints, behindSidePoints, leftSidePoints);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ public class Homograph2 implements Homograph{
|
||||
}
|
||||
|
||||
public void merge() {
|
||||
System.out.println(frontSidePoint);
|
||||
System.out.println(rightSidePoint);
|
||||
double newz = new PointInterpolator(frontSidePoint, rightSidePoint).getCenter().getY();
|
||||
double newx = frontSidePoint.getX(); //baseline
|
||||
double newy = rightSidePoint.getX(); //coming out of the image
|
||||
@ -42,7 +44,7 @@ public class Homograph2 implements Homograph{
|
||||
public Homograph2(Point2D[] frontSidePoints, Point2D[] rightSidePoints) {
|
||||
homographs = new SingleHomograph[frontSidePoints.length];
|
||||
for(int i = 0; i < frontSidePoints.length; i++) {
|
||||
homographs[i] = new SingleHomograph(frontSidePoints[i], frontSidePoints[i]);
|
||||
homographs[i] = new SingleHomograph(frontSidePoints[i], rightSidePoints[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@ public class Homograph4 implements Homograph{
|
||||
mergedFrontBack[i] = interpolatedFrontBehind;
|
||||
mergedRightLeft[i] = interpolatedRightLeft;
|
||||
}
|
||||
|
||||
internalHomograph = new Homograph2(mergedFrontBack, mergedRightLeft);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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) {
|
||||
@ -10,4 +10,9 @@ public class Point3D {
|
||||
y = ny;
|
||||
z = nz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "x: " + x + " y: " + y + " z: " + z;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.cringe_studios.christmastreescanning;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.cringe_studios.christmastreescanning.scanning.SideScanner;
|
||||
import com.cringe_studios.christmastreescanning.scanning.SingleColoredSideScanner;
|
||||
@ -21,14 +22,16 @@ 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, null , null, null);
|
||||
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta, null, null, null);
|
||||
|
||||
frontSideScanner.scan();
|
||||
System.out.println(Arrays.toString(frontSideScanner.getPoints()));
|
||||
frontSideScanner.normalizePoints();
|
||||
Point2D[] frontPoints = frontSideScanner.getPoints();
|
||||
|
||||
rightSideScanner.scan();
|
||||
System.out.println(Arrays.toString(rightSideScanner.getPoints()));
|
||||
rightSideScanner.normalizePoints();
|
||||
Point2D[] rightSidePoints = rightSideScanner.getPoints();
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.cringe_studios.christmastreescanning.scanning;
|
||||
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PointNormalizer {
|
||||
Point2D[] points;
|
||||
@ -52,9 +53,13 @@ public class PointNormalizer {
|
||||
|
||||
normalizedX = normalizedX * 2.0 - 1.0;
|
||||
|
||||
normalizedY = 1.0 - normalizedY;
|
||||
|
||||
normalizedPoints[i] = new Point2D.Double(normalizedX, normalizedY);
|
||||
}
|
||||
|
||||
System.out.println(Arrays.toString(this.points) + " -> " + Arrays.toString(normalizedPoints));
|
||||
|
||||
this.points = normalizedPoints;
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,12 @@ 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 Double baseline = null;
|
||||
protected Double minX = null;
|
||||
protected Double maxX = null;
|
||||
|
||||
protected Point2D foundPoints[] = null;
|
||||
|
||||
//
|
||||
// public SideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||
// this.sideImages = images;
|
||||
|
@ -4,51 +4,41 @@ import java.awt.geom.Point2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import com.cringe_studios.christmastreescanning.scanning.image_scanning.ImageScanner;
|
||||
import com.cringe_studios.christmastreescanning.scanning.image_scanning.SingleRGBImageScanner;
|
||||
|
||||
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;
|
||||
private ImageScanner imageScanners[];
|
||||
|
||||
boolean useDefaultValues;
|
||||
|
||||
Point2D foundPoints[] = null;
|
||||
|
||||
public SingleColoredSideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||
this.sideImages = images;
|
||||
public SingleColoredSideScanner(BufferedImage[] images, byte gammaDelta, Double baseline, Double minX, Double maxX) {
|
||||
this(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;
|
||||
imageScanners = new SingleRGBImageScanner[images.length];
|
||||
|
||||
for(int i = 0; i < images.length; i++) {
|
||||
imageScanners[i] = new SingleRGBImageScanner(images[i]);
|
||||
}
|
||||
|
||||
this.foundPoints = new Point2D[images.length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scan() {
|
||||
int imagesLength = this.sideImages.length;
|
||||
|
||||
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);
|
||||
}
|
||||
this.foundPoints[i] = imageScanners[i].getBrightestSpot(gammaDelta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.cringe_studios.cristmastreescanning;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Point2D;
|
||||
@ -9,6 +10,7 @@ import java.awt.image.DataBufferInt;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
@ -31,12 +33,12 @@ public class ExampleTest {
|
||||
@Test
|
||||
public void scannerTest() {
|
||||
try {
|
||||
BufferedImage LED1Front = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED1_front.png"));
|
||||
BufferedImage LED2Front = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED2_front.png"));
|
||||
BufferedImage LED3Front = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED3_front.png"));
|
||||
BufferedImage LED1Right = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED1_right.png"));
|
||||
BufferedImage LED2Right = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED2_right.png"));
|
||||
BufferedImage LED3Right = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED3_right.png"));
|
||||
BufferedImage LED1Front = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED1_front.png"));
|
||||
BufferedImage LED2Front = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED2_front.png"));
|
||||
BufferedImage LED3Front = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED3_front.png"));
|
||||
BufferedImage LED1Right = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED1_right.png"));
|
||||
BufferedImage LED2Right = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED2_right.png"));
|
||||
BufferedImage LED3Right = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED3_right.png"));
|
||||
|
||||
Scanner scanner = new TwoSidedScanner(new BufferedImage[] {LED1Front, LED2Front, LED3Front}, new BufferedImage[] {LED1Right, LED2Right, LED3Right});
|
||||
scanner.setGammaDelta((byte)(0.1 * 255));
|
||||
@ -45,6 +47,57 @@ public class ExampleTest {
|
||||
homo.renormalize();
|
||||
Point3D points[] = homo.getPoints();
|
||||
|
||||
System.out.println(Arrays.toString(points));
|
||||
|
||||
boolean foundXMin = false; // -1
|
||||
boolean foundXMax = false; // 1
|
||||
boolean foundYMin = false; // -1
|
||||
boolean foundYMax = false; // 1
|
||||
boolean foundZMin = false; // 0
|
||||
boolean foundZMax = false; // 1
|
||||
|
||||
for(int i = 0; i < points.length; i++) {
|
||||
if(Math.abs(points[i].x - (-1.0)) < 0.001) {
|
||||
foundXMin = true;
|
||||
}
|
||||
|
||||
if(Math.abs(points[i].x - (1.0)) < 0.001) {
|
||||
foundXMax = true;
|
||||
}
|
||||
|
||||
if(Math.abs(points[i].y - (-1.0)) < 0.001) {
|
||||
foundYMin = true;
|
||||
}
|
||||
|
||||
if(Math.abs(points[i].y - (1.0)) < 0.001) {
|
||||
foundYMax = true;
|
||||
}
|
||||
|
||||
if(Math.abs(points[i].z - (1.0)) < 0.001) {
|
||||
foundZMax = true;
|
||||
}
|
||||
|
||||
if(Math.abs(points[i].z - (0.0)) < 0.001) {
|
||||
foundZMin = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(foundXMin && foundXMax && foundYMin && foundYMax && foundZMin && foundZMax) {
|
||||
assertTrue(true);
|
||||
}else {
|
||||
System.out.println(foundXMin );
|
||||
System.out.println(foundXMax );
|
||||
System.out.println(foundYMin );
|
||||
System.out.println(foundYMax );
|
||||
System.out.println(foundZMin );
|
||||
System.out.println(foundZMax );
|
||||
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user