-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from .camera import Camera | ||
|
||
from .scene import Scene, split_scene | ||
|
||
from .viewerJS import in_notebook | ||
|
||
# add to __all__ as per pep8 | ||
__all__ = [Scene, split_scene, in_notebook] | ||
__all__ = [Camera, Scene, split_scene, in_notebook] |
This file contains 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,75 @@ | ||
import numpy as np | ||
|
||
|
||
class Camera(object): | ||
|
||
def __init__( | ||
self, | ||
width=None, | ||
height=None, | ||
fx=None, | ||
fy=None, | ||
fovx=None, | ||
fovy=None, | ||
matrix=None, | ||
): | ||
# TODO(unknown): skew is not supported | ||
# TODO(unknown): cx and cy that are not half of width and height | ||
self.width = width | ||
self.height = height | ||
self._fx = fx | ||
self._fy = fy | ||
self._fovx = fovx | ||
self._fovy = fovy | ||
self.matrix = matrix | ||
|
||
@property | ||
def fx(self): | ||
if self._fx is None: | ||
assert self.width is not None | ||
assert self._fovx is not None | ||
self._fx = ( | ||
(self.width / 2.) / | ||
np.tan(np.deg2rad(self._fovx / 2.)) | ||
) | ||
return self._fx | ||
|
||
@property | ||
def fy(self): | ||
if self._fy is None: | ||
assert self._height is not None | ||
assert self._fovy is not None | ||
self._fy = ( | ||
(self._height / 2.) / | ||
np.tan(np.deg2rad(self._fovy / 2.)) | ||
) | ||
return self._fy | ||
|
||
@property | ||
def intrinsics(self): | ||
K = np.eye(3, dtype=np.float64) | ||
K[0, 0] = self.fx | ||
K[1, 1] = self.fy | ||
K[0, 2] = self.width / 2. | ||
K[1, 2] = self._height / 2. | ||
return K | ||
|
||
@property | ||
def fovx(self): | ||
if self._fovx is None: | ||
assert self.width is not None | ||
assert self._fx is not None | ||
self._fovx = 2 * np.rad2deg( | ||
np.arctan(self.width / 2. / self._fx) | ||
) | ||
return self._fovx | ||
|
||
@property | ||
def fovy(self): | ||
if self._fovy is None: | ||
assert self._height is not None | ||
assert self._fy is not None | ||
self._fovy = 2 * np.rad2deg( | ||
np.arctan(self._height / 2. / self._fy) | ||
) | ||
return self._fovy |
This file contains 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 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