Skip to content

Fix calibration array length#1879

Merged
mcm001 merged 4 commits intoPhotonVision:mainfrom
Gold856:fix-calibration-array-length
Apr 13, 2025
Merged

Fix calibration array length#1879
mcm001 merged 4 commits intoPhotonVision:mainfrom
Gold856:fix-calibration-array-length

Conversation

@Gold856
Copy link
Member

@Gold856 Gold856 commented Apr 11, 2025

Description

Fixed a bug where rotated camera distortion coefficient arrays and rotated camera intrensic arrays were 8x bigger than they were supposed to be. The root cause was because of how the data from JsonMatOfDouble was being handled. A Mat was pulled out, then modified, then a new JsonMatOfDouble was made from the Mat. This required a conversion from a Mat to a Java array. The array was incorrectly sized as elements * bytes, when it should've just been elements. Due to some uncertainty as to the types of Mats passed into JsonMatOfDouble.fromMat, the expected Mat type has been explicitly documented. The added regression test rotates the calibration data 4 times, equivalent to not rotating at all. This should mean the arrays are equal, and that is what we check.

Additionally fixes a bug when rotating 180 degrees that flipped width and height

Meta

Merge checklist:

  • Pull Request title is short, imperative summary of proposed changes
  • The description documents the what and why
  • If this PR changes behavior or adds a feature, user documentation is updated
  • If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly
  • If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1
  • If this PR addresses a bug, a regression test for it is added

@Gold856 Gold856 requested a review from a team as a code owner April 11, 2025 05:12
samfreund
samfreund previously approved these changes Apr 11, 2025
Copy link
Member

@samfreund samfreund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Gold856 Gold856 marked this pull request as draft April 11, 2025 07:27
@Gold856 Gold856 force-pushed the fix-calibration-array-length branch from 19d556d to 95fffdc Compare April 11, 2025 07:36
@samfreund samfreund dismissed their stale review April 11, 2025 14:18

I thought it was good to go earlier, but given it's a draft and failing tests now, I'm dismissing.

@Gold856 Gold856 force-pushed the fix-calibration-array-length branch from 95fffdc to 637209e Compare April 13, 2025 03:00
@mcm001 mcm001 force-pushed the fix-calibration-array-length branch from c69478e to da9f364 Compare April 13, 2025 17:31
@mcm001 mcm001 marked this pull request as ready for review April 13, 2025 17:31
@mcm001 mcm001 enabled auto-merge (squash) April 13, 2025 17:32
@mcm001 mcm001 merged commit 9a88e56 into PhotonVision:main Apr 13, 2025
39 checks passed
@Gold856 Gold856 deleted the fix-calibration-array-length branch April 13, 2025 22:08
@Gold856 Gold856 added the backend Things relating to photon-core and photon-server label Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Things relating to photon-core and photon-server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants