mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-06 03:31:41 +00:00
Fix pipeline renaming and saving, RotationMode UI fix
This commit is contained in:
@@ -17,7 +17,7 @@ public class CameraConfig {
|
||||
private final String cameraConfigName;
|
||||
private final CameraJsonConfig preliminaryConfig;
|
||||
|
||||
private final PipelineConfig pipelineConfig;
|
||||
public final PipelineConfig pipelineConfig;
|
||||
|
||||
CameraConfig(CameraJsonConfig config) {
|
||||
preliminaryConfig = config;
|
||||
@@ -31,7 +31,7 @@ public class CameraConfig {
|
||||
checkDriverMode();
|
||||
pipelineConfig.check();
|
||||
|
||||
return new FullCameraConfiguration(loadConfig(), pipelineConfig.load(), loadDriverMode());
|
||||
return new FullCameraConfiguration(loadConfig(), pipelineConfig.load(), loadDriverMode(), this);
|
||||
}
|
||||
|
||||
private CameraJsonConfig loadConfig() {
|
||||
|
||||
@@ -8,10 +8,12 @@ public class FullCameraConfiguration {
|
||||
public final CameraJsonConfig cameraConfig;
|
||||
public final List<CVPipelineSettings> pipelines;
|
||||
public final CVPipelineSettings drivermode;
|
||||
public final CameraConfig fileConfig;
|
||||
|
||||
FullCameraConfiguration(CameraJsonConfig cameraConfig, List<CVPipelineSettings> pipelines, CVPipelineSettings drivermode) {
|
||||
FullCameraConfiguration(CameraJsonConfig cameraConfig, List<CVPipelineSettings> pipelines, CVPipelineSettings drivermode, CameraConfig fileConfig) {
|
||||
this.cameraConfig = cameraConfig;
|
||||
this.pipelines = pipelines;
|
||||
this.drivermode = drivermode;
|
||||
this.fileConfig = fileConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class PipelineConfig {
|
||||
return Files.exists(getPipelinePath(setting));
|
||||
}
|
||||
|
||||
private void save(CVPipelineSettings settings) {
|
||||
public void save(CVPipelineSettings settings) {
|
||||
|
||||
var path = getPipelinePath(settings);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.chameleonvision.vision;
|
||||
|
||||
import com.chameleonvision.config.CameraConfig;
|
||||
import com.chameleonvision.config.CameraJsonConfig;
|
||||
import com.chameleonvision.config.ConfigManager;
|
||||
import com.chameleonvision.config.FullCameraConfiguration;
|
||||
@@ -7,13 +8,11 @@ import com.chameleonvision.util.Helpers;
|
||||
import com.chameleonvision.util.Platform;
|
||||
import com.chameleonvision.vision.camera.CameraCapture;
|
||||
import com.chameleonvision.vision.camera.USBCameraCapture;
|
||||
import com.chameleonvision.vision.pipeline.CVPipeline;
|
||||
import com.chameleonvision.vision.pipeline.CVPipelineSettings;
|
||||
import edu.wpi.cscore.UsbCamera;
|
||||
import edu.wpi.cscore.UsbCameraInfo;
|
||||
import org.opencv.videoio.VideoCapture;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -75,13 +74,6 @@ public class VisionManager {
|
||||
|
||||
loadedCameraConfigs.addAll(ConfigManager.initializeCameras(preliminaryConfigs));
|
||||
|
||||
// TODO: (HIGH) Load pipelines from json
|
||||
// UsbCameraInfosByCameraName.forEach((cameraName, cameraInfo) -> {
|
||||
// Path cameraConfigFolder = Paths.get(CamConfigPath.toString(), String.format("%s\\", cameraName));
|
||||
// Path cameraConfigPath = Paths.get(cameraConfigFolder.toString(), String.format("%s.json", cameraName));
|
||||
// Path cameraPipelinesPath = Paths.get(cameraConfigFolder.toString(), "pipelines.json");
|
||||
// Path cameraDrivermodePath = Paths.get(cameraConfigFolder.toString(), "drivermode.json");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -102,15 +94,23 @@ public class VisionManager {
|
||||
}
|
||||
|
||||
public static void startProcesses() {
|
||||
visionProcesses.forEach((vpm) -> {
|
||||
vpm.visionProcess.start();
|
||||
});
|
||||
visionProcesses.forEach((vpm) -> vpm.visionProcess.start());
|
||||
}
|
||||
|
||||
public static VisionProcess getCurrentUIVisionProcess() {
|
||||
return currentUIVisionProcess;
|
||||
}
|
||||
|
||||
private static CameraConfig getCameraConfig(VisionProcess process) {
|
||||
String cameraName = process.getCamera().getProperties().name;
|
||||
return Objects.requireNonNull(loadedCameraConfigs.stream().filter(x -> x.cameraConfig.name.equals(cameraName)).findFirst().orElse(null)).fileConfig;
|
||||
}
|
||||
|
||||
public static void addPipelineToCamera(CVPipelineSettings newPipeline, VisionProcess process) {
|
||||
getCameraConfig(process).pipelineConfig.save(newPipeline);
|
||||
process.addPipeline(newPipeline);
|
||||
}
|
||||
|
||||
public static void setCurrentProcessByIndex(int processIndex) {
|
||||
if (processIndex > visionProcesses.size() - 1) {
|
||||
return;
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.chameleonvision.vision.VisionProcess;
|
||||
import com.chameleonvision.vision.camera.CameraCapture;
|
||||
import com.chameleonvision.vision.enums.ImageRotationMode;
|
||||
import com.chameleonvision.vision.pipeline.CVPipeline;
|
||||
import com.chameleonvision.vision.pipeline.CVPipeline2dSettings;
|
||||
import com.chameleonvision.vision.pipeline.CVPipelineSettings;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -16,7 +15,6 @@ import io.javalin.websocket.WsCloseContext;
|
||||
import io.javalin.websocket.WsConnectContext;
|
||||
import io.javalin.websocket.WsContext;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.msgpack.jackson.dataformat.MessagePackFactory;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
@@ -86,15 +84,20 @@ public class SocketHandler {
|
||||
CVPipelineSettings origPipeline = currentProcess.getPipelineByIndex(pipelineIndex).settings;
|
||||
String val = mapper.writeValueAsString(origPipeline);
|
||||
CVPipelineSettings newPipeline = mapper.readValue(val, origPipeline.getClass());
|
||||
|
||||
newPipeline.nickname += "(Copy)";
|
||||
|
||||
if (cameraIndex != -1) {
|
||||
VisionProcess newProcess = VisionManager.getVisionProcessByIndex(cameraIndex);
|
||||
if (newProcess != null) {
|
||||
VisionManager.addPipelineToCamera(newPipeline, newProcess);
|
||||
newProcess.addPipeline(newPipeline);
|
||||
}
|
||||
} else {
|
||||
VisionManager.addPipelineToCamera(newPipeline, currentProcess);
|
||||
currentProcess.addPipeline(newPipeline);
|
||||
}
|
||||
|
||||
VisionManager.saveCurrentCameraPipelines();
|
||||
sendFullSettings();
|
||||
break;
|
||||
|
||||
40
chameleon-client/package-lock.json
generated
40
chameleon-client/package-lock.json
generated
@@ -2805,7 +2805,8 @@
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
|
||||
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"coa": {
|
||||
"version": "2.0.2",
|
||||
@@ -9388,7 +9389,8 @@
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz",
|
||||
"integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"rx-lite-aggregates": {
|
||||
"version": "4.0.8",
|
||||
@@ -13498,7 +13500,8 @@
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@@ -13535,7 +13538,8 @@
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
@@ -13544,7 +13548,8 @@
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@@ -13647,7 +13652,8 @@
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@@ -13657,6 +13663,7 @@
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@@ -13669,17 +13676,20 @@
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
@@ -13696,6 +13706,7 @@
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@@ -13768,7 +13779,8 @@
|
||||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@@ -13778,6 +13790,7 @@
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@@ -13853,7 +13866,8 @@
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@@ -13883,6 +13897,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",
|
||||
@@ -13900,6 +13915,7 @@
|
||||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@@ -13938,11 +13954,13 @@
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.2",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -15,12 +15,12 @@ export default new Vuex.Store({
|
||||
ip: "",
|
||||
gateway: "",
|
||||
netmask: "",
|
||||
hostname: "Chameleon-vision"
|
||||
hostname: "chameleon-vision"
|
||||
},
|
||||
pipeline: {
|
||||
exposure: 0,
|
||||
brightness: 0,
|
||||
flipMode: 0,
|
||||
rotationMode: 0,
|
||||
hue: [0, 15],
|
||||
saturation: [0, 15],
|
||||
value: [0, 25],
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<div>
|
||||
<CVslider name="Exposure" v-model="value.exposure" :min="0" :max="100" @input="handleData('exposure')"/>
|
||||
<CVslider name="Brightness" v-model="value.brightness" :min="0" :max="100" @input="handleData('brightness')"/>
|
||||
<CVselect name="Orientation" v-model="value.rotationMode" :list="['Normal','90°','180°','270°']"
|
||||
@input="handleData('flipMode')"/>
|
||||
<CVselect name="Orientation" v-model="value.rotationMode" :list="['Normal','90° CW','180°','90° CCW']"
|
||||
@input="handleData('rotationMode')"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user