bug fixed settings not saving
This commit is contained in:
Ori agranat
2020-03-04 23:12:02 +02:00
committed by GitHub
parent 321a90ac08
commit da6f0e8a81
14 changed files with 239 additions and 64 deletions

View File

@@ -86,18 +86,13 @@ public class VisionProcess {
}
public void start() {
System.out.println("Starting NetworkTables.");
System.out.printf("[%s Process] Creating network table...\n", getCamera().getProperties().getNickname());
initNT(defaultTable);
System.out.println("Starting vision thread.");
System.out.printf("[%s Process] Starting vision thread...\n", getCamera().getProperties().getNickname());
var visionThread = new Thread(visionRunnable);
visionThread.setName(getCamera().getProperties().name + " - Vision Thread");
visionThread.start();
// System.out.println("Starting stream thread.");
// var streamThread = new Thread(streamRunnable);
// streamThread.setName(getCamera().getProperties().name + " - Stream Thread");
// streamThread.start();
}
/**
@@ -299,7 +294,7 @@ public class VisionProcess {
public void addCalibration(CameraCalibrationConfig cal) {
cameraCapture.addCalibrationData(cal);
System.out.println("saving to file");
fileConfig.saveCalibration(cameraCapture.getConfig());
fileConfig.saveCalibration(cameraCapture.getAllCalibrationData());
}
public void setIs3d(Boolean value) {
@@ -329,6 +324,9 @@ public class VisionProcess {
public void run() {
var lastUpdateTimeNanos = System.nanoTime();
var lastStreamTimeMs = System.currentTimeMillis();
System.out.printf("[%s Process] Vision Process Thread -- first run!\n", getCamera().getProperties().getNickname());
while (!Thread.interrupted()) {
// blocking call, will block until camera has a new frame.
@@ -357,14 +355,19 @@ public class VisionProcess {
try {
var currentTime = System.currentTimeMillis();
if ((currentTime - lastStreamTimeMs) / 1000d > 1.0 / 30.0) {
cameraStreamer.runStream(lastPipelineResult.outputMat);
// System.out.println("Ran stream in " + (System.currentTimeMillis() - currentTime) + "ms!");
lastStreamTimeMs = currentTime;
lastPipelineResult.outputMat.release();
if(lastPipelineResult != null) {
cameraStreamer.runStream(lastPipelineResult.outputMat);
lastStreamTimeMs = currentTime;
lastPipelineResult.outputMat.release();
} else {
System.err.printf("[%s Process] Last pipeline result was null!\n", getCamera().getProperties().getNickname());
}
}
} catch (Exception e) {
Debug.printInfo("Vision running faster than stream.");
// Debug.printInfo("Vision running faster than stream.");
System.err.printf("[%s Process] Exception in vision thread!\n", getCamera().getProperties().getNickname());
e.printStackTrace();
}
var deltaTimeNanos = System.nanoTime() - lastUpdateTimeNanos;