Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ext {
rknnVersion = "v2027.0.0"
tfliteVersion = "v2027.0.2-alpha-1"
wpilibYear = "2027_alpha5"
mrcalVersion = "dev-v2027.0.2-6-gb65c352";
mrcalVersion = "dev-v2027.0.2-10-gba8e332";

pubVersion = versionString
isDev = pubVersion.startsWith("dev")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public final class BoardObservation implements Cloneable {
// Solver optimized board poses
public Pose3d optimisedCameraToObject;

// Ids of each corner since ChArUco may produce partial observations
public int[] cornerIds;

// If we should use this observation when re-calculating camera calibration
public boolean[] cornersUsed;

Expand All @@ -60,13 +63,15 @@ public BoardObservation(
List<Point> locationInImageSpace,
List<Point> reprojectionErrors,
Pose3d optimisedCameraToObject,
int[] cornerIds,
boolean[] cornersUsed,
String snapshotName,
Path snapshotDataLocation) {
this.locationInObjectSpace = locationInObjectSpace;
this.locationInImageSpace = locationInImageSpace;
this.reprojectionErrors = reprojectionErrors;
this.optimisedCameraToObject = optimisedCameraToObject;
this.cornerIds = cornerIds;
this.snapshotName = snapshotName;
this.snapshotDataLocation = snapshotDataLocation;

Expand All @@ -88,6 +93,8 @@ public String toString() {
+ reprojectionErrors
+ ", optimisedCameraToObject="
+ optimisedCameraToObject
+ ", cornerIds="
+ cornerIds
+ ", cornersUsed="
+ cornersUsed
+ ", snapshotName="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.opencv.calib3d.Calib3d;
Expand Down Expand Up @@ -221,27 +221,32 @@ protected CameraCalibrationCoefficients calibrateMrcal(
List<FindBoardCornersPipe.FindBoardCornersPipeResult> observationCorners,
FrameStaticProperties imageProps,
Path imageSavePath) {
Iterator<MrCalObservation> observationData =
observationCorners.stream()
.map(
it -> {
var corners = it.imagePoints.toArray();
List<MrCalObservation> observationData =
new AbstractList<MrCalJNI.MrCalObservation>() {
Comment thread
thatcomputerguy0101 marked this conversation as resolved.
Outdated
@Override
public int size() {
return observationCorners.size();
}

var levels = new float[(int) it.imagePoints.total()];
Arrays.fill(levels, it.level);
@Override
public MrCalObservation get(int index) {
var observation = observationCorners.get(index);
var corners = observation.imagePoints.toArray();

var ids = it.ids != null ? it.ids.toArray() : null;
var levels = new float[(int) observation.imagePoints.total()];
Arrays.fill(levels, observation.level);

return new MrCalObservation(corners, levels, ids);
})
.iterator();
var ids = observation.ids != null ? observation.ids.toArray() : null;

return new MrCalObservation(corners, levels, ids);
}
};

int imageWidth = (int) observationCorners.get(0).size.width;
int imageHeight = (int) observationCorners.get(0).size.height;

MrCalResult result =
MrCalJNI.calibrateCamera(
observationCorners.size(),
observationData,
params.boardWidth,
params.boardHeight,
Expand Down Expand Up @@ -428,12 +433,16 @@ private List<BoardObservation> createObservations(
Imgcodecs.imwrite(image_path.toString(), inputImage);
}

var cornerIdsMat = observationData.get(snapshotId).ids;
var cornerIds = cornerIdsMat != null ? cornerIdsMat.toArray() : null;

observations.add(
new BoardObservation(
objectPoints.toList(),
iPoints,
reprojectionError,
camToBoard,
cornerIds,
cornersUsed.get(snapshotId),
snapshotName,
image_path));
Expand Down
3 changes: 1 addition & 2 deletions test-resources/calibration/lifecam_1280.json

Large diffs are not rendered by default.

Loading