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

New feature: Select fisheye projection

parent 8386f85d
......@@ -14,6 +14,7 @@ class MainViewModel(QObject):
self.sensor_size_mm = (5.2, 5.2)
self.sensor_size_px = (1088, 1088)
self.focal_length_mm = 1.8
self.projection_cls = projections.EquisolidProjection
self.origin = (512, 512)
self.blocksize = (64, 64)
......@@ -55,6 +56,10 @@ class MainViewModel(QObject):
self.focal_length_mm = focal_length_mm
self.updateProjections()
def setProjectionCls(self, projection_cls):
self.projection_cls = projection_cls
self.updateProjections()
def setOrigin(self, origin):
self.origin = origin
self.updateProjections()
......@@ -83,7 +88,7 @@ class MainViewModel(QObject):
def updateProjections(self):
focal_length_px = projections.Projection.to_focal_length_px(self.focal_length_mm, self.sensor_size_mm, self.sensor_size_px)
self.projection = projections.EquisolidProjection(focal_length_px)
self.projection = self.projection_cls(focal_length_px)
self.perspective = projections.PerspectiveProjection(focal_length_px)
self.blockSignals(True)
self.updateFisheyeBlockpoints()
......
from PySide2.QtGui import QIntValidator, QDoubleValidator
from PySide2.QtWidgets import QWidget, QLabel, QLineEdit, QGridLayout, QSpacerItem, QSlider, QCheckBox
from PySide2.QtWidgets import QWidget, QLabel, QLineEdit, QGridLayout, QSpacerItem, QSlider, QCheckBox, QComboBox
from PySide2.QtCore import Slot, Qt
from fishui.MainViewModel import MainViewModel
import fishui.projections as projections
class PropertiesWidget(QWidget):
......@@ -54,6 +55,17 @@ class PropertiesWidget(QWidget):
self.focalLengthEdit.editingFinished.connect(self.focalLengthEditingFinished)
self.focalLengthEdit.setEnabled(False)
self.projectionLabel = QLabel(self)
self.projectionLabel.setText("Projection:")
self.projections = {'equisolid': projections.EquisolidProjection,
'equidistant': projections.EquidistantProjection,
'orthographic': projections.OrthographicProjection,
'stereographic': projections.StereographicProjection}
self.projectionComboBox = QComboBox(self)
self.projectionComboBox.addItems(list(self.projections.keys()))
self.projectionComboBox.currentTextChanged.connect(self.projectionComboBoxTextChanged)
self.originLabel = QLabel(self)
self.originLabel.setText("Origin:")
......@@ -123,8 +135,10 @@ class PropertiesWidget(QWidget):
layout.addWidget(self.resolutionLabel, 4, 0, 1, -1)
layout.addWidget(self.resolutionWidthEdit, 5, 0)
layout.addWidget(self.resolutionHeightEdit, 5, 1)
layout.addWidget(self.focalLengthLabel, 6, 0, 1, -1)
layout.addWidget(self.focalLengthLabel, 6, 0)
layout.addWidget(self.projectionLabel, 6, 1)
layout.addWidget(self.focalLengthEdit, 7, 0)
layout.addWidget(self.projectionComboBox, 7, 1)
layout.addItem(QSpacerItem(10, 20), 8, 0)
layout.addWidget(self.originLabel, 9, 0, 1, -1)
layout.addWidget(self.originXEdit, 10, 0)
......@@ -155,6 +169,9 @@ class PropertiesWidget(QWidget):
self.resolutionWidthEdit.setText(f"{self.viewModel.sensor_size_px[0]}")
self.resolutionHeightEdit.setText(f"{self.viewModel.sensor_size_px[1]}")
self.focalLengthEdit.setText(f"{self.viewModel.focal_length_mm}")
self.projectionComboBox.setCurrentText(
list(self.projections.keys())[list(self.projections.values()).index(self.viewModel.projection_cls)]
)
self.originXEdit.setText(f"{self.viewModel.origin[0]}")
self.originYEdit.setText(f"{self.viewModel.origin[1]}")
self.blocksizeWidthEdit.setText(f"{self.viewModel.blocksize[0]}")
......@@ -204,6 +221,10 @@ class PropertiesWidget(QWidget):
def focalLengthEditingFinished(self):
self.viewModel.setFocalLength(float(self.focalLengthEdit.text()))
@Slot()
def projectionComboBoxTextChanged(self):
self.viewModel.setProjectionCls(self.projections[self.projectionComboBox.currentText()])
@Slot()
def originXEditingFinished(self):
origin = self.viewModel.origin
......
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