mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
added current pipeline to full settings and current camera
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.chameleonvision.vision.camera;
|
||||
|
||||
import com.chameleonvision.settings.GeneralSettings;
|
||||
import com.chameleonvision.util.FileHelper;
|
||||
import com.chameleonvision.settings.SettingsManager;
|
||||
import com.chameleonvision.vision.Pipeline;
|
||||
@@ -13,10 +14,7 @@ import org.opencv.videoio.VideoCapture;
|
||||
import java.io.*;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CameraManager {
|
||||
@@ -103,6 +101,16 @@ public class CameraManager {
|
||||
if (curCam == null) throw new CameraException(CameraException.CameraExceptionType.BAD_CAMERA);
|
||||
return curCam;
|
||||
}
|
||||
public static Integer getCurrentCameraIndex() throws CameraException {
|
||||
if (AllCamerasByName.size() == 0) throw new CameraException(CameraException.CameraExceptionType.NO_CAMERA);
|
||||
List<String> arr = new ArrayList<>(AllCamerasByName.keySet());
|
||||
for (var i = 0; i < AllCamerasByName.size(); i++){
|
||||
if (SettingsManager.GeneralSettings.currentCamera.equals(arr.get(i))){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setCurrentCamera(String cameraName) throws CameraException {
|
||||
if (!AllCamerasByName.containsKey(cameraName))
|
||||
|
||||
@@ -70,6 +70,7 @@ public class ServerHandler {
|
||||
}
|
||||
case "changePipelineName": {
|
||||
CameraManager.getCurrentPipeline().nickname = (String) entry.getValue();
|
||||
sendFullSettings();
|
||||
break;
|
||||
}
|
||||
case "duplicatePipeline": {
|
||||
@@ -95,7 +96,7 @@ public class ServerHandler {
|
||||
break;
|
||||
case "deleteCurrentPipeline":
|
||||
int currentIndex = cam.getCurrentPipelineIndex();
|
||||
int nextIndex = 0;
|
||||
int nextIndex;
|
||||
if (currentIndex == cam.getPipelines().size() - 1){
|
||||
nextIndex = currentIndex - 1;
|
||||
} else {
|
||||
@@ -111,13 +112,7 @@ public class ServerHandler {
|
||||
}
|
||||
case "currentCamera": {
|
||||
CameraManager.setCurrentCamera((String) entry.getValue());
|
||||
var cam = CameraManager.getCurrentCamera();
|
||||
HashMap<String, Object> tmp = new HashMap<>();
|
||||
tmp.put("pipeline", cam.getCurrentPipeline());
|
||||
tmp.put("pipelineList", cam.getPipelinesNickname());
|
||||
tmp.put("port", cam.getStreamPort());
|
||||
tmp.put("resolutionList", cam.getResolutionList());
|
||||
broadcastMessage(tmp);
|
||||
sendFullSettings();
|
||||
break;
|
||||
}
|
||||
case "currentPipeline": {
|
||||
@@ -244,6 +239,8 @@ public class ServerHandler {
|
||||
fullSettings.put("pipelineList", currentCamera.getPipelinesNickname());
|
||||
fullSettings.put("resolutionList", currentCamera.getResolutionList());
|
||||
fullSettings.put("port", currentCamera.getStreamPort());
|
||||
fullSettings.put("currentPipelineIndex",CameraManager.getCurrentCamera().getCurrentPipelineIndex());
|
||||
fullSettings.put("currentCameraIndex", CameraManager.getCurrentCameraIndex());
|
||||
} catch (CameraException | IllegalAccessException e) {
|
||||
System.err.println("No camera found!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user