Skip to content

Commit

Permalink
Expose intrinsic parameters (#268)
Browse files Browse the repository at this point in the history
* Expose intrinsic parameters

* Remove unnecessary comments
  • Loading branch information
eigenvivek authored Jun 11, 2024
1 parent 35d9a83 commit 14a348e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 21 deletions.
7 changes: 6 additions & 1 deletion diffdrr/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
'diffdrr/detector.py'),
'diffdrr.detector.Detector.calibration': ( 'api/detector.html#detector.calibration',
'diffdrr/detector.py'),
'diffdrr.detector.Detector.delx': ('api/detector.html#detector.delx', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.dely': ('api/detector.html#detector.dely', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.forward': ('api/detector.html#detector.forward', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.intrinsic': ('api/detector.html#detector.intrinsic', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.reorient': ('api/detector.html#detector.reorient', 'diffdrr/detector.py')},
'diffdrr.detector.Detector.reorient': ('api/detector.html#detector.reorient', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.sdd': ('api/detector.html#detector.sdd', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.x0': ('api/detector.html#detector.x0', 'diffdrr/detector.py'),
'diffdrr.detector.Detector.y0': ('api/detector.html#detector.y0', 'diffdrr/detector.py')},
'diffdrr.drr': { 'diffdrr.drr.DRR': ('api/drr.html#drr', 'diffdrr/drr.py'),
'diffdrr.drr.DRR.__init__': ('api/drr.html#drr.__init__', 'diffdrr/drr.py'),
'diffdrr.drr.DRR.forward': ('api/drr.html#drr.forward', 'diffdrr/drr.py'),
Expand Down
35 changes: 25 additions & 10 deletions diffdrr/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,8 @@ def __init__(
reverse_x_axis: bool = False, # If pose includes reflection (in E(3) not SE(3)), reverse x-axis
):
super().__init__()
# self.sdd = sdd
self.height = height
self.width = width
# self.delx = delx
# self.dely = dely
# self.x0 = x0
# self.y0 = y0
self.n_subsample = n_subsample
if self.n_subsample is not None:
self.subsamples = []
Expand All @@ -65,6 +60,26 @@ def __init__(
),
)

@property
def sdd(self):
return self._calibration[2, 2].item()

@property
def delx(self):
return self._calibration[0, 0].item()

@property
def dely(self):
return self._calibration[1, 1].item()

@property
def x0(self):
return self._calibration[0, -1].item()

@property
def y0(self):
return self._calibration[1, -1].item()

@property
def reorient(self):
return RigidTransform(self._reorient)
Expand All @@ -78,13 +93,13 @@ def calibration(self):
def intrinsic(self):
"""The 3x3 intrinsic matrix."""
return make_intrinsic_matrix(
self._calibration[2, 2].item(),
self._calibration[0, 0].item(),
self._calibration[1, 1].item(),
self.sdd,
self.delx,
self.dely,
self.height,
self.width,
self._calibration[0, -1].item(),
self._calibration[1, -1].item(),
self.x0,
self.y0,
).to(self.source)

# %% ../notebooks/api/02_detector.ipynb 6
Expand Down
35 changes: 25 additions & 10 deletions notebooks/api/02_detector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,8 @@
" reverse_x_axis: bool = False, # If pose includes reflection (in E(3) not SE(3)), reverse x-axis\n",
" ):\n",
" super().__init__()\n",
" # self.sdd = sdd\n",
" self.height = height\n",
" self.width = width\n",
" # self.delx = delx\n",
" # self.dely = dely\n",
" # self.x0 = x0\n",
" # self.y0 = y0\n",
" self.n_subsample = n_subsample\n",
" if self.n_subsample is not None:\n",
" self.subsamples = []\n",
Expand Down Expand Up @@ -121,6 +116,26 @@
" )\n",
"\n",
" @property\n",
" def sdd(self):\n",
" return self._calibration[2, 2].item()\n",
"\n",
" @property\n",
" def delx(self):\n",
" return self._calibration[0, 0].item()\n",
"\n",
" @property\n",
" def dely(self):\n",
" return self._calibration[1, 1].item()\n",
"\n",
" @property\n",
" def x0(self):\n",
" return self._calibration[0, -1].item()\n",
"\n",
" @property\n",
" def y0(self):\n",
" return self._calibration[1, -1].item()\n",
"\n",
" @property\n",
" def reorient(self):\n",
" return RigidTransform(self._reorient)\n",
"\n",
Expand All @@ -133,13 +148,13 @@
" def intrinsic(self):\n",
" \"\"\"The 3x3 intrinsic matrix.\"\"\"\n",
" return make_intrinsic_matrix(\n",
" self._calibration[2, 2].item(),\n",
" self._calibration[0, 0].item(),\n",
" self._calibration[1, 1].item(),\n",
" self.sdd,\n",
" self.delx,\n",
" self.dely,\n",
" self.height,\n",
" self.width,\n",
" self._calibration[0, -1].item(),\n",
" self._calibration[1, -1].item(),\n",
" self.x0,\n",
" self.y0,\n",
" ).to(self.source)"
]
},
Expand Down

0 comments on commit 14a348e

Please sign in to comment.