Start moving stream into vision process

Should probs move into a pipe to be idimatic
This commit is contained in:
Matt
2020-01-03 09:54:05 -08:00
parent 423cf2daf9
commit f9aca69980

View File

@@ -89,10 +89,10 @@ public class VisionProcess {
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();
// System.out.println("Starting stream thread.");
// var streamThread = new Thread(streamRunnable);
// streamThread.setName(getCamera().getProperties().name + " - Stream Thread");
// streamThread.start();
}
/**
@@ -304,6 +304,7 @@ public class VisionProcess {
@Override
public void run() {
var lastUpdateTimeNanos = System.nanoTime();
var lastStreamTimeMs = System.currentTimeMillis();
while (!Thread.interrupted()) {
// blocking call, will block until camera has a new frame.
@@ -330,8 +331,16 @@ public class VisionProcess {
}
try {
streamFrameQueue.clear();
streamFrameQueue.add(lastPipelineResult.outputMat);
// streamFrameQueue.clear();
// streamFrameQueue.add(lastPipelineResult.outputMat);
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();
}
} catch (Exception e) {
Debug.printInfo("Vision running faster than stream.");
}