mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-19 00:41:41 +00:00
Show board outliers in calibration info card (#1267)
This commit is contained in:
@@ -187,6 +187,15 @@ public class Main {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
var logLevel = printDebugLogs ? LogLevel.TRACE : LogLevel.DEBUG;
|
||||
Logger.setLevel(LogGroup.Camera, logLevel);
|
||||
Logger.setLevel(LogGroup.WebServer, logLevel);
|
||||
Logger.setLevel(LogGroup.VisionModule, logLevel);
|
||||
Logger.setLevel(LogGroup.Data, logLevel);
|
||||
Logger.setLevel(LogGroup.Config, logLevel);
|
||||
Logger.setLevel(LogGroup.General, logLevel);
|
||||
logger.info("Logging initialized in debug mode.");
|
||||
|
||||
logger.info(
|
||||
"Starting PhotonVision version "
|
||||
+ PhotonVersion.versionString
|
||||
@@ -257,15 +266,6 @@ public class Main {
|
||||
CVMat.enablePrint(false);
|
||||
PipelineProfiler.enablePrint(false);
|
||||
|
||||
var logLevel = printDebugLogs ? LogLevel.TRACE : LogLevel.DEBUG;
|
||||
Logger.setLevel(LogGroup.Camera, logLevel);
|
||||
Logger.setLevel(LogGroup.WebServer, logLevel);
|
||||
Logger.setLevel(LogGroup.VisionModule, logLevel);
|
||||
Logger.setLevel(LogGroup.Data, logLevel);
|
||||
Logger.setLevel(LogGroup.Config, logLevel);
|
||||
Logger.setLevel(LogGroup.General, logLevel);
|
||||
logger.info("Logging initialized in debug mode.");
|
||||
|
||||
// Add Linux kernel log->Photon logger
|
||||
KernelLogLogger.getInstance();
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.LinkedList;
|
||||
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.core.Size;
|
||||
@@ -525,7 +524,7 @@ public class RequestHandler {
|
||||
public static void onDataCalibrationImportRequest(Context ctx) {
|
||||
try {
|
||||
DataCalibrationImportRequest request =
|
||||
kObjectMapper.readValue(ctx.body(), DataCalibrationImportRequest.class);
|
||||
kObjectMapper.readValue(ctx.req().getInputStream(), DataCalibrationImportRequest.class);
|
||||
|
||||
var uploadCalibrationEvent =
|
||||
new IncomingWebSocketEvent<>(
|
||||
@@ -1000,6 +999,41 @@ public class RequestHandler {
|
||||
ctx.status(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the calibration JSON for a specific observation. Excludes camera image data
|
||||
*
|
||||
* <p>This is excluded from UICalibrationCoefficients by default to save bandwidth on large
|
||||
* calibrations
|
||||
*/
|
||||
public static void onCalibrationJsonRequest(Context ctx) {
|
||||
String cameraUniqueName = ctx.queryParam("cameraUniqueName");
|
||||
var width = Integer.parseInt(ctx.queryParam("width"));
|
||||
var height = Integer.parseInt(ctx.queryParam("height"));
|
||||
|
||||
var module = VisionSourceManager.getInstance().vmm.getModule(cameraUniqueName);
|
||||
if (module == null) {
|
||||
ctx.status(404);
|
||||
return;
|
||||
}
|
||||
|
||||
CameraCalibrationCoefficients calList =
|
||||
module.getStateAsCameraConfig().calibrations.stream()
|
||||
.filter(
|
||||
it ->
|
||||
Math.abs(it.unrotatedImageSize.width - width) < 1e-4
|
||||
&& Math.abs(it.unrotatedImageSize.height - height) < 1e-4)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (calList == null) {
|
||||
ctx.status(404);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.json(calList);
|
||||
ctx.status(200);
|
||||
}
|
||||
|
||||
private record CalibrationRemoveRequest(int width, int height, String cameraUniqueName) {}
|
||||
|
||||
public static void onCalibrationRemoveRequest(Context ctx) {
|
||||
@@ -1065,28 +1099,18 @@ public class RequestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// encode as jpeg to save even more space. reduces size of a 1280p image from
|
||||
// 300k to 25k
|
||||
// encode as jpeg to save even more space. reduces size of a 1280p image from 300k to 25k
|
||||
var mat = calList.observations.get(observationIdx).annotateImage();
|
||||
if (mat == null) {
|
||||
ctx.status(404);
|
||||
return;
|
||||
}
|
||||
|
||||
var jpegBytes = new MatOfByte();
|
||||
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));
|
||||
|
||||
Imgcodecs.imencode(".jpg", mat, jpegBytes, new MatOfInt(Imgcodecs.IMWRITE_JPEG_QUALITY, 60));
|
||||
ctx.result(jpegBytes.toArray());
|
||||
|
||||
mat.release();
|
||||
jpegBytes.release();
|
||||
|
||||
ctx.status(200);
|
||||
|
||||
@@ -68,7 +68,6 @@ public class Server {
|
||||
it.anyHost();
|
||||
});
|
||||
}));
|
||||
|
||||
javalinConfig.requestLogger.http(
|
||||
(ctx, ms) -> {
|
||||
StringJoiner joiner =
|
||||
@@ -129,6 +128,7 @@ public class Server {
|
||||
app.post("/api/settings/camera", RequestHandler::onCameraSettingsRequest);
|
||||
app.post("/api/settings/camera/setNickname", RequestHandler::onCameraNicknameChangeRequest);
|
||||
app.get("/api/settings/camera/getCalibImages", RequestHandler::onCameraCalibImagesRequest);
|
||||
app.get("/api/settings/camera/getCalibration", RequestHandler::onCalibrationJsonRequest);
|
||||
|
||||
// Utilities
|
||||
app.post("/api/utils/offlineUpdate", RequestHandler::onOfflineUpdateRequest);
|
||||
|
||||
Reference in New Issue
Block a user