Show Saved Snapshots in UI (#995)

Add Camera Control tab to Cameras for the button to live in
This commit is contained in:
Sriman Achanta
2023-11-05 11:33:45 -05:00
committed by GitHub
parent 9370937280
commit 623b4e5b84
8 changed files with 277 additions and 10 deletions

View File

@@ -47,14 +47,16 @@ public class FileSaveFrameConsumer implements Consumer<CVMat> {
private final String ntEntryName;
private IntegerEntry saveFrameEntry;
private final String cameraUniqueName;
private String cameraNickname;
private final String streamType;
private long savedImagesCount = 0;
public FileSaveFrameConsumer(String camNickname, String streamPrefix) {
public FileSaveFrameConsumer(String camNickname, String cameraUniqueName, String streamPrefix) {
this.ntEntryName = streamPrefix + NT_SUFFIX;
this.cameraNickname = camNickname;
this.cameraUniqueName = cameraUniqueName;
this.streamType = streamPrefix;
this.rootTable = NetworkTablesManager.getInstance().kRootTable;
@@ -74,7 +76,15 @@ public class FileSaveFrameConsumer implements Consumer<CVMat> {
String fileName =
cameraNickname + "_" + streamType + "_" + df.format(now) + "T" + tf.format(now);
String saveFilePath = FILE_PATH + File.separator + fileName + FILE_EXTENSION;
// Check if the Unique Camera directory exists and create it if it doesn't
String cameraPath = FILE_PATH + File.separator + this.cameraUniqueName;
var cameraDir = new File(cameraPath);
if (!cameraDir.exists()) {
cameraDir.mkdir();
}
String saveFilePath = cameraPath + File.separator + fileName + FILE_EXTENSION;
Imgcodecs.imwrite(saveFilePath, image.getMat());

View File

@@ -176,10 +176,15 @@ public class VisionModule {
this.outputStreamPort = 1181 + (camStreamIdx * 2) + 1;
inputFrameSaver =
new FileSaveFrameConsumer(visionSource.getSettables().getConfiguration().nickname, "input");
new FileSaveFrameConsumer(
visionSource.getSettables().getConfiguration().nickname,
visionSource.getSettables().getConfiguration().uniqueName,
"input");
outputFrameSaver =
new FileSaveFrameConsumer(
visionSource.getSettables().getConfiguration().nickname, "output");
visionSource.getSettables().getConfiguration().nickname,
visionSource.getSettables().getConfiguration().uniqueName,
"output");
String camHostname = CameraServerJNI.getHostname();
inputVideoStreamer =