Skip to content
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

Standalone SpatialOrientation #44

Merged
merged 36 commits into from
Mar 29, 2024

Conversation

braden6521
Copy link
Collaborator

@braden6521 braden6521 commented Mar 21, 2024

Split SpatialOrientation from DisplayShape

  • Removed the spatial orientation (relative camera-screen positions) content from the DisplayShape object. These are not dependent on each other and do not need to be stored together.
  • This is how SofastFixed requires its information. SofastFixed doesn't always need a DisplayShape object, but always requires a SpatialOrientation. (Thus, this was not a problem before SofastFixed existed.)
  • This also streamlines the calibration processes. Spatial orientation information does not need to be saved as an intermediate CSV file; the camera-pose and screen-shape calibrations are now stand-alone calibrations.
  • Deleted everything related to the function save_DisplayShape_file because this is no longer needed.
  • The unit test data had to be rearranged (there is no rvec/tvec stored in the DisplayShape file). The spatial orientation data is now stored in the Sofast dataset HDF files under the folder SpatialOrientation/...
  • Added more unit test coverage where appropriate.
  • Updated/removed Sofast files in /doc

@braden6521 braden6521 added the enhancement New feature or request label Mar 21, 2024
@braden6521 braden6521 changed the title Spatial orientation standalone object Standalone SpatialOrientation Mar 21, 2024
@braden6521 braden6521 force-pushed the spatial_orientation branch 2 times, most recently from 1672d64 to 76ed5ec Compare March 21, 2024 21:42
@braden6521 braden6521 requested a review from bbean23 March 21, 2024 22:15
@braden6521 braden6521 marked this pull request as ready for review March 21, 2024 22:15
@braden6521 braden6521 removed the request for review from bbean23 March 21, 2024 22:34
@braden6521 braden6521 marked this pull request as draft March 21, 2024 22:35
@braden6521 braden6521 force-pushed the spatial_orientation branch from f6cd54c to b27df4e Compare March 25, 2024 15:38
@braden6521 braden6521 marked this pull request as ready for review March 25, 2024 16:31
@braden6521 braden6521 requested a review from bbean23 March 25, 2024 16:31
Copy link
Collaborator

@bbean23 bbean23 left a comment

Choose a reason for hiding this comment

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

Please respond to my comments before I approve. In particular, my comments about scrubbing, test_Display.test_save_load_hdf_dist_3d(), and CalibrateDisplayShape.as_DisplayShape()

@@ -0,0 +1,8 @@
View Camera Distortion
Copy link
Collaborator

Choose a reason for hiding this comment

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

I need to learn what these .rst files do at some point.

return {'xy_screen_fraction': pts_xy_screen_fraction, 'xyz_screen_coords': pts_xyz_screen}

def as_DisplayShape(self, name: str) -> DisplayShape:
"""Saves data to DisplayShape hdf file using the distorted3d model, see
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't actually save the data, does it? It just returns a DisplayShape instance?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, that was a copy/paste error.


from opencsp.common.lib.geometry.Vxy import Vxy
from opencsp.common.lib.geometry.Vxyz import Vxyz
import opencsp.common.lib.tool.hdf5_tools as hdf5_tools
import opencsp.common.lib.tool.hdf5_tools as ht
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably converge on how we import this library. I've been using "import ... as h5", but I'm also good with "ht". I think that "h5" is more descriptive, but "ht" is more consistent with the rest of the code. Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea on being consistent. Since you're already using h5, let's stick with that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to ... as h5 in all (two) files.

@@ -11,7 +11,7 @@
from opencsp.app.sofast.lib.DefinitionFacet import DefinitionFacet
from opencsp.app.sofast.lib.DisplayShape import DisplayShape as Display
import opencsp.app.sofast.lib.image_processing as ip
from opencsp.app.sofast.lib.MeasurementSofastFringe import MeasurementSofastFringe as Measurement
from opencsp.app.sofast.lib.MeasurementSofastFringe import MeasurementSofastFringe
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this change 👍

disp.save_to_hdf(file)

# Load
DisplayShape.load_from_hdf(file)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest expanding this test method to compare the saved and loaded versions of the DisplayShape object.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, updated!

# Load
ori = SpatialOrientation.load_from_hdf(file)
# Check optic is oriented
np.testing.assert_equal(ori.optic_oriented, True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Exactly! Like this! :)

Note that if you're comparing two standard python objects, you can also use self.assertEqual(a, b), which in my opinion produces easier-to-read results in the case that the two instance's aren't equal. In reality, it's just a matter of opinion which one you like more.

Example of np.testing.assert_equal and unittest.TestCase.assertEqual
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like that method a lot better. Updated!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did this file get run through the scrubber? I'm assuming it's safe, but we should make sure it passes the scrubber's checks, anyways.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Same with the rest of the HDF5 files...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Was never able to get the scrubber working/do not know how to use it. Will work on this.

@braden6521
Copy link
Collaborator Author

@bbean23, now the ubi8 CI doesn't work. It started failing on memory_monitor for some reason FYI.

@braden6521 braden6521 force-pushed the spatial_orientation branch 3 times, most recently from 165fe76 to 7ccd13c Compare March 28, 2024 15:20
@braden6521 braden6521 force-pushed the spatial_orientation branch from 92840c7 to f11738c Compare March 29, 2024 04:41
@braden6521
Copy link
Collaborator Author

@bbean23, I believe this is finally ready after a rebase on top of develop! Nothing substantial has changed since your last review.

Copy link
Collaborator

@bbean23 bbean23 left a comment

Choose a reason for hiding this comment

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

Approved!

@braden6521 braden6521 merged commit fee821d into sandialabs:develop Mar 29, 2024
4 checks passed
@braden6521 braden6521 deleted the spatial_orientation branch April 15, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants