mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Various cleanup, slowed down UI FPS counter
This commit is contained in:
@@ -2,6 +2,7 @@ package com.chameleonvision.vision.camera;
|
||||
|
||||
import edu.wpi.cscore.VideoMode;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class CamVideoMode {
|
||||
public final int fps;
|
||||
public final int width;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.chameleonvision.vision.camera;
|
||||
|
||||
import com.chameleonvision.settings.SettingsManager;
|
||||
import com.chameleonvision.vision.Pipeline;
|
||||
import edu.wpi.cscore.*;
|
||||
import edu.wpi.first.cameraserver.CameraServer;
|
||||
@@ -70,7 +69,7 @@ public class Camera {
|
||||
cvSink = cs.getVideo(UsbCam);
|
||||
cvSource = cs.putVideo(name, camVals.ImageWidth, camVals.ImageHeight);
|
||||
var s = (MjpegServer) cs.getServer("serve_" + name);
|
||||
SettingsManager.CameraPorts.put(name, s.getPort());
|
||||
CameraManager.CameraPorts.put(name, s.getPort());
|
||||
}
|
||||
|
||||
public void setCamVideoMode(int videoMode) {
|
||||
@@ -160,10 +159,6 @@ public class Camera {
|
||||
return cvSink.grabFrame(image);
|
||||
}
|
||||
|
||||
public long grabFrame(Mat image, double timeout) {
|
||||
return cvSink.grabFrame(image, timeout);
|
||||
}
|
||||
|
||||
public CameraValues getCamVals() {
|
||||
return camVals;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ public class CameraDeserializer implements JsonDeserializer<Camera> {
|
||||
public Camera deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||
var jsonObj = jsonElement.getAsJsonObject();
|
||||
var camFOV = jsonObj.get("FOV").getAsDouble();
|
||||
var camPath = jsonObj.get("path").getAsString();
|
||||
var camName = jsonObj.get("name").getAsString();
|
||||
|
||||
var pipelines = jsonObj.get("pipelines");
|
||||
|
||||
@@ -39,7 +39,11 @@ public class CameraManager {
|
||||
|
||||
private static HashMap<String, Camera> AllCamerasByName = new HashMap<>();
|
||||
|
||||
public static HashMap<String, Camera> getAllCamerasByName() { return AllCamerasByName; }
|
||||
public static HashMap<String, Camera> getAllCamerasByName() {
|
||||
return AllCamerasByName;
|
||||
}
|
||||
|
||||
public static HashMap<String, Integer> CameraPorts = new HashMap<>();
|
||||
|
||||
public static boolean initializeCameras() {
|
||||
if (AllUsbCameraInfosByName.size() == 0) return false;
|
||||
@@ -77,7 +81,8 @@ public class CameraManager {
|
||||
}
|
||||
|
||||
public static void setCurrentCamera(String cameraName) throws CameraException {
|
||||
if (!AllCamerasByName.containsKey(cameraName)) throw new CameraException(CameraException.CameraExceptionType.BAD_CAMERA);
|
||||
if (!AllCamerasByName.containsKey(cameraName))
|
||||
throw new CameraException(CameraException.CameraExceptionType.BAD_CAMERA);
|
||||
SettingsManager.GeneralSettings.curr_camera = cameraName;
|
||||
SettingsManager.updateCameraSetting(cameraName, getCurrentCamera().getCurrentPipelineIndex());
|
||||
}
|
||||
@@ -90,7 +95,8 @@ public class CameraManager {
|
||||
}
|
||||
|
||||
public static void setCurrentPipeline(int pipelineNumber) throws CameraException {
|
||||
if (!getCurrentCamera().getPipelines().containsKey(pipelineNumber)) throw new CameraException(CameraException.CameraExceptionType.BAD_PIPELINE);
|
||||
if (!getCurrentCamera().getPipelines().containsKey(pipelineNumber))
|
||||
throw new CameraException(CameraException.CameraExceptionType.BAD_PIPELINE);
|
||||
getCurrentCamera().setCurrentPipelineIndex(pipelineNumber);
|
||||
SettingsManager.updatePipelineSetting(pipelineNumber);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ public class CameraSerializer implements JsonSerializer<Camera> {
|
||||
var pipelines = context.serialize(camera.getPipelines());
|
||||
obj.add("pipelines", pipelines);
|
||||
|
||||
var videoModeIndex = camera.getVideoModeIndex();
|
||||
obj.addProperty("resolution", camera.getVideoModeIndex());
|
||||
obj.add("camVideoMode", context.serialize(camera.getVideoMode()));
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.chameleonvision.vision.camera;
|
||||
import org.apache.commons.math3.fraction.Fraction;
|
||||
import org.apache.commons.math3.util.FastMath;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class CameraValues {
|
||||
public final int ImageWidth;
|
||||
public final int ImageHeight;
|
||||
|
||||
Reference in New Issue
Block a user