-
Notifications
You must be signed in to change notification settings - Fork 299
Store calibration units in mm #2480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thatcomputerguy0101
wants to merge
1
commit into
PhotonVision:main
Choose a base branch
from
thatcomputerguy0101:mm-calibration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,32 +110,32 @@ watchEffect(() => { | |
| uniqueVideoResolutionIndex.value = currentIndex; | ||
| }); | ||
| const dimensionUnit = ref<"in" | "mm">("in"); | ||
| const squareSizeIn = ref(1); | ||
| const markerSizeIn = ref(0.75); | ||
| const squareSizeMm = ref(30); | ||
| const markerSizeMm = ref(22); | ||
| const patternWidth = ref(8); | ||
| const patternHeight = ref(8); | ||
| const boardType = ref<CalibrationBoardTypes>(CalibrationBoardTypes.Charuco); | ||
| const useOldPattern = ref(false); | ||
| const tagFamily = ref<CalibrationTagFamilies>(CalibrationTagFamilies.Dict_4X4_1000); | ||
| const requestedVideoFormatIndex = ref(0); | ||
|
|
||
| const convertInchesToDisplay = (valueInInches: number) => | ||
| dimensionUnit.value === "mm" ? valueInInches * MM_PER_INCH : valueInInches; | ||
| const convertMetricToDisplay = (valueInMm: number) => | ||
| dimensionUnit.value === "in" ? valueInMm / MM_PER_INCH : valueInMm; | ||
|
|
||
| const convertDisplayToInches = (displayValue: number) => | ||
| dimensionUnit.value === "mm" ? displayValue / MM_PER_INCH : displayValue; | ||
| const convertDisplayToMetric = (displayValue: number) => | ||
| dimensionUnit.value === "in" ? displayValue * MM_PER_INCH : displayValue; | ||
|
|
||
| const squareSize = computed({ | ||
| get: () => convertInchesToDisplay(squareSizeIn.value), | ||
| get: () => convertMetricToDisplay(squareSizeMm.value), | ||
| set(value) { | ||
| squareSizeIn.value = convertDisplayToInches(value); | ||
| squareSizeMm.value = convertDisplayToMetric(value); | ||
| } | ||
| }); | ||
|
|
||
| const markerSize = computed({ | ||
| get: () => convertInchesToDisplay(markerSizeIn.value), | ||
| get: () => convertMetricToDisplay(markerSizeMm.value), | ||
| set(value) { | ||
| markerSizeIn.value = convertDisplayToInches(value); | ||
| markerSizeMm.value = convertDisplayToMetric(value); | ||
| } | ||
| }); | ||
|
|
||
|
|
@@ -149,7 +149,7 @@ const tooManyPoints = computed( | |
| const downloadCalibBoard = async () => { | ||
| const { jsPDF } = await jspdf; | ||
| const { font } = await PromptRegular; | ||
| const doc = new jsPDF({ unit: "in", format: "letter" }); | ||
| const doc = new jsPDF({ unit: "mm", format: "letter" }); | ||
|
|
||
| doc.addFileToVFS("Prompt-Regular.tff", font); | ||
| doc.addFont("Prompt-Regular.tff", "Prompt-Regular", "normal"); | ||
|
|
@@ -161,28 +161,34 @@ const downloadCalibBoard = async () => { | |
|
|
||
| switch (boardType.value) { | ||
| case CalibrationBoardTypes.Chessboard: | ||
| const chessboardStartX = (paperWidth - patternWidth.value * squareSizeIn.value) / 2; | ||
| const chessboardStartX = (paperWidth - patternWidth.value * squareSizeMm.value) / 2; | ||
|
|
||
| const chessboardStartY = (paperHeight - patternWidth.value * squareSizeIn.value) / 2; | ||
| const chessboardStartY = (paperHeight - patternWidth.value * squareSizeMm.value) / 2; | ||
|
|
||
| for (let squareY = 0; squareY < patternHeight.value; squareY++) { | ||
| for (let squareX = 0; squareX < patternWidth.value; squareX++) { | ||
| const xPos = chessboardStartX + squareX * squareSizeIn.value; | ||
| const yPos = chessboardStartY + squareY * squareSizeIn.value; | ||
| const xPos = chessboardStartX + squareX * squareSizeMm.value; | ||
| const yPos = chessboardStartY + squareY * squareSizeMm.value; | ||
|
|
||
| // Only draw the odd squares to create the chessboard pattern | ||
| if (squareY % 2 !== squareX % 2) { | ||
| doc.rect(xPos, yPos, squareSizeIn.value, squareSizeIn.value, "F"); | ||
| doc.rect(xPos, yPos, squareSizeMm.value, squareSizeMm.value, "F"); | ||
| } | ||
| } | ||
| } | ||
| doc.text(`${patternWidth.value} x ${patternHeight.value} | ${squareSizeIn.value}in`, paperWidth - 1, 1.0, { | ||
| maxWidth: (paperWidth - 2.0) / 2, | ||
| align: "right" | ||
| }); | ||
| doc.text( | ||
| `${patternWidth.value} x ${patternHeight.value} | ${squareSize.value}${dimensionUnit.value}`, | ||
| paperWidth - 1, | ||
| 1.0, | ||
| { | ||
| maxWidth: (paperWidth - 2.0) / 2, | ||
| align: "right" | ||
| } | ||
| ); | ||
| break; | ||
|
|
||
| case CalibrationBoardTypes.Charuco: | ||
| // TODO: Dynamically generate ChArUco using opencv | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot I left this TODO in here. Dynamic ChArUco generation might be the topic of another PR though. |
||
| // Add pregenerated ChArUco | ||
| const charucoImage = new Image(); | ||
| charucoImage.src = CharucoImage; | ||
|
|
@@ -220,8 +226,8 @@ const isCalibrating = computed( | |
|
|
||
| const startCalibration = () => { | ||
| useCameraSettingsStore().startPnPCalibration({ | ||
| squareSizeIn: squareSizeIn.value, | ||
| markerSizeIn: markerSizeIn.value, | ||
| squareSizeMm: squareSizeMm.value, | ||
| markerSizeMm: markerSizeMm.value, | ||
| patternHeight: patternHeight.value, | ||
| patternWidth: patternWidth.value, | ||
| boardType: boardType.value, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which unit do we want to be the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only kept it as inches since that's the existing behaviour.
I reckon whatever the default is should match whatever's in the board PDF.