mirror of
https://github.com/PhotonVision/photonvision
synced 2026-07-03 03:01:40 +00:00
Refactor FileSaveFrameConsumer to close objects and let Java handle paths
This commit is contained in:
@@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user