mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Misc fixes and cleanup
This commit is contained in:
@@ -25,16 +25,10 @@ import java.util.concurrent.LinkedBlockingDeque;
|
||||
public class VisionProcess {
|
||||
|
||||
private final CameraCapture cameraCapture;
|
||||
private final List<CVPipeline> pipelines = new ArrayList<>();
|
||||
private final CameraStreamerRunnable streamRunnable;
|
||||
private final VisionProcessRunnable visionRunnable;
|
||||
public final CameraStreamer cameraStreamer;
|
||||
public final PipelineManager pipelineManager;
|
||||
|
||||
// private CVPipeline currentPipeline;
|
||||
// private int currentPipelineIndex = 0;
|
||||
|
||||
// private CVPipeline driverModePipeline = new DriverVisionPipeline(new CVPipelineSettings());
|
||||
public PipelineManager pipelineManager;
|
||||
|
||||
private volatile CVPipelineResult lastPipelineResult;
|
||||
|
||||
@@ -110,6 +104,7 @@ public class VisionProcess {
|
||||
ntPipelineListenerID = ntPipelineEntry.addListener(this::setPipeline, EntryListenerFlags.kUpdate);
|
||||
ntDriverModeEntry.setBoolean(false);
|
||||
ntPipelineEntry.setNumber(pipelineManager.getCurrentPipelineIndex());
|
||||
pipelineManager.ntIndexEntry = ntPipelineEntry;
|
||||
}
|
||||
|
||||
private void setDriverMode(EntryNotification driverModeEntryNotification) {
|
||||
@@ -126,12 +121,7 @@ public class VisionProcess {
|
||||
*/
|
||||
private void setPipeline(EntryNotification notification) {
|
||||
var wantedPipelineIndex = (int) notification.value.getDouble();
|
||||
|
||||
if (wantedPipelineIndex >= pipelines.size()) {
|
||||
ntPipelineEntry.setNumber(pipelineManager.getCurrentPipelineIndex());
|
||||
} else {
|
||||
pipelineManager.setCurrentPipeline(wantedPipelineIndex);
|
||||
}
|
||||
pipelineManager.setCurrentPipeline(wantedPipelineIndex);
|
||||
}
|
||||
|
||||
private void updateUI(CVPipelineResult data) {
|
||||
@@ -216,18 +206,10 @@ public class VisionProcess {
|
||||
return cameraCapture;
|
||||
}
|
||||
|
||||
public void setDriverModeSettings(CVPipelineSettings settings) {
|
||||
pipelineManager.driverModePipeline.settings = settings;
|
||||
}
|
||||
|
||||
public CVPipelineSettings getDriverModeSettings() {
|
||||
return pipelineManager.driverModePipeline.settings;
|
||||
}
|
||||
|
||||
public boolean getIsDriverMode() {
|
||||
return pipelineManager.getDriverMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* VisionProcessRunnable will process images as quickly as possible
|
||||
*/
|
||||
|
||||
@@ -43,15 +43,17 @@ public class RequestHandler {
|
||||
VisionProcess currentVisionProcess = VisionManager.getCurrentUIVisionProcess();
|
||||
CameraCapture currentCamera = currentVisionProcess.getCamera();
|
||||
|
||||
Integer newFOV = (Integer) camSettings.get("fov");
|
||||
|
||||
double newFOV;
|
||||
try {
|
||||
newFOV = (Double) camSettings.get("fov");
|
||||
} catch (Exception ignored) {
|
||||
newFOV = (Integer) camSettings.get("fov");
|
||||
}
|
||||
Integer newStreamDivisor = (Integer) camSettings.get("streamDivisor");
|
||||
Integer newResolution = (Integer) camSettings.get("resolution");
|
||||
|
||||
currentCamera.getProperties().setFOV(newFOV);
|
||||
|
||||
currentVisionProcess.cameraStreamer.setDivisor(StreamDivisor.values()[newStreamDivisor], true);
|
||||
|
||||
currentCamera.setVideoMode(newResolution);
|
||||
|
||||
VisionManager.saveCurrentCameraSettings();
|
||||
|
||||
@@ -138,7 +138,7 @@ public class SocketHandler {
|
||||
default: {
|
||||
|
||||
// TODO handle not setting binary stuff on driver mode
|
||||
if(currentProcess.getIsDriverMode()) break;
|
||||
if(currentProcess.pipelineManager.getDriverMode()) break;
|
||||
|
||||
setField(currentPipeline.settings, entry.getKey(), entry.getValue());
|
||||
switch (entry.getKey()) {
|
||||
|
||||
Reference in New Issue
Block a user