From 7792b752ae4a3e1f0a3a080a115a225216825e1f Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Thu, 18 Jun 2020 12:16:50 +0159 Subject: [PATCH 1/7] ppt_gui.py: remove tabs --- linux/ppt_gui.py | 260 +++++++++++++++++++++++------------------------ 1 file changed, 130 insertions(+), 130 deletions(-) diff --git a/linux/ppt_gui.py b/linux/ppt_gui.py index 9cc99f2..49a9683 100644 --- a/linux/ppt_gui.py +++ b/linux/ppt_gui.py @@ -6,13 +6,13 @@ from PyQt4 import QtGui from PyQt4 import QtCore -#################################################################### +#################################################################### class PPTGUI(QtGui.QWidget): - - + + def __init__(self): super(PPTGUI, self).__init__() - self.tabWidget = QtGui.QTabWidget(self) + self.tabWidget = QtGui.QTabWidget(self) self.tabWidget.setGeometry(QtCore.QRect(0, 0, 900, 580)) self.tabWidget.setObjectName("tabWidget") self.tab = QtGui.QWidget() @@ -33,10 +33,10 @@ def __init__(self): self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("MainWindow", "or run PMVS without CMVS", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), QtGui.QApplication.translate("MainWindow", "Check Camera Database", None, QtGui.QApplication.UnicodeUTF8)) def initUI(self): -#################################################################### +#################################################################### #BUNDLER -# button 1 for pictures directory +# button 1 for pictures directory self.button1 = QtGui.QPushButton('Select Photos Path', self.tab) self.button1.setFocusPolicy(QtCore.Qt.NoFocus) self.button1.move(20, 30) @@ -52,8 +52,8 @@ def initUI(self): self.text4.resize(550, 27) # help button select directory - self.help_button1 = QtGui.QPushButton("", self.tab) - self.help_button1.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button1 = QtGui.QPushButton("", self.tab) + self.help_button1.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button1.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button1.move(800, 26) self.connect(self.help_button1, QtCore.SIGNAL('clicked()'), self.on_help1_clicked) @@ -64,7 +64,7 @@ def initUI(self): self.label16.move(20, 84) self.text15 = QtGui.QLineEdit("siftvlfeat", self.tab) - self.text15.setReadOnly(True) + self.text15.setReadOnly(True) self.combo = QtGui.QComboBox(self.tab) self.combo.addItem("siftvlfeat") self.combo.addItem("siftlowe") @@ -75,8 +75,8 @@ def initUI(self): self.connect(self.combo, QtCore.SIGNAL('activated(QString)'), self.onActivated) # help button features extractor - self.help_button2 = QtGui.QPushButton("", self.tab) - self.help_button2.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button2 = QtGui.QPushButton("", self.tab) + self.help_button2.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button2.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button2.move(300, 76) self.connect(self.help_button2, QtCore.SIGNAL('clicked()'), self.on_help2_clicked) @@ -95,8 +95,8 @@ def initUI(self): self.text13.resize(70, 27) # help button width - self.help_button3 = QtGui.QPushButton("", self.tab) - self.help_button3.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button3 = QtGui.QPushButton("", self.tab) + self.help_button3.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button3.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button3.move(720, 76) self.connect(self.help_button3, QtCore.SIGNAL('clicked()'), self.on_help3_clicked) @@ -107,13 +107,13 @@ def initUI(self): self.cb2.setFocusPolicy(QtCore.Qt.NoFocus) self.cb2.move(380, 130) self.cb2.toggle() - self.cb2.setChecked(False) + self.cb2.setChecked(False) self.connect(self.cb2, QtCore.SIGNAL('stateChanged(int)'), self.changesize2) self.text11 = QtGui.QLineEdit("1", self.tab) - self.text11.setReadOnly(True) + self.text11.setReadOnly(True) self.combo2 = QtGui.QComboBox(self.tab) - self.combo2.hide() + self.combo2.hide() self.combo2.addItem("1") self.combo2.addItem("0.75") self.combo2.addItem("0.5") @@ -125,28 +125,28 @@ def initUI(self): self.connect(self.combo2, QtCore.SIGNAL('activated(QString)'), self.onActivated2) # help button resize - self.help_button4 = QtGui.QPushButton("", self.tab) - self.help_button4.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button4 = QtGui.QPushButton("", self.tab) + self.help_button4.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button4.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button4.move(720, 126) self.connect(self.help_button4, QtCore.SIGNAL('clicked()'), self.on_help4_clicked) self.setFocus() -# button 4 for start bundler +# button 4 for start bundler self.button4 = QtGui.QPushButton('Run', self.tab) - self.button4.setIcon(QtGui.QIcon('icons/python_icon.png')) + self.button4.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button4.move(20, 180) self.connect(self.button4, QtCore.SIGNAL('clicked()'), self.startbundler) self.text2 = QtGui.QLineEdit(self.tab) - self.text2.move(120, 184) - self.text2.setReadOnly(True) + self.text2.move(120, 184) + self.text2.setReadOnly(True) self.text2.resize(760, 27) - self.connect(self.text4, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathbundler) - self.connect(self.text15, QtCore.SIGNAL('textChanged(QString)'), self.onChangedextractor) - self.connect(self.text13, QtCore.SIGNAL('textChanged(QString)'), self.onChangedwidth) - self.connect(self.text11, QtCore.SIGNAL('textChanged(QString)'), self.onChangedsize) + self.connect(self.text4, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathbundler) + self.connect(self.text15, QtCore.SIGNAL('textChanged(QString)'), self.onChangedextractor) + self.connect(self.text13, QtCore.SIGNAL('textChanged(QString)'), self.onChangedwidth) + self.connect(self.text11, QtCore.SIGNAL('textChanged(QString)'), self.onChangedsize) #output @@ -159,16 +159,16 @@ def initUI(self): self.label20 = QtGui.QLabel('Output Bundler:', self.tab) self.label20.move(20, 240) - self.output1 = QtGui.QTextBrowser(self.tab) + self.output1 = QtGui.QTextBrowser(self.tab) self.output1.move(20, 264) self.output1.resize(850, 270) self.output1.setAcceptRichText(True) self.output1.setAutoFormatting(QtGui.QTextEdit.AutoBulletList) -# CMVS/PMVS +# CMVS/PMVS # button 2 for Bundler output directory - + self.button2 = QtGui.QPushButton('Select Bundler Output Path', self.tab_3) self.button2.setFocusPolicy(QtCore.Qt.NoFocus) self.button2.move(20, 30) @@ -184,8 +184,8 @@ def initUI(self): self.text3.resize(500, 27) # help button 5 select bundler output directory - self.help_button5 = QtGui.QPushButton("", self.tab_3) - self.help_button5.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button5 = QtGui.QPushButton("", self.tab_3) + self.help_button5.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button5.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button5.move(800, 26) self.connect(self.help_button5, QtCore.SIGNAL('clicked()'), self.on_help5_clicked) @@ -200,8 +200,8 @@ def initUI(self): self.text5.resize(70, 27) # help button 6 select bundler output directory - self.help_button6 = QtGui.QPushButton("", self.tab_3) - self.help_button6.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button6 = QtGui.QPushButton("", self.tab_3) + self.help_button6.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button6.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button6.move(580, 79) self.connect(self.help_button6, QtCore.SIGNAL('clicked()'), self.on_help6_clicked) @@ -209,17 +209,17 @@ def initUI(self): # button run CMVS self.button5 = QtGui.QPushButton('Run', self.tab_3) - self.button5.setIcon(QtGui.QIcon('icons/python_icon.png')) + self.button5.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button5.move(20, 130) self.connect(self.button5, QtCore.SIGNAL('clicked()'), self.startcmvs) self.text6 = QtGui.QLineEdit(self.tab_3) - self.text6.move(120, 134) - self.text6.setReadOnly(True) + self.text6.move(120, 134) + self.text6.setReadOnly(True) self.text6.resize(760, 27) - self.connect(self.text3, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathcmvs) - self.connect(self.text5, QtCore.SIGNAL('textChanged(QString)'), self.onChangedcluster) + self.connect(self.text3, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathcmvs) + self.connect(self.text5, QtCore.SIGNAL('textChanged(QString)'), self.onChangedcluster) #output @@ -232,7 +232,7 @@ def initUI(self): self.label21 = QtGui.QLabel('Output CMVS/PMVS:', self.tab_3) self.label21.move(20, 240) - self.output2 = QtGui.QTextBrowser(self.tab_3) + self.output2 = QtGui.QTextBrowser(self.tab_3) self.output2.move(20, 264) self.output2.resize(850, 270) self.output2.setAcceptRichText(True) @@ -243,50 +243,50 @@ def initUI(self): self.cb3.setFocusPolicy(QtCore.Qt.NoFocus) self.cb3.move(20, 30) self.cb3.toggle() - self.cb3.setChecked(False) + self.cb3.setChecked(False) self.connect(self.cb3, QtCore.SIGNAL('stateChanged(int)'), self.openpmvs) # button 3 for output directory self.button3 = QtGui.QPushButton('Select Bundler Output Path', self.tab_2) self.button3.setFocusPolicy(QtCore.Qt.NoFocus) self.button3.move(20, 80) - self.button3.hide() + self.button3.hide() self.connect(self.button3, QtCore.SIGNAL('clicked()'), self.showDialog3) self.setFocus() # directory output path label self.label14 = QtGui.QLabel('path:', self.tab_2) self.label14.move(240, 84) - self.label14.hide() + self.label14.hide() self.text7 = QtGui.QLineEdit(self.tab_2) self.text7.move(280, 80) - self.text7.hide() + self.text7.hide() self.text7.resize(500, 27) # help button 7 select bundler output directory - self.help_button7 = QtGui.QPushButton("", self.tab_2) - self.help_button7.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button7 = QtGui.QPushButton("", self.tab_2) + self.help_button7.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button7.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button7.move(800, 76) - self.help_button7.hide() + self.help_button7.hide() self.connect(self.help_button7, QtCore.SIGNAL('clicked()'), self.on_help5_clicked) self.setFocus() # run PMVS self.button6 = QtGui.QPushButton('Run', self.tab_2) - self.button6.setIcon(QtGui.QIcon('icons/python_icon.png')) + self.button6.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button6.move(20, 130) - self.button6.hide() + self.button6.hide() self.connect(self.button6, QtCore.SIGNAL('clicked()'), self.startpmvs) self.text8 = QtGui.QLineEdit(self.tab_2) - self.text8.move(120, 134) - self.text8.setReadOnly(True) - self.text8.hide() + self.text8.move(120, 134) + self.text8.setReadOnly(True) + self.text8.hide() self.text8.resize(760, 27) - self.connect(self.text7, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathpmvs) + self.connect(self.text7, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathpmvs) #output @@ -299,16 +299,16 @@ def initUI(self): self.label22 = QtGui.QLabel('Output PMVS:', self.tab_2) self.label22.move(20, 240) - self.output3 = QtGui.QTextBrowser(self.tab_2) + self.output3 = QtGui.QTextBrowser(self.tab_2) self.output3.move(20, 264) self.output3.resize(850, 270) self.output3.setAcceptRichText(True) self.output3.setAutoFormatting(QtGui.QTextEdit.AutoBulletList) - -# Set Camera Database - -# button 1 for pictures directory + +# Set Camera Database + +# button 1 for pictures directory self.button8 = QtGui.QPushButton('Select Photos Path', self.tab_4) self.button8.setFocusPolicy(QtCore.Qt.NoFocus) self.button8.move(20, 30) @@ -324,26 +324,26 @@ def initUI(self): self.text9.resize(550, 27) # help button select directory - self.help_button9 = QtGui.QPushButton("", self.tab_4) - self.help_button9.setIcon(QtGui.QIcon('icons/info_icon.png')) + self.help_button9 = QtGui.QPushButton("", self.tab_4) + self.help_button9.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button9.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button9.move(800, 26) self.connect(self.help_button9, QtCore.SIGNAL('clicked()'), self.on_help9_clicked) self.setFocus() - + # button run Camera Database self.button10 = QtGui.QPushButton('Run', self.tab_4) - self.button10.setIcon(QtGui.QIcon('icons/python_icon.png')) + self.button10.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button10.move(20, 80) self.connect(self.button10, QtCore.SIGNAL('clicked()'), self.startcamdat) self.text10 = QtGui.QLineEdit(self.tab_4) - self.text10.move(120, 84) - self.text10.setReadOnly(True) + self.text10.move(120, 84) + self.text10.setReadOnly(True) self.text10.resize(760, 27) - self.connect(self.text9, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathcamdat) - + self.connect(self.text9, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathcamdat) + #output self.line4 = QtGui.QFrame(self.tab_4) @@ -355,164 +355,164 @@ def initUI(self): self.label23 = QtGui.QLabel('Output Camera Database:', self.tab_4) self.label23.move(20, 240) - self.output4 = QtGui.QTextBrowser(self.tab_4) + self.output4 = QtGui.QTextBrowser(self.tab_4) self.output4.move(20, 264) self.output4.resize(850, 270) self.output4.setAcceptRichText(True) self.output4.setAutoFormatting(QtGui.QTextEdit.AutoBulletList) - -#################################################################### + +#################################################################### self.setWindowTitle('Python Photogrammetry Toolbox GUI v 0.1') self.setGeometry(300, 300, 900, 580) - self.setWindowIcon(QtGui.QIcon('icons/python_icon.png')) -#################################################################### + self.setWindowIcon(QtGui.QIcon('icons/python_icon.png')) +#################################################################### # select directory with photos def showDialog1(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') + directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') self.text4.setText(directoryname) - + # combo vlfeat-sift - def onActivated(self, text): + def onActivated(self, text): self.text15.setText(text) # combo size-image - def onActivated2(self, text): + def onActivated2(self, text): self.text11.setText(text) - + # width-size select - def changesize1(self, value): + def changesize1(self, value): if self.cb1.isChecked(): - self.combo2.hide() - self.text13.show() + self.combo2.hide() + self.text13.show() self.cb2.setChecked(False) self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --maxPhotoDimension=" + self.text13.displayText()) - def changesize2(self, text): + def changesize2(self, text): if self.cb2.isChecked(): - self.combo2.show() - self.text13.hide() + self.combo2.show() + self.text13.hide() self.cb1.setChecked(False) self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --photoScalingFactor=" + self.text11.displayText()) # start bundler def startbundler(self): - command = self.text2.displayText() - proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) - output = proc.stdout.read() - self.output1.append(str(output)) + command = self.text2.displayText() + proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) + output = proc.stdout.read() + self.output1.append(str(output)) # help button 1 - select directory def on_help1_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format.", QtGui.QMessageBox.Ok) + QtGui.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format.", QtGui.QMessageBox.Ok) # help button 2 - feature extractor def on_help2_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the feature extractore between VLFEAT and SIFT. \n\nVLFEAT (http://www.vlfeat.org/) is released under GPL v.2 license. \n\nSIFT (http://www.cs.ubc.ca/~lowe/keypoints/) is being made available for individual research use only. Any commercial use or any redistribution of this software requires a license from the University of British Columbia. Before use SIFT download and copy the binary into the folder.", QtGui.QMessageBox.Ok) + QtGui.QMessageBox.information(self, "Help!", "Select the feature extractore between VLFEAT and SIFT. \n\nVLFEAT (http://www.vlfeat.org/) is released under GPL v.2 license. \n\nSIFT (http://www.cs.ubc.ca/~lowe/keypoints/) is being made available for individual research use only. Any commercial use or any redistribution of this software requires a license from the University of British Columbia. Before use SIFT download and copy the binary into the folder.", QtGui.QMessageBox.Ok) # help button 3 - feature extractor def on_help3_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Copy of a photo will be scaled down if either width or height exceeds the value insert in . After scaling the maximum of width and height will be equal to the value insert in . \n\nDefault value is 1200: an image of 3008x2000 px will be scale into a copy of 1200x798 px.", QtGui.QMessageBox.Ok) + QtGui.QMessageBox.information(self, "Help!", "Copy of a photo will be scaled down if either width or height exceeds the value insert in . After scaling the maximum of width and height will be equal to the value insert in . \n\nDefault value is 1200: an image of 3008x2000 px will be scale into a copy of 1200x798 px.", QtGui.QMessageBox.Ok) # help button 4 - feature extractor def on_help4_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Scale all photos to the specified scaling factor: \n\n1 = original size \n\n0.75 = 75% of the original size \n\n0.5 = half size \n\n0.25 = 25% of the original size.", QtGui.QMessageBox.Ok) + QtGui.QMessageBox.information(self, "Help!", "Scale all photos to the specified scaling factor: \n\n1 = original size \n\n0.75 = 75% of the original size \n\n0.5 = half size \n\n0.25 = 25% of the original size.", QtGui.QMessageBox.Ok) # connection path-command def onChangedpathbundler(self, text): - if self.cb2.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --photoScalingFactor=" + self.text11.displayText()) - if self.cb1.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --maxPhotoDimension=" + self.text13.displayText()) + if self.cb2.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --photoScalingFactor=" + self.text11.displayText()) + if self.cb1.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --maxPhotoDimension=" + self.text13.displayText()) # connection extractor-command def onChangedextractor(self, text): - if self.cb2.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --photoScalingFactor=" + self.text11.displayText()) - if self.cb1.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --maxPhotoDimension=" + self.text13.displayText()) + if self.cb2.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --photoScalingFactor=" + self.text11.displayText()) + if self.cb1.isChecked(): self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --maxPhotoDimension=" + self.text13.displayText()) # connection width-command def onChangedwidth(self, text): - self.cb2.setChecked(False) - self.cb1.setChecked(True) + self.cb2.setChecked(False) + self.cb1.setChecked(True) self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --maxPhotoDimension=" + self.text13.displayText()) # connection size-command def onChangedsize(self, text): - self.cb1.setChecked(False) - self.cb2.setChecked(True) + self.cb1.setChecked(False) + self.cb2.setChecked(True) self.text2.setText("python ./RunBundler.py --photos=" + self.text4.displayText() + " --featureExtractor=" + self.text15.displayText()+ " --photoScalingFactor=" + self.text11.displayText()) # select directory with photos def showDialog2(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') + directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') self.text3.setText(directoryname) # help button 5 - select directory def on_help5_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the Bundler output directory.", QtGui.QMessageBox.Ok) + QtGui.QMessageBox.information(self, "Help!", "Select the Bundler output directory.", QtGui.QMessageBox.Ok) # connection path-command def onChangedpathcmvs(self, text): - self.text6.setText("python ./RunCMVS.py --bundlerOutputPath=" + self.text3.displayText() + " --ClusterToCompute=" + self.text5.displayText()) + self.text6.setText("python ./RunCMVS.py --bundlerOutputPath=" + self.text3.displayText() + " --ClusterToCompute=" + self.text5.displayText()) # connection number cluster def onChangedcluster(self, text): - self.text6.setText("python ./RunCMVS.py --bundlerOutputPath=" + self.text3.displayText() + " --ClusterToCompute=" + self.text5.displayText()) + self.text6.setText("python ./RunCMVS.py --bundlerOutputPath=" + self.text3.displayText() + " --ClusterToCompute=" + self.text5.displayText()) # help button 6 - cluster def on_help6_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the max number of photos for each cluster that CMVS should compute. Separated PLY output files will be created. \n\nDepends on the CPUs of your computer: if infinite loop occur, stop the process and try a different value. \n\nDefault value is 10: an image set with 28 photos will be compute in 3 separated clusters.", QtGui.QMessageBox.Ok) - + QtGui.QMessageBox.information(self, "Help!", "Select the max number of photos for each cluster that CMVS should compute. Separated PLY output files will be created. \n\nDepends on the CPUs of your computer: if infinite loop occur, stop the process and try a different value. \n\nDefault value is 10: an image set with 28 photos will be compute in 3 separated clusters.", QtGui.QMessageBox.Ok) + # start cmvs def startcmvs(self): - command = self.text6.displayText() - proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) - output = proc.stdout.read() - self.output2.append(str(output)) + command = self.text6.displayText() + proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) + output = proc.stdout.read() + self.output2.append(str(output)) -# open pmvs - def openpmvs(self, text): +# open pmvs + def openpmvs(self, text): if self.cb3.isChecked(): - self.button3.show() - self.button6.show() - self.text7.show() - self.text8.show() - self.label14.show() - self.help_button7.show() - else: self.label14.hide(), self.button3.hide(), self.button6.hide(), self.text7.hide(), self.text8.hide(), self.help_button7.hide() - + self.button3.show() + self.button6.show() + self.text7.show() + self.text8.show() + self.label14.show() + self.help_button7.show() + else: self.label14.hide(), self.button3.hide(), self.button6.hide(), self.text7.hide(), self.text8.hide(), self.help_button7.hide() + # select directory with bundler output def showDialog3(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') + directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') self.text7.setText(directoryname) # connection path-command def onChangedpathpmvs(self, text): - self.text8.setText("python ./RunPMVS.py --bundlerOutputPath=" + self.text7.displayText()) + self.text8.setText("python ./RunPMVS.py --bundlerOutputPath=" + self.text7.displayText()) # start pmvs def startpmvs(self): - command = self.text8.displayText() - proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) - output = proc.stdout.read() - self.output3.append(str(output)) - + command = self.text8.displayText() + proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) + output = proc.stdout.read() + self.output3.append(str(output)) + # select directory with photos (Camera Database) def showDialog4(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') + directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') self.text9.setText(directoryname) - + # help button 9 - select directory def on_help9_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format. \n\nPress the RUN button to check if the camera is inset inside the database. \n\nIf the camera is not correctly saved, please insert in the terminal windows the CCD width in mm", QtGui.QMessageBox.Ok) + QtGui.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format. \n\nPress the RUN button to check if the camera is inset inside the database. \n\nIf the camera is not correctly saved, please insert in the terminal windows the CCD width in mm", QtGui.QMessageBox.Ok) # connection path-command def onChangedpathcamdat(self, text): - self.text10.setText("python ./RunBundler.py --photos=" + self.text9.displayText() + " --checkCameraDatabase") + self.text10.setText("python ./RunBundler.py --photos=" + self.text9.displayText() + " --checkCameraDatabase") # start Camera Database def startcamdat(self): - command = self.text10.displayText() - proc = subprocess.Popen((str(command)), shell=True) + command = self.text10.displayText() + proc = subprocess.Popen((str(command)), shell=True) if __name__ == '__main__': From 2698294f39950105d3e2c322c0ce6673fb06d9c6 Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Thu, 18 Jun 2020 13:42:00 +0159 Subject: [PATCH 2/7] ppt_gui.py: convert to pyqt5 using pyqt4topyqt5 Thanks to https://github.com/rferrazz/pyqt4topyqt5 --- linux/ppt_gui.py | 232 +++++++++++++++++++++++------------------------ 1 file changed, 116 insertions(+), 116 deletions(-) diff --git a/linux/ppt_gui.py b/linux/ppt_gui.py index 49a9683..4e9f2ce 100644 --- a/linux/ppt_gui.py +++ b/linux/ppt_gui.py @@ -3,116 +3,116 @@ import sys, subprocess -from PyQt4 import QtGui -from PyQt4 import QtCore +from PyQt5 import QtGui, QtWidgets +from PyQt5 import QtCore, QtWidgets #################################################################### -class PPTGUI(QtGui.QWidget): +class PPTGUI(QtWidgets.QWidget): def __init__(self): super(PPTGUI, self).__init__() - self.tabWidget = QtGui.QTabWidget(self) + self.tabWidget = QtWidgets.QTabWidget(self) self.tabWidget.setGeometry(QtCore.QRect(0, 0, 900, 580)) self.tabWidget.setObjectName("tabWidget") - self.tab = QtGui.QWidget() + self.tab = QtWidgets.QWidget() self.tab.setObjectName("tab") self.tabWidget.addTab(self.tab, "") - self.tab_3 = QtGui.QWidget() + self.tab_3 = QtWidgets.QWidget() self.tab_3.setObjectName("tab_3") self.tabWidget.addTab(self.tab_3, "") - self.tab_2 = QtGui.QWidget() + self.tab_2 = QtWidgets.QWidget() self.tab_2.setObjectName("tab_2") self.tabWidget.addTab(self.tab_2, "") - self.tab_4 = QtGui.QWidget() + self.tab_4 = QtWidgets.QWidget() self.tab_4.setObjectName("tab_4") self.tabWidget.addTab(self.tab_4, "") self.initUI() - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "1. Run Bundler", None, QtGui.QApplication.UnicodeUTF8)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), QtGui.QApplication.translate("MainWindow", "2. Run CMVS/PMVS", None, QtGui.QApplication.UnicodeUTF8)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtGui.QApplication.translate("MainWindow", "or run PMVS without CMVS", None, QtGui.QApplication.UnicodeUTF8)) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), QtGui.QApplication.translate("MainWindow", "Check Camera Database", None, QtGui.QApplication.UnicodeUTF8)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtCore.QCoreApplication.translate("MainWindow", "1. Run Bundler", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), QtCore.QCoreApplication.translate("MainWindow", "2. Run CMVS/PMVS", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), QtCore.QCoreApplication.translate("MainWindow", "or run PMVS without CMVS", None)) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), QtCore.QCoreApplication.translate("MainWindow", "Check Camera Database", None)) def initUI(self): #################################################################### #BUNDLER # button 1 for pictures directory - self.button1 = QtGui.QPushButton('Select Photos Path', self.tab) + self.button1 = QtWidgets.QPushButton('Select Photos Path', self.tab) self.button1.setFocusPolicy(QtCore.Qt.NoFocus) self.button1.move(20, 30) - self.connect(self.button1, QtCore.SIGNAL('clicked()'), self.showDialog1) + self.button1.clicked.connect(self.showDialog1) self.setFocus() # directory path label - self.label9 = QtGui.QLabel('path:', self.tab) + self.label9 = QtWidgets.QLabel('path:', self.tab) self.label9.move(190, 34) - self.text4 = QtGui.QLineEdit(self.tab) + self.text4 = QtWidgets.QLineEdit(self.tab) self.text4.move(235, 30) self.text4.resize(550, 27) # help button select directory - self.help_button1 = QtGui.QPushButton("", self.tab) + self.help_button1 = QtWidgets.QPushButton("", self.tab) self.help_button1.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button1.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button1.move(800, 26) - self.connect(self.help_button1, QtCore.SIGNAL('clicked()'), self.on_help1_clicked) + self.help_button1.clicked.connect(self.on_help1_clicked) self.setFocus() # features extractor combo - self.label16 = QtGui.QLabel('Select Feature Extractor:', self.tab) + self.label16 = QtWidgets.QLabel('Select Feature Extractor:', self.tab) self.label16.move(20, 84) - self.text15 = QtGui.QLineEdit("siftvlfeat", self.tab) + self.text15 = QtWidgets.QLineEdit("siftvlfeat", self.tab) self.text15.setReadOnly(True) - self.combo = QtGui.QComboBox(self.tab) + self.combo = QtWidgets.QComboBox(self.tab) self.combo.addItem("siftvlfeat") self.combo.addItem("siftlowe") self.combo.move(200, 80) self.text15.move(360, 100) self.text15.resize(0, 0) - self.connect(self.combo, QtCore.SIGNAL('activated(QString)'), self.onActivated) + self.combo.activated['QString'].connect(self.onActivated) # help button features extractor - self.help_button2 = QtGui.QPushButton("", self.tab) + self.help_button2 = QtWidgets.QPushButton("", self.tab) self.help_button2.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button2.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button2.move(300, 76) - self.connect(self.help_button2, QtCore.SIGNAL('clicked()'), self.on_help2_clicked) + self.help_button2.clicked.connect(self.on_help2_clicked) self.setFocus() # image width - self.cb1 = QtGui.QCheckBox('Set desired Photos Width:', self.tab) + self.cb1 = QtWidgets.QCheckBox('Set desired Photos Width:', self.tab) self.cb1.setFocusPolicy(QtCore.Qt.NoFocus) self.cb1.move(380, 80) self.cb1.toggle() - self.connect(self.cb1, QtCore.SIGNAL('stateChanged(int)'), self.changesize1) + self.cb1.stateChanged[int].connect(self.changesize1) - self.text13 = QtGui.QLineEdit('1200', self.tab) + self.text13 = QtWidgets.QLineEdit('1200', self.tab) self.text13.move(600, 78) self.text13.resize(70, 27) # help button width - self.help_button3 = QtGui.QPushButton("", self.tab) + self.help_button3 = QtWidgets.QPushButton("", self.tab) self.help_button3.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button3.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button3.move(720, 76) - self.connect(self.help_button3, QtCore.SIGNAL('clicked()'), self.on_help3_clicked) + self.help_button3.clicked.connect(self.on_help3_clicked) self.setFocus() # image resize - self.cb2 = QtGui.QCheckBox('Scale Photos with a Scaling Factor', self.tab) + self.cb2 = QtWidgets.QCheckBox('Scale Photos with a Scaling Factor', self.tab) self.cb2.setFocusPolicy(QtCore.Qt.NoFocus) self.cb2.move(380, 130) self.cb2.toggle() self.cb2.setChecked(False) - self.connect(self.cb2, QtCore.SIGNAL('stateChanged(int)'), self.changesize2) + self.cb2.stateChanged[int].connect(self.changesize2) - self.text11 = QtGui.QLineEdit("1", self.tab) + self.text11 = QtWidgets.QLineEdit("1", self.tab) self.text11.setReadOnly(True) - self.combo2 = QtGui.QComboBox(self.tab) + self.combo2 = QtWidgets.QComboBox(self.tab) self.combo2.hide() self.combo2.addItem("1") self.combo2.addItem("0.75") @@ -122,244 +122,244 @@ def initUI(self): self.text11.move(390, 100) self.text11.resize(0, 0) - self.connect(self.combo2, QtCore.SIGNAL('activated(QString)'), self.onActivated2) + self.combo2.activated['QString'].connect(self.onActivated2) # help button resize - self.help_button4 = QtGui.QPushButton("", self.tab) + self.help_button4 = QtWidgets.QPushButton("", self.tab) self.help_button4.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button4.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button4.move(720, 126) - self.connect(self.help_button4, QtCore.SIGNAL('clicked()'), self.on_help4_clicked) + self.help_button4.clicked.connect(self.on_help4_clicked) self.setFocus() # button 4 for start bundler - self.button4 = QtGui.QPushButton('Run', self.tab) + self.button4 = QtWidgets.QPushButton('Run', self.tab) self.button4.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button4.move(20, 180) - self.connect(self.button4, QtCore.SIGNAL('clicked()'), self.startbundler) + self.button4.clicked.connect(self.startbundler) - self.text2 = QtGui.QLineEdit(self.tab) + self.text2 = QtWidgets.QLineEdit(self.tab) self.text2.move(120, 184) self.text2.setReadOnly(True) self.text2.resize(760, 27) - self.connect(self.text4, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathbundler) - self.connect(self.text15, QtCore.SIGNAL('textChanged(QString)'), self.onChangedextractor) - self.connect(self.text13, QtCore.SIGNAL('textChanged(QString)'), self.onChangedwidth) - self.connect(self.text11, QtCore.SIGNAL('textChanged(QString)'), self.onChangedsize) + self.text4.textChanged['QString'].connect(self.onChangedpathbundler) + self.text15.textChanged['QString'].connect(self.onChangedextractor) + self.text13.textChanged['QString'].connect(self.onChangedwidth) + self.text11.textChanged['QString'].connect(self.onChangedsize) #output - self.line1 = QtGui.QFrame(self.tab) + self.line1 = QtWidgets.QFrame(self.tab) self.line1.setGeometry(QtCore.QRect(10, 220, 880, 20)) - self.line1.setFrameShape(QtGui.QFrame.HLine) - self.line1.setFrameShadow(QtGui.QFrame.Sunken) + self.line1.setFrameShape(QtWidgets.QFrame.HLine) + self.line1.setFrameShadow(QtWidgets.QFrame.Sunken) self.line1.setObjectName("line1") - self.label20 = QtGui.QLabel('Output Bundler:', self.tab) + self.label20 = QtWidgets.QLabel('Output Bundler:', self.tab) self.label20.move(20, 240) - self.output1 = QtGui.QTextBrowser(self.tab) + self.output1 = QtWidgets.QTextBrowser(self.tab) self.output1.move(20, 264) self.output1.resize(850, 270) self.output1.setAcceptRichText(True) - self.output1.setAutoFormatting(QtGui.QTextEdit.AutoBulletList) + self.output1.setAutoFormatting(QtWidgets.QTextEdit.AutoBulletList) # CMVS/PMVS # button 2 for Bundler output directory - self.button2 = QtGui.QPushButton('Select Bundler Output Path', self.tab_3) + self.button2 = QtWidgets.QPushButton('Select Bundler Output Path', self.tab_3) self.button2.setFocusPolicy(QtCore.Qt.NoFocus) self.button2.move(20, 30) - self.connect(self.button2, QtCore.SIGNAL('clicked()'), self.showDialog2) + self.button2.clicked.connect(self.showDialog2) self.setFocus() # directory output path label - self.label10 = QtGui.QLabel('path:', self.tab_3) + self.label10 = QtWidgets.QLabel('path:', self.tab_3) self.label10.move(240, 34) - self.text3 = QtGui.QLineEdit(self.tab_3) + self.text3 = QtWidgets.QLineEdit(self.tab_3) self.text3.move(285, 30) self.text3.resize(500, 27) # help button 5 select bundler output directory - self.help_button5 = QtGui.QPushButton("", self.tab_3) + self.help_button5 = QtWidgets.QPushButton("", self.tab_3) self.help_button5.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button5.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button5.move(800, 26) - self.connect(self.help_button5, QtCore.SIGNAL('clicked()'), self.on_help5_clicked) + self.help_button5.clicked.connect(self.on_help5_clicked) self.setFocus() # number images for cluster - self.label11 = QtGui.QLabel('Number of Photos in each Cluster:', self.tab_3) + self.label11 = QtWidgets.QLabel('Number of Photos in each Cluster:', self.tab_3) self.label11.move(240, 84) - self.text5 = QtGui.QLineEdit('10', self.tab_3) + self.text5 = QtWidgets.QLineEdit('10', self.tab_3) self.text5.move(490, 82) self.text5.resize(70, 27) # help button 6 select bundler output directory - self.help_button6 = QtGui.QPushButton("", self.tab_3) + self.help_button6 = QtWidgets.QPushButton("", self.tab_3) self.help_button6.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button6.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button6.move(580, 79) - self.connect(self.help_button6, QtCore.SIGNAL('clicked()'), self.on_help6_clicked) + self.help_button6.clicked.connect(self.on_help6_clicked) self.setFocus() # button run CMVS - self.button5 = QtGui.QPushButton('Run', self.tab_3) + self.button5 = QtWidgets.QPushButton('Run', self.tab_3) self.button5.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button5.move(20, 130) - self.connect(self.button5, QtCore.SIGNAL('clicked()'), self.startcmvs) + self.button5.clicked.connect(self.startcmvs) - self.text6 = QtGui.QLineEdit(self.tab_3) + self.text6 = QtWidgets.QLineEdit(self.tab_3) self.text6.move(120, 134) self.text6.setReadOnly(True) self.text6.resize(760, 27) - self.connect(self.text3, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathcmvs) - self.connect(self.text5, QtCore.SIGNAL('textChanged(QString)'), self.onChangedcluster) + self.text3.textChanged['QString'].connect(self.onChangedpathcmvs) + self.text5.textChanged['QString'].connect(self.onChangedcluster) #output - self.line3 = QtGui.QFrame(self.tab_3) + self.line3 = QtWidgets.QFrame(self.tab_3) self.line3.setGeometry(QtCore.QRect(10, 220, 880, 20)) - self.line3.setFrameShape(QtGui.QFrame.HLine) - self.line3.setFrameShadow(QtGui.QFrame.Sunken) + self.line3.setFrameShape(QtWidgets.QFrame.HLine) + self.line3.setFrameShadow(QtWidgets.QFrame.Sunken) self.line3.setObjectName("line3") - self.label21 = QtGui.QLabel('Output CMVS/PMVS:', self.tab_3) + self.label21 = QtWidgets.QLabel('Output CMVS/PMVS:', self.tab_3) self.label21.move(20, 240) - self.output2 = QtGui.QTextBrowser(self.tab_3) + self.output2 = QtWidgets.QTextBrowser(self.tab_3) self.output2.move(20, 264) self.output2.resize(850, 270) self.output2.setAcceptRichText(True) - self.output2.setAutoFormatting(QtGui.QTextEdit.AutoBulletList) + self.output2.setAutoFormatting(QtWidgets.QTextEdit.AutoBulletList) # run only PMVS - self.cb3 = QtGui.QCheckBox('Use directly PMVS2 (without CMVS):', self.tab_2) + self.cb3 = QtWidgets.QCheckBox('Use directly PMVS2 (without CMVS):', self.tab_2) self.cb3.setFocusPolicy(QtCore.Qt.NoFocus) self.cb3.move(20, 30) self.cb3.toggle() self.cb3.setChecked(False) - self.connect(self.cb3, QtCore.SIGNAL('stateChanged(int)'), self.openpmvs) + self.cb3.stateChanged[int].connect(self.openpmvs) # button 3 for output directory - self.button3 = QtGui.QPushButton('Select Bundler Output Path', self.tab_2) + self.button3 = QtWidgets.QPushButton('Select Bundler Output Path', self.tab_2) self.button3.setFocusPolicy(QtCore.Qt.NoFocus) self.button3.move(20, 80) self.button3.hide() - self.connect(self.button3, QtCore.SIGNAL('clicked()'), self.showDialog3) + self.button3.clicked.connect(self.showDialog3) self.setFocus() # directory output path label - self.label14 = QtGui.QLabel('path:', self.tab_2) + self.label14 = QtWidgets.QLabel('path:', self.tab_2) self.label14.move(240, 84) self.label14.hide() - self.text7 = QtGui.QLineEdit(self.tab_2) + self.text7 = QtWidgets.QLineEdit(self.tab_2) self.text7.move(280, 80) self.text7.hide() self.text7.resize(500, 27) # help button 7 select bundler output directory - self.help_button7 = QtGui.QPushButton("", self.tab_2) + self.help_button7 = QtWidgets.QPushButton("", self.tab_2) self.help_button7.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button7.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button7.move(800, 76) self.help_button7.hide() - self.connect(self.help_button7, QtCore.SIGNAL('clicked()'), self.on_help5_clicked) + self.help_button7.clicked.connect(self.on_help5_clicked) self.setFocus() # run PMVS - self.button6 = QtGui.QPushButton('Run', self.tab_2) + self.button6 = QtWidgets.QPushButton('Run', self.tab_2) self.button6.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button6.move(20, 130) self.button6.hide() - self.connect(self.button6, QtCore.SIGNAL('clicked()'), self.startpmvs) + self.button6.clicked.connect(self.startpmvs) - self.text8 = QtGui.QLineEdit(self.tab_2) + self.text8 = QtWidgets.QLineEdit(self.tab_2) self.text8.move(120, 134) self.text8.setReadOnly(True) self.text8.hide() self.text8.resize(760, 27) - self.connect(self.text7, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathpmvs) + self.text7.textChanged['QString'].connect(self.onChangedpathpmvs) #output - self.line2 = QtGui.QFrame(self.tab_2) + self.line2 = QtWidgets.QFrame(self.tab_2) self.line2.setGeometry(QtCore.QRect(10, 220, 880, 20)) - self.line2.setFrameShape(QtGui.QFrame.HLine) - self.line2.setFrameShadow(QtGui.QFrame.Sunken) + self.line2.setFrameShape(QtWidgets.QFrame.HLine) + self.line2.setFrameShadow(QtWidgets.QFrame.Sunken) self.line2.setObjectName("line2") - self.label22 = QtGui.QLabel('Output PMVS:', self.tab_2) + self.label22 = QtWidgets.QLabel('Output PMVS:', self.tab_2) self.label22.move(20, 240) - self.output3 = QtGui.QTextBrowser(self.tab_2) + self.output3 = QtWidgets.QTextBrowser(self.tab_2) self.output3.move(20, 264) self.output3.resize(850, 270) self.output3.setAcceptRichText(True) - self.output3.setAutoFormatting(QtGui.QTextEdit.AutoBulletList) + self.output3.setAutoFormatting(QtWidgets.QTextEdit.AutoBulletList) # Set Camera Database # button 1 for pictures directory - self.button8 = QtGui.QPushButton('Select Photos Path', self.tab_4) + self.button8 = QtWidgets.QPushButton('Select Photos Path', self.tab_4) self.button8.setFocusPolicy(QtCore.Qt.NoFocus) self.button8.move(20, 30) - self.connect(self.button8, QtCore.SIGNAL('clicked()'), self.showDialog4) + self.button8.clicked.connect(self.showDialog4) self.setFocus() # directory path label - self.label12 = QtGui.QLabel('path:', self.tab_4) + self.label12 = QtWidgets.QLabel('path:', self.tab_4) self.label12.move(190, 34) - self.text9 = QtGui.QLineEdit(self.tab_4) + self.text9 = QtWidgets.QLineEdit(self.tab_4) self.text9.move(235, 30) self.text9.resize(550, 27) # help button select directory - self.help_button9 = QtGui.QPushButton("", self.tab_4) + self.help_button9 = QtWidgets.QPushButton("", self.tab_4) self.help_button9.setIcon(QtGui.QIcon('icons/info_icon.png')) self.help_button9.setFocusPolicy(QtCore.Qt.NoFocus) self.help_button9.move(800, 26) - self.connect(self.help_button9, QtCore.SIGNAL('clicked()'), self.on_help9_clicked) + self.help_button9.clicked.connect(self.on_help9_clicked) self.setFocus() # button run Camera Database - self.button10 = QtGui.QPushButton('Run', self.tab_4) + self.button10 = QtWidgets.QPushButton('Run', self.tab_4) self.button10.setIcon(QtGui.QIcon('icons/python_icon.png')) self.button10.move(20, 80) - self.connect(self.button10, QtCore.SIGNAL('clicked()'), self.startcamdat) + self.button10.clicked.connect(self.startcamdat) - self.text10 = QtGui.QLineEdit(self.tab_4) + self.text10 = QtWidgets.QLineEdit(self.tab_4) self.text10.move(120, 84) self.text10.setReadOnly(True) self.text10.resize(760, 27) - self.connect(self.text9, QtCore.SIGNAL('textChanged(QString)'), self.onChangedpathcamdat) + self.text9.textChanged['QString'].connect(self.onChangedpathcamdat) #output - self.line4 = QtGui.QFrame(self.tab_4) + self.line4 = QtWidgets.QFrame(self.tab_4) self.line4.setGeometry(QtCore.QRect(10, 220, 880, 20)) - self.line4.setFrameShape(QtGui.QFrame.HLine) - self.line4.setFrameShadow(QtGui.QFrame.Sunken) + self.line4.setFrameShape(QtWidgets.QFrame.HLine) + self.line4.setFrameShadow(QtWidgets.QFrame.Sunken) self.line4.setObjectName("line1") - self.label23 = QtGui.QLabel('Output Camera Database:', self.tab_4) + self.label23 = QtWidgets.QLabel('Output Camera Database:', self.tab_4) self.label23.move(20, 240) - self.output4 = QtGui.QTextBrowser(self.tab_4) + self.output4 = QtWidgets.QTextBrowser(self.tab_4) self.output4.move(20, 264) self.output4.resize(850, 270) self.output4.setAcceptRichText(True) - self.output4.setAutoFormatting(QtGui.QTextEdit.AutoBulletList) + self.output4.setAutoFormatting(QtWidgets.QTextEdit.AutoBulletList) #################################################################### @@ -370,7 +370,7 @@ def initUI(self): # select directory with photos def showDialog1(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') + directoryname = QtWidgets.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') self.text4.setText(directoryname) # combo vlfeat-sift @@ -405,19 +405,19 @@ def startbundler(self): # help button 1 - select directory def on_help1_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format.", QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format.", QtWidgets.QMessageBox.Ok) # help button 2 - feature extractor def on_help2_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the feature extractore between VLFEAT and SIFT. \n\nVLFEAT (http://www.vlfeat.org/) is released under GPL v.2 license. \n\nSIFT (http://www.cs.ubc.ca/~lowe/keypoints/) is being made available for individual research use only. Any commercial use or any redistribution of this software requires a license from the University of British Columbia. Before use SIFT download and copy the binary into the folder.", QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.information(self, "Help!", "Select the feature extractore between VLFEAT and SIFT. \n\nVLFEAT (http://www.vlfeat.org/) is released under GPL v.2 license. \n\nSIFT (http://www.cs.ubc.ca/~lowe/keypoints/) is being made available for individual research use only. Any commercial use or any redistribution of this software requires a license from the University of British Columbia. Before use SIFT download and copy the binary into the folder.", QtWidgets.QMessageBox.Ok) # help button 3 - feature extractor def on_help3_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Copy of a photo will be scaled down if either width or height exceeds the value insert in . After scaling the maximum of width and height will be equal to the value insert in . \n\nDefault value is 1200: an image of 3008x2000 px will be scale into a copy of 1200x798 px.", QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.information(self, "Help!", "Copy of a photo will be scaled down if either width or height exceeds the value insert in . After scaling the maximum of width and height will be equal to the value insert in . \n\nDefault value is 1200: an image of 3008x2000 px will be scale into a copy of 1200x798 px.", QtWidgets.QMessageBox.Ok) # help button 4 - feature extractor def on_help4_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Scale all photos to the specified scaling factor: \n\n1 = original size \n\n0.75 = 75% of the original size \n\n0.5 = half size \n\n0.25 = 25% of the original size.", QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.information(self, "Help!", "Scale all photos to the specified scaling factor: \n\n1 = original size \n\n0.75 = 75% of the original size \n\n0.5 = half size \n\n0.25 = 25% of the original size.", QtWidgets.QMessageBox.Ok) # connection path-command def onChangedpathbundler(self, text): @@ -443,12 +443,12 @@ def onChangedsize(self, text): # select directory with photos def showDialog2(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') + directoryname = QtWidgets.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') self.text3.setText(directoryname) # help button 5 - select directory def on_help5_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the Bundler output directory.", QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.information(self, "Help!", "Select the Bundler output directory.", QtWidgets.QMessageBox.Ok) # connection path-command def onChangedpathcmvs(self, text): @@ -460,7 +460,7 @@ def onChangedcluster(self, text): # help button 6 - cluster def on_help6_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the max number of photos for each cluster that CMVS should compute. Separated PLY output files will be created. \n\nDepends on the CPUs of your computer: if infinite loop occur, stop the process and try a different value. \n\nDefault value is 10: an image set with 28 photos will be compute in 3 separated clusters.", QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.information(self, "Help!", "Select the max number of photos for each cluster that CMVS should compute. Separated PLY output files will be created. \n\nDepends on the CPUs of your computer: if infinite loop occur, stop the process and try a different value. \n\nDefault value is 10: an image set with 28 photos will be compute in 3 separated clusters.", QtWidgets.QMessageBox.Ok) # start cmvs def startcmvs(self): @@ -482,7 +482,7 @@ def openpmvs(self, text): # select directory with bundler output def showDialog3(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') + directoryname = QtWidgets.QFileDialog.getExistingDirectory(self, 'Open directory with Bundler output files', '/home') self.text7.setText(directoryname) # connection path-command @@ -498,12 +498,12 @@ def startpmvs(self): # select directory with photos (Camera Database) def showDialog4(self): - directoryname = QtGui.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') + directoryname = QtWidgets.QFileDialog.getExistingDirectory(self, 'Open directory with photos', '/home') self.text9.setText(directoryname) # help button 9 - select directory def on_help9_clicked(self): - QtGui.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format. \n\nPress the RUN button to check if the camera is inset inside the database. \n\nIf the camera is not correctly saved, please insert in the terminal windows the CCD width in mm", QtGui.QMessageBox.Ok) + QtWidgets.QMessageBox.information(self, "Help!", "Select the directory with original photos. Pictures have to be in JPG file format. \n\nPress the RUN button to check if the camera is inset inside the database. \n\nIf the camera is not correctly saved, please insert in the terminal windows the CCD width in mm", QtWidgets.QMessageBox.Ok) # connection path-command def onChangedpathcamdat(self, text): @@ -516,7 +516,7 @@ def startcamdat(self): if __name__ == '__main__': - app = QtGui.QApplication(sys.argv) + app = QtWidgets.QApplication(sys.argv) ppt = PPTGUI() ppt.show() app.exec_() From 94d06e8be5e1090398db9e2d092c3a7958a8fcc7 Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Thu, 18 Jun 2020 13:52:05 +0159 Subject: [PATCH 3/7] 2to3: convert to python3 there are still tabs 'n spaces problems. --- linux/osmbundler/__init__.py | 38 ++++++++++++------------- linux/osmbundler/features/sift.py | 2 +- linux/osmbundler/features/siftlowe.py | 2 +- linux/osmbundler/features/siftvlfeat.py | 2 +- linux/osmbundler/matching/bundler.py | 2 +- linux/osmbundler/matching/manual.py | 2 +- linux/osmcmvs/__init__.py | 24 ++++++++-------- linux/osmpmvs/__init__.py | 22 +++++++------- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/linux/osmbundler/__init__.py b/linux/osmbundler/__init__.py index 9f0569e..c257f4e 100755 --- a/linux/osmbundler/__init__.py +++ b/linux/osmbundler/__init__.py @@ -5,13 +5,13 @@ from PIL import Image from PIL.ExifTags import TAGS -import defaults +from . import defaults -import matching -from matching import * +from . import matching +from .matching import * -import features -from features import * +from . import features +from .features import * # a helper function to get list of photos from a directory def getPhotosFromDirectory(photoDir): @@ -86,7 +86,7 @@ def __init__(self): logging.info("Working directory created: "+self.workDir) if not (os.path.isdir(self.photosArg) or os.path.isfile(self.photosArg)): - raise Exception, "'%s' is neither directory nor a file name" % self.photosArg + raise Exception("'%s' is neither directory nor a file name" % self.photosArg) # initialize mathing engine based on command line arguments self.initMatchingEngine() @@ -152,7 +152,7 @@ def preparePhotos(self, *kargs, **kwargs): if os.path.isdir(self.photosArg): # directory with images photos = getPhotosFromDirectory(self.photosArg) - if len(photos)<3: raise Exception, "The directory with images should contain at least 3 .jpg photos" + if len(photos)<3: raise Exception("The directory with images should contain at least 3 .jpg photos") for photo in photos: photoInfo = dict(dirname=self.photosArg, basename=photo) self._preparePhoto(photoInfo) @@ -208,8 +208,8 @@ def checkCameraInDatabase(self, photoPath): ccdWidth = self.getCcdWidthFromDatabase(exifMake, exifModel) if ccdWidth==None: while True: - print "Type CCD width in mm for the camera %s, %s. Press Enter to skip the camera." % (exifMake, exifModel) - userInput = raw_input("CCD width in mm: ") + print("Type CCD width in mm for the camera %s, %s. Press Enter to skip the camera." % (exifMake, exifModel)) + userInput = input("CCD width in mm: ") # Enter key was pressed if not userInput: return try: @@ -217,16 +217,16 @@ def checkCameraInDatabase(self, photoPath): if ccdWidth==0: raise ZeroValueException self.dbCursor.execute("insert into cameras(make, model, ccd_width, source) values(?, ?, ?, 2)", (exifMake, exifModel, ccdWidth)) except ZeroValueException: - print "\nCCD width can not be equal to zero." + print("\nCCD width can not be equal to zero.") except ValueError: - print "\nIncorrect value for the CCD width. Please enter CCD width in mm." + print("\nIncorrect value for the CCD width. Please enter CCD width in mm.") except: - print "\nCan not insert CCD width to the database." + print("\nCan not insert CCD width to the database.") else: - print "CCD width %s for the cameras %s,%s has been successively inserted to the database" % (ccdWidth, exifMake, exifModel) + print("CCD width %s for the cameras %s,%s has been successively inserted to the database" % (ccdWidth, exifMake, exifModel)) return else: - print "Camera is already inserted into the database" + print("Camera is already inserted into the database") return def _preparePhoto(self, photoInfo): @@ -288,7 +288,7 @@ def _getExif(self, photoHandle): exif = {} info = photoHandle._getexif() if info: - for attr, value in info.items(): + for attr, value in list(info.items()): decodedAttr = TAGS.get(attr, attr) if decodedAttr in exifAttrs: exif[decodedAttr] = value if 'FocalLength' in exif: exif['FocalLength'] = float(exif['FocalLength'][0])/float(exif['FocalLength'][1]) @@ -321,7 +321,7 @@ def initMatchingEngine(self): matchingEngineClass = getattr(matchingEngine, matchingEngine.className) self.matchingEngine = matchingEngineClass(os.path.join(distrPath, "software")) except: - raise Exception, "Unable initialize matching engine %s" % self.featureExtractor + raise Exception("Unable initialize matching engine %s" % self.featureExtractor) def initFeatureExtractor(self): try: @@ -329,7 +329,7 @@ def initFeatureExtractor(self): featureExtractorClass = getattr(featureExtractor, featureExtractor.className) self.featureExtractor = featureExtractorClass(os.path.join(distrPath, "software")) except: - raise Exception, "Unable initialize feature extractor %s" % self.featureExtractor + raise Exception("Unable initialize feature extractor %s" % self.featureExtractor) def extractFeatures(self, photo): # let self.featureExtractor do its job @@ -369,11 +369,11 @@ def printHelpExit(self): def openResult(self): if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) if sys.platform == "linux2": subprocess.call(["xdg-open", self.workDir]) - else: print "Thanks" + else: print("Thanks") def printHelp(self): helpFile = open(os.path.join(distrPath, "osmbundler/help.txt"), "r") - print helpFile.read() + print(helpFile.read()) helpFile.close() # a helper function to get CCD width from sqlite database diff --git a/linux/osmbundler/features/sift.py b/linux/osmbundler/features/sift.py index a5f5edb..f0851c2 100755 --- a/linux/osmbundler/features/sift.py +++ b/linux/osmbundler/features/sift.py @@ -1,6 +1,6 @@ import sys, os, logging -from extractor import FeatureExtractor +from .extractor import FeatureExtractor class Sift(FeatureExtractor): diff --git a/linux/osmbundler/features/siftlowe.py b/linux/osmbundler/features/siftlowe.py index 04e13fb..1e9c5f8 100755 --- a/linux/osmbundler/features/siftlowe.py +++ b/linux/osmbundler/features/siftlowe.py @@ -1,6 +1,6 @@ import os, subprocess, gzip -from sift import Sift +from .sift import Sift className = "LoweSift" class LoweSift(Sift): diff --git a/linux/osmbundler/features/siftvlfeat.py b/linux/osmbundler/features/siftvlfeat.py index c967772..41147fc 100755 --- a/linux/osmbundler/features/siftvlfeat.py +++ b/linux/osmbundler/features/siftvlfeat.py @@ -1,6 +1,6 @@ import os, subprocess, gzip, logging -from sift import Sift +from .sift import Sift className = "VlfeatSift" class VlfeatSift(Sift): diff --git a/linux/osmbundler/matching/bundler.py b/linux/osmbundler/matching/bundler.py index 298b830..078b1f1 100755 --- a/linux/osmbundler/matching/bundler.py +++ b/linux/osmbundler/matching/bundler.py @@ -1,6 +1,6 @@ import sys,os,subprocess,logging -from engine import MatchingEngine +from .engine import MatchingEngine className = "BundlerMatching" class BundlerMatching(MatchingEngine): diff --git a/linux/osmbundler/matching/manual.py b/linux/osmbundler/matching/manual.py index 6084d2c..d884f84 100755 --- a/linux/osmbundler/matching/manual.py +++ b/linux/osmbundler/matching/manual.py @@ -1,4 +1,4 @@ -from engine import MatchingEngine +from .engine import MatchingEngine className = "ManualMatching" class ManualMatching(MatchingEngine): diff --git a/linux/osmcmvs/__init__.py b/linux/osmcmvs/__init__.py index f86184f..9c5aa60 100755 --- a/linux/osmcmvs/__init__.py +++ b/linux/osmcmvs/__init__.py @@ -47,7 +47,7 @@ def __init__(self): logging.info("Working directory created: "+self.workDir) if not (os.path.isdir(self.bundleOutArg) or os.path.isfile(self.bundleOutArg)): - raise Exception, "'%s' is neither directory nor a file name" % self.bundleOutArg + raise Exception("'%s' is neither directory nor a file name" % self.bundleOutArg) def parseCommandLineFlags(self): try: @@ -77,21 +77,21 @@ def doBundle2PMVS(self): os.mkdir("pmvs/models") #$BASE_PATH/bin32/Bundle2PMVS.exe list.txt bundle/bundle.out - print "Running Bundle2PMVS to generate geometry and converted camera file" + print("Running Bundle2PMVS to generate geometry and converted camera file") subprocess.call([bundler2PmvsExecutable, "list.txt", "bundle/bundle.out"]) # Apply radial undistortion to the images - print "Running RadialUndistort to undistort input images" + print("Running RadialUndistort to undistort input images") subprocess.call([RadialUndistordExecutable, "list.txt", "bundle/bundle.out", "pmvs"]) - print "Running Bundle2Vis to generate vis.dat" + print("Running Bundle2Vis to generate vis.dat") subprocess.call([Bundle2VisExecutable, "pmvs/bundle.rd.out", "pmvs/vis.dat"]) os.chdir(os.path.join(self.workDir,"pmvs")) #Rename all the files to the correct name undistortTextFile = open("list.rd.txt", "r") imagesStrings = undistortTextFile.readlines() - print "Move files in the correct directory" + print("Move files in the correct directory") cpt = 0 for imageString in imagesStrings: image = imageString.split(".") @@ -123,16 +123,16 @@ def doCMVS(self): # for file in files: # if "option-" in file: # subprocess.call([pmvsExecutable, "./", file]) - print "Finished! See the results in the '%s' directory" % self.workDir + print("Finished! See the results in the '%s' directory" % self.workDir) if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) if sys.platform == "linux2": subprocess.call(["xdg-open", self.workDir]) - else: print "Thanks" + else: print("Thanks") def doPMVS(self, path, optionFile): os.chdir(os.path.join(path,"pmvs")) - print "Run PMVS2 : %s " % pmvsExecutable + print("Run PMVS2 : %s " % pmvsExecutable) subprocess.call([pmvsExecutable, "./", optionFile]) - print "Finished! See the results in the '%s' directory" % self.workDir + print("Finished! See the results in the '%s' directory" % self.workDir) def printHelpExit(self): self.printHelp() @@ -140,11 +140,11 @@ def printHelpExit(self): def openResult(self): if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) - else: print "See the results in the '%s' directory" % self.workDir + else: print("See the results in the '%s' directory" % self.workDir) def printHelp(self): - print "Error" + print("Error") helpFile = open(os.path.join(distrPath, "osmcmvs/help.txt"), "r") - print helpFile.read() + print(helpFile.read()) helpFile.close() diff --git a/linux/osmpmvs/__init__.py b/linux/osmpmvs/__init__.py index 02177d8..7de92b2 100755 --- a/linux/osmpmvs/__init__.py +++ b/linux/osmpmvs/__init__.py @@ -43,7 +43,7 @@ def __init__(self): logging.info("Working directory created: "+self.workDir) if not (os.path.isdir(self.bundleOutArg) or os.path.isfile(self.bundleOutArg)): - raise Exception, "'%s' is neither directory nor a file name" % self.bundleOutArg + raise Exception("'%s' is neither directory nor a file name" % self.bundleOutArg) def parseCommandLineFlags(self): try: @@ -71,21 +71,21 @@ def doBundle2PMVS(self): os.mkdir("pmvs/models") #$BASE_PATH/bin32/Bundle2PMVS.exe list.txt bundle/bundle.out - print "Running Bundle2PMVS to generate geometry and converted camera file" + print("Running Bundle2PMVS to generate geometry and converted camera file") subprocess.call([bundler2PmvsExecutable, "list.txt", "bundle/bundle.out"]) # Apply radial undistortion to the images - print "Running RadialUndistort to undistort input images" + print("Running RadialUndistort to undistort input images") subprocess.call([RadialUndistordExecutable, "list.txt", "bundle/bundle.out", "pmvs"]) - print "Running Bundle2Vis to generate vis.dat" + print("Running Bundle2Vis to generate vis.dat") subprocess.call([Bundle2VisExecutable, "pmvs/bundle.rd.out", "pmvs/vis.dat"]) os.chdir(os.path.join(self.workDir,"pmvs")) #Rename all the files to the correct name undistortTextFile = open("list.rd.txt", "r") imagesStrings = undistortTextFile.readlines() - print "Move files in the correct directory" + print("Move files in the correct directory") cpt = 0 for imageString in imagesStrings: image = imageString.split(".") @@ -102,12 +102,12 @@ def doBundle2PMVS(self): logging.info("Finished!") def doPMVS(self): - print "Run PMVS2 : %s " % pmvsExecutable + print("Run PMVS2 : %s " % pmvsExecutable) subprocess.call([pmvsExecutable, "./", "pmvs_options.txt"]) - print "Finished! See the results in the '%s' directory" % self.workDir + print("Finished! See the results in the '%s' directory" % self.workDir) if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) if sys.platform == "linux2": subprocess.call(["xdg-open", self.workDir]) - else: print "Thanks" + else: print("Thanks") def printHelpExit(self): self.printHelp() @@ -115,11 +115,11 @@ def printHelpExit(self): def openResult(self): if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) - else: print "See the results in the '%s' directory" % self.workDir + else: print("See the results in the '%s' directory" % self.workDir) def printHelp(self): - print "Error" + print("Error") helpFile = open(os.path.join(distrPath, "osmpmvs/help.txt"), "r") - print helpFile.read() + print(helpFile.read()) helpFile.close() From 98189416130d9474da2b4a2c8e037a1887c00f58 Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Thu, 18 Jun 2020 13:54:57 +0159 Subject: [PATCH 4/7] osmbundler/__init__.py: remove tabs and useless whitespace --- linux/osmbundler/__init__.py | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/linux/osmbundler/__init__.py b/linux/osmbundler/__init__.py index c257f4e..1aa15fa 100755 --- a/linux/osmbundler/__init__.py +++ b/linux/osmbundler/__init__.py @@ -47,36 +47,36 @@ class OsmBundler(): currentDir = "" workDir = "" - + # value of command line argument --photos=<..> photosArg = "" - + featureExtractor = None - + matchingEngine = None - + # sqlite cursor dbCursor = None - + # list of photos with focal distances for bundler input bundlerListFile = None - + # list of files with extracted features featuresListFile = None - + # information about each processed photo is stored in the following dictionary # photo file name in self.workDir is used as the key in this dictionary photoDict = {} - + featureExtractionNeeded = True - + photoScalingFactor = 0 def __init__(self): for attr in dir(defaults): if attr[0]!='_': setattr(self, attr, getattr(defaults, attr)) - + self.parseCommandLineFlags() # save current directory (i.e. from where RunBundler.py is called) @@ -84,10 +84,10 @@ def __init__(self): # create a working directory self.workDir = tempfile.mkdtemp(prefix="osm-bundler-") logging.info("Working directory created: "+self.workDir) - + if not (os.path.isdir(self.photosArg) or os.path.isfile(self.photosArg)): raise Exception("'%s' is neither directory nor a file name" % self.photosArg) - + # initialize mathing engine based on command line arguments self.initMatchingEngine() @@ -127,18 +127,18 @@ def parseCommandLineFlags(self): sys.exit(2) elif opt=="help": self.printHelpExit() - + if self.photosArg=="": self.printHelpExit() def preparePhotos(self, *kargs, **kwargs): # open each photo, resize, convert to pgm, copy it to self.workDir and calculate focal distance # conversion to pgm is performed by PIL library # EXIF reading is performed by PIL library - + # open connection to cameras database conn = sqlite3.connect(camerasDatabase) self.dbCursor = conn.cursor() - + # open list of photos with focal distances for bundler input self.bundlerListFile = open(os.path.join(self.workDir,bundlerListFileName), "w") @@ -180,7 +180,7 @@ def checkCamerasInDatabase(self): # open connection to cameras database conn = sqlite3.connect(camerasDatabase) self.dbCursor = conn.cursor() - + if os.path.isdir(self.photosArg): # directory with images photos = getPhotosFromDirectory(self.photosArg) @@ -225,10 +225,10 @@ def checkCameraInDatabase(self, photoPath): else: print("CCD width %s for the cameras %s,%s has been successively inserted to the database" % (ccdWidth, exifMake, exifModel)) return - else: - print("Camera is already inserted into the database") + else: + print("Camera is already inserted into the database") return - + def _preparePhoto(self, photoInfo): photo = photoInfo['basename'] photoDir = photoInfo['dirname'] @@ -241,7 +241,7 @@ def _preparePhoto(self, photoInfo): # get EXIF information as a dictionary exif = self._getExif(photoHandle) self._calculateFocalDistance(photo, photoInfo, exif) - + # resize photo if necessary # self.photoScalingFactor takes precedence over self.maxPhotoDimension scale = 0 @@ -255,12 +255,12 @@ def _preparePhoto(self, photoInfo): newHeight = int(scale * photoHandle.size[1]) photoHandle = photoHandle.resize((newWidth, newHeight)) logging.info("\tCopy of the photo has been scaled down to %sx%s" % (newWidth,newHeight)) - + photoInfo['width'] = photoHandle.size[0] photoInfo['height'] = photoHandle.size[1] - + photoHandle.save(outputFileNameJpg) - + # put photoInfo to self.photoDict self.photoDict[photo] = photoInfo @@ -293,7 +293,7 @@ def _getExif(self, photoHandle): if decodedAttr in exifAttrs: exif[decodedAttr] = value if 'FocalLength' in exif: exif['FocalLength'] = float(exif['FocalLength'][0])/float(exif['FocalLength'][1]) return exif - + def _calculateFocalDistance(self, photo, photoInfo, exif): hasFocal = False if 'Make' in exif and 'Model' in exif: @@ -337,20 +337,20 @@ def extractFeatures(self, photo): self.featureExtractor.extract(photo, self.photoDict[photo]) self.featuresListFile.write("%s.%s\n" % (photo, self.featureExtractor.fileExtension)) os.chdir(self.currentDir) - + def matchFeatures(self): # let self.matchingEngine do its job os.chdir(self.workDir) self.matchingEngine.match() os.chdir(self.currentDir) - + def doBundleAdjustment(self): # just run Bundler here logging.info("\nPerforming bundle adjustment...") os.chdir(self.workDir) os.mkdir("bundle") - + # create options.txt optionsFile = open("options.txt", "w") optionsFile.writelines(defaults.bundlerOptions) @@ -361,16 +361,16 @@ def doBundleAdjustment(self): bundlerOutputFile.close() os.chdir(self.currentDir) logging.info("Finished! See the results in the '%s' directory" % self.workDir) - + def printHelpExit(self): self.printHelp() sys.exit(2) - + def openResult(self): if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) - if sys.platform == "linux2": subprocess.call(["xdg-open", self.workDir]) + if sys.platform == "linux2": subprocess.call(["xdg-open", self.workDir]) else: print("Thanks") - + def printHelp(self): helpFile = open(os.path.join(distrPath, "osmbundler/help.txt"), "r") print(helpFile.read()) From 6aec51bf9ec2bbf72ee30087c3b6880f75c0cdc1 Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Thu, 18 Jun 2020 17:51:59 +0159 Subject: [PATCH 5/7] fix some indentation and another bug. --- linux/osmbundler/__init__.py | 6 +++--- linux/osmbundler/features/siftvlfeat.py | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/linux/osmbundler/__init__.py b/linux/osmbundler/__init__.py index 1aa15fa..fcf1396 100755 --- a/linux/osmbundler/__init__.py +++ b/linux/osmbundler/__init__.py @@ -226,8 +226,8 @@ def checkCameraInDatabase(self, photoPath): print("CCD width %s for the cameras %s,%s has been successively inserted to the database" % (ccdWidth, exifMake, exifModel)) return else: - print("Camera is already inserted into the database") - return + print("Camera is already inserted into the database") + return def _preparePhoto(self, photoInfo): photo = photoInfo['basename'] @@ -369,7 +369,7 @@ def printHelpExit(self): def openResult(self): if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) if sys.platform == "linux2": subprocess.call(["xdg-open", self.workDir]) - else: print("Thanks") + else: print("Thanks") def printHelp(self): helpFile = open(os.path.join(distrPath, "osmbundler/help.txt"), "r") diff --git a/linux/osmbundler/features/siftvlfeat.py b/linux/osmbundler/features/siftvlfeat.py index 41147fc..5526ca9 100755 --- a/linux/osmbundler/features/siftvlfeat.py +++ b/linux/osmbundler/features/siftvlfeat.py @@ -4,7 +4,7 @@ className = "VlfeatSift" class VlfeatSift(Sift): - + win32Executable = "vlfeat/bin/w32/sift.exe" linuxExecutable = "vlfeat/bin/glx/sift" @@ -20,19 +20,17 @@ def extract(self, photo, photoInfo): featureStrings = vlfeatTextFile.readlines() numFeatures = len(featureStrings) # write header - loweGzipFile.write("%s 128\n" % numFeatures) + loweGzipFile.write(("%s 128\n" % numFeatures).encode()) for featureString in featureStrings: features = featureString.split() # swap features[0] and features[1] - tmp = features[0] - features[0] = features[1] - features[1] = tmp + features[1], features[0] = features[0:2] i1 = 0 for i2 in (4,24,44,64,84,104,124,132): - loweGzipFile.write("%s\n" % " ".join(features[i1:i2])) + loweGzipFile.write(("%s\n" % " ".join(features[i1:i2])).encode()) i1 = i2 loweGzipFile.close() vlfeatTextFile.close() # remove original SIFT file os.remove("%s.key" % photo) - logging.info("\tFound %s features" % numFeatures) \ No newline at end of file + logging.info("\tFound %s features" % numFeatures) From 47cd19132c4e5439a079f53d5a6dc6aba62fa6a2 Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Fri, 19 Jun 2020 16:39:34 +0159 Subject: [PATCH 6/7] fix whitespace, linux platform check Since python3, sys.platform will just be linux. But for older python versions, startswith is the compatible check. --- linux/osmpmvs/__init__.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/linux/osmpmvs/__init__.py b/linux/osmpmvs/__init__.py index 7de92b2..81fdd9c 100755 --- a/linux/osmpmvs/__init__.py +++ b/linux/osmpmvs/__init__.py @@ -5,7 +5,7 @@ def getExecPath(dir, fileName): if sys.platform == "win32": fileName = "%s.exe" % fileName return os.path.join(dir, fileName) - + distrPath = os.path.dirname( os.path.abspath(sys.argv[0]) ) pmvsExecutable = getExecPath(distrPath, "software/pmvs/bin/pmvs2") @@ -28,12 +28,12 @@ class OsmPmvs(): currentDir = "" workDir = "" - + # value of command line argument --bundlerOutputPath=<..> bundleOutArg = "" def __init__(self): - + self.parseCommandLineFlags() # save current directory (i.e. from where RunBundler.py is called) @@ -41,7 +41,7 @@ def __init__(self): # create a working directory self.workDir = self.bundleOutArg logging.info("Working directory created: "+self.workDir) - + if not (os.path.isdir(self.bundleOutArg) or os.path.isfile(self.bundleOutArg)): raise Exception("'%s' is neither directory nor a file name" % self.bundleOutArg) @@ -56,9 +56,9 @@ def parseCommandLineFlags(self): self.bundleOutArg = val elif opt=="--help": self.printHelpExit() - + if self.bundleOutArg=="": self.printHelpExit() - + def doBundle2PMVS(self): # just run Bundle2PMVS here logging.info("\nPerforming Bundler2PMVS conversion...") @@ -69,15 +69,15 @@ def doBundle2PMVS(self): os.mkdir("pmvs/txt") os.mkdir("pmvs/visualize") os.mkdir("pmvs/models") - + #$BASE_PATH/bin32/Bundle2PMVS.exe list.txt bundle/bundle.out print("Running Bundle2PMVS to generate geometry and converted camera file") subprocess.call([bundler2PmvsExecutable, "list.txt", "bundle/bundle.out"]) - + # Apply radial undistortion to the images print("Running RadialUndistort to undistort input images") subprocess.call([RadialUndistordExecutable, "list.txt", "bundle/bundle.out", "pmvs"]) - + print("Running Bundle2Vis to generate vis.dat") subprocess.call([Bundle2VisExecutable, "pmvs/bundle.rd.out", "pmvs/vis.dat"]) @@ -96,27 +96,27 @@ def doBundle2PMVS(self): os.remove(image[0]+".rd.jpg") os.remove("%08d.txt"%cpt) cpt+=1 - + undistortTextFile.close() - + logging.info("Finished!") - + def doPMVS(self): print("Run PMVS2 : %s " % pmvsExecutable) subprocess.call([pmvsExecutable, "./", "pmvs_options.txt"]) - print("Finished! See the results in the '%s' directory" % self.workDir) - if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) - if sys.platform == "linux2": subprocess.call(["xdg-open", self.workDir]) + print("Finished! See the results in the '%s' directory" % self.workDir) + if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) + if sys.platform.startswith('linux'): subprocess.call(["xdg-open", self.workDir]) else: print("Thanks") def printHelpExit(self): self.printHelp() sys.exit(2) - + def openResult(self): if sys.platform == "win32": subprocess.call(["explorer", self.workDir]) else: print("See the results in the '%s' directory" % self.workDir) - + def printHelp(self): print("Error") helpFile = open(os.path.join(distrPath, "osmpmvs/help.txt"), "r") From bc9d9f6623871dd577eb807bdb5a49618fd896e8 Mon Sep 17 00:00:00 2001 From: Martin Castillo Date: Fri, 19 Jun 2020 16:56:15 +0159 Subject: [PATCH 7/7] gui: properly decode subprogram outputs --- linux/ppt_gui.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/ppt_gui.py b/linux/ppt_gui.py index 4e9f2ce..92bca6e 100644 --- a/linux/ppt_gui.py +++ b/linux/ppt_gui.py @@ -401,7 +401,7 @@ def startbundler(self): command = self.text2.displayText() proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) output = proc.stdout.read() - self.output1.append(str(output)) + self.output1.append(output.decode(errors='replace')) # help button 1 - select directory def on_help1_clicked(self): @@ -467,7 +467,7 @@ def startcmvs(self): command = self.text6.displayText() proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) output = proc.stdout.read() - self.output2.append(str(output)) + self.output2.append(output.decode(errors='replace')) # open pmvs def openpmvs(self, text): @@ -494,7 +494,7 @@ def startpmvs(self): command = self.text8.displayText() proc = subprocess.Popen((str(command)), shell=True, stdout=subprocess.PIPE) output = proc.stdout.read() - self.output3.append(str(output)) + self.output3.append(output.decode(errors='replace')) # select directory with photos (Camera Database) def showDialog4(self):