fixed resolution list send to ui

This commit is contained in:
ori agranat
2019-11-29 13:34:38 +02:00
parent 25613d2625
commit 288000b295
4 changed files with 14 additions and 10 deletions

View File

@@ -4,15 +4,22 @@ import edu.wpi.cscore.VideoMode;
import org.opencv.core.Scalar;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
public class Helpers {
private Helpers() {}
private Helpers() {
}
public static Scalar colorToScalar(Color color) {
return new Scalar(color.getRed(), color.getGreen(), color.getBlue());
}
public static String VideoModeToString(VideoMode videoMode) {
return String.format("%dx%d@%dFPS in %s", videoMode.width, videoMode.height, videoMode.fps, videoMode.pixelFormat.toString());
public static HashMap VideoModeToHashMap(VideoMode videoMode) {
return new HashMap<String, Object>() {{
put("width", videoMode.width);
put("height", videoMode.height);
put("fps", videoMode.fps);
put("pixelFormat", videoMode.pixelFormat.toString());}};
}
}

View File

@@ -171,11 +171,11 @@ public class VisionManager {
ConfigManager.saveCameraDriverMode(getCurrentCameraName(), driverModeSettings);
}
public static List<String> getCameraResolutionList(CameraCapture capture) {
return capture.getProperties().getVideoModes().stream().map(Helpers::VideoModeToString).collect(Collectors.toList());
public static List<HashMap> getCameraResolutionList(CameraCapture capture) {
return capture.getProperties().getVideoModes().stream().map(object -> Helpers.VideoModeToHashMap(object)).collect(Collectors.toList());
}
public static List<String> getCurrentCameraResolutionList() {
public static List<HashMap> getCurrentCameraResolutionList() {
return getCameraResolutionList(currentUIVisionProcess.getCamera());
}

View File

@@ -240,7 +240,6 @@ public class SocketHandler {
tmp.put("fov", currentCamera.getProperties().getFOV());
tmp.put("streamDivisor", currentVisionProcess.cameraStreamer.getDivisor().ordinal());
// TODO: (HIGH) get videomode index!
// tmp.put("resolution", currentCamera.getVideoModeIndex());
return tmp;
}
@@ -263,8 +262,6 @@ public class SocketHandler {
CVPipeline currentPipeline = currentProcess.getCurrentPipeline();
try {
// fullSettings.putAll(settingsToMap(ConfigManager.settings));
// fullSettings.putAll(pipelineToMap(currentPipeline.settings));
fullSettings.put("settings", getOrdinalSettings());
fullSettings.put("cameraSettings", getOrdinalCameraSettings());
fullSettings.put("cameraList", VisionManager.getAllCameraNicknames());