forked from gisma/MetashapeTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msInterface.py
175 lines (132 loc) · 5.01 KB
/
msInterface.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""MetaShape tools+
@author Marvin Ludwig Chris Reudenbach
@copyright Copyright 2016-2022, gisma
@license GPL 3.0
@version 0.1.0
@maintainer Chris Reudenbach
@email [email protected]"""
import Metashape
from msFunctions.msSubsetImages import subsetImages
from msFunctions.msError import exportMarker
from msFunctions.msExportTiepointError import *
from msFunctions.msOptimizeSparsecloud import *
from msFunctions.msReproducibility import *
from msFunctions.msDenseCloud import *
from msFunctions.msSparseCloud import *
from msFunctions.msOrtho import *
from msFunctions.msError import *
from msFunctions.ms_Forest_BP_step1 import *
from msFunctions.ms_Forest_BP_step3 import *
from msFunctions.ms_Forest_BP_step4 import *
from msFunctions.gradual_selection import *
from os.path import expanduser
from PySide2.QtGui import *
from PySide2.QtCore import *
from PySide2.QtWidgets import *
import os
import sys
import re
import glob
import textwrap
import copy
#goal = sys.argv[1] if len(sys.argv) > 1 else 0
#imgPath = sys.argv[2] if len(sys.argv) > 2 else 0
#projName = sys.argv[3] if len(sys.argv) > 3 else 0
#alignQuality = sys.argv[4] if len(sys.argv) > 4 else 0
#orthoRes = sys.argv[5] if len(sys.argv) > 5 else 0
# helper for optional all chunk processing:
def menuHelper(fun):
def menuFunc():
ac = Metashape.app.getBool("Process all chunks?")
if ac:
for chunk in Metashape.app.document.chunks:
fun(chunk)
else:
fun(chunk)
return menuFunc
def show_message(msg):
msgBox = QMessageBox()
#print(msg)
msgBox.setText(msg)
msgBox.exec()
#menuSubsetImages = menuHelper(subsetImages)
def menuError():
ac = Metashape.app.getBool("Process all chunks?")
if ac:
for chunk in Metashape.app.document.chunks:
exportMarker(chunk)
else:
exportMarker(chunk)
def menuTiepoints():
ac = Metashape.app.getBool("Process all chunks?")
if ac:
for chunk in Metashape.app.document.chunks:
ExportTiepointError(chunk)
else:
ExportTiepointError(chunk)
def menuDensecloud():
ac = Metashape.app.getBool("Process all chunks?")
if ac:
for chunk in Metashape.app.document.chunks:
createDenseCloud(chunk)
else:
createDenseCloud(Metashape.app.document.chunk)
def menufasteCreateSparse():
chunk = Metashape.app.document.chunk
fastCreateSparse(chunk)
def menuReproducibility():
RE = Metashape.app.getFloat(label = "Optimal Reprojection Error", value = 1)
RU = Metashape.app.getFloat(label = "Optimal Reconstruction Uncertainty", value = 10)
PA = Metashape.app.getFloat(label = "Optimal Projection Accuracy", value = 2)
k = Metashape.app.getInt(label = "Times", value = 5)
chunk = Metashape.app.document.chunk
repro(chunk, RE = RE, RU = RU, PA = PA , k = k)
def helpmsg():
link = "https://github.com/gisma/MetashapeTools"
msg = "Get more information at the Ortho+: <a href='%s'>GitHub Repository</a>" % link
show_message(msg)
def Toolchain03():
orthoRes = Metashape.app.getFloat("Target Resolution of Orthoimage in meter?",value =0.05)
ac = Metashape.app.getBool("Process all Chunks?")
if ac:
for chunk in Metashape.app.document.chunks:
sparse2ortho(chunk,orthoRes)
exportOrtho(chunk)
#exportSeamlines(chunk)
exportMarker(chunk,orthoRes)
else:
chunk = Metashape.app.document.chunk
sparse2ortho(chunk,orthoRes)
exportOrtho(chunk)
#exportSeamlines(chunk)
exportMarker(chunk)
def gradual_selection():
ac = Metashape.app.getBool("Process all Chunks?")
if ac:
for chunk in Metashape.app.document.chunks:
gradualSelection(chunk)
else:
chunk = Metashape.app.document.chunk
gradualSelection(chunk)
def toolchain09():
ac = Metashape.app.getBool("Process all Chunks?")
if ac:
for chunk in Metashape.app.document.chunks:
Toolchain09(chunk)
else:
chunk = Metashape.app.document.chunk
Toolchain09(chunk)
Metashape.app.addMenuSeparator("Ortho+/BestPractice/ForestOrtho")
Metashape.app.addMenuSeparator("Ortho+/Tools+")
Metashape.app.addMenuItem("Ortho+/Tools+/All-in-one Orthoimage-no-GCP", toolchain09)
Metashape.app.addMenuItem("Ortho+/Tools+/Iterative Sparse Cloud filtering", gradual_selection)
Metashape.app.addMenuItem("Ortho+/Tools+/Reduce Overlap", menufasteCreateSparse)
Metashape.app.addMenuItem("Ortho+/Tools+/Create Densecloud", menuDensecloud)
Metashape.app.addMenuItem("Ortho+/Tools+/Create Orthoimage", Toolchain03)
Metashape.app.addMenuSeparator("Ortho+/Utilities")
Metashape.app.addMenuItem("Ortho+/Utilities/Export Marker Error", menuError)
Metashape.app.addMenuItem("Ortho+/Utilities/Export Tiepoint Error", menuTiepoints)
Metashape.app.addMenuItem("Ortho+/Tools+/Reproducibility Runs", menuReproducibility)
Metashape.app.addMenuItem("Ortho+/Help", helpmsg)