-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfisheye_view.py
More file actions
66 lines (55 loc) · 2.26 KB
/
fisheye_view.py
File metadata and controls
66 lines (55 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# fisheye_view.py
# Viewer for fisheye imagery and visualizing sample angles.
#
# Copyright 2014-2015 Program of Computer Graphics, Cornell University
# 580 Rhodes Hall
# Cornell University
# Ithaca NY 14853
# Web: http://www.graphics.cornell.edu/
#
# Not for commercial use. Do not redistribute without permission.
#
import sys, os
import PySide
from PySide import QtCore, QtGui
sys.modules['PyQt4'] = PySide
from datetime import time, timedelta, datetime
import angle_utilities
class FisheyeViewer(QtGui.QLabel):
def __init__(self, fisheyeFile=None, parent=None):
super(FisheyeViewer, self).__init__(parent)
self.fisheyeFile = fisheyeFile
self.setAlignment(QtCore.Qt.AlignCenter)
# Set up the label container for the fisheye image
if self.fisheyeFile:
self.loadFisheyeFile(self.fisheyeFile)
def drawAnglePosition(self, theta, phi, inRadians=True):
""" Draw a marker on the fisheye image at the current sample. """
if not self.fisheyeFile:
return
pixmap = self.pixmap()
# Determine the pixel location of the angles.
theta, phi = angle_utilities.FisheyeAngleWarp(theta, phi, inRadians=inRadians)
angleU, angleV = angle_utilities.GetUVFromAngle(theta, phi, inRadians=inRadians)
angleU = angleU * pixmap.width()
angleV = angleV * pixmap.height()
# Paint at the angle position on the fisheye pixmap.
painter = QtGui.QPainter(pixmap)
painter.setPen(QtGui.QColor(255, 0, 0, 255))
brush = QtGui.QBrush(QtGui.QColor(255, 0, 0, 255))
painter.setBrush(brush)
painter.drawEllipse(angleU, angleV, 5, 5)
# Update the fisheyeContainer with the new pixmap
self.setPixmap(pixmap)
def loadFisheyeFile(self, fisheyeFile):
""" Load the specified fisheye file into widget. """
self.fisheyeFile = fisheyeFile
pixmap = QtGui.QPixmap(fisheyeFile)
pixmap = pixmap.scaled(300, 300, QtCore.Qt.KeepAspectRatio)
self.setPixmap(pixmap)
#self.setFixedSize(pixmap.size())
def reset(self):
""" Resets the view to be the clean fisheye image without any angles
drawn on the image.
"""
self.loadFisheyeFile(self.fisheyeFile)