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 behindSideScanner;
|
||||||
private SideScanner leftSideScanner;
|
private SideScanner leftSideScanner;
|
||||||
|
|
||||||
|
private BufferedImage frontSideImages[];
|
||||||
|
private BufferedImage rightSideImages[];
|
||||||
|
private BufferedImage behindSideImages[];
|
||||||
|
private BufferedImage leftSideImages[];
|
||||||
|
|
||||||
public FourSidedScanner(BufferedImage frontSideImages[], BufferedImage rightSideImages[], BufferedImage behindSideImages[], 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
|
//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
|
@Override
|
||||||
public Homograph scan() {
|
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.scan();
|
||||||
frontSideScanner.normalizePoints();
|
frontSideScanner.normalizePoints();
|
||||||
Point2D[] frontPoints = frontSideScanner.getPoints();
|
Point2D[] frontSidePoints = frontSideScanner.getPoints();
|
||||||
|
|
||||||
rightSideScanner.scan();
|
rightSideScanner.scan();
|
||||||
rightSideScanner.normalizePoints();
|
rightSideScanner.normalizePoints();
|
||||||
@ -41,6 +50,6 @@ public class FourSidedScanner extends SingleColorScanner {
|
|||||||
leftSideScanner.normalizePoints();
|
leftSideScanner.normalizePoints();
|
||||||
Point2D[] leftSidePoints = leftSideScanner.getPoints();
|
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() {
|
public void merge() {
|
||||||
|
System.out.println(frontSidePoint);
|
||||||
|
System.out.println(rightSidePoint);
|
||||||
double newz = new PointInterpolator(frontSidePoint, rightSidePoint).getCenter().getY();
|
double newz = new PointInterpolator(frontSidePoint, rightSidePoint).getCenter().getY();
|
||||||
double newx = frontSidePoint.getX(); //baseline
|
double newx = frontSidePoint.getX(); //baseline
|
||||||
double newy = rightSidePoint.getX(); //coming out of the image
|
double newy = rightSidePoint.getX(); //coming out of the image
|
||||||
@ -42,7 +44,7 @@ public class Homograph2 implements Homograph{
|
|||||||
public Homograph2(Point2D[] frontSidePoints, Point2D[] rightSidePoints) {
|
public Homograph2(Point2D[] frontSidePoints, Point2D[] rightSidePoints) {
|
||||||
homographs = new SingleHomograph[frontSidePoints.length];
|
homographs = new SingleHomograph[frontSidePoints.length];
|
||||||
for(int i = 0; i < frontSidePoints.length; i++) {
|
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;
|
mergedFrontBack[i] = interpolatedFrontBehind;
|
||||||
mergedRightLeft[i] = interpolatedRightLeft;
|
mergedRightLeft[i] = interpolatedRightLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internalHomograph = new Homograph2(mergedFrontBack, mergedRightLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,7 +2,7 @@ package com.cringe_studios.christmastreescanning;
|
|||||||
|
|
||||||
public class Point3D {
|
public class Point3D {
|
||||||
public double x; // baseline
|
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 double z; // The height
|
||||||
|
|
||||||
public Point3D(double nx, double ny, double nz) {
|
public Point3D(double nx, double ny, double nz) {
|
||||||
@ -10,4 +10,9 @@ public class Point3D {
|
|||||||
y = ny;
|
y = ny;
|
||||||
z = nz;
|
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.geom.Point2D;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.cringe_studios.christmastreescanning.scanning.SideScanner;
|
import com.cringe_studios.christmastreescanning.scanning.SideScanner;
|
||||||
import com.cringe_studios.christmastreescanning.scanning.SingleColoredSideScanner;
|
import com.cringe_studios.christmastreescanning.scanning.SingleColoredSideScanner;
|
||||||
@ -21,14 +22,16 @@ public class TwoSidedScanner extends SingleColorScanner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Homograph scan() {
|
public Homograph scan() {
|
||||||
frontSideScanner = new SingleColoredSideScanner(frontSideImages, this.gammaDelta, , , );
|
frontSideScanner = new SingleColoredSideScanner(frontSideImages, this.gammaDelta, null , null, null);
|
||||||
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta, , , );
|
rightSideScanner = new SingleColoredSideScanner(rightSideImages, this.gammaDelta, null, null, null);
|
||||||
|
|
||||||
frontSideScanner.scan();
|
frontSideScanner.scan();
|
||||||
|
System.out.println(Arrays.toString(frontSideScanner.getPoints()));
|
||||||
frontSideScanner.normalizePoints();
|
frontSideScanner.normalizePoints();
|
||||||
Point2D[] frontPoints = frontSideScanner.getPoints();
|
Point2D[] frontPoints = frontSideScanner.getPoints();
|
||||||
|
|
||||||
rightSideScanner.scan();
|
rightSideScanner.scan();
|
||||||
|
System.out.println(Arrays.toString(rightSideScanner.getPoints()));
|
||||||
rightSideScanner.normalizePoints();
|
rightSideScanner.normalizePoints();
|
||||||
Point2D[] rightSidePoints = rightSideScanner.getPoints();
|
Point2D[] rightSidePoints = rightSideScanner.getPoints();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.cringe_studios.christmastreescanning.scanning;
|
package com.cringe_studios.christmastreescanning.scanning;
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class PointNormalizer {
|
public class PointNormalizer {
|
||||||
Point2D[] points;
|
Point2D[] points;
|
||||||
@ -52,9 +53,13 @@ public class PointNormalizer {
|
|||||||
|
|
||||||
normalizedX = normalizedX * 2.0 - 1.0;
|
normalizedX = normalizedX * 2.0 - 1.0;
|
||||||
|
|
||||||
|
normalizedY = 1.0 - normalizedY;
|
||||||
|
|
||||||
normalizedPoints[i] = new Point2D.Double(normalizedX, normalizedY);
|
normalizedPoints[i] = new Point2D.Double(normalizedX, normalizedY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println(Arrays.toString(this.points) + " -> " + Arrays.toString(normalizedPoints));
|
||||||
|
|
||||||
this.points = normalizedPoints;
|
this.points = normalizedPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,12 @@ public abstract class SideScanner {
|
|||||||
// private BufferedImage sideImagesBlue[];
|
// private BufferedImage sideImagesBlue[];
|
||||||
//
|
//
|
||||||
protected byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
|
protected byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
|
||||||
protected double baseline = 0.0;
|
protected Double baseline = null;
|
||||||
protected double minX = Double.NEGATIVE_INFINITY;
|
protected Double minX = null;
|
||||||
protected double maxX = Double.POSITIVE_INFINITY;
|
protected Double maxX = null;
|
||||||
|
|
||||||
protected boolean useDefaultValues;
|
|
||||||
|
|
||||||
protected Point2D foundPoints[] = null;
|
protected Point2D foundPoints[] = null;
|
||||||
|
|
||||||
//
|
//
|
||||||
// public SideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX, double maxX) {
|
// public SideScanner(BufferedImage[] images, byte gammaDelta, double baseline, double minX, double maxX) {
|
||||||
// this.sideImages = images;
|
// this.sideImages = images;
|
||||||
|
@ -4,51 +4,41 @@ import java.awt.geom.Point2D;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import com.cringe_studios.christmastreescanning.scanning.image_scanning.ImageScanner;
|
import com.cringe_studios.christmastreescanning.scanning.image_scanning.ImageScanner;
|
||||||
|
import com.cringe_studios.christmastreescanning.scanning.image_scanning.SingleRGBImageScanner;
|
||||||
|
|
||||||
public class SingleColoredSideScanner extends SideScanner {
|
public class SingleColoredSideScanner extends SideScanner {
|
||||||
private BufferedImage sideImages[];
|
private BufferedImage sideImages[];
|
||||||
|
|
||||||
|
private ImageScanner imageScanners[];
|
||||||
|
|
||||||
byte gammaDelta = ImageScanner.GAMMA_DELTA_DEFAULT;
|
public SingleColoredSideScanner(BufferedImage[] images, byte gammaDelta, Double baseline, Double minX, Double maxX) {
|
||||||
double baseline = 0.0;
|
this(images);
|
||||||
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) {
|
|
||||||
this.sideImages = images;
|
|
||||||
|
|
||||||
this.gammaDelta = gammaDelta;
|
this.gammaDelta = gammaDelta;
|
||||||
this.baseline = baseline;
|
this.baseline = baseline;
|
||||||
this.minX = minX;
|
this.minX = minX;
|
||||||
this.maxX = maxX;
|
this.maxX = maxX;
|
||||||
|
|
||||||
this.useDefaultValues = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything default values
|
// Everything default values
|
||||||
public SingleColoredSideScanner(BufferedImage[] images) {
|
public SingleColoredSideScanner(BufferedImage[] images) {
|
||||||
this.sideImages = 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
|
@Override
|
||||||
public void scan() {
|
public void scan() {
|
||||||
int imagesLength = this.sideImages.length;
|
int imagesLength = this.sideImages.length;
|
||||||
|
|
||||||
foundPoints = new Point2D[imagesLength];
|
|
||||||
|
|
||||||
for (int i = 0; i < imagesLength; i++) {
|
for (int i = 0; i < imagesLength; i++) {
|
||||||
if (this.useDefaultValues) {
|
this.foundPoints[i] = imageScanners[i].getBrightestSpot(gammaDelta);
|
||||||
//TODO
|
|
||||||
//foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i]);
|
|
||||||
} else {
|
|
||||||
//TODO
|
|
||||||
//foundPoints[i] = ImageScanner.getBrightestSpot(sideImages[i], this.gammaDelta);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.cringe_studios.cristmastreescanning;
|
package com.cringe_studios.cristmastreescanning;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
@ -9,6 +10,7 @@ import java.awt.image.DataBufferInt;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
@ -31,12 +33,12 @@ public class ExampleTest {
|
|||||||
@Test
|
@Test
|
||||||
public void scannerTest() {
|
public void scannerTest() {
|
||||||
try {
|
try {
|
||||||
BufferedImage LED1Front = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED1_front.png"));
|
BufferedImage LED1Front = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED1_front.png"));
|
||||||
BufferedImage LED2Front = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED2_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 LED3Front = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED3_front.png"));
|
||||||
BufferedImage LED1Right = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED1_right.png"));
|
BufferedImage LED1Right = ImageIO.read(ExampleTest.class.getResourceAsStream("/ScannerTest1_LED1_right.png"));
|
||||||
BufferedImage LED2Right = ImageIO.read(ExampleTest.class.getResourceAsStream("ScannerTest1_LED2_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 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 scanner = new TwoSidedScanner(new BufferedImage[] {LED1Front, LED2Front, LED3Front}, new BufferedImage[] {LED1Right, LED2Right, LED3Right});
|
||||||
scanner.setGammaDelta((byte)(0.1 * 255));
|
scanner.setGammaDelta((byte)(0.1 * 255));
|
||||||
@ -45,6 +47,57 @@ public class ExampleTest {
|
|||||||
homo.renormalize();
|
homo.renormalize();
|
||||||
Point3D points[] = homo.getPoints();
|
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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user