mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
More UI fixes, add videomode and StreamDivisor to config
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package com.chameleonvision.config;
|
||||
|
||||
import com.chameleonvision.vision.camera.USBCameraCapture;
|
||||
import com.chameleonvision.vision.VisionProcess;
|
||||
import com.chameleonvision.vision.camera.USBCameraProperties;
|
||||
import com.chameleonvision.vision.enums.StreamDivisor;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@@ -10,17 +11,23 @@ public class CameraJsonConfig {
|
||||
public final String path;
|
||||
public final String name;
|
||||
public final String nickname;
|
||||
public final int videomode;
|
||||
public final StreamDivisor streamDivisor;
|
||||
|
||||
@JsonCreator
|
||||
public CameraJsonConfig(
|
||||
@JsonProperty("fov") double fov,
|
||||
@JsonProperty("path") String path,
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("nickname") String nickname) {
|
||||
@JsonProperty("nickname") String nickname,
|
||||
@JsonProperty("videomode") int videomode,
|
||||
@JsonProperty("streamDivisor") StreamDivisor streamDivisor) {
|
||||
this.fov = fov;
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.nickname = nickname;
|
||||
this.videomode = videomode;
|
||||
this.streamDivisor = streamDivisor;
|
||||
}
|
||||
|
||||
public CameraJsonConfig(String path, String name) {
|
||||
@@ -28,10 +35,14 @@ public class CameraJsonConfig {
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.nickname = name;
|
||||
this.videomode = 0;
|
||||
this.streamDivisor = StreamDivisor.NONE;
|
||||
}
|
||||
|
||||
public static CameraJsonConfig fromUSBCameraProcess(USBCameraCapture process) {
|
||||
USBCameraProperties camProps = process.getProperties();
|
||||
return new CameraJsonConfig(camProps.getFOV(), camProps.path, camProps.name, camProps.getNickname());
|
||||
public static CameraJsonConfig fromVisionProcess(VisionProcess process) {
|
||||
USBCameraProperties camProps = process.getCamera().getProperties();
|
||||
int videomode = camProps.getCurrentVideoModeIndex();
|
||||
StreamDivisor streamDivisor = process.cameraStreamer.getDivisor();
|
||||
return new CameraJsonConfig(camProps.getFOV(), camProps.path, camProps.name, camProps.getNickname(), videomode, streamDivisor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class VisionManager {
|
||||
String cameraName = process.getCamera().getProperties().name;
|
||||
List<CVPipelineSettings> pipelines = process.getPipelines().stream().map(cvPipeline -> cvPipeline.settings).collect(Collectors.toList());
|
||||
CVPipelineSettings driverMode = process.getDriverModeSettings();
|
||||
CameraJsonConfig config = CameraJsonConfig.fromUSBCameraProcess((USBCameraCapture) process.getCamera());
|
||||
CameraJsonConfig config = CameraJsonConfig.fromVisionProcess(process);
|
||||
ConfigManager.saveCameraPipelines(cameraName, pipelines);
|
||||
ConfigManager.saveCameraDriverMode(cameraName, driverMode);
|
||||
ConfigManager.saveCameraConfig(cameraName, config);
|
||||
@@ -157,7 +157,7 @@ public class VisionManager {
|
||||
}
|
||||
|
||||
public static void saveCurrentCameraSettings() {
|
||||
CameraJsonConfig config = CameraJsonConfig.fromUSBCameraProcess((USBCameraCapture) currentUIVisionProcess.getCamera());
|
||||
CameraJsonConfig config = CameraJsonConfig.fromVisionProcess(currentUIVisionProcess);
|
||||
ConfigManager.saveCameraConfig(getCurrentCameraName(), config);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class VisionManager {
|
||||
}
|
||||
|
||||
public static List<HashMap> getCameraResolutionList(CameraCapture capture) {
|
||||
return capture.getProperties().getVideoModes().stream().map(object -> Helpers.VideoModeToHashMap(object)).collect(Collectors.toList());
|
||||
return capture.getProperties().getVideoModes().stream().map(Helpers::VideoModeToHashMap).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<HashMap> getCurrentCameraResolutionList() {
|
||||
|
||||
@@ -257,6 +257,8 @@ public class VisionProcess {
|
||||
|
||||
public void addBlankPipeline() {
|
||||
// TODO: (2.1) add to UI option between 2d and 3d pipeline
|
||||
var newPipeline = new CVPipeline2d();
|
||||
// if (pipelines.stream().filter(x -> x.settings.nickname.equals(newPipeline.settings.nickname));
|
||||
addPipeline(new CVPipeline2d());
|
||||
}
|
||||
|
||||
@@ -269,7 +271,7 @@ public class VisionProcess {
|
||||
addPipeline(new CVPipeline2d((CVPipeline2dSettings) settings));
|
||||
}
|
||||
}
|
||||
public void deletePipeline(int index){
|
||||
public void deletePipeline(int index) {
|
||||
pipelines.remove(index);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import edu.wpi.cscore.VideoMode;
|
||||
public interface CameraCapture extends ImageCapture {
|
||||
USBCameraProperties getProperties();
|
||||
|
||||
public VideoMode getCurrentVideoMode();
|
||||
VideoMode getCurrentVideoMode();
|
||||
|
||||
/**
|
||||
* Set the exposure of the camera
|
||||
@@ -22,10 +22,16 @@ public interface CameraCapture extends ImageCapture {
|
||||
|
||||
/**
|
||||
* Set the video mode (fps and resolution) of the camera
|
||||
* @param mode the wanted mode
|
||||
* @param mode the desired mode
|
||||
*/
|
||||
void setVideoMode(VideoMode mode);
|
||||
|
||||
/**
|
||||
* Set the video mode (fps and resolution) of the camera
|
||||
* @param index the index of the desired mode
|
||||
*/
|
||||
void setVideoMode(int index);
|
||||
|
||||
/**
|
||||
* Set the gain of the camera
|
||||
* NOTE - Not all cameras support this.
|
||||
|
||||
@@ -68,14 +68,11 @@ public class USBCameraCapture implements CameraCapture {
|
||||
System.err.println("Failed to change camera video mode!");
|
||||
}
|
||||
}
|
||||
|
||||
public void setVideoMode(int index){
|
||||
VideoMode mode = properties.getVideoModes().get(index);
|
||||
setVideoMode(mode);
|
||||
}
|
||||
public int getVideoModeIndex(){
|
||||
return properties.getVideoModes().indexOf(properties.getStaticProperties().mode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setGain(int gain) {
|
||||
|
||||
@@ -68,8 +68,10 @@ public class USBCameraProperties extends CaptureProperties {
|
||||
}
|
||||
|
||||
public void setFOV(double FOV) {
|
||||
this.FOV = FOV;
|
||||
staticProperties = new CaptureStaticProperties(staticProperties.mode, staticProperties.imageWidth, staticProperties.imageHeight, FOV);
|
||||
if (this.FOV != FOV) {
|
||||
this.FOV = FOV;
|
||||
staticProperties = new CaptureStaticProperties(staticProperties.mode, staticProperties.imageWidth, staticProperties.imageHeight, FOV);
|
||||
}
|
||||
}
|
||||
|
||||
public double getFOV() {
|
||||
@@ -97,4 +99,11 @@ public class USBCameraProperties extends CaptureProperties {
|
||||
public List<VideoMode> getVideoModes() {
|
||||
return videoModes;
|
||||
}
|
||||
|
||||
public VideoMode getCurrentVideoMode() { return staticProperties.mode; }
|
||||
|
||||
public int getCurrentVideoModeIndex(){
|
||||
return getVideoModes().indexOf(getCurrentVideoMode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,21 +43,17 @@ public class RequestHandler {
|
||||
VisionProcess currentVisionProcess = VisionManager.getCurrentUIVisionProcess();
|
||||
CameraCapture currentCamera = currentVisionProcess.getCamera();
|
||||
|
||||
Number newFOV = (Number) camSettings.get("fov");
|
||||
Double newFOV = (Double) camSettings.get("fov");
|
||||
Integer newStreamDivisor = (Integer) camSettings.get("streamDivisor");
|
||||
Integer newResolution = (Integer) camSettings.get("resolution");
|
||||
|
||||
currentCamera.getProperties().setFOV((double) newFOV);
|
||||
currentCamera.getProperties().setFOV(newFOV);
|
||||
|
||||
currentVisionProcess.cameraStreamer.setDivisor(StreamDivisor.values()[newStreamDivisor], true);
|
||||
|
||||
// TODO: Video Mode Index!!!!
|
||||
// var currentResolutionIndex = curCam.getVideoModeIndex();
|
||||
// if (currentResolutionIndex != newResolution) {
|
||||
// curCam.setCamVideoMode(newResolution, true);
|
||||
// }
|
||||
currentCamera.setVideoMode(newResolution);
|
||||
|
||||
VisionManager.saveAllCameras();
|
||||
VisionManager.saveCurrentCameraSettings();
|
||||
SocketHandler.sendFullSettings();
|
||||
ctx.status(200);
|
||||
} catch (JsonProcessingException e) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.chameleonvision.config.ConfigManager;
|
||||
import com.chameleonvision.vision.VisionManager;
|
||||
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.CVPipelineSettings;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@@ -105,6 +104,7 @@ public class SocketHandler {
|
||||
case "command": {
|
||||
switch ((String) entry.getValue()) {
|
||||
case "addNewPipeline":
|
||||
|
||||
currentProcess.addBlankPipeline();
|
||||
sendFullSettings();
|
||||
VisionManager.saveCurrentCameraPipelines();
|
||||
@@ -117,7 +117,6 @@ public class SocketHandler {
|
||||
currentProcess.deletePipeline(currentIndex);
|
||||
sendFullSettings();
|
||||
VisionManager.saveCurrentCameraPipelines();
|
||||
// TODO remove pipeline file after deleting
|
||||
break;
|
||||
case "save":
|
||||
ConfigManager.saveGeneralSettings();
|
||||
@@ -225,7 +224,7 @@ public class SocketHandler {
|
||||
CameraCapture currentCamera = VisionManager.getCurrentUIVisionProcess().getCamera();
|
||||
tmp.put("fov", currentCamera.getProperties().getFOV());
|
||||
tmp.put("streamDivisor", currentVisionProcess.cameraStreamer.getDivisor().ordinal());
|
||||
// TODO: (HIGH) get videomode index!
|
||||
tmp.put("resolution", currentVisionProcess.getCamera().getProperties().getCurrentVideoModeIndex());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
return this.value;
|
||||
},
|
||||
set(value) {
|
||||
this.$emit('input', parseInt(value));
|
||||
this.$emit('input', parseFloat(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</v-col>
|
||||
<v-col class="colsClass" v-show="selectedTab === 1 || selectedTab === 2">
|
||||
<div class="videoClass">
|
||||
<img :src="steamAddress">
|
||||
<img :src="streamAddress" alt="Camera Stream">
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -52,7 +52,7 @@
|
||||
return "";
|
||||
}
|
||||
},
|
||||
steamAddress: {
|
||||
streamAddress: {
|
||||
get: function () {
|
||||
return "http://" + location.hostname + ":" + this.$store.state.port + "/stream.mjpg";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user