Skip to content

Commit 2498663

Browse files
committed
Fix major bug with Agisoft install
1 parent 499c0cb commit 2498663

File tree

3 files changed

+27
-33
lines changed

3 files changed

+27
-33
lines changed

resources/other/camera_calib_m3t_no_process.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

tools/agisoft_part.py

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,35 @@
11
import os
22
import resources as res
33
from PySide6 import QtCore, QtGui, QtWidgets
4-
import subprocess
54
import sys
6-
import pkg_resources
75

6+
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
7+
print('running in a PyInstaller bundle')
88

9-
def install_agisoft_module():
10-
# install Metashape module if necessary
11-
def install(package):
12-
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
9+
else:
10+
print('running in a normal Python process')
11+
# if run in Python process, then the app needs to check if Agisoft is installed
12+
import subprocess
13+
import pkg_resources
1314

14-
metashape_module = res.find('other/Metashape-2.0.1-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl')
15-
install(metashape_module)
1615

17-
# check if module is installed
18-
required = {'metashape'}
19-
installed = {pkg.key for pkg in pkg_resources.working_set}
20-
print(installed)
21-
missing = required - installed
22-
if missing:
23-
print(r"Ok let's intall Agisoft!")
24-
install_agisoft_module()
16+
def install_agisoft_module():
17+
# install Metashape module if necessary
18+
def install(package):
19+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
20+
21+
metashape_module = res.find('other/Metashape-2.0.1-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl')
22+
install(metashape_module)
23+
24+
# check if module is installed
25+
required = {'metashape'}
26+
installed = {pkg.key for pkg in pkg_resources.working_set}
27+
print(installed)
28+
missing = required - installed
29+
if missing:
30+
print(r"Ok let's intall Agisoft!")
31+
install_agisoft_module()
32+
2533

2634
import Metashape
2735

@@ -75,9 +83,9 @@ def run(self):
7583
pdf_path = os.path.join(self.output_folder, 'thermal_document.pdf')
7684

7785
# drone model specific data
78-
if self.drone_model == 'MAVIC2-ENTERPRISE-ADVANCED':
86+
if self.drone_model.name == 'MAVIC2-ENTERPRISE-ADVANCED':
7987
calib_file = res.find('other/camera_calib_m2t.xml')
80-
elif self.drone_model == 'M3T':
88+
elif self.drone_model.name == 'M3T':
8189
calib_file = res.find('other/camera_calib_m3t.xml')
8290

8391
# compute number of steps

tools/thermal_tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
class DroneModel():
3737
def __init__(self,name):
38+
self.name = name
3839
if name == 'MAVIC2-ENTERPRISE-ADVANCED':
3940
self.rgb_xml_path = m2t_rgb_xml_path
4041
self.ir_xml_path = m2t_ir_xml_path

0 commit comments

Comments
 (0)