Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
BytingBulldogs3539 committed May 6, 2024
1 parent 640407f commit 63f8dcb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const getUniqueVideoFormatsByResolution = (): VideoFormat[] => {
const calib = useCameraSettingsStore().getCalibrationCoeffs(format.resolution);
if (calib !== undefined) {
// For each error, square it, sum the squares, and divide by total points N
if (calib.meanErrors.length)
format.mean = calib.meanErrors.reduce((a, b) => a + b, 0) / calib.meanErrors.length;
if (calib.meanErrors.length) format.mean = calib.meanErrors.reduce((a, b) => a + b, 0) / calib.meanErrors.length;
else format.mean = NaN;
format.horizontalFOV =
Expand All @@ -43,20 +42,19 @@ const getUniqueVideoFormatsByResolution = (): VideoFormat[] => {
(180 / Math.PI);
}
uniqueResolutions.push(format);
});
uniqueResolutions.sort(
(a, b) => b.resolution.width + b.resolution.height - (a.resolution.width + a.resolution.height)
);
useStateStore().calibrationData.videoFormatIndex = uniqueResolutions[uniqueResolutions.length-1].index;
useStateStore().calibrationData.videoFormatIndex = uniqueResolutions[uniqueResolutions.length - 1].index;
return uniqueResolutions;
};
const getUniqueVideoResolutionStrings = (): { name: string; value: number }[] =>
getUniqueVideoFormatsByResolution().map<{ name: string; value: number }>((f) => ({
name: `${getResolutionString(f.resolution)}`,
value: f.index || 0 // Index won't ever be undefined
value: f.index || 0 // Index won't ever be undefined
}));
const calibrationDivisors = computed(() =>
[1, 2, 4].filter((v) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ protected CameraCalibrationCoefficients calibrateMrcal(
List<MatOfPoint2f> corner_locations =
in.stream().map(it -> it.imagePoints).map(MatOfPoint2f::new).collect(Collectors.toList());

List<MatOfFloat> levels = in.stream().map(it -> it.levels).map(MatOfFloat::new)
.collect(Collectors.toList());

List<MatOfFloat> levels =
in.stream().map(it -> it.levels).map(MatOfFloat::new).collect(Collectors.toList());

int imageWidth = (int) in.get(0).size.width;
int imageHeight = (int) in.get(0).size.height;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ public PhotonConfiguration.UICameraConfiguration toUICameraConfig() {
internalMap.put(
"pixelFormat",
((uniqueVideoModes.get(k) instanceof LibcameraGpuSource.FPSRatedVideoMode)
? "kPicam"
: uniqueVideoModes.get(k).pixelFormat.toString())
? "kPicam"
: uniqueVideoModes.get(k).pixelFormat.toString())
.substring(1)); // Remove the k prefix
uniqueMap.put(k, internalMap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import edu.wpi.first.cscore.VideoMode;
import java.util.HashMap;
import java.util.Map;

import org.photonvision.common.configuration.CameraConfiguration;
import org.photonvision.common.logging.LogGroup;
import org.photonvision.common.logging.Logger;
Expand Down Expand Up @@ -88,28 +87,27 @@ public void setVideoModeIndex(int index) {

public abstract HashMap<Integer, VideoMode> getAllVideoModes();

public HashMap<Integer, VideoMode> getUniqueVideoModes()
{
public HashMap<Integer, VideoMode> getUniqueVideoModes() {
HashMap<Integer, VideoMode> output = new HashMap<Integer, VideoMode>();
HashMap<Integer, VideoMode> map = getAllVideoModes();
for (Map.Entry<Integer, VideoMode> mode : map.entrySet()) {
boolean added = false;
for (Map.Entry<Integer, VideoMode> otherMode : output.entrySet()) {
if(otherMode.getValue().height == mode.getValue().height && otherMode.getValue().width == mode.getValue().width){
if(mode.getValue().fps>otherMode.getValue().fps)
{
if (otherMode.getValue().height == mode.getValue().height
&& otherMode.getValue().width == mode.getValue().width) {
if (mode.getValue().fps > otherMode.getValue().fps) {
output.remove(otherMode.getKey());
output.put(mode.getKey(), mode.getValue());
added = true;
break;
}
}
}
}
if (!added) {
output.put(mode.getKey(), mode.getValue());
}
}
return output;
return output;
}

public double getFOV() {
Expand Down

0 comments on commit 63f8dcb

Please sign in to comment.