mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Fix large calibration datasets crashes (#1453)
The target list in networktables is limited to 127 items. When you capture more than 127 calibration images it breaks this limit and errors out and dies. Do not publish calibration targets to nt. And also move cal images into their own folder
This commit is contained in:
@@ -31,6 +31,7 @@ import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import javax.imageio.ImageIO;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.core.MatOfInt;
|
||||
import org.opencv.imgcodecs.Imgcodecs;
|
||||
@@ -579,11 +580,23 @@ public class RequestHandler {
|
||||
|
||||
// encode as jpeg to save even more space. reduces size of a 1280p image from 300k to 25k
|
||||
var jpegBytes = new MatOfByte();
|
||||
Imgcodecs.imencode(
|
||||
".jpg",
|
||||
calList.observations.get(observationIdx).snapshotData.getAsMat(),
|
||||
jpegBytes,
|
||||
new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 60));
|
||||
Mat img = null;
|
||||
try {
|
||||
img =
|
||||
Imgcodecs.imread(
|
||||
calList.observations.get(observationIdx).snapshotDataLocation.toString());
|
||||
} catch (Exception e) {
|
||||
ctx.status(500);
|
||||
ctx.result("Unable to read calibration image");
|
||||
return;
|
||||
}
|
||||
if (img == null || img.empty()) {
|
||||
ctx.status(500);
|
||||
ctx.result("Unable to read calibration image");
|
||||
return;
|
||||
}
|
||||
|
||||
Imgcodecs.imencode(".jpg", img, jpegBytes, new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 60));
|
||||
|
||||
ctx.result(jpegBytes.toArray());
|
||||
jpegBytes.release();
|
||||
|
||||
Reference in New Issue
Block a user