-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Camera Projection Transforms #27
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
gselzer
wants to merge
25
commits into
pyapp-kit:main
Choose a base branch
from
gselzer:camera-projection
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 21 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
0e3ad3c
Add camera projection Transformation
gselzer 39ca744
Add a projection example
gselzer f7b57e6
Remove zoom and center
gselzer fb48e04
Add projection setter to Camera adapter
gselzer 244282a
perspective: Fix Transform construction
gselzer 5fbfb39
Merge remote-tracking branch 'upstream/main' into camera-projection
gselzer 7d63ca4
Copy clims between render materials
gselzer 0363267
Test orthographic projection matrices
gselzer 2ef5f0b
Improve perspective transforms
gselzer ee65c56
Minor fixes
gselzer ed1bbc0
HACK: Zero out the perspective matrix
gselzer 7a9a2a9
perspective: Don't use Matrix3D
gselzer 09e5b4d
Add pylinalg as explicit dependency
gselzer 09058cc
Transform: Use Annotated for root type
gselzer c3211e0
Merge remote-tracking branch 'upstream/main' into camera-projection
gselzer 748679b
Fix projection transform example
gselzer 7920d4c
vispy projections: Starting to work
gselzer 732b9c2
HACK: vispy: Tap into vispy view size computation
gselzer 94fe13f
Clean up vispy camera class
gselzer 798a787
Delete obsolete projection code
gselzer 2ca7ca6
Fix typo
gselzer 336a139
Remove camera type from model
gselzer 8f91699
Update default projection matrices
gselzer 85d1235
Clean up vispy adaptor tests
gselzer 9fbeae3
Add pygfx camera adaptor tests
gselzer 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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| from math import atan, pi | ||
|
|
||
| import numpy as np | ||
|
|
||
| import scenex as snx | ||
| from scenex.model._transform import Transform | ||
| from scenex.utils import projections | ||
|
|
||
| try: | ||
| from imageio.v2 import volread | ||
|
|
||
| url = "https://gitlab.com/scikit-image/data/-/raw/2cdc5ce89b334d28f06a58c9f0ca21aa6992a5ba/cells3d.tif" | ||
| data = np.asarray(volread(url)).astype(np.uint16)[:, 0, :, :] | ||
| except ImportError: | ||
| data = np.random.randint(0, 2, (3, 3, 3)).astype(np.uint16) | ||
|
|
||
| view = snx.View( | ||
| blending="default", | ||
| scene=snx.Scene( | ||
| children=[ | ||
| snx.Volume( | ||
| data=data, | ||
| clims=(data.min(), data.max()), | ||
| ), | ||
| ] | ||
| ), | ||
| ) | ||
|
|
||
| canvas = snx.show(view) | ||
|
|
||
| # Translate the camera to the center of the volume, and distance the camera from the | ||
| # volume in the z dimension (important for perspective transforms) | ||
| view.camera.transform = Transform().translated((127.5, 127.5, 300)) | ||
|
|
||
| # view.camera.projection = projections.orthographic( | ||
| # 1.1 * data.shape[1], | ||
| # 1.1 * data.shape[2], | ||
| # 1000, | ||
| # ) | ||
|
|
||
| view.camera.projection = projections.perspective( | ||
| # TODO: Create a helper function for this. | ||
| fov=2 * atan(data.shape[1] / 2 / 300) * 180 / pi, | ||
| near=300, | ||
| far=1_000_000, # Just need something big | ||
| ) | ||
|
|
||
| snx.run() | ||
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
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
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.
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.
Wonder whether some documentation/comments here would be helpful - I can't think of much right now though