mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Start adding config deserialization to ConfigManager
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.chameleonvision.classabstraction;
|
||||
|
||||
import com.chameleonvision.classabstraction.config.ConfigManager;
|
||||
import com.chameleonvision.settings.SettingsManager;
|
||||
import com.chameleonvision.util.FileHelper;
|
||||
import com.google.gson.Gson;
|
||||
@@ -13,6 +14,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class VisionManager {
|
||||
@@ -45,43 +47,46 @@ public class VisionManager {
|
||||
|
||||
FileHelper.CheckPath(CamConfigPath);
|
||||
|
||||
UsbCameraInfosByCameraName.forEach((cameraName, cameraInfo) -> {
|
||||
Path cameraConfigFolder = Paths.get(CamConfigPath.toString(), String.format("%s\\", cameraName));
|
||||
Path cameraConfigPath = Paths.get(cameraConfigFolder.toString(), String.format("%s.json", cameraName));
|
||||
Path cameraPipelinesPath = Paths.get(cameraConfigFolder.toString(), "pipelines.json");
|
||||
Path cameraDrivermodePath = Paths.get(cameraConfigFolder.toString(), "drivermode.json");
|
||||
// load the config
|
||||
var loadedConfigs = ConfigManager.initializeCameraConfig(new ArrayList<>(UsbCameraInfosByCameraName.keySet()));
|
||||
|
||||
try {
|
||||
|
||||
boolean cameraFolderExists = Files.exists(cameraConfigFolder);
|
||||
|
||||
if (!cameraFolderExists) {
|
||||
Files.createDirectory(cameraConfigFolder);
|
||||
}
|
||||
boolean cameraConfigExists = cameraFolderExists && Files.exists(cameraConfigPath);
|
||||
|
||||
if (Files.exists(cameraConfigFolder)) {
|
||||
if (Files.exists(cameraConfigPath)) {
|
||||
File cameraConfigFile = new File(cameraConfigPath.toString());
|
||||
if (cameraConfigFile.length() != 0) {
|
||||
try {
|
||||
Gson gson = new GsonBuilder().create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Files.createFile(cameraConfigPath);
|
||||
}
|
||||
} else {
|
||||
Files.createDirectory(cameraConfigFolder);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
// UsbCameraInfosByCameraName.forEach((cameraName, cameraInfo) -> {
|
||||
// Path cameraConfigFolder = Paths.get(CamConfigPath.toString(), String.format("%s\\", cameraName));
|
||||
// Path cameraConfigPath = Paths.get(cameraConfigFolder.toString(), String.format("%s.json", cameraName));
|
||||
// Path cameraPipelinesPath = Paths.get(cameraConfigFolder.toString(), "pipelines.json");
|
||||
// Path cameraDrivermodePath = Paths.get(cameraConfigFolder.toString(), "drivermode.json");
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// boolean cameraFolderExists = Files.exists(cameraConfigFolder);
|
||||
//
|
||||
// if (!cameraFolderExists) {
|
||||
// Files.createDirectory(cameraConfigFolder);
|
||||
// }
|
||||
// boolean cameraConfigExists = cameraFolderExists && Files.exists(cameraConfigPath);
|
||||
//
|
||||
// if (Files.exists(cameraConfigFolder)) {
|
||||
// if (Files.exists(cameraConfigPath)) {
|
||||
// File cameraConfigFile = new File(cameraConfigPath.toString());
|
||||
// if (cameraConfigFile.length() != 0) {
|
||||
// try {
|
||||
// Gson gson = new GsonBuilder().create();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// Files.createFile(cameraConfigPath);
|
||||
// }
|
||||
// } else {
|
||||
// Files.createDirectory(cameraConfigFolder);
|
||||
// }
|
||||
// } catch (IOException ex) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// });
|
||||
|
||||
// FileHelper.CheckPath(CamConfigPath);
|
||||
// UsbCameraInfosByCameraName.forEach((cameraName, cameraInfo) -> {
|
||||
|
||||
Reference in New Issue
Block a user