Commit b7131da9 authored by Andy Regensky's avatar Andy Regensky
Browse files

Limit blocks to FOV 180° boundary

parent 3bcdf5ea
......@@ -31,6 +31,7 @@ class MainViewModel(QObject):
self.projection = None
self.perspective = None
self.fov_180_radius = None
self.center = None
self.block_xf = None
self.block_yf = None
self.block_xp = None
......@@ -106,6 +107,7 @@ class MainViewModel(QObject):
self.projection = self.projection_cls(focal_length_px)
self.perspective = projections.PerspectiveProjection(focal_length_px)
self.fov_180_radius = self.projection.radius(np.deg2rad(90))
self.center = (np.asarray(self.sensor_size_px) - 1) / 2
self.blockSignals(True)
self.updateFisheyeBlockpoints()
self.updatePerspectiveBlockpoints()
......@@ -135,14 +137,20 @@ class MainViewModel(QObject):
block_x[3 * self.samples_per_edge:4 * self.samples_per_edge] = self.origin[0]
block_y[3 * self.samples_per_edge:4 * self.samples_per_edge] = np.linspace(self.origin[1] + self.blocksize[1], self.origin[1],
self.samples_per_edge)
# Filter within FOV 180
r, _ = coordinate_conversion.cartesian_to_polar(block_y - self.center[0],
block_x - self.center[1])
block_x = block_x[r <= self.fov_180_radius]
block_y = block_y[r <= self.fov_180_radius]
self.block_xf = block_x
self.block_yf = block_y
self.didChange.emit()
def updatePerspectiveBlockpoints(self):
center = np.asarray(self.sensor_size_px)/2
block_yfc = self.block_yf - center[0]
block_xfc = self.block_xf - center[1]
block_yfc = self.block_yf - self.center[0]
block_xfc = self.block_xf - self.center[1]
r_f, phi = coordinate_conversion.cartesian_to_polar(block_yfc, block_xfc)
r_p = self.projection.transform_to(self.perspective, r_f)
......@@ -174,9 +182,9 @@ class MainViewModel(QObject):
self.didChange.emit()
def updateControlBlockpoints(self):
center = np.asarray(self.sensor_size_px) / 2
block_center = np.asarray(self.origin) + (np.asarray(self.blocksize) - 1) / 2
r_f, phi = coordinate_conversion.cartesian_to_polar(block_center[1] - center[0], block_center[0] - center[1])
r_f, phi = coordinate_conversion.cartesian_to_polar(block_center[1] - self.center[0],
block_center[0] - self.center[1])
r_p = self.projection.transform_to(self.perspective, r_f)
cp0_y, cp0_x = coordinate_conversion.polar_to_cartesian(r_p, phi)
cp0_y = cp0_y - self.blocksize[1] / 2
......
......@@ -54,8 +54,8 @@ class FisheyeBlockWidget(QWidget):
painter.setPen(pen)
painter.drawEllipse(
QRect(
(self.viewModel.sensor_size_px[1]-1)/2 - self.viewModel.fov_180_radius,
(self.viewModel.sensor_size_px[0]-1)/2 - self.viewModel.fov_180_radius,
self.viewModel.center[1] - self.viewModel.fov_180_radius,
self.viewModel.center[0] - self.viewModel.fov_180_radius,
2 * self.viewModel.fov_180_radius,
2 * self.viewModel.fov_180_radius
)
......
......@@ -54,7 +54,6 @@ class PropertiesWidget(QWidget):
self.focalLengthEdit = QLineEdit(self)
self.focalLengthEdit.setValidator(doubleValidator)
self.focalLengthEdit.editingFinished.connect(self.focalLengthEditingFinished)
self.focalLengthEdit.setEnabled(False)
self.projectionLabel = QLabel(self)
self.projectionLabel.setText("Projection:")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment