forked from zhijieshen-bjtu/DOPNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualizer.py
70 lines (57 loc) · 2.28 KB
/
visualizer.py
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
67
68
69
70
from PyQt5 import QtWidgets, QtGui, QtOpenGL
from PyQt5.QtWidgets import *
from PyQt5.QtGui import QIcon
import PyQt5.QtCore as QtCore
import os
import sys
import cv2
import numpy as np
from imageio import imread
import json
import argparse
import visualization.visualizer.shader
import glm
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from visualization.visualizer.Viewer import Utils
from visualization.visualizer.Viewer import LayoutView
class TopWindow(QMainWindow):
def __init__(self, img, layout, floor_reverse=False, parent=None):
super().__init__(parent)
sizeObject = QtWidgets.QDesktopWidget().screenGeometry(-1)
[self.h, self.w] = [sizeObject.height(), sizeObject.width()]
ratio = 0.9
self.h = int(self.h * ratio)
self.w = int(self.w * ratio)
self.setGeometry(20, 60, self.w, self.h)
self.setWindowTitle("Layout Visualizer")
self.centeralWidget = QWidget(self)
self.layout = layout
self.LayoutViewer = LayoutView.GLWindow(img, main=self, parent=self.centeralWidget)
wallNum, wallPoints, lines, mesh = Utils.Label2Mesh(Utils.OldFormat2Mine(self.layout), floor_reverse)
self.LayoutViewer.updateLayoutMesh(wallNum, wallPoints, lines, mesh)
layout = QGridLayout()
layout.setRowStretch(0, 1)
layout.setColumnStretch(0, 1)
layout.addWidget(self.LayoutViewer, 0, 0, 1, 1)
self.centeralWidget.setLayout(layout)
self.setCentralWidget(self.centeralWidget)
def enterEvent(self, event):
self.setFocus(True)
def visualize_3d(layout, img):
app = QtWidgets.QApplication(sys.argv)
window = TopWindow(img, layout=layout)
window.show()
# cv2.waitKey()
sys.exit(app.exec_())
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='360 Layout Visualizer',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--img', type=str, required=True, help='The panorama path')
parser.add_argument('--json', type=str, required=True, help='The output json path')
args = parser.parse_args()
img = imread(args.img, pilmode='RGB')
with open(args.json, 'r') as f:
layout = json.load(f)
visualize_3d(layout, img)