Update cameraRunnable fps with video mode change

This commit is contained in:
Matt
2019-11-23 09:09:31 -08:00
parent 4dc86c6f25
commit dbe22417ae
2 changed files with 7 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ package com.chameleonvision.util;
* A thread that tries to run at a specified loop time
*/
public abstract class LoopingRunnable implements Runnable {
private final Long loopTimeMs;
protected volatile Long loopTimeMs;
protected abstract void process();

View File

@@ -61,8 +61,7 @@ public class VisionProcess {
// Thread to grab frames from the camera
// TODO: (HIGH) fix video modes!!!
// TODO: (HIGH) FIX FPS!!!!!!!
this.cameraRunnable = new CameraFrameRunnable(cameraProcess.getProperties().videoModes.get(0).fps);
this.cameraRunnable = new CameraFrameRunnable(cameraProcess.getProperties().videoModes.get(0).f ps);
lastPipelineResult = new DriverVisionPipeline.DriverPipelineResult(
null, cameraRunnable.getFrame(new Mat()), 0
@@ -229,6 +228,7 @@ public class VisionProcess {
public void setVideoMode(VideoMode newMode) {
cameraProcess.setVideoMode(newMode);
cameraRunnable.updateCameraFPS(newMode.fps);
cameraStreamer.setNewVideoMode(newMode);
}
@@ -290,6 +290,10 @@ public class VisionProcess {
super(1000L/(cameraFPS + 2));
}
void updateCameraFPS(int newFPS) {
super.loopTimeMs = 1000L / (newFPS + 2);
}
@Override
public void process() {
System.out.println("running camera grabber process");