mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-22 01:11:40 +00:00
Start moving stream into vision process
Should probs move into a pipe to be idimatic
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user