diff --git a/Main/chameleon-vision.iml b/Main/chameleon-vision.iml index 5d990481a..46611ad3c 100644 --- a/Main/chameleon-vision.iml +++ b/Main/chameleon-vision.iml @@ -10,6 +10,7 @@ + @@ -33,7 +34,7 @@ - + diff --git a/Main/pom.xml b/Main/pom.xml index 456b1a8bf..87c75c8f6 100644 --- a/Main/pom.xml +++ b/Main/pom.xml @@ -75,7 +75,7 @@ org.slf4j - slf4j-simple + slf4j-nop 1.7.26 diff --git a/Main/src/main/java/com/chameleonvision/vision/CalibrationMode.java b/Main/src/main/java/com/chameleonvision/vision/CalibrationMode.java new file mode 100644 index 000000000..64de036ed --- /dev/null +++ b/Main/src/main/java/com/chameleonvision/vision/CalibrationMode.java @@ -0,0 +1,5 @@ +package com.chameleonvision.vision; + +public enum CalibrationMode { + None,Single,Dual +} diff --git a/Main/src/main/java/com/chameleonvision/vision/Pipeline.java b/Main/src/main/java/com/chameleonvision/vision/Pipeline.java index 2490a45af..4d0bf96db 100644 --- a/Main/src/main/java/com/chameleonvision/vision/Pipeline.java +++ b/Main/src/main/java/com/chameleonvision/vision/Pipeline.java @@ -22,6 +22,7 @@ public class Pipeline { public TargetIntersection targetIntersection = TargetIntersection.Up; public double m = 1; public double b = 0; - public boolean isCalibrated = false; + public List point = Arrays.asList(0,0); + public CalibrationMode calibrationMode = CalibrationMode.None; public String nickname; } diff --git a/Main/src/main/java/com/chameleonvision/vision/camera/CameraValues.java b/Main/src/main/java/com/chameleonvision/vision/camera/CameraValues.java index 0ea7e8873..f429b98d2 100644 --- a/Main/src/main/java/com/chameleonvision/vision/camera/CameraValues.java +++ b/Main/src/main/java/com/chameleonvision/vision/camera/CameraValues.java @@ -12,6 +12,7 @@ public class CameraValues { public final double CenterX; public final double CenterY; public final double DiagonalView; + public final double DiagonalAspect; public final Fraction AspectFraction; public final int HorizontalRatio; public final int VerticalRatio; @@ -35,8 +36,9 @@ public class CameraValues { AspectFraction = new Fraction(ImageWidth, ImageHeight); HorizontalRatio = AspectFraction.getNumerator(); VerticalRatio = AspectFraction.getDenominator(); - HorizontalView = FastMath.atan(FastMath.tan(DiagonalView / 2) * (HorizontalRatio / DiagonalView)) * 2; - VerticalView = FastMath.atan(FastMath.tan(DiagonalView/2) * (VerticalRatio / DiagonalView)) * 2; + DiagonalAspect = FastMath.hypot(HorizontalRatio, VerticalRatio); + HorizontalView = FastMath.atan(FastMath.tan(DiagonalView / 2) * (HorizontalRatio / DiagonalAspect)) * 2; + VerticalView = FastMath.atan(FastMath.tan(DiagonalView / 2) * (VerticalRatio / DiagonalAspect)) * 2; HorizontalFocalLength = ImageWidth / (2 * FastMath.tan(HorizontalView /2)); VerticalFocalLength = ImageHeight / (2 * FastMath.tan(VerticalView /2)); } diff --git a/Main/src/main/java/com/chameleonvision/vision/process/VisionProcess.java b/Main/src/main/java/com/chameleonvision/vision/process/VisionProcess.java index 21d55fe7c..1ed5d91a6 100644 --- a/Main/src/main/java/com/chameleonvision/vision/process/VisionProcess.java +++ b/Main/src/main/java/com/chameleonvision/vision/process/VisionProcess.java @@ -1,6 +1,7 @@ package com.chameleonvision.vision.process; import com.chameleonvision.settings.SettingsManager; +import com.chameleonvision.vision.CalibrationMode; import com.chameleonvision.vision.Orientation; import com.chameleonvision.vision.Pipeline; import com.chameleonvision.vision.camera.Camera; @@ -155,15 +156,24 @@ public class VisionProcess implements Runnable { groupedContours = cvProcess.groupTargets(deSpeckledContours, currentPipeline.targetIntersection, currentPipeline.targetGroup); if (groupedContours.size() > 0) { var finalRect = cvProcess.sortTargetsToOne(groupedContours, currentPipeline.sortMode); - // System.out.printf("Largest Contour Area: %.2f\n", finalRect.size.area()); pipelineResult.RawPoint = finalRect; pipelineResult.IsValid = true; - if (!currentPipeline.isCalibrated) { - pipelineResult.CalibratedX = camera.getCamVals().CenterX; - pipelineResult.CalibratedY = camera.getCamVals().CenterY; - } else { - pipelineResult.CalibratedX = (finalRect.center.y - currentPipeline.b) / currentPipeline.m; - pipelineResult.CalibratedY = (finalRect.center.x * currentPipeline.m) + currentPipeline.b; + switch (currentPipeline.calibrationMode){ + case None: + ///use the center of the camera to find the pitch and yaw difference + pipelineResult.CalibratedX = camera.getCamVals().CenterX; + pipelineResult.CalibratedY = camera.getCamVals().CenterY; + break; + case Single: + // use the static point as a calibration method instead of the center + pipelineResult.CalibratedX = currentPipeline.point.get(0).doubleValue(); + pipelineResult.CalibratedY = currentPipeline.point.get(1).doubleValue(); + break; + case Dual: + // use the calculated line to find the difference in length between the point and the line + pipelineResult.CalibratedX = (finalRect.center.y - currentPipeline.b) / currentPipeline.m; + pipelineResult.CalibratedY = (finalRect.center.x * currentPipeline.m) + currentPipeline.b; + break; } pipelineResult.Pitch = camera.getCamVals().CalculatePitch(finalRect.center.y, pipelineResult.CalibratedY); pipelineResult.Yaw = camera.getCamVals().CalculateYaw(finalRect.center.x, pipelineResult.CalibratedX); diff --git a/Main/src/main/java/com/chameleonvision/web/ServerHandler.java b/Main/src/main/java/com/chameleonvision/web/ServerHandler.java index c2e52a55d..8930d42ea 100644 --- a/Main/src/main/java/com/chameleonvision/web/ServerHandler.java +++ b/Main/src/main/java/com/chameleonvision/web/ServerHandler.java @@ -53,6 +53,7 @@ public class ServerHandler { setField(SettingsManager.GeneralSettings, e.getKey(), e.getValue()); } SettingsManager.saveSettings(); + sendFullSettings(); break; } case "cameraSettings": { @@ -61,16 +62,19 @@ public class ServerHandler { CameraManager.getCurrentCamera().setStreamDivisor((Integer) camSettings.get("streamDivisor")); CameraManager.getCurrentCamera().setCamVideoMode((Integer) camSettings.get("resolution"), true); SettingsManager.saveSettings(); + sendFullSettings(); break; } case "changeCameraName": { CameraManager.getCurrentCamera().setNickname((String) entry.getValue()); sendFullSettings(); + SettingsManager.saveSettings(); break; } case "changePipelineName": { CameraManager.getCurrentPipeline().nickname = (String) entry.getValue(); sendFullSettings(); + SettingsManager.saveSettings(); break; } case "duplicatePipeline": { @@ -85,6 +89,7 @@ public class ServerHandler { } else { CameraManager.getCurrentCamera().addPipeline(origPipeline); } + SettingsManager.saveSettings(); break; } case "command": { @@ -93,6 +98,7 @@ public class ServerHandler { case "addNewPipeline": cam.addPipeline(); sendFullSettings(); + SettingsManager.saveSettings(); break; case "deleteCurrentPipeline": int currentIndex = cam.getCurrentPipelineIndex(); @@ -105,6 +111,10 @@ public class ServerHandler { cam.deletePipeline(); cam.setCurrentPipelineIndex(nextIndex); sendFullSettings(); + SettingsManager.saveSettings(); + break; + case "save": + SettingsManager.saveSettings(); break; } // used to define all incoming commands @@ -118,9 +128,7 @@ public class ServerHandler { case "currentPipeline": { var cam = CameraManager.getCurrentCamera(); cam.setCurrentPipelineIndex((Integer) entry.getValue()); - HashMap tmp = new HashMap<>(); - tmp.put("pipeline", getOrdinalPipeline()); - broadcastMessage(tmp); + sendFullSettings(); try { cam.setBrightness(cam.getCurrentPipeline().brightness); cam.setExposure(cam.getCurrentPipeline().exposure); diff --git a/chameleon-client/package-lock.json b/chameleon-client/package-lock.json index 2beadcea2..963d66adc 100644 --- a/chameleon-client/package-lock.json +++ b/chameleon-client/package-lock.json @@ -13493,7 +13493,8 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", @@ -13502,7 +13503,8 @@ }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -13605,7 +13607,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -13615,6 +13618,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -13640,6 +13644,7 @@ "minipass": { "version": "2.2.4", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -13656,6 +13661,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -13728,7 +13734,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -13738,6 +13745,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -13843,6 +13851,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/chameleon-client/src/components/OutputTab/DualCalibration.vue b/chameleon-client/src/components/OutputTab/DualCalibration.vue new file mode 100644 index 000000000..6fcbd8dcd --- /dev/null +++ b/chameleon-client/src/components/OutputTab/DualCalibration.vue @@ -0,0 +1,64 @@ + + + + + Take Point A + + + Take Point B + + + Clear All Points + + + + + + + + \ No newline at end of file diff --git a/chameleon-client/src/components/OutputTab/SingleCalibration.vue b/chameleon-client/src/components/OutputTab/SingleCalibration.vue new file mode 100644 index 000000000..77ab8eafe --- /dev/null +++ b/chameleon-client/src/components/OutputTab/SingleCalibration.vue @@ -0,0 +1,31 @@ + + + + + Take Point + + + Clear Point + + + + + + + + \ No newline at end of file diff --git a/chameleon-client/src/store.js b/chameleon-client/src/store.js index 6a382b0ed..85e05e73b 100644 --- a/chameleon-client/src/store.js +++ b/chameleon-client/src/store.js @@ -33,7 +33,8 @@ export default new Vuex.Store({ targetGrouping:0, targetIntersection:0, sortMode:0, - isBinary:0 + isBinary:0, + calibrationMode:0 }, cameraSettings:{}, resolutionList:[], @@ -54,7 +55,12 @@ export default new Vuex.Store({ currentPipelineIndex: set('currentPipelineIndex'), cameraList: set('cameraList'), pipelineList: set('pipelineList'), - point:set('point') + point:set('point'), + setPipeValues(state,obj){ + for(let i in obj){ + Vue.set(state.pipeline,i,obj[i]); + } + } }, actions: { settings: state => state.settings, @@ -67,10 +73,5 @@ export default new Vuex.Store({ cameraList: state =>state.cameraList, pipelineList: state =>state.pipelineList, point: state =>state.point, - setPipeValues(state,obj){ - for(let i in obj){ - Vue.set(state.pipeline,i,obj[i]); - } - } } }) diff --git a/chameleon-client/src/views/Camera.vue b/chameleon-client/src/views/Camera.vue index 917bc92f1..3a2fabd9d 100644 --- a/chameleon-client/src/views/Camera.vue +++ b/chameleon-client/src/views/Camera.vue @@ -4,52 +4,63 @@ - - + + - + - - + + - - + + - + menu - + - + - + - + - - + + @@ -66,7 +77,7 @@ - + @@ -78,7 +89,7 @@ - + No Cameras Are connected {{point}} @@ -90,14 +101,15 @@ Duplicate Pipeline - - - + + + - + Duplicate Cancels @@ -213,7 +225,7 @@ import CVinput from '../components/cv-input' checkCameraName(){ if(this.newCameraName !== this.cameraList[this.currentCameraIndex]){ for(let cam in this.cameraList){ - if(this.newCameraName == this.cameraList[cam]){ + if(this.newCameraName === this.cameraList[cam]){ return "Camera by that name already Exists" } } @@ -285,7 +297,7 @@ import CVinput from '../components/cv-input' return this.$store.state.pipeline; } }, - steamAdress: { + streamAddress: { get: function(){ return "http://"+location.hostname + ":"+ this.$store.state.port +"/stream.mjpg"; } diff --git a/chameleon-client/src/views/CameraViewes/OutputTab.vue b/chameleon-client/src/views/CameraViewes/OutputTab.vue index 822c87947..b740bac70 100644 --- a/chameleon-client/src/views/CameraViewes/OutputTab.vue +++ b/chameleon-client/src/views/CameraViewes/OutputTab.vue @@ -1,19 +1,13 @@ - - Calibrate: - - - Take Point A - - - Take Point B - - - Clear All Points - - - + + Calibrate: + + + Points are too close Close @@ -23,54 +17,39 @@