Refactor FileSaveFrameConsumer to close objects and let Java handle paths

This commit is contained in:
Gold856
2025-03-20 01:32:14 -04:00
committed by Matt Morley
parent c45c2a0a1f
commit 8a2c9f2ae0

View File

@@ -103,19 +103,17 @@ public class FileSaveFrameConsumer implements Consumer<CVMat> {
+ matchData; + matchData;
// Check if the Unique Camera directory exists and create it if it doesn't // 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(FILE_PATH, this.cameraUniqueName);
var cameraDir = new File(cameraPath);
if (!cameraDir.exists()) { if (!cameraDir.exists()) {
cameraDir.mkdir(); cameraDir.mkdir();
} }
var saveFilePath = cameraDir.toPath().resolve(fileName + FILE_EXTENSION);
String saveFilePath = cameraPath + File.separator + fileName + FILE_EXTENSION;
logger.info("Saving image to: " + saveFilePath); logger.info("Saving image to: " + saveFilePath);
if (image == null || image.getMat() == null || image.getMat().empty()) { if (image == null || image.getMat() == null || image.getMat().empty()) {
Imgcodecs.imwrite(saveFilePath, StaticFrames.LOST_MAT); Imgcodecs.imwrite(saveFilePath.toString(), StaticFrames.LOST_MAT);
} else { } else {
Imgcodecs.imwrite(saveFilePath, image.getMat()); Imgcodecs.imwrite(saveFilePath.toString(), image.getMat());
} }
savedImagesCount++; savedImagesCount++;
@@ -178,6 +176,9 @@ public class FileSaveFrameConsumer implements Consumer<CVMat> {
} }
public void close() { public void close() {
// troododfa;lkjadsf;lkfdsaj otgooadflsk;j saveFrameEntry.close();
ntEventName.close();
ntMatchNum.close();
ntMatchType.close();
} }
} }